@signaliz/sdk 1.0.16 → 1.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +113 -10
- package/dist/{chunk-5JNKSMNW.mjs → chunk-ZKE4L57J.mjs} +1568 -115
- package/dist/cli.js +4977 -3173
- package/dist/cli.mjs +209 -23
- package/dist/index.d.mts +2569 -1940
- package/dist/index.d.ts +2569 -1940
- package/dist/index.js +1568 -115
- package/dist/index.mjs +1 -1
- package/dist/mcp-config.js +1568 -115
- package/dist/mcp-config.mjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -265,25 +265,31 @@ var HttpClient = class {
|
|
|
265
265
|
async getToken() {
|
|
266
266
|
if (this.apiKey) return this.apiKey;
|
|
267
267
|
if (this.accessToken) return this.accessToken;
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
throw new SignalizError({
|
|
279
|
-
code: "AUTH_FAILED",
|
|
280
|
-
message: "Failed to obtain access token",
|
|
281
|
-
errorType: "auth_expired"
|
|
268
|
+
if (this.accessTokenPromise) return this.accessTokenPromise;
|
|
269
|
+
this.accessTokenPromise = (async () => {
|
|
270
|
+
const res = await fetch("https://api.signaliz.com/token", {
|
|
271
|
+
method: "POST",
|
|
272
|
+
headers: { "Content-Type": "application/json" },
|
|
273
|
+
body: JSON.stringify({
|
|
274
|
+
grant_type: "client_credentials",
|
|
275
|
+
client_id: this.clientId,
|
|
276
|
+
client_secret: this.clientSecret
|
|
277
|
+
})
|
|
282
278
|
});
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
279
|
+
if (!res.ok) {
|
|
280
|
+
throw new SignalizError({
|
|
281
|
+
code: "AUTH_FAILED",
|
|
282
|
+
message: "Failed to obtain access token",
|
|
283
|
+
errorType: "auth_expired"
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
const data = await res.json();
|
|
287
|
+
this.accessToken = data.access_token;
|
|
288
|
+
return this.accessToken;
|
|
289
|
+
})().finally(() => {
|
|
290
|
+
this.accessTokenPromise = void 0;
|
|
291
|
+
});
|
|
292
|
+
return this.accessTokenPromise;
|
|
287
293
|
}
|
|
288
294
|
};
|
|
289
295
|
function sleep(ms) {
|
|
@@ -532,7 +538,6 @@ var Signals = class {
|
|
|
532
538
|
if (params.online !== void 0) args.online = params.online;
|
|
533
539
|
if (params.targetSignalCount) args.target_signal_count = params.targetSignalCount;
|
|
534
540
|
if (params.lookbackDays) args.lookback_days = params.lookbackDays;
|
|
535
|
-
if (params.model) args.model = params.model;
|
|
536
541
|
if (params.enableDeepSearch) args.enable_deep_search = params.enableDeepSearch;
|
|
537
542
|
if (params.enableOutreachIntelligence) args.enable_outreach_intelligence = params.enableOutreachIntelligence;
|
|
538
543
|
if (params.enablePredictiveIntelligence) args.enable_predictive_intelligence = params.enablePredictiveIntelligence;
|
|
@@ -827,6 +832,10 @@ var Campaigns = class {
|
|
|
827
832
|
async artifacts(campaignBuildId) {
|
|
828
833
|
return this.listCampaignBuildArtifacts(campaignBuildId);
|
|
829
834
|
}
|
|
835
|
+
/** Generate fresh signed URLs for a downloadable campaign artifact. */
|
|
836
|
+
async downloadArtifact(campaignBuildId, options) {
|
|
837
|
+
return this.downloadCampaignArtifact(campaignBuildId, options);
|
|
838
|
+
}
|
|
830
839
|
/** Cancel a queued or running build. */
|
|
831
840
|
async cancel(campaignBuildId, reason) {
|
|
832
841
|
return this.cancelCampaignBuild(campaignBuildId, reason);
|
|
@@ -871,12 +880,16 @@ var Campaigns = class {
|
|
|
871
880
|
dryRun: isDryRun,
|
|
872
881
|
requestedTargetCount: data.requested_target_count,
|
|
873
882
|
plannedTargetCount: data.planned_target_count,
|
|
883
|
+
acquisitionMode: data.acquisition_mode,
|
|
884
|
+
acquisitionSource: data.acquisition_source,
|
|
885
|
+
cacheReusePolicy: data.cache_reuse_policy,
|
|
874
886
|
estimatedCredits: data.estimated_credits,
|
|
875
887
|
estimatedDurationSeconds: data.estimated_duration_seconds,
|
|
876
888
|
targetLimitApplied: data.target_limit_applied,
|
|
877
889
|
targetLimitReason: data.target_limit_reason,
|
|
878
890
|
maxSupportedTargetCount: data.max_supported_target_count,
|
|
879
891
|
brainContext: data.brain_context ?? {},
|
|
892
|
+
learningHoldout: data.learning_holdout ?? {},
|
|
880
893
|
providerRoute: mapProviderRoute(data)
|
|
881
894
|
};
|
|
882
895
|
}
|
|
@@ -892,14 +905,24 @@ var Campaigns = class {
|
|
|
892
905
|
});
|
|
893
906
|
return (data.artifacts ?? []).map(mapArtifact);
|
|
894
907
|
}
|
|
908
|
+
async downloadCampaignArtifact(campaignBuildId, options) {
|
|
909
|
+
const args = { campaign_build_id: campaignBuildId };
|
|
910
|
+
if (options?.format) args.format = options.format;
|
|
911
|
+
const data = await this.callMcp("download_campaign_artifact", args);
|
|
912
|
+
return mapArtifactDownloadResult(data);
|
|
913
|
+
}
|
|
895
914
|
async getCampaignBuildRows(campaignBuildId, options) {
|
|
896
915
|
const args = { campaign_build_id: campaignBuildId };
|
|
897
916
|
if (options?.limit) args.page_size = options.limit;
|
|
898
917
|
if (options?.cursor) args.cursor = options.cursor;
|
|
918
|
+
if (options?.includeData !== void 0) args.include_data = options.includeData;
|
|
919
|
+
if (options?.includeRaw !== void 0) args.include_raw = options.includeRaw;
|
|
899
920
|
const filters = {};
|
|
900
921
|
if (options?.segment) filters.segment = options.segment;
|
|
901
922
|
if (options?.rowStatus) filters.row_status = options.rowStatus;
|
|
902
923
|
if (options?.qualified !== void 0) filters.qualified = options.qualified;
|
|
924
|
+
if (options?.cached !== void 0) filters.cached = options.cached;
|
|
925
|
+
if (options?.exportReady !== void 0) filters.export_ready = options.exportReady;
|
|
903
926
|
if (Object.keys(filters).length > 0) args.filters = filters;
|
|
904
927
|
const data = await this.callMcp("get_campaign_build_rows", args);
|
|
905
928
|
return {
|
|
@@ -924,6 +947,7 @@ var Campaigns = class {
|
|
|
924
947
|
};
|
|
925
948
|
if (options?.destinationId) args.destination_id = options.destinationId;
|
|
926
949
|
if (options?.destinationConfig) args.destination_config = options.destinationConfig;
|
|
950
|
+
if (options?.allowPartialDelivery === true) args.allow_partial_delivery = true;
|
|
927
951
|
const data = await this.callMcp("approve_campaign_delivery", args);
|
|
928
952
|
return {
|
|
929
953
|
campaignBuildId: data.campaign_build_id,
|
|
@@ -932,7 +956,10 @@ var Campaigns = class {
|
|
|
932
956
|
message: data.message ?? "",
|
|
933
957
|
deliveryId: data.delivery_id,
|
|
934
958
|
deliveryIds: data.delivery_ids,
|
|
935
|
-
approvedCount: data.approved_count
|
|
959
|
+
approvedCount: data.approved_count,
|
|
960
|
+
partialDelivery: data.partial_delivery,
|
|
961
|
+
effectiveTargetCount: data.effective_target_count,
|
|
962
|
+
requestedTargetCount: data.requested_target_count
|
|
936
963
|
};
|
|
937
964
|
}
|
|
938
965
|
async cancelCampaignBuild(campaignBuildId, reason) {
|
|
@@ -985,17 +1012,50 @@ function mapStatus(data) {
|
|
|
985
1012
|
warnings: diagnosticMessages(data.warnings),
|
|
986
1013
|
errors: diagnosticMessages(data.errors),
|
|
987
1014
|
artifactCount: data.artifact_count ?? 0,
|
|
1015
|
+
artifactDownloads: Array.isArray(data.artifact_downloads) ? data.artifact_downloads.map(mapArtifactDownload) : [],
|
|
1016
|
+
customerRowCounts: mapCustomerRowCounts(data.customer_row_counts),
|
|
1017
|
+
phaseAttemptTotals: recordOrNull(data.phase_attempt_totals) ?? void 0,
|
|
988
1018
|
providerRoute: mapProviderRoute(data),
|
|
989
1019
|
triggerRunId: typeof data.trigger_run_id === "string" ? data.trigger_run_id : null,
|
|
990
1020
|
staleRunningPhase: data.stale_running_phase === true,
|
|
991
1021
|
phaseAgeSeconds: numberOrNull(data.phase_age_seconds),
|
|
992
1022
|
diagnostics: recordOrNull(data.diagnostics) ?? {},
|
|
993
1023
|
nextAction: formatNextAction(data.next_action),
|
|
1024
|
+
approvalAction: formatNextAction(data.approval_action),
|
|
994
1025
|
createdAt: data.created_at,
|
|
995
1026
|
updatedAt: data.updated_at,
|
|
996
1027
|
completedAt: data.completed_at
|
|
997
1028
|
};
|
|
998
1029
|
}
|
|
1030
|
+
function mapCustomerRowCounts(value) {
|
|
1031
|
+
const record = recordOrNull(value);
|
|
1032
|
+
if (!record) return void 0;
|
|
1033
|
+
return {
|
|
1034
|
+
requestedTarget: numberOrNull(record.requested_target),
|
|
1035
|
+
acquiredRows: numberOrNull(record.acquired_rows) ?? void 0,
|
|
1036
|
+
acceptedRows: numberOrNull(record.accepted_rows) ?? void 0,
|
|
1037
|
+
usableRows: numberOrNull(record.usable_rows) ?? void 0,
|
|
1038
|
+
copiedRows: numberOrNull(record.copied_rows) ?? void 0,
|
|
1039
|
+
approvalReadyRows: numberOrNull(record.approval_ready_rows) ?? void 0,
|
|
1040
|
+
qaReadyRows: numberOrNull(record.qa_ready_rows) ?? void 0,
|
|
1041
|
+
deliveredRows: numberOrNull(record.delivered_rows) ?? void 0,
|
|
1042
|
+
disqualifiedRows: numberOrNull(record.disqualified_rows) ?? void 0,
|
|
1043
|
+
reviewableRows: numberOrNull(record.reviewable_rows) ?? void 0,
|
|
1044
|
+
rowFailures: numberOrNull(record.row_failures) ?? void 0,
|
|
1045
|
+
acceptedShortfall: numberOrNull(record.accepted_shortfall),
|
|
1046
|
+
usableShortfall: numberOrNull(record.usable_shortfall),
|
|
1047
|
+
qaReadyShortfall: numberOrNull(record.qa_ready_shortfall),
|
|
1048
|
+
deliveryShortfall: numberOrNull(record.delivery_shortfall),
|
|
1049
|
+
fillRatio: numberOrNull(record.fill_ratio),
|
|
1050
|
+
qaReadyFillRatio: numberOrNull(record.qa_ready_fill_ratio),
|
|
1051
|
+
deliveredFillRatio: numberOrNull(record.delivered_fill_ratio),
|
|
1052
|
+
terminalReason: typeof record.terminal_reason === "string" ? record.terminal_reason : null,
|
|
1053
|
+
acceptedShortfallReason: typeof record.accepted_shortfall_reason === "string" ? record.accepted_shortfall_reason : null,
|
|
1054
|
+
usableShortfallReason: typeof record.usable_shortfall_reason === "string" ? record.usable_shortfall_reason : null,
|
|
1055
|
+
qaReadyShortfallReason: typeof record.qa_ready_shortfall_reason === "string" ? record.qa_ready_shortfall_reason : null,
|
|
1056
|
+
deliveryShortfallReason: typeof record.delivery_shortfall_reason === "string" ? record.delivery_shortfall_reason : null
|
|
1057
|
+
};
|
|
1058
|
+
}
|
|
999
1059
|
function mapProviderRoute(data) {
|
|
1000
1060
|
const brainContext = recordOrNull(data?.brain_context);
|
|
1001
1061
|
const plan = recordOrNull(data?.provider_route_plan) ?? recordOrNull(brainContext?.provider_route_plan);
|
|
@@ -1073,13 +1133,56 @@ function mapArtifact(a) {
|
|
|
1073
1133
|
artifactType: a.artifact_type,
|
|
1074
1134
|
destination: a.destination,
|
|
1075
1135
|
storagePath: a.storage_path,
|
|
1136
|
+
format: a.format ?? null,
|
|
1076
1137
|
signedUrl: a.signed_url,
|
|
1138
|
+
downloadUrl: a.download_url ?? null,
|
|
1139
|
+
manifestUrl: a.manifest_url ?? null,
|
|
1140
|
+
expiresAt: a.expires_at ?? null,
|
|
1077
1141
|
rowCount: a.row_count ?? 0,
|
|
1078
1142
|
checksum: a.checksum,
|
|
1079
1143
|
metadata: a.metadata ?? {},
|
|
1080
1144
|
createdAt: a.created_at
|
|
1081
1145
|
};
|
|
1082
1146
|
}
|
|
1147
|
+
function mapArtifactDownload(data) {
|
|
1148
|
+
return {
|
|
1149
|
+
id: data.id,
|
|
1150
|
+
artifactType: data.artifact_type ?? null,
|
|
1151
|
+
format: data.format ?? null,
|
|
1152
|
+
rowCount: data.row_count ?? 0,
|
|
1153
|
+
signedUrl: data.signed_url ?? null,
|
|
1154
|
+
downloadUrl: data.download_url ?? null,
|
|
1155
|
+
manifestUrl: data.manifest_url ?? null,
|
|
1156
|
+
expiresAt: data.expires_at ?? null
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1159
|
+
function mapArtifactDownloadResult(data) {
|
|
1160
|
+
return {
|
|
1161
|
+
campaignBuildId: data.campaign_build_id,
|
|
1162
|
+
artifactId: data.artifact_id,
|
|
1163
|
+
format: data.format,
|
|
1164
|
+
rowCount: data.row_count ?? 0,
|
|
1165
|
+
byteSize: numberOrNull(data.byte_size),
|
|
1166
|
+
partCount: data.part_count ?? 0,
|
|
1167
|
+
checksum: data.checksum ?? null,
|
|
1168
|
+
signedUrl: data.signed_url ?? null,
|
|
1169
|
+
downloadUrl: data.download_url ?? null,
|
|
1170
|
+
manifestUrl: data.manifest_url ?? null,
|
|
1171
|
+
expiresAt: data.expires_at ?? null,
|
|
1172
|
+
parts: Array.isArray(data.parts) ? data.parts.map(mapArtifactDownloadPart) : [],
|
|
1173
|
+
downloadCommands: recordOrNull(data.download_commands) ?? {},
|
|
1174
|
+
expiresInSeconds: numberOrNull(data.expires_in_seconds)
|
|
1175
|
+
};
|
|
1176
|
+
}
|
|
1177
|
+
function mapArtifactDownloadPart(data) {
|
|
1178
|
+
return {
|
|
1179
|
+
partIndex: data.part_index ?? 0,
|
|
1180
|
+
rowCount: data.row_count ?? 0,
|
|
1181
|
+
byteSize: numberOrNull(data.byte_size),
|
|
1182
|
+
checksum: data.checksum ?? null,
|
|
1183
|
+
signedUrl: data.signed_url ?? null
|
|
1184
|
+
};
|
|
1185
|
+
}
|
|
1083
1186
|
function mapScope(data) {
|
|
1084
1187
|
return {
|
|
1085
1188
|
campaignScopeId: data.campaign_scope_id,
|
|
@@ -1133,8 +1236,29 @@ function buildArgs(request) {
|
|
|
1133
1236
|
if (request.allowDownscale !== void 0) args.allow_downscale = request.allowDownscale;
|
|
1134
1237
|
if (request.confirmSpend !== void 0) args.confirm_spend = request.confirmSpend;
|
|
1135
1238
|
if (request.dedupKeys) args.dedup_keys = request.dedupKeys;
|
|
1239
|
+
if (request.acquisitionMode) args.acquisition_mode = request.acquisitionMode;
|
|
1240
|
+
if (request.cacheReusePolicy) {
|
|
1241
|
+
args.cache_reuse_policy = {
|
|
1242
|
+
allow_verified_cache: request.cacheReusePolicy.allowVerifiedCache,
|
|
1243
|
+
suppress_prior_campaign_ids: request.cacheReusePolicy.suppressPriorCampaignIds,
|
|
1244
|
+
suppress_prior_list_ids: request.cacheReusePolicy.suppressPriorListIds,
|
|
1245
|
+
uniqueness: request.cacheReusePolicy.uniqueness,
|
|
1246
|
+
require_usage_metadata: request.cacheReusePolicy.requireUsageMetadata
|
|
1247
|
+
};
|
|
1248
|
+
}
|
|
1136
1249
|
if (request.brainPreflight) args.brain_preflight = request.brainPreflight;
|
|
1137
1250
|
if (request.brainDefaults) args.brain_defaults = request.brainDefaults;
|
|
1251
|
+
if (request.learningHoldout) {
|
|
1252
|
+
args.learning_holdout = {
|
|
1253
|
+
enabled: request.learningHoldout.enabled,
|
|
1254
|
+
control_percentage: request.learningHoldout.controlPercentage,
|
|
1255
|
+
min_control_size: request.learningHoldout.minControlSize,
|
|
1256
|
+
experiment_key: request.learningHoldout.experimentKey,
|
|
1257
|
+
source_campaign_id: request.learningHoldout.sourceCampaignId,
|
|
1258
|
+
primary_metric: request.learningHoldout.primaryMetric
|
|
1259
|
+
};
|
|
1260
|
+
}
|
|
1261
|
+
if (request.campaignStrategyContext) args.campaign_strategy_context = request.campaignStrategyContext;
|
|
1138
1262
|
if (request.deliveryRisk) args.delivery_risk = request.deliveryRisk;
|
|
1139
1263
|
if (request.icp) {
|
|
1140
1264
|
args.icp = {
|
|
@@ -1176,7 +1300,17 @@ function buildArgs(request) {
|
|
|
1176
1300
|
max_body_words: request.copy.maxBodyWords,
|
|
1177
1301
|
sender_context: request.copy.senderContext,
|
|
1178
1302
|
offer_context: request.copy.offerContext,
|
|
1179
|
-
model: request.copy.model
|
|
1303
|
+
model: request.copy.model,
|
|
1304
|
+
style_source: request.copy.styleSource ? {
|
|
1305
|
+
sample_text: request.copy.styleSource.sampleText,
|
|
1306
|
+
campaign_ids: request.copy.styleSource.campaignIds,
|
|
1307
|
+
artifact_ids: request.copy.styleSource.artifactIds
|
|
1308
|
+
} : void 0,
|
|
1309
|
+
sequence_steps: request.copy.sequenceSteps,
|
|
1310
|
+
copy_schema: request.copy.copySchema,
|
|
1311
|
+
banned_phrases: request.copy.bannedPhrases,
|
|
1312
|
+
approval_required: request.copy.approvalRequired,
|
|
1313
|
+
quality_tier: request.copy.qualityTier
|
|
1180
1314
|
};
|
|
1181
1315
|
}
|
|
1182
1316
|
if (request.delivery) {
|
|
@@ -1239,6 +1373,8 @@ var DEFAULT_SIGNALIZ_CAMPAIGN_BUILDER_DEFAULTS = {
|
|
|
1239
1373
|
}
|
|
1240
1374
|
};
|
|
1241
1375
|
var DEFAULT_CAMPAIGN_BUILDER_BUILT_INS = [
|
|
1376
|
+
"company_discovery",
|
|
1377
|
+
"people_discovery",
|
|
1242
1378
|
"lead_generation",
|
|
1243
1379
|
"email_finding",
|
|
1244
1380
|
"email_verification",
|
|
@@ -1247,6 +1383,8 @@ var DEFAULT_CAMPAIGN_BUILDER_BUILT_INS = [
|
|
|
1247
1383
|
var CAMPAIGN_BUILDER_BUILT_IN_ROUTE_IDS = {
|
|
1248
1384
|
lead_generation: "signaliz-lead-generation",
|
|
1249
1385
|
local_leads: "signaliz-local-leads",
|
|
1386
|
+
company_discovery: "signaliz-company-discovery",
|
|
1387
|
+
people_discovery: "signaliz-people-discovery",
|
|
1250
1388
|
email_finding: "signaliz-email-finding",
|
|
1251
1389
|
email_verification: "signaliz-email-verification",
|
|
1252
1390
|
signals: "signaliz-signals"
|
|
@@ -1264,8 +1402,8 @@ var CAMPAIGN_BUILDER_OPERATING_PLAYBOOKS = [
|
|
|
1264
1402
|
slug: "cache-first-large-list",
|
|
1265
1403
|
label: "Cache-First Large List",
|
|
1266
1404
|
whenToUse: [
|
|
1267
|
-
"The
|
|
1268
|
-
"The deliverable is a
|
|
1405
|
+
"The operator explicitly references a previous campaign, prior list, seed list, or suppression baseline.",
|
|
1406
|
+
"The deliverable is a top-up, continuation, or backfill where prior campaign context should guide reuse."
|
|
1269
1407
|
],
|
|
1270
1408
|
sequence: [
|
|
1271
1409
|
"Inventory reusable cache before paid sourcing.",
|
|
@@ -1471,7 +1609,7 @@ var CAMPAIGN_BUILDER_STRATEGY_TEMPLATES = [
|
|
|
1471
1609
|
],
|
|
1472
1610
|
requireVerifiedEmail: true
|
|
1473
1611
|
},
|
|
1474
|
-
builtIns: ["lead_generation", "email_finding", "email_verification", "signals"],
|
|
1612
|
+
builtIns: ["company_discovery", "people_discovery", "lead_generation", "email_finding", "email_verification", "signals"],
|
|
1475
1613
|
preferredProviders: ["signaliz_native"],
|
|
1476
1614
|
memoryQueries: [{
|
|
1477
1615
|
query: "industrial OT net-new prior email suppression verified manufacturing embedded systems field service cyber resilience business continuity",
|
|
@@ -1545,7 +1683,7 @@ var CAMPAIGN_BUILDER_STRATEGY_TEMPLATES = [
|
|
|
1545
1683
|
],
|
|
1546
1684
|
requireVerifiedEmail: true
|
|
1547
1685
|
},
|
|
1548
|
-
builtIns: ["lead_generation", "local_leads", "email_finding", "email_verification", "signals"],
|
|
1686
|
+
builtIns: ["company_discovery", "people_discovery", "lead_generation", "local_leads", "email_finding", "email_verification", "signals"],
|
|
1549
1687
|
preferredProviders: ["signaliz_native", "octave", "clay_webhook", "apify"],
|
|
1550
1688
|
memoryQueries: [{
|
|
1551
1689
|
query: "mature non-medical home care agencies billable hours franchise caregiver recruiting proof gate qualification export approval",
|
|
@@ -1611,7 +1749,7 @@ var CAMPAIGN_BUILDER_STRATEGY_TEMPLATES = [
|
|
|
1611
1749
|
exclusions: ["enterprise holding company", "staffing", "recruiting", "software-only vendor", "freelancer-only profile"],
|
|
1612
1750
|
requireVerifiedEmail: true
|
|
1613
1751
|
},
|
|
1614
|
-
builtIns: ["lead_generation", "email_finding", "email_verification", "signals"],
|
|
1752
|
+
builtIns: ["company_discovery", "people_discovery", "lead_generation", "email_finding", "email_verification", "signals"],
|
|
1615
1753
|
preferredProviders: ["signaliz_native", "octave"],
|
|
1616
1754
|
memoryQueries: [{
|
|
1617
1755
|
query: "agency founder owner CEO marketing services suppression domain pool email verification final approval gate",
|
|
@@ -1693,7 +1831,7 @@ var CAMPAIGN_BUILDER_STRATEGY_TEMPLATES = [
|
|
|
1693
1831
|
],
|
|
1694
1832
|
requireVerifiedEmail: true
|
|
1695
1833
|
},
|
|
1696
|
-
builtIns: ["lead_generation", "email_finding", "email_verification", "signals"],
|
|
1834
|
+
builtIns: ["company_discovery", "people_discovery", "lead_generation", "email_finding", "email_verification", "signals"],
|
|
1697
1835
|
preferredProviders: ["signaliz_native", "octave"],
|
|
1698
1836
|
memoryQueries: [{
|
|
1699
1837
|
query: "cloud hosting infrastructure VMware Broadcom qualification verified email persona trigger SKU mapping",
|
|
@@ -1726,25 +1864,21 @@ var CampaignBuilderAgent = class {
|
|
|
1726
1864
|
async createPlan(request, options = {}) {
|
|
1727
1865
|
const resolvedRequest = applyCampaignBuilderStrategyTemplate(request);
|
|
1728
1866
|
const warnings = [];
|
|
1729
|
-
const workspaceContext =
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1867
|
+
const [workspaceContext, scopeResult] = await Promise.all([
|
|
1868
|
+
resolvedRequest.workspaceContext ? Promise.resolve(resolvedRequest.workspaceContext) : this.getWorkspaceContext(warnings),
|
|
1869
|
+
options.scopeCampaign === false ? Promise.resolve(void 0) : this.scopeCampaign(resolvedRequest, warnings),
|
|
1870
|
+
options.discoverCapabilities === false ? Promise.resolve(void 0) : this.discoverPlannedRoutes(resolvedRequest, warnings)
|
|
1871
|
+
]);
|
|
1734
1872
|
const plan = createCampaignBuilderAgentPlan(resolvedRequest, {
|
|
1735
1873
|
workspaceContext,
|
|
1736
1874
|
scopeBuildArgs: asRecord(scopeResult?.build_campaign_args ?? scopeResult?.buildCampaignArgs),
|
|
1737
1875
|
warnings
|
|
1738
1876
|
});
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
}
|
|
1745
|
-
if (options.includeDeliveryRisk !== false) {
|
|
1746
|
-
await this.attachDeliveryRiskPreflight(plan, warnings);
|
|
1747
|
-
}
|
|
1877
|
+
await Promise.all([
|
|
1878
|
+
options.includeStrategyMemoryStatus === false ? Promise.resolve() : this.attachStrategyMemoryStatus(plan, warnings),
|
|
1879
|
+
options.includeKernelPlan === false ? Promise.resolve() : this.attachKernelCampaignBuildPlan(plan, warnings),
|
|
1880
|
+
options.includeDeliveryRisk === false ? Promise.resolve() : this.attachDeliveryRiskPreflight(plan, warnings)
|
|
1881
|
+
]);
|
|
1748
1882
|
return plan;
|
|
1749
1883
|
}
|
|
1750
1884
|
async readiness(request, options = {}) {
|
|
@@ -1792,6 +1926,7 @@ var CampaignBuilderAgent = class {
|
|
|
1792
1926
|
},
|
|
1793
1927
|
brain_defaults: plan.buildRequest.brainDefaults,
|
|
1794
1928
|
brain_preflight: plan.buildRequest.brainPreflight,
|
|
1929
|
+
campaign_strategy_context: plan.buildRequest.campaignStrategyContext,
|
|
1795
1930
|
delivery_risk_preflight: plan.buildRequest.deliveryRisk,
|
|
1796
1931
|
delivery_risk: plan.buildRequest.deliveryRisk
|
|
1797
1932
|
}),
|
|
@@ -1913,7 +2048,8 @@ var CampaignBuilderAgent = class {
|
|
|
1913
2048
|
const destinationType = options.deliveryDestinationType ?? plan.buildRequest.delivery?.destinationType ?? "json";
|
|
1914
2049
|
result.deliveryApproval = await this.approveCampaignDelivery(campaignBuildId, destinationType, {
|
|
1915
2050
|
destinationId: options.deliveryDestinationId,
|
|
1916
|
-
destinationConfig: options.deliveryDestinationConfig ?? plan.buildRequest.delivery?.destinationConfig
|
|
2051
|
+
destinationConfig: options.deliveryDestinationConfig ?? plan.buildRequest.delivery?.destinationConfig,
|
|
2052
|
+
allowPartialDelivery: options.allowPartialDelivery
|
|
1917
2053
|
});
|
|
1918
2054
|
finalStatus = await this.waitForCampaignBuildStatus(
|
|
1919
2055
|
campaignBuildId,
|
|
@@ -1936,8 +2072,12 @@ var CampaignBuilderAgent = class {
|
|
|
1936
2072
|
const args = compact({
|
|
1937
2073
|
campaign_build_id: campaignBuildId,
|
|
1938
2074
|
page_size: options.limit,
|
|
1939
|
-
cursor: options.cursor
|
|
2075
|
+
cursor: options.cursor,
|
|
2076
|
+
include_data: options.includeData,
|
|
2077
|
+
include_raw: options.includeRaw
|
|
1940
2078
|
});
|
|
2079
|
+
if (options.cached !== void 0) filters.cached = options.cached;
|
|
2080
|
+
if (options.exportReady !== void 0) filters.export_ready = options.exportReady;
|
|
1941
2081
|
if (Object.keys(filters).length > 0) args.filters = filters;
|
|
1942
2082
|
const data = await this.callMcp("get_campaign_build_rows", args);
|
|
1943
2083
|
return mapAgentCampaignRowsResult(data);
|
|
@@ -1952,12 +2092,14 @@ var CampaignBuilderAgent = class {
|
|
|
1952
2092
|
return this.approveCampaignDelivery(campaignBuildId, destinationType, options);
|
|
1953
2093
|
}
|
|
1954
2094
|
async reviewBuild(campaignBuildId, options = {}) {
|
|
1955
|
-
const status = await
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
2095
|
+
const [status, rows, artifacts] = await Promise.all([
|
|
2096
|
+
this.getBuildStatus(campaignBuildId),
|
|
2097
|
+
this.getBuildRows(campaignBuildId, {
|
|
2098
|
+
...options,
|
|
2099
|
+
limit: options.limit ?? 100
|
|
2100
|
+
}),
|
|
2101
|
+
this.listBuildArtifacts(campaignBuildId)
|
|
2102
|
+
]);
|
|
1961
2103
|
return createCampaignBuilderBuildReview(status, rows, artifacts);
|
|
1962
2104
|
}
|
|
1963
2105
|
async getCampaignBuildStatus(campaignBuildId) {
|
|
@@ -1985,7 +2127,8 @@ var CampaignBuilderAgent = class {
|
|
|
1985
2127
|
campaign_build_id: campaignBuildId,
|
|
1986
2128
|
destination_type: destinationType,
|
|
1987
2129
|
destination_id: options?.destinationId,
|
|
1988
|
-
destination_config: options?.destinationConfig
|
|
2130
|
+
destination_config: options?.destinationConfig,
|
|
2131
|
+
allow_partial_delivery: options?.allowPartialDelivery === true ? true : void 0
|
|
1989
2132
|
});
|
|
1990
2133
|
const data = await this.callMcp("approve_campaign_delivery", args);
|
|
1991
2134
|
return {
|
|
@@ -1995,7 +2138,10 @@ var CampaignBuilderAgent = class {
|
|
|
1995
2138
|
message: data.message ?? "",
|
|
1996
2139
|
deliveryId: data.delivery_id,
|
|
1997
2140
|
deliveryIds: data.delivery_ids,
|
|
1998
|
-
approvedCount: data.approved_count
|
|
2141
|
+
approvedCount: data.approved_count,
|
|
2142
|
+
partialDelivery: data.partial_delivery,
|
|
2143
|
+
effectiveTargetCount: data.effective_target_count,
|
|
2144
|
+
requestedTargetCount: data.requested_target_count
|
|
1999
2145
|
};
|
|
2000
2146
|
}
|
|
2001
2147
|
async getWorkspaceContext(warnings) {
|
|
@@ -2031,15 +2177,19 @@ var CampaignBuilderAgent = class {
|
|
|
2031
2177
|
const providers = new Set(
|
|
2032
2178
|
[...request.integrations ?? [], ...routesFromCustomerTools(request.customerTools ?? [])].filter((route) => route.provider !== "signaliz").map((route) => route.provider)
|
|
2033
2179
|
);
|
|
2034
|
-
|
|
2180
|
+
const warningsByProvider = await Promise.all(Array.from(providers, async (provider) => {
|
|
2035
2181
|
try {
|
|
2036
2182
|
await this.callMcp("discover_capabilities", {
|
|
2037
2183
|
query: `campaign builder ${provider} ${request.goal}`,
|
|
2038
2184
|
category: "campaign"
|
|
2039
2185
|
});
|
|
2186
|
+
return void 0;
|
|
2040
2187
|
} catch (error) {
|
|
2041
|
-
|
|
2188
|
+
return `Capability discovery for ${provider} failed: ${errorMessage(error)}`;
|
|
2042
2189
|
}
|
|
2190
|
+
}));
|
|
2191
|
+
for (const warning of warningsByProvider) {
|
|
2192
|
+
if (warning) warnings.push(warning);
|
|
2043
2193
|
}
|
|
2044
2194
|
}
|
|
2045
2195
|
async attachStrategyMemoryStatus(plan, warnings) {
|
|
@@ -2063,8 +2213,24 @@ var CampaignBuilderAgent = class {
|
|
|
2063
2213
|
const kernelPlan = await this.callMcp("gtm_campaign_build_plan", asRecord(plannerStep.arguments));
|
|
2064
2214
|
plan.kernelPlan = asRecord(kernelPlan);
|
|
2065
2215
|
const brainDefaults = asRecord(plan.kernelPlan.brain_defaults ?? plan.kernelPlan.brainDefaults);
|
|
2216
|
+
const corpusContext = asRecord(plan.kernelPlan.corpus_context ?? plan.kernelPlan.corpusContext);
|
|
2217
|
+
const campaignStrategyContext = asRecord(plan.kernelPlan.campaign_strategy_context ?? plan.kernelPlan.campaignStrategyContext);
|
|
2218
|
+
const memoryExamples = Array.isArray(plan.kernelPlan.memory_examples) ? plan.kernelPlan.memory_examples.map((item) => asRecord(item)).filter((item) => Object.keys(item).length > 0).slice(0, 15) : [];
|
|
2066
2219
|
if (Object.keys(brainDefaults).length > 0 && Object.keys(asRecord(plan.buildRequest.brainDefaults)).length === 0) {
|
|
2067
2220
|
plan.buildRequest.brainDefaults = brainDefaults;
|
|
2221
|
+
}
|
|
2222
|
+
if (Object.keys(campaignStrategyContext).length > 0) {
|
|
2223
|
+
plan.buildRequest.campaignStrategyContext = campaignStrategyContext;
|
|
2224
|
+
}
|
|
2225
|
+
if (Object.keys(corpusContext).length > 0 || memoryExamples.length > 0 || Object.keys(brainDefaults).length > 0 || Object.keys(campaignStrategyContext).length > 0) {
|
|
2226
|
+
plan.buildRequest.brainPreflight = compact({
|
|
2227
|
+
...asRecord(plan.buildRequest.brainPreflight),
|
|
2228
|
+
corpus_context: Object.keys(corpusContext).length > 0 ? corpusContext : void 0,
|
|
2229
|
+
memory_examples: memoryExamples.length > 0 ? memoryExamples : void 0,
|
|
2230
|
+
brain_defaults: Object.keys(brainDefaults).length > 0 ? brainDefaults : void 0,
|
|
2231
|
+
campaign_strategy_context: Object.keys(campaignStrategyContext).length > 0 ? campaignStrategyContext : void 0
|
|
2232
|
+
});
|
|
2233
|
+
plan.brainPreflight = asRecord(plan.buildRequest.brainPreflight);
|
|
2068
2234
|
refreshBuildStepArguments(plan);
|
|
2069
2235
|
}
|
|
2070
2236
|
} catch (error) {
|
|
@@ -2245,6 +2411,9 @@ function createCampaignBuilderProofReceipt(plan, result) {
|
|
|
2245
2411
|
campaign_build_id: dryRunResult.campaignBuildId ?? dryRunResult.campaign_build_id ?? null
|
|
2246
2412
|
}
|
|
2247
2413
|
];
|
|
2414
|
+
const learnBackPlan = summarizeCampaignBuilderProofLearnBack(
|
|
2415
|
+
asRecord(asRecord(plan.buildRequest.brainPreflight).learn_back_plan ?? asRecord(plan.brainPreflight).learn_back_plan)
|
|
2416
|
+
);
|
|
2248
2417
|
return {
|
|
2249
2418
|
receipt_version: "campaign-agent-proof.v1",
|
|
2250
2419
|
source: "signaliz.campaignBuilderAgent.proof",
|
|
@@ -2267,6 +2436,7 @@ function createCampaignBuilderProofReceipt(plan, result) {
|
|
|
2267
2436
|
gates,
|
|
2268
2437
|
strategy_memory_status: summarizeCampaignBuilderProofStrategyMemory(strategyMemory),
|
|
2269
2438
|
dry_run_result: summarizeCampaignBuilderProofDryRun(dryRunResult),
|
|
2439
|
+
learn_back_plan: learnBackPlan,
|
|
2270
2440
|
recommended_next_actions: [
|
|
2271
2441
|
"Review the plan, approvals, and dry-run result.",
|
|
2272
2442
|
"Use campaign-agent commit-plan --confirm-write only after review.",
|
|
@@ -2823,6 +2993,13 @@ function campaignBuilderMemoryKitSdkExample(request, seedManifestFile) {
|
|
|
2823
2993
|
function campaignBuilderMemoryKitSource(source) {
|
|
2824
2994
|
const normalized = normalizeTemplateKey(source || "agency");
|
|
2825
2995
|
const catalog = {
|
|
2996
|
+
northStar: {
|
|
2997
|
+
id: "north_star_campaign_builder",
|
|
2998
|
+
label: "North Star campaign-builder acceptance patterns",
|
|
2999
|
+
seed_source: "north-star",
|
|
3000
|
+
scope: "redacted_acceptance_seed_packs",
|
|
3001
|
+
privacy: "redacted aggregate counts, QA gates, and fixture shape only"
|
|
3002
|
+
},
|
|
2826
3003
|
agency: {
|
|
2827
3004
|
id: "agency_campaign_builder",
|
|
2828
3005
|
label: "Agency campaign-builder strategy patterns",
|
|
@@ -2848,6 +3025,10 @@ function campaignBuilderMemoryKitSource(source) {
|
|
|
2848
3025
|
const sourceMap = {
|
|
2849
3026
|
agency: "agency",
|
|
2850
3027
|
"campaign-builder": "agency",
|
|
3028
|
+
"north-star": "northStar",
|
|
3029
|
+
northstar: "northStar",
|
|
3030
|
+
"campaign-builder-north-star": "northStar",
|
|
3031
|
+
acceptance: "northStar",
|
|
2851
3032
|
"strategy-memory": "agency",
|
|
2852
3033
|
"workflow-patterns": "workflow",
|
|
2853
3034
|
workflow: "workflow",
|
|
@@ -2863,13 +3044,13 @@ function campaignBuilderMemoryKitSource(source) {
|
|
|
2863
3044
|
return {
|
|
2864
3045
|
seedSource: "all",
|
|
2865
3046
|
verifyScript: null,
|
|
2866
|
-
memorySources: [catalog.agency, catalog.workflow, catalog.feedback]
|
|
3047
|
+
memorySources: [catalog.northStar, catalog.agency, catalog.workflow, catalog.feedback]
|
|
2867
3048
|
};
|
|
2868
3049
|
}
|
|
2869
3050
|
const item = catalog[selected];
|
|
2870
3051
|
return {
|
|
2871
3052
|
seedSource: item.seed_source,
|
|
2872
|
-
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,
|
|
3053
|
+
verifyScript: item.seed_source === "north-star" ? "scripts/gtm-kernel/verify-north-star-import-manifest.mjs" : item.seed_source === "agency" ? "scripts/gtm-kernel/verify-agency-import-manifest.mjs" : item.seed_source === "building-clay" ? "scripts/gtm-kernel/verify-building-clay-import-manifest.mjs" : null,
|
|
2873
3054
|
memorySources: [item]
|
|
2874
3055
|
};
|
|
2875
3056
|
}
|
|
@@ -3049,11 +3230,11 @@ function builtInRoutesFor(request) {
|
|
|
3049
3230
|
routes.push({
|
|
3050
3231
|
id: "signaliz-lead-generation",
|
|
3051
3232
|
layer: "source",
|
|
3052
|
-
|
|
3233
|
+
gtmLayer: "lead_generation",
|
|
3053
3234
|
provider: "signaliz",
|
|
3054
3235
|
mode: "required",
|
|
3055
3236
|
toolName: "generate_leads",
|
|
3056
|
-
rationale: "
|
|
3237
|
+
rationale: "Inventory verified cache first, then use Signaliz fresh workspace acquisition for the remaining approved gap."
|
|
3057
3238
|
});
|
|
3058
3239
|
}
|
|
3059
3240
|
if (builtIns.has("local_leads")) {
|
|
@@ -3067,6 +3248,28 @@ function builtInRoutesFor(request) {
|
|
|
3067
3248
|
rationale: "Use Signaliz local-leads sourcing for geography-bound local business campaigns."
|
|
3068
3249
|
});
|
|
3069
3250
|
}
|
|
3251
|
+
if (builtIns.has("company_discovery")) {
|
|
3252
|
+
routes.push({
|
|
3253
|
+
id: "signaliz-company-discovery",
|
|
3254
|
+
layer: "source",
|
|
3255
|
+
gtmLayer: "find_company",
|
|
3256
|
+
provider: "signaliz",
|
|
3257
|
+
mode: "if_available",
|
|
3258
|
+
toolName: "find_companies_signaliz",
|
|
3259
|
+
rationale: "Find and qualify company domains before people/email fill for account-led campaigns."
|
|
3260
|
+
});
|
|
3261
|
+
}
|
|
3262
|
+
if (builtIns.has("people_discovery")) {
|
|
3263
|
+
routes.push({
|
|
3264
|
+
id: "signaliz-people-discovery",
|
|
3265
|
+
layer: "source",
|
|
3266
|
+
gtmLayer: "find_people",
|
|
3267
|
+
provider: "signaliz",
|
|
3268
|
+
mode: "if_available",
|
|
3269
|
+
toolName: "find_people_signaliz",
|
|
3270
|
+
rationale: "Find people directly when the brief is contact research or LinkedIn-style prospecting."
|
|
3271
|
+
});
|
|
3272
|
+
}
|
|
3070
3273
|
if (builtIns.has("email_finding")) {
|
|
3071
3274
|
routes.push({
|
|
3072
3275
|
id: "signaliz-email-finding",
|
|
@@ -3111,7 +3314,7 @@ function normalizeBuiltIns(request) {
|
|
|
3111
3314
|
return [...builtIns].filter(isCampaignBuilderBuiltInTool);
|
|
3112
3315
|
}
|
|
3113
3316
|
function isCampaignBuilderBuiltInTool(value) {
|
|
3114
|
-
return ["lead_generation", "local_leads", "email_finding", "email_verification", "signals"].includes(String(value));
|
|
3317
|
+
return ["lead_generation", "local_leads", "company_discovery", "people_discovery", "email_finding", "email_verification", "signals"].includes(String(value));
|
|
3115
3318
|
}
|
|
3116
3319
|
function looksLikeLocalLeadCampaign(request) {
|
|
3117
3320
|
const text = [
|
|
@@ -3166,7 +3369,11 @@ function createBuildRequest(request, defaults, targetCount, campaignName, scopeB
|
|
|
3166
3369
|
qualification: defaults.qualification,
|
|
3167
3370
|
copy: defaults.copy,
|
|
3168
3371
|
delivery: defaults.delivery,
|
|
3169
|
-
enhancers: enhancerConfig(request)
|
|
3372
|
+
enhancers: enhancerConfig(request),
|
|
3373
|
+
sourceRouting: request.sourceRouting ?? {
|
|
3374
|
+
mode: looksLikeLocalLeadCampaign(request) ? "local_leads" : "auto",
|
|
3375
|
+
fillPolicy: "aggressive"
|
|
3376
|
+
}
|
|
3170
3377
|
};
|
|
3171
3378
|
const scoped = asRecord(scopeBuildArgs);
|
|
3172
3379
|
buildRequest.gtmCampaignId = request.gtmCampaignId ?? stringValue(scoped.gtm_campaign_id ?? scoped.gtmCampaignId);
|
|
@@ -3248,9 +3455,132 @@ function createBrainPreflight(request, buildRequest, routes, memory) {
|
|
|
3248
3455
|
{ tool: "gtm_brain_learning_cycle_plan", purpose: "Plan the Brain learning loop for this campaign.", arguments: learningArgs },
|
|
3249
3456
|
{ tool: "gtm_brain_seed_defaults", purpose: "Seed campaign defaults from workspace memory and safe aggregate patterns.", arguments: defaultsArgs },
|
|
3250
3457
|
{ tool: "gtm_brain_delivery_risk", purpose: "Check deliverability risk before launch or external writes.", arguments: riskArgs }
|
|
3251
|
-
]
|
|
3458
|
+
],
|
|
3459
|
+
learn_back_plan: createCampaignBuilderLearnBackPlan(request, buildRequest)
|
|
3252
3460
|
};
|
|
3253
3461
|
}
|
|
3462
|
+
function createCampaignBuilderLearnBackPlan(request, buildRequest) {
|
|
3463
|
+
const instantlyFeedbackContext = campaignBuilderProviderFeedbackContext(request, buildRequest, "instantly");
|
|
3464
|
+
const postBuildSequence = [
|
|
3465
|
+
{
|
|
3466
|
+
tool: "get_campaign_build_status",
|
|
3467
|
+
approval_boundary: "read_only",
|
|
3468
|
+
arguments_template: { campaign_build_id: "<build_campaign.campaign_build_id>" },
|
|
3469
|
+
reason: "Wait for the Campaign Builder run to finish before deriving memory."
|
|
3470
|
+
},
|
|
3471
|
+
{
|
|
3472
|
+
tool: "gtm_campaign_build_backfill_preview",
|
|
3473
|
+
approval_boundary: "read_only",
|
|
3474
|
+
arguments_template: { campaign_build_id: "<build_campaign.campaign_build_id>", create_memory: true },
|
|
3475
|
+
reason: "Preview the provider-neutral Kernel import payload without writing rows."
|
|
3476
|
+
},
|
|
3477
|
+
{
|
|
3478
|
+
tool: "gtm_campaign_build_backfill_run",
|
|
3479
|
+
approval_boundary: "dry_run",
|
|
3480
|
+
arguments_template: { campaign_build_ids: ["<build_campaign.campaign_build_id>"], dry_run: true, create_memory: true, run_brain_cycle: false },
|
|
3481
|
+
reason: "Dry-run the Kernel history import before creating campaign memory."
|
|
3482
|
+
},
|
|
3483
|
+
{
|
|
3484
|
+
tool: "gtm_campaign_build_backfill_run",
|
|
3485
|
+
approval_boundary: "explicit_write_approval",
|
|
3486
|
+
arguments_template: { campaign_build_ids: ["<build_campaign.campaign_build_id>"], dry_run: false, create_memory: true, run_brain_cycle: true, brain_cycle_write_mode: "dry_run" },
|
|
3487
|
+
reason: "After review, queue the Kernel history import; Brain learning remains dry-run unless separately approved."
|
|
3488
|
+
}
|
|
3489
|
+
];
|
|
3490
|
+
if (instantlyFeedbackContext) {
|
|
3491
|
+
postBuildSequence.push({
|
|
3492
|
+
tool: "gtm_instantly_feedback_pull",
|
|
3493
|
+
approval_boundary: "dry_run_first_explicit_write_approval",
|
|
3494
|
+
arguments_template: {
|
|
3495
|
+
campaign_id: buildRequest.gtmCampaignId || "<gtm_campaign_id_after_commit>",
|
|
3496
|
+
campaign_build_id: "<build_campaign.campaign_build_id>",
|
|
3497
|
+
source: "emails",
|
|
3498
|
+
email_type: "received",
|
|
3499
|
+
...instantlyFeedbackContext,
|
|
3500
|
+
dry_run: true,
|
|
3501
|
+
create_memory: true,
|
|
3502
|
+
write_routine_outcomes: true,
|
|
3503
|
+
run_brain_cycle: true,
|
|
3504
|
+
brain_cycle_write_mode: "dry_run"
|
|
3505
|
+
},
|
|
3506
|
+
reason: "After Instantly delivery has live outcomes, pull reply and bounce history into private feedback memory before Brain learning."
|
|
3507
|
+
});
|
|
3508
|
+
}
|
|
3509
|
+
postBuildSequence.push(
|
|
3510
|
+
{
|
|
3511
|
+
tool: "gtm_campaign_learning_status",
|
|
3512
|
+
approval_boundary: "read_only",
|
|
3513
|
+
arguments_template: {
|
|
3514
|
+
campaign_id: buildRequest.gtmCampaignId || "<gtm_campaign_id_after_commit>",
|
|
3515
|
+
campaign_build_id: "<build_campaign.campaign_build_id>",
|
|
3516
|
+
write_mode: "dry_run"
|
|
3517
|
+
},
|
|
3518
|
+
reason: "Confirm feedback, memory, and Brain learning readiness after the import."
|
|
3519
|
+
},
|
|
3520
|
+
{
|
|
3521
|
+
tool: "gtm_memory_search",
|
|
3522
|
+
approval_boundary: "read_only",
|
|
3523
|
+
arguments_template: {
|
|
3524
|
+
query: request.goal,
|
|
3525
|
+
...buildRequest.gtmCampaignId ? { campaign_id: buildRequest.gtmCampaignId } : {},
|
|
3526
|
+
limit: 10
|
|
3527
|
+
},
|
|
3528
|
+
reason: "Verify the new private memory is retrievable for future campaign planning."
|
|
3529
|
+
},
|
|
3530
|
+
{
|
|
3531
|
+
tool: "gtm_brain_learning_cycle_plan",
|
|
3532
|
+
approval_boundary: "read_only",
|
|
3533
|
+
arguments_template: {
|
|
3534
|
+
...buildRequest.gtmCampaignId ? { campaign_id: buildRequest.gtmCampaignId } : {},
|
|
3535
|
+
include_memory: true,
|
|
3536
|
+
write_mode: "dry_run"
|
|
3537
|
+
},
|
|
3538
|
+
reason: "Plan the Brain phases from the imported outcomes before any pattern writes."
|
|
3539
|
+
}
|
|
3540
|
+
);
|
|
3541
|
+
return {
|
|
3542
|
+
source_tool: "campaign-builder-agent",
|
|
3543
|
+
gtm_campaign_id: buildRequest.gtmCampaignId ?? null,
|
|
3544
|
+
trigger: "After build_campaign returns a campaign_build_id and the build reaches a terminal reviewed state.",
|
|
3545
|
+
build_result_placeholders: {
|
|
3546
|
+
campaign_build_id: "<build_campaign.campaign_build_id>"
|
|
3547
|
+
},
|
|
3548
|
+
memory_write_policy: {
|
|
3549
|
+
target_tables: ["gtm_campaigns", "gtm_campaign_provider_links", "gtm_campaign_feedback_events", "gtm_memory_items", "gtm_brain_patterns"],
|
|
3550
|
+
gtm_memory_items: {
|
|
3551
|
+
shareable: false,
|
|
3552
|
+
allowed_redaction_states: ["redacted", "abstracted"],
|
|
3553
|
+
raw_private_fields_withheld: ["reply_text", "copy_body", "lead_email", "lead_domain", "company_domain", "provider_campaign_id", "provider_payload", "webhook_url", "secret"]
|
|
3554
|
+
},
|
|
3555
|
+
gtm_brain_patterns: "Workspace-scoped by default. Global promotion requires abstracted_only=true, shared opt-in, and privacy thresholds."
|
|
3556
|
+
},
|
|
3557
|
+
post_build_sequence: postBuildSequence.map((item, index) => ({ step: index + 1, ...item })),
|
|
3558
|
+
approval_policy: "This agent plan never writes learn-back rows. Backfill and provider-feedback writes require dry_run=false after review, and Brain writes require their own approved learning-cycle run.",
|
|
3559
|
+
privacy_policy: "Learn-back memory is workspace-private. Raw replies, copy bodies, leads, emails, domains, provider payloads, webhook URLs, secrets, private source paths, and raw client labels are withheld from memory rows and agent-visible outputs."
|
|
3560
|
+
};
|
|
3561
|
+
}
|
|
3562
|
+
function campaignBuilderProviderFeedbackContext(request, buildRequest, provider) {
|
|
3563
|
+
const normalizedProvider = String(provider).toLowerCase();
|
|
3564
|
+
const routes = [...request.integrations ?? [], ...routesFromCustomerTools(request.customerTools ?? [])];
|
|
3565
|
+
const providerRoute = routes.find((route) => String(route.provider).toLowerCase() === normalizedProvider);
|
|
3566
|
+
const routeConfig = asRecord(providerRoute?.config);
|
|
3567
|
+
const deliveryConfig = asRecord(buildRequest.delivery?.destinationConfig);
|
|
3568
|
+
const hasProviderContext = [
|
|
3569
|
+
...request.preferredProviders ?? [],
|
|
3570
|
+
...routes.map((route) => route.provider),
|
|
3571
|
+
stringValue(deliveryConfig.provider),
|
|
3572
|
+
stringValue(deliveryConfig.provider_id ?? deliveryConfig.providerId),
|
|
3573
|
+
stringValue(deliveryConfig.destination_provider ?? deliveryConfig.destinationProvider),
|
|
3574
|
+
stringValue(deliveryConfig.sink ?? deliveryConfig.sink_type ?? deliveryConfig.sinkType)
|
|
3575
|
+
].some((value) => String(value).toLowerCase() === normalizedProvider);
|
|
3576
|
+
if (!hasProviderContext) return void 0;
|
|
3577
|
+
return compact({
|
|
3578
|
+
provider_link_id: stringValue(routeConfig.provider_link_id ?? routeConfig.providerLinkId ?? deliveryConfig.provider_link_id ?? deliveryConfig.providerLinkId),
|
|
3579
|
+
provider_campaign_id: stringValue(routeConfig.provider_campaign_id ?? routeConfig.providerCampaignId ?? routeConfig.instantly_campaign_id ?? routeConfig.instantlyCampaignId ?? deliveryConfig.provider_campaign_id ?? deliveryConfig.providerCampaignId ?? deliveryConfig.instantly_campaign_id ?? deliveryConfig.instantlyCampaignId),
|
|
3580
|
+
integration_id: stringValue(routeConfig.integration_id ?? routeConfig.integrationId ?? deliveryConfig.integration_id ?? deliveryConfig.integrationId),
|
|
3581
|
+
instantly_profile: stringValue(routeConfig.instantly_profile ?? routeConfig.instantlyProfile ?? routeConfig.profile ?? deliveryConfig.instantly_profile ?? deliveryConfig.instantlyProfile ?? deliveryConfig.profile)
|
|
3582
|
+
});
|
|
3583
|
+
}
|
|
3254
3584
|
function gtmLayersForBuilderLayer(layer) {
|
|
3255
3585
|
const map = {
|
|
3256
3586
|
workspace_context: ["customer_data"],
|
|
@@ -3655,6 +3985,7 @@ function buildFallbackPlanSnapshot(plan) {
|
|
|
3655
3985
|
target_count: plan.targetCount,
|
|
3656
3986
|
approvals: plan.approvals,
|
|
3657
3987
|
brain_preflight: plan.brainPreflight,
|
|
3988
|
+
campaign_strategy_context: plan.buildRequest.campaignStrategyContext,
|
|
3658
3989
|
operating_playbooks: plan.operatingPlaybooks
|
|
3659
3990
|
});
|
|
3660
3991
|
}
|
|
@@ -3787,6 +4118,7 @@ function buildCampaignArgs(request) {
|
|
|
3787
4118
|
if (request.dedupKeys) args.dedup_keys = request.dedupKeys;
|
|
3788
4119
|
if (request.brainPreflight) args.brain_preflight = request.brainPreflight;
|
|
3789
4120
|
if (request.brainDefaults) args.brain_defaults = request.brainDefaults;
|
|
4121
|
+
if (request.campaignStrategyContext) args.campaign_strategy_context = request.campaignStrategyContext;
|
|
3790
4122
|
if (request.deliveryRisk) args.delivery_risk = request.deliveryRisk;
|
|
3791
4123
|
if (request.icp) {
|
|
3792
4124
|
args.icp = compact({
|
|
@@ -3806,6 +4138,15 @@ function buildCampaignArgs(request) {
|
|
|
3806
4138
|
model: request.policy.model
|
|
3807
4139
|
});
|
|
3808
4140
|
}
|
|
4141
|
+
if (request.sourceRouting) {
|
|
4142
|
+
args.source_routing = compact({
|
|
4143
|
+
mode: request.sourceRouting.mode,
|
|
4144
|
+
fill_policy: request.sourceRouting.fillPolicy,
|
|
4145
|
+
shard_size: request.sourceRouting.shardSize,
|
|
4146
|
+
max_source_shard_size: request.sourceRouting.maxSourceShardSize,
|
|
4147
|
+
max_local_source_shard_size: request.sourceRouting.maxLocalSourceShardSize
|
|
4148
|
+
});
|
|
4149
|
+
}
|
|
3809
4150
|
if (request.signals) {
|
|
3810
4151
|
args.signals = compact({
|
|
3811
4152
|
enabled: request.signals.enabled,
|
|
@@ -3877,7 +4218,8 @@ function buildExecutionPrepareArgs(request, dryRun, confirmSpend) {
|
|
|
3877
4218
|
qualification: buildArgs2.qualification,
|
|
3878
4219
|
copy: buildArgs2.copy,
|
|
3879
4220
|
delivery: buildArgs2.delivery,
|
|
3880
|
-
enhancers: buildArgs2.enhancers
|
|
4221
|
+
enhancers: buildArgs2.enhancers,
|
|
4222
|
+
source_routing: buildArgs2.source_routing
|
|
3881
4223
|
});
|
|
3882
4224
|
}
|
|
3883
4225
|
function buildDeliveryApprovalArgs(request) {
|
|
@@ -3926,17 +4268,62 @@ function mapAgentCampaignBuildStatus(data) {
|
|
|
3926
4268
|
warnings: diagnosticMessages2(data.warnings),
|
|
3927
4269
|
errors: diagnosticMessages2(data.errors),
|
|
3928
4270
|
artifactCount: numberOrUndefined2(data.artifact_count) ?? 0,
|
|
4271
|
+
artifactDownloads: Array.isArray(data.artifact_downloads) ? data.artifact_downloads.map(mapAgentCampaignArtifactDownload) : [],
|
|
4272
|
+
customerRowCounts: mapAgentCustomerRowCounts(data.customer_row_counts),
|
|
4273
|
+
phaseAttemptTotals: nullableRecord(data.phase_attempt_totals) ?? void 0,
|
|
3929
4274
|
providerRoute: mapProviderRoute2(data),
|
|
3930
4275
|
triggerRunId: stringValue(data.trigger_run_id) ?? null,
|
|
3931
4276
|
staleRunningPhase: data.stale_running_phase === true,
|
|
3932
4277
|
phaseAgeSeconds: numberOrNull2(data.phase_age_seconds),
|
|
3933
4278
|
diagnostics: nullableRecord(data.diagnostics) ?? {},
|
|
3934
4279
|
nextAction: formatAgentNextAction(data.next_action),
|
|
4280
|
+
approvalAction: formatAgentNextAction(data.approval_action),
|
|
3935
4281
|
createdAt: stringValue(data.created_at) ?? "",
|
|
3936
4282
|
updatedAt: stringValue(data.updated_at) ?? "",
|
|
3937
4283
|
completedAt: stringValue(data.completed_at) ?? null
|
|
3938
4284
|
};
|
|
3939
4285
|
}
|
|
4286
|
+
function mapAgentCampaignArtifactDownload(data) {
|
|
4287
|
+
return {
|
|
4288
|
+
id: stringValue(data.id) ?? "",
|
|
4289
|
+
artifactType: stringValue(data.artifact_type) ?? null,
|
|
4290
|
+
format: stringValue(data.format) ?? null,
|
|
4291
|
+
rowCount: numberOrUndefined2(data.row_count) ?? 0,
|
|
4292
|
+
signedUrl: stringValue(data.signed_url) ?? null,
|
|
4293
|
+
downloadUrl: stringValue(data.download_url) ?? null,
|
|
4294
|
+
manifestUrl: stringValue(data.manifest_url) ?? null,
|
|
4295
|
+
expiresAt: stringValue(data.expires_at) ?? null
|
|
4296
|
+
};
|
|
4297
|
+
}
|
|
4298
|
+
function mapAgentCustomerRowCounts(value) {
|
|
4299
|
+
const record = nullableRecord(value);
|
|
4300
|
+
if (!record) return void 0;
|
|
4301
|
+
return {
|
|
4302
|
+
requestedTarget: numberOrNull2(record.requested_target),
|
|
4303
|
+
acquiredRows: numberOrUndefined2(record.acquired_rows),
|
|
4304
|
+
acceptedRows: numberOrUndefined2(record.accepted_rows),
|
|
4305
|
+
usableRows: numberOrUndefined2(record.usable_rows),
|
|
4306
|
+
copiedRows: numberOrUndefined2(record.copied_rows),
|
|
4307
|
+
approvalReadyRows: numberOrUndefined2(record.approval_ready_rows),
|
|
4308
|
+
qaReadyRows: numberOrUndefined2(record.qa_ready_rows),
|
|
4309
|
+
deliveredRows: numberOrUndefined2(record.delivered_rows),
|
|
4310
|
+
disqualifiedRows: numberOrUndefined2(record.disqualified_rows),
|
|
4311
|
+
reviewableRows: numberOrUndefined2(record.reviewable_rows),
|
|
4312
|
+
rowFailures: numberOrUndefined2(record.row_failures),
|
|
4313
|
+
acceptedShortfall: numberOrNull2(record.accepted_shortfall),
|
|
4314
|
+
usableShortfall: numberOrNull2(record.usable_shortfall),
|
|
4315
|
+
qaReadyShortfall: numberOrNull2(record.qa_ready_shortfall),
|
|
4316
|
+
deliveryShortfall: numberOrNull2(record.delivery_shortfall),
|
|
4317
|
+
fillRatio: numberOrNull2(record.fill_ratio),
|
|
4318
|
+
qaReadyFillRatio: numberOrNull2(record.qa_ready_fill_ratio),
|
|
4319
|
+
deliveredFillRatio: numberOrNull2(record.delivered_fill_ratio),
|
|
4320
|
+
terminalReason: stringValue(record.terminal_reason) ?? null,
|
|
4321
|
+
acceptedShortfallReason: stringValue(record.accepted_shortfall_reason) ?? null,
|
|
4322
|
+
usableShortfallReason: stringValue(record.usable_shortfall_reason) ?? null,
|
|
4323
|
+
qaReadyShortfallReason: stringValue(record.qa_ready_shortfall_reason) ?? null,
|
|
4324
|
+
deliveryShortfallReason: stringValue(record.delivery_shortfall_reason) ?? null
|
|
4325
|
+
};
|
|
4326
|
+
}
|
|
3940
4327
|
function mapAgentCampaignRowsResult(data) {
|
|
3941
4328
|
const rows = Array.isArray(data.rows) ? data.rows : [];
|
|
3942
4329
|
return {
|
|
@@ -3964,7 +4351,11 @@ function mapAgentCampaignArtifact(data) {
|
|
|
3964
4351
|
artifactType: stringValue(data.artifact_type) ?? "",
|
|
3965
4352
|
destination: stringValue(data.destination) ?? "",
|
|
3966
4353
|
storagePath: stringValue(data.storage_path) ?? "",
|
|
4354
|
+
format: stringValue(data.format) ?? null,
|
|
3967
4355
|
signedUrl: stringValue(data.signed_url) ?? null,
|
|
4356
|
+
downloadUrl: stringValue(data.download_url) ?? null,
|
|
4357
|
+
manifestUrl: stringValue(data.manifest_url) ?? null,
|
|
4358
|
+
expiresAt: stringValue(data.expires_at) ?? null,
|
|
3968
4359
|
rowCount: numberOrUndefined2(data.row_count) ?? 0,
|
|
3969
4360
|
checksum: stringValue(data.checksum) ?? null,
|
|
3970
4361
|
metadata: nullableRecord(data.metadata) ?? {},
|
|
@@ -4126,6 +4517,8 @@ function readinessLaneLabel(route, builtIn) {
|
|
|
4126
4517
|
const labels = {
|
|
4127
4518
|
lead_generation: "Signaliz lead generation",
|
|
4128
4519
|
local_leads: "Signaliz local leads",
|
|
4520
|
+
company_discovery: "Signaliz company discovery",
|
|
4521
|
+
people_discovery: "Signaliz people discovery",
|
|
4129
4522
|
email_finding: "Signaliz email finding",
|
|
4130
4523
|
email_verification: "Signaliz email verification",
|
|
4131
4524
|
signals: "Signaliz signals"
|
|
@@ -4210,6 +4603,35 @@ function summarizeCampaignBuilderProofDryRun(dryRunResult) {
|
|
|
4210
4603
|
plannedTargetCount: dryRunResult.plannedTargetCount ?? dryRunResult.planned_target_count ?? null
|
|
4211
4604
|
};
|
|
4212
4605
|
}
|
|
4606
|
+
function summarizeCampaignBuilderProofLearnBack(plan) {
|
|
4607
|
+
if (Object.keys(plan).length === 0) return { ready: false };
|
|
4608
|
+
const memoryPolicy = asRecord(plan.memory_write_policy);
|
|
4609
|
+
const memoryItemsPolicy = asRecord(memoryPolicy.gtm_memory_items);
|
|
4610
|
+
const sequence = Array.isArray(plan.post_build_sequence) ? plan.post_build_sequence.map((step) => {
|
|
4611
|
+
const record = asRecord(step);
|
|
4612
|
+
return compact({
|
|
4613
|
+
step: record.step,
|
|
4614
|
+
tool: stringValue(record.tool),
|
|
4615
|
+
approval_boundary: stringValue(record.approval_boundary),
|
|
4616
|
+
reason: stringValue(record.reason)
|
|
4617
|
+
});
|
|
4618
|
+
}).filter((step) => typeof step.tool === "string") : [];
|
|
4619
|
+
return {
|
|
4620
|
+
ready: sequence.length > 0,
|
|
4621
|
+
source_tool: firstNonEmptyString(plan.source_tool, plan.sourceTool),
|
|
4622
|
+
post_build_sequence: sequence,
|
|
4623
|
+
memory_write_policy: {
|
|
4624
|
+
target_tables: Array.isArray(memoryPolicy.target_tables) ? memoryPolicy.target_tables : [],
|
|
4625
|
+
gtm_memory_items: {
|
|
4626
|
+
shareable: memoryItemsPolicy.shareable === false ? false : memoryItemsPolicy.shareable ?? null,
|
|
4627
|
+
allowed_redaction_states: Array.isArray(memoryItemsPolicy.allowed_redaction_states) ? memoryItemsPolicy.allowed_redaction_states : [],
|
|
4628
|
+
raw_private_fields_withheld: Array.isArray(memoryItemsPolicy.raw_private_fields_withheld) ? memoryItemsPolicy.raw_private_fields_withheld : []
|
|
4629
|
+
}
|
|
4630
|
+
},
|
|
4631
|
+
approval_policy: firstNonEmptyString(plan.approval_policy, plan.approvalPolicy),
|
|
4632
|
+
privacy_policy: firstNonEmptyString(plan.privacy_policy, plan.privacyPolicy)
|
|
4633
|
+
};
|
|
4634
|
+
}
|
|
4213
4635
|
function firstNonEmptyString(...values) {
|
|
4214
4636
|
for (const value of values) {
|
|
4215
4637
|
if (typeof value === "string" && value.trim()) return value;
|
|
@@ -4692,14 +5114,87 @@ var Ops = class {
|
|
|
4692
5114
|
const body = typeof params === "string" ? { prompt: params } : buildOpsCreateBody(params);
|
|
4693
5115
|
return normalizeOpsCreateResult(withExecutionRefs(await this.call("ops_create", body)));
|
|
4694
5116
|
}
|
|
5117
|
+
async schedule(params) {
|
|
5118
|
+
const createBody = typeof params === "string" ? { prompt: params, cadence: "daily" } : { ...buildOpsCreateBody(params), cadence: params.cadence ?? "daily" };
|
|
5119
|
+
const { activate: _activate, ...body } = createBody;
|
|
5120
|
+
return normalizeOpsCreateResult(withExecutionRefs(await this.call("ops_schedule", body)));
|
|
5121
|
+
}
|
|
5122
|
+
async scheduleAndWait(params) {
|
|
5123
|
+
const options = typeof params === "string" ? { schedule: { prompt: params, cadence: "daily" }, run: {}, wait: {} } : buildOpsScheduleAndWaitOptions(params);
|
|
5124
|
+
const raw = await this.call("ops_schedule_and_wait", buildOpsScheduleAndWaitBody(options));
|
|
5125
|
+
return normalizeOpsScheduleAndWaitCallResult(raw, options.wait, {
|
|
5126
|
+
approvalMessage: "ops.scheduleAndWait requires an approved schedulable Op. Retry with confirmSpend=true after reviewing approval details.",
|
|
5127
|
+
notCreatedMessage: "ops.scheduleAndWait requires ops_schedule_and_wait to create an op_id. Use ops.schedule for approval review flows."
|
|
5128
|
+
});
|
|
5129
|
+
}
|
|
5130
|
+
/** Schedule a recurring Op that delivers through a customer-owned Nango API connection. */
|
|
5131
|
+
async scheduleNangoAction(input) {
|
|
5132
|
+
return normalizeOpsCreateResult(withExecutionRefs(await this.call("ops_nango_schedule", buildOpsNangoScheduleBody(input))));
|
|
5133
|
+
}
|
|
5134
|
+
/** Schedule a recurring Nango-backed Op, run the first tick, and return result readback. */
|
|
5135
|
+
async scheduleNangoActionAndWait(input) {
|
|
5136
|
+
const options = buildOpsNangoScheduleAndWaitOptions(input);
|
|
5137
|
+
const raw = await this.call("ops_nango_schedule_and_wait", buildOpsNangoScheduleAndWaitBody(options));
|
|
5138
|
+
return normalizeOpsScheduleAndWaitCallResult(raw, options.wait, {
|
|
5139
|
+
approvalMessage: "ops.scheduleNangoActionAndWait requires an approved Nango-backed Op. Retry with confirmSpend=true after reviewing approval details.",
|
|
5140
|
+
notCreatedMessage: "ops.scheduleNangoActionAndWait requires ops_nango_schedule_and_wait to create an op_id. Use ops.scheduleNangoAction for approval review flows."
|
|
5141
|
+
});
|
|
5142
|
+
}
|
|
4695
5143
|
async execute(params) {
|
|
4696
5144
|
const body = typeof params === "string" ? { prompt: params } : buildOpsExecuteBody(params);
|
|
4697
5145
|
return normalizeOpsExecuteResult(withExecutionRefs(await this.call("ops_execute", body)));
|
|
4698
5146
|
}
|
|
5147
|
+
async executeAndWait(params) {
|
|
5148
|
+
const options = typeof params === "string" ? { execute: { prompt: params, auto_run: true }, wait: {} } : buildOpsExecuteAndWaitOptions(params);
|
|
5149
|
+
const execute = await this.execute(options.execute);
|
|
5150
|
+
if (execute.approval_required || execute.error_code === "APPROVAL_REQUIRED") {
|
|
5151
|
+
throw new SignalizError({
|
|
5152
|
+
code: "APPROVAL_REQUIRED",
|
|
5153
|
+
errorType: "validation",
|
|
5154
|
+
message: "ops.executeAndWait requires an approved executable Op. Retry with confirmSpend=true after reviewing approval details.",
|
|
5155
|
+
details: { execute }
|
|
5156
|
+
});
|
|
5157
|
+
}
|
|
5158
|
+
if (!execute.op_id) {
|
|
5159
|
+
throw new SignalizError({
|
|
5160
|
+
code: "OP_NOT_CREATED",
|
|
5161
|
+
errorType: "validation",
|
|
5162
|
+
message: "ops.executeAndWait requires ops_execute to create an op_id. Use ops.execute for dry runs or approval review flows.",
|
|
5163
|
+
details: { execute }
|
|
5164
|
+
});
|
|
5165
|
+
}
|
|
5166
|
+
const waited = await this.waitForResults({
|
|
5167
|
+
...options.wait,
|
|
5168
|
+
op_id: execute.op_id
|
|
5169
|
+
});
|
|
5170
|
+
const runId = execute.run_id ?? execute.runId ?? waited.status.run_id ?? waited.status.runId ?? null;
|
|
5171
|
+
return {
|
|
5172
|
+
...waited,
|
|
5173
|
+
execute,
|
|
5174
|
+
run_id: runId,
|
|
5175
|
+
runId,
|
|
5176
|
+
execution_refs: mergeExecutionRefsFrom([execute, waited])
|
|
5177
|
+
};
|
|
5178
|
+
}
|
|
4699
5179
|
async run(params) {
|
|
4700
5180
|
const body = typeof params === "string" ? { op_id: params } : buildOpsRunBody(params);
|
|
4701
5181
|
return normalizeOpsRunResult(withExecutionRefs(await this.call("ops_run", body)));
|
|
4702
5182
|
}
|
|
5183
|
+
async runAndWait(params) {
|
|
5184
|
+
const options = typeof params === "string" ? { op_id: params } : buildOpsRunAndWaitOptions(params);
|
|
5185
|
+
if (!options.op_id) throw new Error("ops.runAndWait requires op_id or opId");
|
|
5186
|
+
const run = await this.run({
|
|
5187
|
+
op_id: options.op_id,
|
|
5188
|
+
instruction: options.instruction,
|
|
5189
|
+
force: options.force
|
|
5190
|
+
});
|
|
5191
|
+
const waited = await this.waitForResults(options);
|
|
5192
|
+
return {
|
|
5193
|
+
...waited,
|
|
5194
|
+
run,
|
|
5195
|
+
execution_refs: mergeExecutionRefsFrom([run, waited])
|
|
5196
|
+
};
|
|
5197
|
+
}
|
|
4703
5198
|
async status(params) {
|
|
4704
5199
|
const body = typeof params === "string" ? { op_id: params } : buildOpsStatusBody(params);
|
|
4705
5200
|
return normalizeOpsStatusResult(withExecutionRefs(await this.call("ops_status", body)));
|
|
@@ -4708,6 +5203,173 @@ var Ops = class {
|
|
|
4708
5203
|
const body = typeof params === "string" ? { op_id: params } : buildOpsResultsBody(params);
|
|
4709
5204
|
return normalizeOpsResultsResult(withExecutionRefs(await this.call("ops_results", body)));
|
|
4710
5205
|
}
|
|
5206
|
+
async waitForResults(params) {
|
|
5207
|
+
const options = typeof params === "string" ? { op_id: params } : buildOpsWaitForResultsOptions(params);
|
|
5208
|
+
if (!options.op_id) throw new Error("ops.waitForResults requires op_id or opId");
|
|
5209
|
+
const waitResult = await this.call("ops_wait", buildOpsWaitBody(options));
|
|
5210
|
+
return normalizeOpsWaitForResultsResult(waitResult, options);
|
|
5211
|
+
}
|
|
5212
|
+
/** Create a short-lived Nango Connect session from the Ops namespace. */
|
|
5213
|
+
async createNangoConnectSession(input) {
|
|
5214
|
+
return this.call("nango_connect_session_create", {
|
|
5215
|
+
provider_id: input.providerId,
|
|
5216
|
+
integration_id: input.integrationId,
|
|
5217
|
+
provider_display_name: input.providerDisplayName,
|
|
5218
|
+
integration_display_name: input.integrationDisplayName,
|
|
5219
|
+
allowed_integrations: input.allowedIntegrations,
|
|
5220
|
+
surface: input.surface,
|
|
5221
|
+
source: input.source,
|
|
5222
|
+
user_email: input.userEmail,
|
|
5223
|
+
user_display_name: input.userDisplayName
|
|
5224
|
+
});
|
|
5225
|
+
}
|
|
5226
|
+
/** Prepare the full Nango provider search, connect, pull/export, Ops, and route flow. */
|
|
5227
|
+
async prepareNangoIntegrationFlow(input = {}) {
|
|
5228
|
+
return this.call("nango_integration_flow_prepare", {
|
|
5229
|
+
query: input.query,
|
|
5230
|
+
search: input.search,
|
|
5231
|
+
provider_id: input.providerId,
|
|
5232
|
+
provider: input.provider,
|
|
5233
|
+
integration_id: input.integrationId,
|
|
5234
|
+
provider_config_key: input.providerConfigKey,
|
|
5235
|
+
workspace_connection_id: input.workspaceConnectionId,
|
|
5236
|
+
connection_id: input.connectionId,
|
|
5237
|
+
nango_connection_id: input.nangoConnectionId,
|
|
5238
|
+
intent: input.intent,
|
|
5239
|
+
action_name: input.actionName,
|
|
5240
|
+
tool_name: input.toolName,
|
|
5241
|
+
proxy_path: input.proxyPath,
|
|
5242
|
+
method: input.method,
|
|
5243
|
+
input: input.input,
|
|
5244
|
+
cadence: input.cadence,
|
|
5245
|
+
field_map: input.fieldMap,
|
|
5246
|
+
required_fields: input.requiredFields,
|
|
5247
|
+
confirm_spend: input.confirmSpend,
|
|
5248
|
+
write_confirmed: input.writeConfirmed,
|
|
5249
|
+
layer: input.layer,
|
|
5250
|
+
campaign_id: input.campaignId,
|
|
5251
|
+
limit: input.limit,
|
|
5252
|
+
include_provider_catalog: input.includeProviderCatalog
|
|
5253
|
+
});
|
|
5254
|
+
}
|
|
5255
|
+
/** List Nango-backed action tools for a workspace connection without executing them. */
|
|
5256
|
+
async listNangoTools(options = {}) {
|
|
5257
|
+
return this.call("nango_mcp_tools_list", {
|
|
5258
|
+
workspace_connection_id: options.workspaceConnectionId,
|
|
5259
|
+
connection_id: options.connectionId,
|
|
5260
|
+
provider_config_key: options.providerConfigKey,
|
|
5261
|
+
integration_id: options.integrationId,
|
|
5262
|
+
nango_connection_id: options.nangoConnectionId,
|
|
5263
|
+
format: options.format,
|
|
5264
|
+
include_raw: options.includeRaw
|
|
5265
|
+
});
|
|
5266
|
+
}
|
|
5267
|
+
/** Audit connected Nango rows, action/proxy readiness, and read/write proof gaps. */
|
|
5268
|
+
async proveNangoReadWrite(options = {}) {
|
|
5269
|
+
return this.call("nango_mcp_read_write_audit", {
|
|
5270
|
+
workspace_connection_id: options.workspaceConnectionId,
|
|
5271
|
+
connection_id: options.connectionId,
|
|
5272
|
+
provider_config_key: options.providerConfigKey,
|
|
5273
|
+
integration_id: options.integrationId,
|
|
5274
|
+
nango_connection_id: options.nangoConnectionId,
|
|
5275
|
+
limit: options.limit,
|
|
5276
|
+
include_raw: options.includeRaw,
|
|
5277
|
+
read_proxy_path: options.readProxyPath,
|
|
5278
|
+
write_proxy_path: options.writeProxyPath,
|
|
5279
|
+
method: options.method,
|
|
5280
|
+
execute_read_probe: options.executeReadProbe,
|
|
5281
|
+
execute_write_probe: options.executeWriteProbe,
|
|
5282
|
+
confirm: options.confirm,
|
|
5283
|
+
confirm_write: options.confirmWrite,
|
|
5284
|
+
input: options.input,
|
|
5285
|
+
write_input: options.writeInput
|
|
5286
|
+
});
|
|
5287
|
+
}
|
|
5288
|
+
/** Dry-run or execute a Nango-backed action tool through the approval-aware MCP bridge. */
|
|
5289
|
+
async callNangoTool(input) {
|
|
5290
|
+
return this.call("nango_mcp_tool_call", {
|
|
5291
|
+
workspace_connection_id: input.workspaceConnectionId,
|
|
5292
|
+
connection_id: input.connectionId,
|
|
5293
|
+
provider_config_key: input.providerConfigKey,
|
|
5294
|
+
integration_id: input.integrationId,
|
|
5295
|
+
nango_connection_id: input.nangoConnectionId,
|
|
5296
|
+
action_name: input.actionName,
|
|
5297
|
+
tool_name: input.toolName,
|
|
5298
|
+
delivery_mode: input.deliveryMode,
|
|
5299
|
+
proxy_path: input.proxyPath,
|
|
5300
|
+
nango_proxy_path: input.nangoProxyPath,
|
|
5301
|
+
method: input.method,
|
|
5302
|
+
http_method: input.httpMethod,
|
|
5303
|
+
proxy_headers: input.proxyHeaders,
|
|
5304
|
+
input: input.input,
|
|
5305
|
+
async: input.async,
|
|
5306
|
+
max_retries: input.maxRetries,
|
|
5307
|
+
dry_run: input.dryRun,
|
|
5308
|
+
confirm: input.confirm,
|
|
5309
|
+
confirm_write: input.confirmWrite
|
|
5310
|
+
});
|
|
5311
|
+
}
|
|
5312
|
+
/** Execute a Nango action and poll its async result when a status URL/action id is returned. */
|
|
5313
|
+
async callNangoToolAndWait(input) {
|
|
5314
|
+
const result = await this.call("nango_mcp_tool_call_and_wait", {
|
|
5315
|
+
workspace_connection_id: input.workspaceConnectionId,
|
|
5316
|
+
connection_id: input.connectionId,
|
|
5317
|
+
provider_config_key: input.providerConfigKey,
|
|
5318
|
+
integration_id: input.integrationId,
|
|
5319
|
+
nango_connection_id: input.nangoConnectionId,
|
|
5320
|
+
action_name: input.actionName,
|
|
5321
|
+
tool_name: input.toolName,
|
|
5322
|
+
delivery_mode: input.deliveryMode,
|
|
5323
|
+
proxy_path: input.proxyPath,
|
|
5324
|
+
nango_proxy_path: input.nangoProxyPath,
|
|
5325
|
+
method: input.method,
|
|
5326
|
+
http_method: input.httpMethod,
|
|
5327
|
+
proxy_headers: input.proxyHeaders,
|
|
5328
|
+
input: input.input,
|
|
5329
|
+
async: input.async ?? true,
|
|
5330
|
+
max_retries: input.maxRetries,
|
|
5331
|
+
dry_run: input.dryRun,
|
|
5332
|
+
confirm: input.confirm,
|
|
5333
|
+
confirm_write: input.confirmWrite,
|
|
5334
|
+
interval_ms: input.intervalMs,
|
|
5335
|
+
max_polls: input.maxPolls,
|
|
5336
|
+
timeout_ms: input.timeoutMs
|
|
5337
|
+
});
|
|
5338
|
+
const packet = asRecord2(result);
|
|
5339
|
+
const actionId = optionalString(packet.actionId) ?? optionalString(packet.action_id);
|
|
5340
|
+
const statusUrl = optionalString(packet.statusUrl) ?? optionalString(packet.status_url);
|
|
5341
|
+
const maxPolls = Number(packet.maxPolls ?? packet.max_polls ?? 0);
|
|
5342
|
+
const intervalMs = Number(packet.intervalMs ?? packet.interval_ms ?? 0);
|
|
5343
|
+
const timeoutMs = Number(packet.timeoutMs ?? packet.timeout_ms ?? 0);
|
|
5344
|
+
const timedOut = Boolean(packet.timedOut ?? packet.timed_out);
|
|
5345
|
+
return {
|
|
5346
|
+
...packet,
|
|
5347
|
+
success: typeof packet.success === "boolean" ? packet.success : void 0,
|
|
5348
|
+
call: packet.call,
|
|
5349
|
+
result: packet.result,
|
|
5350
|
+
status: optionalString(packet.status),
|
|
5351
|
+
action_id: actionId,
|
|
5352
|
+
actionId,
|
|
5353
|
+
status_url: statusUrl,
|
|
5354
|
+
statusUrl,
|
|
5355
|
+
polls: Number(packet.polls ?? 0),
|
|
5356
|
+
max_polls: maxPolls,
|
|
5357
|
+
maxPolls,
|
|
5358
|
+
interval_ms: intervalMs,
|
|
5359
|
+
intervalMs,
|
|
5360
|
+
timeout_ms: timeoutMs,
|
|
5361
|
+
timeoutMs,
|
|
5362
|
+
timed_out: timedOut,
|
|
5363
|
+
timedOut
|
|
5364
|
+
};
|
|
5365
|
+
}
|
|
5366
|
+
/** Poll an async Nango action result by action id or status URL. */
|
|
5367
|
+
async getNangoActionResult(input) {
|
|
5368
|
+
return this.call("nango_mcp_action_result_get", {
|
|
5369
|
+
action_id: input.actionId,
|
|
5370
|
+
status_url: input.statusUrl
|
|
5371
|
+
});
|
|
5372
|
+
}
|
|
4711
5373
|
async proof(params = {}) {
|
|
4712
5374
|
const data = await this.call("ops_proof", {
|
|
4713
5375
|
window_hours: params.windowHours,
|
|
@@ -4734,51 +5396,57 @@ var Ops = class {
|
|
|
4734
5396
|
addRefs(collectExecutionReferences(status.latest_run));
|
|
4735
5397
|
}
|
|
4736
5398
|
const runRefs = Array.from(refs.values()).filter((ref) => ref.kind === "trigger_run" || ref.kind === "dataplane_run" || ref.kind === "replay_run");
|
|
4737
|
-
|
|
4738
|
-
for (const ref of runRefs) {
|
|
4739
|
-
try {
|
|
4740
|
-
const result = await this.getTriggerRunStatus(ref.id);
|
|
4741
|
-
const runs = "runs" in result ? result.runs : [result];
|
|
4742
|
-
runStatuses.push(...runs);
|
|
4743
|
-
for (const run of runs) addRefs(run.execution_refs);
|
|
4744
|
-
} catch (err) {
|
|
4745
|
-
recordError(`run-status:${ref.id}`, err);
|
|
4746
|
-
}
|
|
4747
|
-
}
|
|
5399
|
+
let runStatuses = [];
|
|
4748
5400
|
let queue;
|
|
4749
|
-
if (options.include_queue !== false) {
|
|
4750
|
-
try {
|
|
4751
|
-
queue = await this.getQueueStatus({ summary: true });
|
|
4752
|
-
addRefs(queue.execution_refs);
|
|
4753
|
-
} catch (err) {
|
|
4754
|
-
recordError("queue", err);
|
|
4755
|
-
}
|
|
4756
|
-
}
|
|
4757
5401
|
let dashboardRecent;
|
|
4758
|
-
if (options.include_dashboard !== false) {
|
|
4759
|
-
try {
|
|
4760
|
-
dashboardRecent = await this.getDashboard({
|
|
4761
|
-
section: "recent",
|
|
4762
|
-
limit: options.dashboard_limit ?? 10,
|
|
4763
|
-
timeRangeDays: options.time_range_days
|
|
4764
|
-
});
|
|
4765
|
-
} catch (err) {
|
|
4766
|
-
recordError("dashboard:recent", err);
|
|
4767
|
-
}
|
|
4768
|
-
}
|
|
4769
5402
|
let results;
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
5403
|
+
await Promise.all([
|
|
5404
|
+
(async () => {
|
|
5405
|
+
if (runRefs.length === 0) return;
|
|
5406
|
+
try {
|
|
5407
|
+
const result = await this.getTriggerRunStatus({ run_ids: runRefs.map((ref) => ref.id) });
|
|
5408
|
+
const runs = "runs" in result ? result.runs : [result];
|
|
5409
|
+
runStatuses = runs;
|
|
5410
|
+
for (const run of runs) addRefs(run.execution_refs);
|
|
5411
|
+
} catch (err) {
|
|
5412
|
+
recordError(runRefs.length === 1 ? `run-status:${runRefs[0].id}` : "run-status:batch", err);
|
|
5413
|
+
}
|
|
5414
|
+
})(),
|
|
5415
|
+
(async () => {
|
|
5416
|
+
if (options.include_queue === false) return;
|
|
5417
|
+
try {
|
|
5418
|
+
queue = await this.getQueueStatus({ summary: true });
|
|
5419
|
+
addRefs(queue.execution_refs);
|
|
5420
|
+
} catch (err) {
|
|
5421
|
+
recordError("queue", err);
|
|
5422
|
+
}
|
|
5423
|
+
})(),
|
|
5424
|
+
(async () => {
|
|
5425
|
+
if (options.include_dashboard === false) return;
|
|
5426
|
+
try {
|
|
5427
|
+
dashboardRecent = await this.getDashboard({
|
|
5428
|
+
section: "recent",
|
|
5429
|
+
limit: options.dashboard_limit ?? 10,
|
|
5430
|
+
timeRangeDays: options.time_range_days
|
|
5431
|
+
});
|
|
5432
|
+
} catch (err) {
|
|
5433
|
+
recordError("dashboard:recent", err);
|
|
5434
|
+
}
|
|
5435
|
+
})(),
|
|
5436
|
+
(async () => {
|
|
5437
|
+
if (!options.include_results) return;
|
|
5438
|
+
try {
|
|
5439
|
+
results = await this.results({
|
|
5440
|
+
op_id: options.op_id,
|
|
5441
|
+
limit: options.results_limit ?? 25,
|
|
5442
|
+
include_failed_runs: true
|
|
5443
|
+
});
|
|
5444
|
+
addRefs(results.execution_refs);
|
|
5445
|
+
} catch (err) {
|
|
5446
|
+
recordError("results", err);
|
|
5447
|
+
}
|
|
5448
|
+
})()
|
|
5449
|
+
]);
|
|
4782
5450
|
const executionRefs = Array.from(refs.values());
|
|
4783
5451
|
const replayCandidates = executionRefs.filter((ref) => ref.kind === "execution_event");
|
|
4784
5452
|
const nextActions = buildDebugNextActions(status, executionRefs, diagnosticErrors);
|
|
@@ -4980,6 +5648,69 @@ function mergeExecutionRefs(result) {
|
|
|
4980
5648
|
for (const ref of collectExecutionReferences(result)) add(ref);
|
|
4981
5649
|
return Array.from(refs.values());
|
|
4982
5650
|
}
|
|
5651
|
+
function mergeExecutionRefsFrom(results) {
|
|
5652
|
+
const refs = /* @__PURE__ */ new Map();
|
|
5653
|
+
for (const result of results) {
|
|
5654
|
+
if (!result) continue;
|
|
5655
|
+
for (const ref of mergeExecutionRefs(result)) refs.set(`${ref.kind}:${ref.id}`, ref);
|
|
5656
|
+
}
|
|
5657
|
+
return Array.from(refs.values());
|
|
5658
|
+
}
|
|
5659
|
+
function normalizeOpsScheduleAndWaitCallResult(raw, waitOptions, messages) {
|
|
5660
|
+
if (raw.approval_required || raw.approvalRequired || raw.error_code === "APPROVAL_REQUIRED" || raw.errorCode === "APPROVAL_REQUIRED") {
|
|
5661
|
+
throw new SignalizError({
|
|
5662
|
+
code: "APPROVAL_REQUIRED",
|
|
5663
|
+
errorType: "validation",
|
|
5664
|
+
message: messages.approvalMessage,
|
|
5665
|
+
details: { schedule: raw }
|
|
5666
|
+
});
|
|
5667
|
+
}
|
|
5668
|
+
const opId = stringValue2(raw.op_id ?? raw.opId);
|
|
5669
|
+
if (!opId) {
|
|
5670
|
+
throw new SignalizError({
|
|
5671
|
+
code: "OP_NOT_CREATED",
|
|
5672
|
+
errorType: "validation",
|
|
5673
|
+
message: messages.notCreatedMessage,
|
|
5674
|
+
details: { schedule: raw }
|
|
5675
|
+
});
|
|
5676
|
+
}
|
|
5677
|
+
const scheduleRaw = asRecord2(raw.schedule ?? raw.schedule_result ?? raw.scheduleResult);
|
|
5678
|
+
const runRaw = asRecord2(raw.run ?? raw.run_result ?? raw.runResult);
|
|
5679
|
+
const schedule = normalizeOpsCreateResult(withExecutionRefs(
|
|
5680
|
+
Object.keys(scheduleRaw).length > 0 ? scheduleRaw : {
|
|
5681
|
+
...raw,
|
|
5682
|
+
op_id: opId,
|
|
5683
|
+
routine_id: raw.routine_id ?? raw.routineId ?? opId,
|
|
5684
|
+
status: "ready",
|
|
5685
|
+
phase: "scheduled",
|
|
5686
|
+
next_action: raw.next_action ?? raw.nextAction
|
|
5687
|
+
}
|
|
5688
|
+
));
|
|
5689
|
+
const run = normalizeOpsRunResult(withExecutionRefs(
|
|
5690
|
+
Object.keys(runRaw).length > 0 ? runRaw : {
|
|
5691
|
+
success: raw.success !== false,
|
|
5692
|
+
op_id: opId,
|
|
5693
|
+
routine_id: raw.routine_id ?? raw.routineId ?? opId,
|
|
5694
|
+
run_id: raw.run_id ?? raw.runId ?? null,
|
|
5695
|
+
status: "running",
|
|
5696
|
+
phase: "queued",
|
|
5697
|
+
next_action: raw.next_action ?? raw.nextAction,
|
|
5698
|
+
results_count: 0,
|
|
5699
|
+
results_url: raw.results_url ?? raw.resultsUrl,
|
|
5700
|
+
delivery_status: raw.delivery_status ?? raw.deliveryStatus
|
|
5701
|
+
}
|
|
5702
|
+
));
|
|
5703
|
+
const waited = normalizeOpsWaitForResultsResult(raw, { ...waitOptions, op_id: opId });
|
|
5704
|
+
const runId = run.run_id ?? run.runId ?? waited.run_id ?? waited.runId ?? waited.status.run_id ?? waited.status.runId ?? null;
|
|
5705
|
+
return {
|
|
5706
|
+
...waited,
|
|
5707
|
+
schedule,
|
|
5708
|
+
run,
|
|
5709
|
+
run_id: runId,
|
|
5710
|
+
runId,
|
|
5711
|
+
execution_refs: mergeExecutionRefsFrom([schedule, run, waited])
|
|
5712
|
+
};
|
|
5713
|
+
}
|
|
4983
5714
|
function normalizeOpsPrimitiveRetryPolicy(policy = {}) {
|
|
4984
5715
|
return {
|
|
4985
5716
|
...policy,
|
|
@@ -5055,8 +5786,122 @@ function normalizeOpsPrimitive(primitive) {
|
|
|
5055
5786
|
observability: normalizeOpsPrimitiveObservabilityPolicy(primitive.observability)
|
|
5056
5787
|
};
|
|
5057
5788
|
}
|
|
5789
|
+
function normalizeOpsExecutionToolCall(rawCall) {
|
|
5790
|
+
const call = asRecord2(rawCall);
|
|
5791
|
+
return {
|
|
5792
|
+
...call,
|
|
5793
|
+
tool: stringValue2(call.tool),
|
|
5794
|
+
arguments: asRecord2(call.arguments),
|
|
5795
|
+
purpose: stringValue2(call.purpose)
|
|
5796
|
+
};
|
|
5797
|
+
}
|
|
5798
|
+
function normalizeOpsExecutionScheduleContract(rawSchedule) {
|
|
5799
|
+
const schedule = asRecord2(rawSchedule);
|
|
5800
|
+
const wakeOnEvents = Array.isArray(schedule.wake_on_events) ? schedule.wake_on_events.map(String) : Array.isArray(schedule.wakeOnEvents) ? schedule.wakeOnEvents.map(String) : [];
|
|
5801
|
+
return {
|
|
5802
|
+
...schedule,
|
|
5803
|
+
create_tool: stringValue2(schedule.create_tool ?? schedule.createTool),
|
|
5804
|
+
createTool: stringValue2(schedule.createTool ?? schedule.create_tool),
|
|
5805
|
+
activate_tool: stringValue2(schedule.activate_tool ?? schedule.activateTool),
|
|
5806
|
+
activateTool: stringValue2(schedule.activateTool ?? schedule.activate_tool),
|
|
5807
|
+
cadence: stringValue2(schedule.cadence, "manual"),
|
|
5808
|
+
recurrence: stringValue2(schedule.recurrence),
|
|
5809
|
+
wake_on_events: wakeOnEvents,
|
|
5810
|
+
wakeOnEvents
|
|
5811
|
+
};
|
|
5812
|
+
}
|
|
5813
|
+
function normalizeOpsExecutionApprovalContract(rawApproval) {
|
|
5814
|
+
const approval = asRecord2(rawApproval);
|
|
5815
|
+
return {
|
|
5816
|
+
...approval,
|
|
5817
|
+
required: Boolean(approval.required),
|
|
5818
|
+
tool: stringValue2(approval.tool),
|
|
5819
|
+
reason: stringValue2(approval.reason)
|
|
5820
|
+
};
|
|
5821
|
+
}
|
|
5822
|
+
function normalizeOpsExecutionMonitorContract(rawMonitor) {
|
|
5823
|
+
const monitor = asRecord2(rawMonitor);
|
|
5824
|
+
const pollAfterMs = numberValue(monitor.poll_after_ms ?? monitor.pollAfterMs);
|
|
5825
|
+
return {
|
|
5826
|
+
...monitor,
|
|
5827
|
+
status_tool: stringValue2(monitor.status_tool ?? monitor.statusTool),
|
|
5828
|
+
statusTool: stringValue2(monitor.statusTool ?? monitor.status_tool),
|
|
5829
|
+
wait_tool: stringValue2(monitor.wait_tool ?? monitor.waitTool),
|
|
5830
|
+
waitTool: stringValue2(monitor.waitTool ?? monitor.wait_tool),
|
|
5831
|
+
results_tool: stringValue2(monitor.results_tool ?? monitor.resultsTool),
|
|
5832
|
+
resultsTool: stringValue2(monitor.resultsTool ?? monitor.results_tool),
|
|
5833
|
+
poll_after_ms: pollAfterMs,
|
|
5834
|
+
pollAfterMs
|
|
5835
|
+
};
|
|
5836
|
+
}
|
|
5837
|
+
function normalizeOpsExecutionResultContract(rawResult) {
|
|
5838
|
+
const result = asRecord2(rawResult);
|
|
5839
|
+
const shape = Array.isArray(result.shape) ? result.shape.map(String) : [];
|
|
5840
|
+
return {
|
|
5841
|
+
...result,
|
|
5842
|
+
tool: stringValue2(result.tool),
|
|
5843
|
+
wait_tool: stringValue2(result.wait_tool ?? result.waitTool),
|
|
5844
|
+
waitTool: stringValue2(result.waitTool ?? result.wait_tool),
|
|
5845
|
+
shape,
|
|
5846
|
+
empty_result_recovery: stringValue2(result.empty_result_recovery ?? result.emptyResultRecovery),
|
|
5847
|
+
emptyResultRecovery: stringValue2(result.emptyResultRecovery ?? result.empty_result_recovery)
|
|
5848
|
+
};
|
|
5849
|
+
}
|
|
5850
|
+
function normalizeOpsExecutionNangoRouteContract(rawRoute) {
|
|
5851
|
+
if (!rawRoute || typeof rawRoute !== "object" || Array.isArray(rawRoute)) return void 0;
|
|
5852
|
+
const route = asRecord2(rawRoute);
|
|
5853
|
+
const requiredFields = Array.isArray(route.required_fields) ? route.required_fields.map(String) : Array.isArray(route.requiredFields) ? route.requiredFields.map(String) : [];
|
|
5854
|
+
return {
|
|
5855
|
+
...route,
|
|
5856
|
+
enabled: route.enabled !== false,
|
|
5857
|
+
connect_tool: stringValue2(route.connect_tool ?? route.connectTool),
|
|
5858
|
+
connectTool: stringValue2(route.connectTool ?? route.connect_tool),
|
|
5859
|
+
discover_tool: stringValue2(route.discover_tool ?? route.discoverTool),
|
|
5860
|
+
discoverTool: stringValue2(route.discoverTool ?? route.discover_tool),
|
|
5861
|
+
dry_run_tool: stringValue2(route.dry_run_tool ?? route.dryRunTool),
|
|
5862
|
+
dryRunTool: stringValue2(route.dryRunTool ?? route.dry_run_tool),
|
|
5863
|
+
execute_tool: stringValue2(route.execute_tool ?? route.executeTool),
|
|
5864
|
+
executeTool: stringValue2(route.executeTool ?? route.execute_tool),
|
|
5865
|
+
execute_and_wait_tool: stringValue2(route.execute_and_wait_tool ?? route.executeAndWaitTool),
|
|
5866
|
+
executeAndWaitTool: stringValue2(route.executeAndWaitTool ?? route.execute_and_wait_tool),
|
|
5867
|
+
schedule_tool: stringValue2(route.schedule_tool ?? route.scheduleTool),
|
|
5868
|
+
scheduleTool: stringValue2(route.scheduleTool ?? route.schedule_tool),
|
|
5869
|
+
schedule_and_wait_tool: stringValue2(route.schedule_and_wait_tool ?? route.scheduleAndWaitTool),
|
|
5870
|
+
scheduleAndWaitTool: stringValue2(route.scheduleAndWaitTool ?? route.schedule_and_wait_tool),
|
|
5871
|
+
result_tool: stringValue2(route.result_tool ?? route.resultTool),
|
|
5872
|
+
resultTool: stringValue2(route.resultTool ?? route.result_tool),
|
|
5873
|
+
write_gate: stringValue2(route.write_gate ?? route.writeGate),
|
|
5874
|
+
writeGate: stringValue2(route.writeGate ?? route.write_gate),
|
|
5875
|
+
required_fields: requiredFields,
|
|
5876
|
+
requiredFields,
|
|
5877
|
+
schedule_arguments: asRecord2(route.schedule_arguments ?? route.scheduleArguments),
|
|
5878
|
+
scheduleArguments: asRecord2(route.scheduleArguments ?? route.schedule_arguments),
|
|
5879
|
+
schedule_and_wait_arguments: asRecord2(route.schedule_and_wait_arguments ?? route.scheduleAndWaitArguments),
|
|
5880
|
+
scheduleAndWaitArguments: asRecord2(route.scheduleAndWaitArguments ?? route.schedule_and_wait_arguments)
|
|
5881
|
+
};
|
|
5882
|
+
}
|
|
5883
|
+
function normalizeOpsExecutionContract(rawContract) {
|
|
5884
|
+
if (!rawContract || typeof rawContract !== "object" || Array.isArray(rawContract)) return void 0;
|
|
5885
|
+
const contract = asRecord2(rawContract);
|
|
5886
|
+
const nangoRoute = normalizeOpsExecutionNangoRouteContract(contract.nango_route ?? contract.nangoRoute);
|
|
5887
|
+
const sequence = Array.isArray(contract.sequence) ? contract.sequence.map(normalizeOpsExecutionToolCall) : [];
|
|
5888
|
+
return {
|
|
5889
|
+
...contract,
|
|
5890
|
+
mode: stringValue2(contract.mode, "run_once"),
|
|
5891
|
+
run_now: normalizeOpsExecutionToolCall(contract.run_now ?? contract.runNow),
|
|
5892
|
+
runNow: normalizeOpsExecutionToolCall(contract.runNow ?? contract.run_now),
|
|
5893
|
+
schedule: normalizeOpsExecutionScheduleContract(contract.schedule),
|
|
5894
|
+
approval: normalizeOpsExecutionApprovalContract(contract.approval),
|
|
5895
|
+
monitor: normalizeOpsExecutionMonitorContract(contract.monitor),
|
|
5896
|
+
result_contract: normalizeOpsExecutionResultContract(contract.result_contract ?? contract.resultContract),
|
|
5897
|
+
resultContract: normalizeOpsExecutionResultContract(contract.resultContract ?? contract.result_contract),
|
|
5898
|
+
...nangoRoute ? { nango_route: nangoRoute, nangoRoute } : {},
|
|
5899
|
+
sequence
|
|
5900
|
+
};
|
|
5901
|
+
}
|
|
5058
5902
|
function normalizeOpsPlanResult(result) {
|
|
5059
5903
|
const primitiveGraph = result.primitive_graph ?? result.primitiveGraph;
|
|
5904
|
+
const executionContract = normalizeOpsExecutionContract(result.execution_contract ?? result.executionContract);
|
|
5060
5905
|
return {
|
|
5061
5906
|
...result,
|
|
5062
5907
|
plan_id: result.plan_id ?? result.planId,
|
|
@@ -5080,7 +5925,8 @@ function normalizeOpsPlanResult(result) {
|
|
|
5080
5925
|
destination_status: result.destination_status ?? result.destinationStatus,
|
|
5081
5926
|
destinationStatus: result.destinationStatus ?? result.destination_status,
|
|
5082
5927
|
primitive_graph: primitiveGraph?.map(normalizeOpsPrimitive),
|
|
5083
|
-
primitiveGraph: primitiveGraph?.map(normalizeOpsPrimitive)
|
|
5928
|
+
primitiveGraph: primitiveGraph?.map(normalizeOpsPrimitive),
|
|
5929
|
+
...executionContract ? { execution_contract: executionContract, executionContract } : {}
|
|
5084
5930
|
};
|
|
5085
5931
|
}
|
|
5086
5932
|
function normalizeOpsCreateResult(result) {
|
|
@@ -5102,7 +5948,18 @@ function normalizeOpsCreateResult(result) {
|
|
|
5102
5948
|
deliveryStatus: result.deliveryStatus ?? result.delivery_status,
|
|
5103
5949
|
estimated_credits: result.estimated_credits ?? result.estimatedCredits,
|
|
5104
5950
|
estimatedCredits: result.estimatedCredits ?? result.estimated_credits,
|
|
5105
|
-
|
|
5951
|
+
error_code: result.error_code ?? result.errorCode,
|
|
5952
|
+
errorCode: result.errorCode ?? result.error_code,
|
|
5953
|
+
approval_required: result.approval_required ?? result.approvalRequired,
|
|
5954
|
+
approvalRequired: result.approvalRequired ?? result.approval_required,
|
|
5955
|
+
retry_arguments: result.retry_arguments ?? result.retryArguments,
|
|
5956
|
+
retryArguments: result.retryArguments ?? result.retry_arguments,
|
|
5957
|
+
blockers: result.blockers,
|
|
5958
|
+
plan: result.plan ? normalizeOpsPlanResult(result.plan) : result.plan,
|
|
5959
|
+
next_step: result.next_step ?? result.nextStep,
|
|
5960
|
+
nextStep: result.nextStep ?? result.next_step,
|
|
5961
|
+
next_steps: result.next_steps ?? result.nextSteps,
|
|
5962
|
+
nextSteps: result.nextSteps ?? result.next_steps
|
|
5106
5963
|
};
|
|
5107
5964
|
}
|
|
5108
5965
|
function normalizeOpsExecuteResult(result) {
|
|
@@ -5230,6 +6087,40 @@ function normalizeOpsStatusResult(result) {
|
|
|
5230
6087
|
diagnosis: result.diagnosis ? normalizeOpsDebugDiagnosis(result.diagnosis) : void 0
|
|
5231
6088
|
};
|
|
5232
6089
|
}
|
|
6090
|
+
function normalizeOpsResultsSummary(value) {
|
|
6091
|
+
const summary = asRecord2(value);
|
|
6092
|
+
if (Object.keys(summary).length === 0) return void 0;
|
|
6093
|
+
const resultsTotal = summary.results_total ?? summary.resultsTotal;
|
|
6094
|
+
const nextCursor = summary.next_cursor ?? summary.nextCursor ?? null;
|
|
6095
|
+
const resultsUrl = summary.results_url ?? summary.resultsUrl;
|
|
6096
|
+
const nextAction = summary.next_action ?? summary.nextAction;
|
|
6097
|
+
const runId = summary.run_id ?? summary.runId ?? null;
|
|
6098
|
+
const creditsUsed = summary.credits_used ?? summary.creditsUsed;
|
|
6099
|
+
return {
|
|
6100
|
+
...summary,
|
|
6101
|
+
label: optionalString(summary.label),
|
|
6102
|
+
status: optionalString(summary.status),
|
|
6103
|
+
phase: optionalString(summary.phase),
|
|
6104
|
+
results_count: numberValue(summary.results_count ?? summary.resultsCount),
|
|
6105
|
+
resultsCount: numberValue(summary.results_count ?? summary.resultsCount),
|
|
6106
|
+
results_total: resultsTotal === null || resultsTotal === void 0 ? resultsTotal : numberValue(resultsTotal),
|
|
6107
|
+
resultsTotal: resultsTotal === null || resultsTotal === void 0 ? resultsTotal : numberValue(resultsTotal),
|
|
6108
|
+
delivery_status: optionalString(summary.delivery_status ?? summary.deliveryStatus),
|
|
6109
|
+
deliveryStatus: optionalString(summary.delivery_status ?? summary.deliveryStatus),
|
|
6110
|
+
has_more: Boolean(summary.has_more ?? summary.hasMore),
|
|
6111
|
+
hasMore: Boolean(summary.has_more ?? summary.hasMore),
|
|
6112
|
+
next_cursor: nextCursor === null ? null : optionalString(nextCursor),
|
|
6113
|
+
nextCursor: nextCursor === null ? null : optionalString(nextCursor),
|
|
6114
|
+
results_url: optionalString(resultsUrl),
|
|
6115
|
+
resultsUrl: optionalString(resultsUrl),
|
|
6116
|
+
next_action: optionalString(nextAction),
|
|
6117
|
+
nextAction: optionalString(nextAction),
|
|
6118
|
+
run_id: runId === null ? null : optionalString(runId),
|
|
6119
|
+
runId: runId === null ? null : optionalString(runId),
|
|
6120
|
+
credits_used: creditsUsed === void 0 ? void 0 : numberValue(creditsUsed),
|
|
6121
|
+
creditsUsed: creditsUsed === void 0 ? void 0 : numberValue(creditsUsed)
|
|
6122
|
+
};
|
|
6123
|
+
}
|
|
5233
6124
|
function normalizeOpsResultsResult(result) {
|
|
5234
6125
|
const nextCursor = result.next_cursor ?? result.nextCursor ?? null;
|
|
5235
6126
|
const hasMore = result.has_more ?? result.hasMore ?? false;
|
|
@@ -5254,7 +6145,104 @@ function normalizeOpsResultsResult(result) {
|
|
|
5254
6145
|
results_url: result.results_url ?? result.resultsUrl,
|
|
5255
6146
|
resultsUrl: result.resultsUrl ?? result.results_url,
|
|
5256
6147
|
delivery_status: result.delivery_status ?? result.deliveryStatus,
|
|
5257
|
-
deliveryStatus: result.deliveryStatus ?? result.delivery_status
|
|
6148
|
+
deliveryStatus: result.deliveryStatus ?? result.delivery_status,
|
|
6149
|
+
summary: normalizeOpsResultsSummary(result.summary)
|
|
6150
|
+
};
|
|
6151
|
+
}
|
|
6152
|
+
function normalizeOpsWaitForResultsPoll(value, fallbackPoll) {
|
|
6153
|
+
const raw = asRecord2(value);
|
|
6154
|
+
const checkedAt = stringValue2(raw.checked_at ?? raw.checkedAt);
|
|
6155
|
+
const resultsCount = raw.results_count ?? raw.resultsCount;
|
|
6156
|
+
const runId = raw.run_id ?? raw.runId ?? null;
|
|
6157
|
+
const nextAction = raw.next_action ?? raw.nextAction;
|
|
6158
|
+
return {
|
|
6159
|
+
...raw,
|
|
6160
|
+
poll: numberValue(raw.poll) || fallbackPoll,
|
|
6161
|
+
checked_at: checkedAt,
|
|
6162
|
+
checkedAt,
|
|
6163
|
+
status: stringValue2(raw.status, "unknown"),
|
|
6164
|
+
phase: optionalString(raw.phase),
|
|
6165
|
+
results_count: resultsCount === void 0 ? void 0 : numberValue(resultsCount),
|
|
6166
|
+
resultsCount: resultsCount === void 0 ? void 0 : numberValue(resultsCount),
|
|
6167
|
+
run_id: runId === null ? null : optionalString(runId),
|
|
6168
|
+
runId: runId === null ? null : optionalString(runId),
|
|
6169
|
+
next_action: optionalString(nextAction),
|
|
6170
|
+
nextAction: optionalString(nextAction)
|
|
6171
|
+
};
|
|
6172
|
+
}
|
|
6173
|
+
function normalizeOpsWaitForResultsResult(result, options) {
|
|
6174
|
+
const opId = stringValue2(result.op_id ?? result.opId ?? options.op_id);
|
|
6175
|
+
const routineId = stringValue2(result.routine_id ?? result.routineId ?? opId);
|
|
6176
|
+
const runId = result.run_id ?? result.runId ?? null;
|
|
6177
|
+
const timedOut = Boolean(result.timed_out ?? result.timedOut);
|
|
6178
|
+
const statusRaw = asRecord2(result.status_result ?? result.statusResult);
|
|
6179
|
+
const resultsRaw = asRecord2(result.results_result ?? result.resultsResult);
|
|
6180
|
+
const historySource = Array.isArray(result.poll_history) ? result.poll_history : Array.isArray(result.history) ? result.history : [];
|
|
6181
|
+
const history = historySource.map((item, index) => normalizeOpsWaitForResultsPoll(item, index + 1));
|
|
6182
|
+
const status = normalizeOpsStatusResult(withExecutionRefs({
|
|
6183
|
+
success: result.success !== false,
|
|
6184
|
+
op_id: opId,
|
|
6185
|
+
routine_id: routineId,
|
|
6186
|
+
run_id: runId,
|
|
6187
|
+
status: stringValue2(result.status, "unknown"),
|
|
6188
|
+
phase: stringValue2(result.phase, "unknown"),
|
|
6189
|
+
next_action: stringValue2(result.next_action ?? result.nextAction),
|
|
6190
|
+
results_count: numberValue(result.results_count ?? result.resultsCount),
|
|
6191
|
+
results_url: optionalString(result.results_url ?? result.resultsUrl),
|
|
6192
|
+
delivery_status: optionalString(result.delivery_status ?? result.deliveryStatus),
|
|
6193
|
+
...statusRaw
|
|
6194
|
+
}));
|
|
6195
|
+
const includeResults = options.include_results !== false && options.includeResults !== false;
|
|
6196
|
+
const hasResultsPacket = Object.keys(resultsRaw).length > 0 || Array.isArray(result.results);
|
|
6197
|
+
const results = includeResults && hasResultsPacket ? normalizeOpsResultsResult(withExecutionRefs({
|
|
6198
|
+
success: result.success !== false,
|
|
6199
|
+
op_id: opId,
|
|
6200
|
+
routine_id: routineId,
|
|
6201
|
+
run_id: runId,
|
|
6202
|
+
status: stringValue2(result.status, status.status),
|
|
6203
|
+
phase: stringValue2(result.phase, status.phase),
|
|
6204
|
+
results_count: numberValue(result.results_count ?? result.resultsCount),
|
|
6205
|
+
results_total: result.results_total ?? result.resultsTotal ?? null,
|
|
6206
|
+
results: Array.isArray(result.results) ? result.results : [],
|
|
6207
|
+
next_cursor: result.next_cursor ?? result.nextCursor ?? null,
|
|
6208
|
+
has_more: Boolean(result.has_more ?? result.hasMore),
|
|
6209
|
+
next_action: stringValue2(result.next_action ?? result.nextAction),
|
|
6210
|
+
results_url: optionalString(result.results_url ?? result.resultsUrl),
|
|
6211
|
+
delivery_status: optionalString(result.delivery_status ?? result.deliveryStatus),
|
|
6212
|
+
...resultsRaw
|
|
6213
|
+
})) : void 0;
|
|
6214
|
+
const polls = numberValue(result.polls) || history.length;
|
|
6215
|
+
const maxPolls = result.max_polls ?? result.maxPolls;
|
|
6216
|
+
const intervalMs = result.interval_ms ?? result.intervalMs;
|
|
6217
|
+
const timeoutMs = result.timeout_ms ?? result.timeoutMs;
|
|
6218
|
+
const stopReason = result.stop_reason ?? result.stopReason;
|
|
6219
|
+
const nextAction = result.next_action ?? result.nextAction ?? results?.next_action ?? status.next_action;
|
|
6220
|
+
return {
|
|
6221
|
+
...result,
|
|
6222
|
+
success: result.success !== false && !timedOut,
|
|
6223
|
+
op_id: opId,
|
|
6224
|
+
opId,
|
|
6225
|
+
routine_id: routineId,
|
|
6226
|
+
routineId,
|
|
6227
|
+
run_id: runId === null ? null : optionalString(runId),
|
|
6228
|
+
runId: runId === null ? null : optionalString(runId),
|
|
6229
|
+
status,
|
|
6230
|
+
results,
|
|
6231
|
+
timed_out: timedOut,
|
|
6232
|
+
timedOut,
|
|
6233
|
+
polls,
|
|
6234
|
+
max_polls: maxPolls === void 0 ? void 0 : numberValue(maxPolls),
|
|
6235
|
+
maxPolls: maxPolls === void 0 ? void 0 : numberValue(maxPolls),
|
|
6236
|
+
interval_ms: intervalMs === void 0 ? void 0 : numberValue(intervalMs),
|
|
6237
|
+
intervalMs: intervalMs === void 0 ? void 0 : numberValue(intervalMs),
|
|
6238
|
+
timeout_ms: timeoutMs === void 0 ? void 0 : numberValue(timeoutMs),
|
|
6239
|
+
timeoutMs: timeoutMs === void 0 ? void 0 : numberValue(timeoutMs),
|
|
6240
|
+
stop_reason: optionalString(stopReason),
|
|
6241
|
+
stopReason: optionalString(stopReason),
|
|
6242
|
+
history,
|
|
6243
|
+
next_action: optionalString(nextAction),
|
|
6244
|
+
nextAction: optionalString(nextAction),
|
|
6245
|
+
execution_refs: mergeExecutionRefsFrom([result, status, results, { history }])
|
|
5258
6246
|
};
|
|
5259
6247
|
}
|
|
5260
6248
|
function normalizeOpsProofResult(data) {
|
|
@@ -5334,11 +6322,107 @@ function normalizeOpsProofResult(data) {
|
|
|
5334
6322
|
raw: data
|
|
5335
6323
|
};
|
|
5336
6324
|
}
|
|
6325
|
+
function normalizeOpsAutopilotSchedulePacket(rawPacket) {
|
|
6326
|
+
const packet = asRecord2(rawPacket);
|
|
6327
|
+
return {
|
|
6328
|
+
...packet,
|
|
6329
|
+
cadence: stringValue2(packet.cadence, "manual"),
|
|
6330
|
+
recurrence: stringValue2(packet.recurrence),
|
|
6331
|
+
activate_with: stringValue2(packet.activate_with ?? packet.activateWith),
|
|
6332
|
+
activateWith: stringValue2(packet.activate_with ?? packet.activateWith),
|
|
6333
|
+
run_now_with: stringValue2(packet.run_now_with ?? packet.runNowWith),
|
|
6334
|
+
runNowWith: stringValue2(packet.run_now_with ?? packet.runNowWith),
|
|
6335
|
+
monitor_with: stringValue2(packet.monitor_with ?? packet.monitorWith),
|
|
6336
|
+
monitorWith: stringValue2(packet.monitor_with ?? packet.monitorWith),
|
|
6337
|
+
retrieve_with: stringValue2(packet.retrieve_with ?? packet.retrieveWith),
|
|
6338
|
+
retrieveWith: stringValue2(packet.retrieve_with ?? packet.retrieveWith)
|
|
6339
|
+
};
|
|
6340
|
+
}
|
|
6341
|
+
function normalizeOpsAutopilotNangoRoutePacket(rawPacket) {
|
|
6342
|
+
if (!rawPacket || typeof rawPacket !== "object" || Array.isArray(rawPacket)) return void 0;
|
|
6343
|
+
const packet = asRecord2(rawPacket);
|
|
6344
|
+
const requiredFields = Array.isArray(packet.required_fields) ? packet.required_fields.map(String) : Array.isArray(packet.requiredFields) ? packet.requiredFields.map(String) : [];
|
|
6345
|
+
return {
|
|
6346
|
+
...packet,
|
|
6347
|
+
enabled: packet.enabled !== false,
|
|
6348
|
+
route_label: stringValue2(packet.route_label ?? packet.routeLabel),
|
|
6349
|
+
routeLabel: stringValue2(packet.route_label ?? packet.routeLabel),
|
|
6350
|
+
connect_tool: stringValue2(packet.connect_tool ?? packet.connectTool),
|
|
6351
|
+
connectTool: stringValue2(packet.connect_tool ?? packet.connectTool),
|
|
6352
|
+
discover_tool: stringValue2(packet.discover_tool ?? packet.discoverTool),
|
|
6353
|
+
discoverTool: stringValue2(packet.discover_tool ?? packet.discoverTool),
|
|
6354
|
+
dry_run_tool: stringValue2(packet.dry_run_tool ?? packet.dryRunTool),
|
|
6355
|
+
dryRunTool: stringValue2(packet.dry_run_tool ?? packet.dryRunTool),
|
|
6356
|
+
execute_tool: stringValue2(packet.execute_tool ?? packet.executeTool),
|
|
6357
|
+
executeTool: stringValue2(packet.execute_tool ?? packet.executeTool),
|
|
6358
|
+
execute_and_wait_tool: stringValue2(packet.execute_and_wait_tool ?? packet.executeAndWaitTool),
|
|
6359
|
+
executeAndWaitTool: stringValue2(packet.execute_and_wait_tool ?? packet.executeAndWaitTool),
|
|
6360
|
+
schedule_tool: stringValue2(packet.schedule_tool ?? packet.scheduleTool),
|
|
6361
|
+
scheduleTool: stringValue2(packet.schedule_tool ?? packet.scheduleTool),
|
|
6362
|
+
schedule_and_wait_tool: stringValue2(packet.schedule_and_wait_tool ?? packet.scheduleAndWaitTool),
|
|
6363
|
+
scheduleAndWaitTool: stringValue2(packet.schedule_and_wait_tool ?? packet.scheduleAndWaitTool),
|
|
6364
|
+
result_tool: stringValue2(packet.result_tool ?? packet.resultTool),
|
|
6365
|
+
resultTool: stringValue2(packet.result_tool ?? packet.resultTool),
|
|
6366
|
+
write_gate: stringValue2(packet.write_gate ?? packet.writeGate),
|
|
6367
|
+
writeGate: stringValue2(packet.write_gate ?? packet.writeGate),
|
|
6368
|
+
required_fields: requiredFields,
|
|
6369
|
+
requiredFields,
|
|
6370
|
+
placeholders: asRecord2(packet.placeholders),
|
|
6371
|
+
dry_run_arguments: asRecord2(packet.dry_run_arguments ?? packet.dryRunArguments),
|
|
6372
|
+
dryRunArguments: asRecord2(packet.dry_run_arguments ?? packet.dryRunArguments),
|
|
6373
|
+
execute_arguments: asRecord2(packet.execute_arguments ?? packet.executeArguments),
|
|
6374
|
+
executeArguments: asRecord2(packet.execute_arguments ?? packet.executeArguments),
|
|
6375
|
+
execute_and_wait_arguments: asRecord2(packet.execute_and_wait_arguments ?? packet.executeAndWaitArguments),
|
|
6376
|
+
executeAndWaitArguments: asRecord2(packet.execute_and_wait_arguments ?? packet.executeAndWaitArguments),
|
|
6377
|
+
schedule_arguments: asRecord2(packet.schedule_arguments ?? packet.scheduleArguments),
|
|
6378
|
+
scheduleArguments: asRecord2(packet.schedule_arguments ?? packet.scheduleArguments),
|
|
6379
|
+
schedule_and_wait_arguments: asRecord2(packet.schedule_and_wait_arguments ?? packet.scheduleAndWaitArguments),
|
|
6380
|
+
scheduleAndWaitArguments: asRecord2(packet.schedule_and_wait_arguments ?? packet.scheduleAndWaitArguments),
|
|
6381
|
+
result_arguments: asRecord2(packet.result_arguments ?? packet.resultArguments),
|
|
6382
|
+
resultArguments: asRecord2(packet.result_arguments ?? packet.resultArguments)
|
|
6383
|
+
};
|
|
6384
|
+
}
|
|
6385
|
+
function normalizeOpsAutopilotResultPacket(rawPacket) {
|
|
6386
|
+
const packet = asRecord2(rawPacket);
|
|
6387
|
+
const resultShape = Array.isArray(packet.result_shape) ? packet.result_shape.map(String) : Array.isArray(packet.resultShape) ? packet.resultShape.map(String) : [];
|
|
6388
|
+
const deliveryReceipts = Array.isArray(packet.delivery_receipts) ? packet.delivery_receipts.map(String) : Array.isArray(packet.deliveryReceipts) ? packet.deliveryReceipts.map(String) : [];
|
|
6389
|
+
return {
|
|
6390
|
+
...packet,
|
|
6391
|
+
retrieve_tool: stringValue2(packet.retrieve_tool ?? packet.retrieveTool),
|
|
6392
|
+
retrieveTool: stringValue2(packet.retrieve_tool ?? packet.retrieveTool),
|
|
6393
|
+
result_shape: resultShape,
|
|
6394
|
+
resultShape,
|
|
6395
|
+
delivery_receipts: deliveryReceipts,
|
|
6396
|
+
deliveryReceipts,
|
|
6397
|
+
empty_result_recovery: stringValue2(packet.empty_result_recovery ?? packet.emptyResultRecovery),
|
|
6398
|
+
emptyResultRecovery: stringValue2(packet.empty_result_recovery ?? packet.emptyResultRecovery)
|
|
6399
|
+
};
|
|
6400
|
+
}
|
|
6401
|
+
function normalizeOpsAutopilotOperatingPacket(rawPacket) {
|
|
6402
|
+
if (!rawPacket || typeof rawPacket !== "object" || Array.isArray(rawPacket)) return void 0;
|
|
6403
|
+
const packet = asRecord2(rawPacket);
|
|
6404
|
+
const nangoRoute = normalizeOpsAutopilotNangoRoutePacket(packet.nango_route ?? packet.nangoRoute);
|
|
6405
|
+
const approvalBoundaries = Array.isArray(packet.approval_boundaries) ? packet.approval_boundaries.map(String) : Array.isArray(packet.approvalBoundaries) ? packet.approvalBoundaries.map(String) : [];
|
|
6406
|
+
return {
|
|
6407
|
+
...packet,
|
|
6408
|
+
north_star: stringValue2(packet.north_star ?? packet.northStar),
|
|
6409
|
+
northStar: stringValue2(packet.north_star ?? packet.northStar),
|
|
6410
|
+
schedule: normalizeOpsAutopilotSchedulePacket(packet.schedule),
|
|
6411
|
+
...nangoRoute ? { nango_route: nangoRoute, nangoRoute } : {},
|
|
6412
|
+
result_contract: normalizeOpsAutopilotResultPacket(packet.result_contract ?? packet.resultContract),
|
|
6413
|
+
resultContract: normalizeOpsAutopilotResultPacket(packet.result_contract ?? packet.resultContract),
|
|
6414
|
+
approval_boundaries: approvalBoundaries,
|
|
6415
|
+
approvalBoundaries,
|
|
6416
|
+
saved_command_hint: stringValue2(packet.saved_command_hint ?? packet.savedCommandHint),
|
|
6417
|
+
savedCommandHint: stringValue2(packet.saved_command_hint ?? packet.savedCommandHint)
|
|
6418
|
+
};
|
|
6419
|
+
}
|
|
5337
6420
|
function normalizeOpsAutopilotMotion(rawMotion) {
|
|
5338
6421
|
const motion = asRecord2(rawMotion);
|
|
5339
6422
|
const targetCount = numberValue(motion.target_count ?? motion.targetCount);
|
|
5340
6423
|
const estimatedCredits = numberValue(motion.estimated_credits ?? motion.estimatedCredits);
|
|
5341
6424
|
const mcpSequence = Array.isArray(motion.mcp_sequence) ? motion.mcp_sequence : Array.isArray(motion.mcpSequence) ? motion.mcpSequence : [];
|
|
6425
|
+
const operatingPacket = normalizeOpsAutopilotOperatingPacket(motion.operating_packet ?? motion.operatingPacket);
|
|
5342
6426
|
return {
|
|
5343
6427
|
...motion,
|
|
5344
6428
|
id: stringValue2(motion.id),
|
|
@@ -5361,12 +6445,16 @@ function normalizeOpsAutopilotMotion(rawMotion) {
|
|
|
5361
6445
|
cli_command: optionalString(motion.cli_command ?? motion.cliCommand),
|
|
5362
6446
|
cliCommand: optionalString(motion.cli_command ?? motion.cliCommand),
|
|
5363
6447
|
mcp_sequence: mcpSequence,
|
|
5364
|
-
mcpSequence
|
|
6448
|
+
mcpSequence,
|
|
6449
|
+
...operatingPacket ? { operating_packet: operatingPacket, operatingPacket } : {}
|
|
5365
6450
|
};
|
|
5366
6451
|
}
|
|
5367
6452
|
function normalizeOpsAutopilotResult(result) {
|
|
5368
6453
|
const primary = normalizeOpsAutopilotMotion(result.primary_motion ?? result.primaryMotion);
|
|
5369
6454
|
const motions = Array.isArray(result.motions) ? result.motions.map(normalizeOpsAutopilotMotion) : [];
|
|
6455
|
+
const operatingPacket = normalizeOpsAutopilotOperatingPacket(
|
|
6456
|
+
result.operating_packet ?? result.operatingPacket ?? primary.operating_packet ?? primary.operatingPacket
|
|
6457
|
+
);
|
|
5370
6458
|
const queryErrors = Array.isArray(result.query_errors) ? result.query_errors.map(String) : Array.isArray(result.queryErrors) ? result.queryErrors.map(String) : [];
|
|
5371
6459
|
return {
|
|
5372
6460
|
...result,
|
|
@@ -5382,6 +6470,7 @@ function normalizeOpsAutopilotResult(result) {
|
|
|
5382
6470
|
scaleRule: optionalString(result.scale_rule ?? result.scaleRule),
|
|
5383
6471
|
agent_handoff: optionalString(result.agent_handoff ?? result.agentHandoff),
|
|
5384
6472
|
agentHandoff: optionalString(result.agent_handoff ?? result.agentHandoff),
|
|
6473
|
+
...operatingPacket ? { operating_packet: operatingPacket, operatingPacket } : {},
|
|
5385
6474
|
proof_state: optionalString(result.proof_state ?? result.proofState),
|
|
5386
6475
|
proofState: optionalString(result.proof_state ?? result.proofState),
|
|
5387
6476
|
proof_summary: result.proof_summary ?? result.proofSummary,
|
|
@@ -5646,11 +6735,125 @@ function normalizeOpsRoutineTickItemsResult(result) {
|
|
|
5646
6735
|
hasMore
|
|
5647
6736
|
};
|
|
5648
6737
|
}
|
|
6738
|
+
function buildOpsNangoScheduleBody(input) {
|
|
6739
|
+
const {
|
|
6740
|
+
workspaceConnectionId,
|
|
6741
|
+
workspace_connection_id,
|
|
6742
|
+
connectionId,
|
|
6743
|
+
connection_id,
|
|
6744
|
+
providerConfigKey,
|
|
6745
|
+
provider_config_key,
|
|
6746
|
+
integrationId,
|
|
6747
|
+
integration_id,
|
|
6748
|
+
nangoConnectionId,
|
|
6749
|
+
nango_connection_id,
|
|
6750
|
+
actionName,
|
|
6751
|
+
action_name,
|
|
6752
|
+
toolName,
|
|
6753
|
+
tool_name,
|
|
6754
|
+
proxyPath,
|
|
6755
|
+
proxy_path,
|
|
6756
|
+
nangoProxyPath,
|
|
6757
|
+
nango_proxy_path,
|
|
6758
|
+
method,
|
|
6759
|
+
httpMethod,
|
|
6760
|
+
http_method,
|
|
6761
|
+
input: nangoInput,
|
|
6762
|
+
arguments: nangoArguments,
|
|
6763
|
+
fieldMap,
|
|
6764
|
+
field_map,
|
|
6765
|
+
requiredFields,
|
|
6766
|
+
required_fields,
|
|
6767
|
+
writeConfirmed,
|
|
6768
|
+
write_confirmed,
|
|
6769
|
+
agentWriteConfirmed,
|
|
6770
|
+
agent_write_confirmed,
|
|
6771
|
+
config,
|
|
6772
|
+
destinations: _destinations,
|
|
6773
|
+
...schedule
|
|
6774
|
+
} = input;
|
|
6775
|
+
return {
|
|
6776
|
+
...buildOpsCreateBody({
|
|
6777
|
+
...schedule,
|
|
6778
|
+
cadence: schedule.cadence ?? "daily"
|
|
6779
|
+
}),
|
|
6780
|
+
workspace_connection_id: workspace_connection_id ?? workspaceConnectionId,
|
|
6781
|
+
connection_id: connection_id ?? connectionId,
|
|
6782
|
+
provider_config_key: provider_config_key ?? providerConfigKey,
|
|
6783
|
+
integration_id: integration_id ?? integrationId,
|
|
6784
|
+
nango_connection_id: nango_connection_id ?? nangoConnectionId,
|
|
6785
|
+
action_name: action_name ?? actionName,
|
|
6786
|
+
tool_name: tool_name ?? toolName,
|
|
6787
|
+
proxy_path: proxy_path ?? proxyPath ?? nango_proxy_path ?? nangoProxyPath,
|
|
6788
|
+
nango_proxy_path: nango_proxy_path ?? nangoProxyPath,
|
|
6789
|
+
method: method ?? http_method ?? httpMethod,
|
|
6790
|
+
input: nangoInput ?? nangoArguments,
|
|
6791
|
+
field_map: field_map ?? fieldMap,
|
|
6792
|
+
required_fields: required_fields ?? requiredFields,
|
|
6793
|
+
write_confirmed: write_confirmed ?? writeConfirmed,
|
|
6794
|
+
agent_write_confirmed: agent_write_confirmed ?? agentWriteConfirmed,
|
|
6795
|
+
config
|
|
6796
|
+
};
|
|
6797
|
+
}
|
|
6798
|
+
function buildOpsNangoScheduleAndWaitOptions(params) {
|
|
6799
|
+
const {
|
|
6800
|
+
force,
|
|
6801
|
+
instruction,
|
|
6802
|
+
nextCursor,
|
|
6803
|
+
includeFailedRuns,
|
|
6804
|
+
intervalMs,
|
|
6805
|
+
maxPolls,
|
|
6806
|
+
timeoutMs,
|
|
6807
|
+
includeResults,
|
|
6808
|
+
cursor,
|
|
6809
|
+
state,
|
|
6810
|
+
limit,
|
|
6811
|
+
include_failed_runs,
|
|
6812
|
+
interval_ms,
|
|
6813
|
+
max_polls,
|
|
6814
|
+
timeout_ms,
|
|
6815
|
+
include_results,
|
|
6816
|
+
...schedule
|
|
6817
|
+
} = params;
|
|
6818
|
+
return {
|
|
6819
|
+
schedule: {
|
|
6820
|
+
...schedule,
|
|
6821
|
+
cadence: schedule.cadence ?? "daily"
|
|
6822
|
+
},
|
|
6823
|
+
run: {
|
|
6824
|
+
force,
|
|
6825
|
+
instruction
|
|
6826
|
+
},
|
|
6827
|
+
wait: {
|
|
6828
|
+
cursor: cursor ?? nextCursor,
|
|
6829
|
+
state,
|
|
6830
|
+
limit,
|
|
6831
|
+
include_failed_runs: include_failed_runs ?? includeFailedRuns,
|
|
6832
|
+
interval_ms: interval_ms ?? intervalMs,
|
|
6833
|
+
max_polls: max_polls ?? maxPolls,
|
|
6834
|
+
timeout_ms: timeout_ms ?? timeoutMs,
|
|
6835
|
+
include_results: include_results ?? includeResults
|
|
6836
|
+
}
|
|
6837
|
+
};
|
|
6838
|
+
}
|
|
6839
|
+
function buildOpsNangoScheduleAndWaitBody(options) {
|
|
6840
|
+
const waitBody = buildOpsWaitBody(options.wait);
|
|
6841
|
+
const { op_id: _opId, ...waitWithoutOp } = waitBody;
|
|
6842
|
+
return {
|
|
6843
|
+
...buildOpsNangoScheduleBody(options.schedule),
|
|
6844
|
+
...waitWithoutOp,
|
|
6845
|
+
instruction: options.run.instruction,
|
|
6846
|
+
force: options.run.force
|
|
6847
|
+
};
|
|
6848
|
+
}
|
|
5649
6849
|
function buildOpsPlanBody(params) {
|
|
5650
|
-
const { targetCount, companyDomains, customAiPrompt, signalPrompt, outputPrompt, ...rest } = params;
|
|
6850
|
+
const { targetCount, wakeOnEvents, companyDomains, customAiPrompt, signalPrompt, outputPrompt, ...rest } = params;
|
|
6851
|
+
const destinations = Array.isArray(rest.destinations) ? rest.destinations.map(normalizeOpsDestinationRequest) : rest.destinations;
|
|
5651
6852
|
return {
|
|
5652
6853
|
...rest,
|
|
6854
|
+
destinations,
|
|
5653
6855
|
target_count: rest.target_count ?? targetCount,
|
|
6856
|
+
wake_on_events: rest.wake_on_events ?? wakeOnEvents,
|
|
5654
6857
|
company_domains: rest.company_domains ?? companyDomains,
|
|
5655
6858
|
custom_ai_prompt: rest.custom_ai_prompt ?? customAiPrompt,
|
|
5656
6859
|
signal_prompt: rest.signal_prompt ?? signalPrompt,
|
|
@@ -5673,6 +6876,95 @@ function buildOpsExecuteBody(params) {
|
|
|
5673
6876
|
output_format: rest.output_format ?? outputFormat
|
|
5674
6877
|
};
|
|
5675
6878
|
}
|
|
6879
|
+
function buildOpsExecuteAndWaitOptions(params) {
|
|
6880
|
+
const {
|
|
6881
|
+
nextCursor,
|
|
6882
|
+
includeFailedRuns,
|
|
6883
|
+
intervalMs,
|
|
6884
|
+
maxPolls,
|
|
6885
|
+
timeoutMs,
|
|
6886
|
+
includeResults,
|
|
6887
|
+
cursor,
|
|
6888
|
+
state,
|
|
6889
|
+
limit,
|
|
6890
|
+
include_failed_runs,
|
|
6891
|
+
interval_ms,
|
|
6892
|
+
max_polls,
|
|
6893
|
+
timeout_ms,
|
|
6894
|
+
include_results,
|
|
6895
|
+
...execute
|
|
6896
|
+
} = params;
|
|
6897
|
+
return {
|
|
6898
|
+
execute: {
|
|
6899
|
+
...execute,
|
|
6900
|
+
auto_run: execute.auto_run ?? execute.autoRun ?? true
|
|
6901
|
+
},
|
|
6902
|
+
wait: {
|
|
6903
|
+
cursor: cursor ?? nextCursor,
|
|
6904
|
+
state,
|
|
6905
|
+
limit,
|
|
6906
|
+
include_failed_runs: include_failed_runs ?? includeFailedRuns,
|
|
6907
|
+
interval_ms: interval_ms ?? intervalMs,
|
|
6908
|
+
max_polls: max_polls ?? maxPolls,
|
|
6909
|
+
timeout_ms: timeout_ms ?? timeoutMs,
|
|
6910
|
+
include_results: include_results ?? includeResults
|
|
6911
|
+
}
|
|
6912
|
+
};
|
|
6913
|
+
}
|
|
6914
|
+
function buildOpsScheduleAndWaitOptions(params) {
|
|
6915
|
+
const {
|
|
6916
|
+
force,
|
|
6917
|
+
instruction,
|
|
6918
|
+
nextCursor,
|
|
6919
|
+
includeFailedRuns,
|
|
6920
|
+
intervalMs,
|
|
6921
|
+
maxPolls,
|
|
6922
|
+
timeoutMs,
|
|
6923
|
+
includeResults,
|
|
6924
|
+
cursor,
|
|
6925
|
+
state,
|
|
6926
|
+
limit,
|
|
6927
|
+
include_failed_runs,
|
|
6928
|
+
interval_ms,
|
|
6929
|
+
max_polls,
|
|
6930
|
+
timeout_ms,
|
|
6931
|
+
include_results,
|
|
6932
|
+
...schedule
|
|
6933
|
+
} = params;
|
|
6934
|
+
return {
|
|
6935
|
+
schedule: {
|
|
6936
|
+
...schedule,
|
|
6937
|
+
cadence: schedule.cadence ?? "daily"
|
|
6938
|
+
},
|
|
6939
|
+
run: {
|
|
6940
|
+
force,
|
|
6941
|
+
instruction
|
|
6942
|
+
},
|
|
6943
|
+
wait: {
|
|
6944
|
+
cursor: cursor ?? nextCursor,
|
|
6945
|
+
state,
|
|
6946
|
+
limit,
|
|
6947
|
+
include_failed_runs: include_failed_runs ?? includeFailedRuns,
|
|
6948
|
+
interval_ms: interval_ms ?? intervalMs,
|
|
6949
|
+
max_polls: max_polls ?? maxPolls,
|
|
6950
|
+
timeout_ms: timeout_ms ?? timeoutMs,
|
|
6951
|
+
include_results: include_results ?? includeResults
|
|
6952
|
+
}
|
|
6953
|
+
};
|
|
6954
|
+
}
|
|
6955
|
+
function buildOpsScheduleAndWaitBody(options) {
|
|
6956
|
+
const waitBody = buildOpsWaitBody(options.wait);
|
|
6957
|
+
const { op_id: _opId, ...waitWithoutOp } = waitBody;
|
|
6958
|
+
return {
|
|
6959
|
+
...buildOpsCreateBody({
|
|
6960
|
+
...options.schedule,
|
|
6961
|
+
cadence: options.schedule.cadence ?? "daily"
|
|
6962
|
+
}),
|
|
6963
|
+
...waitWithoutOp,
|
|
6964
|
+
instruction: options.run.instruction,
|
|
6965
|
+
force: options.run.force
|
|
6966
|
+
};
|
|
6967
|
+
}
|
|
5676
6968
|
function buildOpsRunBody(params) {
|
|
5677
6969
|
const { opId, ...rest } = params;
|
|
5678
6970
|
return {
|
|
@@ -5680,6 +6972,28 @@ function buildOpsRunBody(params) {
|
|
|
5680
6972
|
op_id: rest.op_id ?? opId
|
|
5681
6973
|
};
|
|
5682
6974
|
}
|
|
6975
|
+
function buildOpsRunAndWaitOptions(params) {
|
|
6976
|
+
const {
|
|
6977
|
+
opId,
|
|
6978
|
+
nextCursor,
|
|
6979
|
+
includeFailedRuns,
|
|
6980
|
+
intervalMs,
|
|
6981
|
+
maxPolls,
|
|
6982
|
+
timeoutMs,
|
|
6983
|
+
includeResults,
|
|
6984
|
+
...rest
|
|
6985
|
+
} = params;
|
|
6986
|
+
return {
|
|
6987
|
+
...rest,
|
|
6988
|
+
op_id: rest.op_id ?? opId,
|
|
6989
|
+
cursor: rest.cursor ?? nextCursor,
|
|
6990
|
+
include_failed_runs: rest.include_failed_runs ?? includeFailedRuns,
|
|
6991
|
+
interval_ms: rest.interval_ms ?? intervalMs,
|
|
6992
|
+
max_polls: rest.max_polls ?? maxPolls,
|
|
6993
|
+
timeout_ms: rest.timeout_ms ?? timeoutMs,
|
|
6994
|
+
include_results: rest.include_results ?? includeResults
|
|
6995
|
+
};
|
|
6996
|
+
}
|
|
5683
6997
|
function buildOpsStatusBody(params) {
|
|
5684
6998
|
const { opId, ...rest } = params;
|
|
5685
6999
|
return {
|
|
@@ -5696,6 +7010,50 @@ function buildOpsResultsBody(params) {
|
|
|
5696
7010
|
include_failed_runs: rest.include_failed_runs ?? includeFailedRuns
|
|
5697
7011
|
};
|
|
5698
7012
|
}
|
|
7013
|
+
function buildOpsWaitForResultsOptions(params) {
|
|
7014
|
+
const {
|
|
7015
|
+
opId,
|
|
7016
|
+
nextCursor,
|
|
7017
|
+
includeFailedRuns,
|
|
7018
|
+
intervalMs,
|
|
7019
|
+
maxPolls,
|
|
7020
|
+
timeoutMs,
|
|
7021
|
+
includeResults,
|
|
7022
|
+
...rest
|
|
7023
|
+
} = params;
|
|
7024
|
+
return {
|
|
7025
|
+
...rest,
|
|
7026
|
+
op_id: rest.op_id ?? opId,
|
|
7027
|
+
cursor: rest.cursor ?? nextCursor,
|
|
7028
|
+
include_failed_runs: rest.include_failed_runs ?? includeFailedRuns,
|
|
7029
|
+
interval_ms: rest.interval_ms ?? intervalMs,
|
|
7030
|
+
max_polls: rest.max_polls ?? maxPolls,
|
|
7031
|
+
timeout_ms: rest.timeout_ms ?? timeoutMs,
|
|
7032
|
+
include_results: rest.include_results ?? includeResults
|
|
7033
|
+
};
|
|
7034
|
+
}
|
|
7035
|
+
function buildOpsWaitBody(params) {
|
|
7036
|
+
const {
|
|
7037
|
+
opId,
|
|
7038
|
+
nextCursor,
|
|
7039
|
+
includeFailedRuns,
|
|
7040
|
+
intervalMs,
|
|
7041
|
+
maxPolls,
|
|
7042
|
+
timeoutMs,
|
|
7043
|
+
includeResults,
|
|
7044
|
+
...rest
|
|
7045
|
+
} = params;
|
|
7046
|
+
return {
|
|
7047
|
+
...rest,
|
|
7048
|
+
op_id: rest.op_id ?? opId,
|
|
7049
|
+
cursor: rest.cursor ?? nextCursor,
|
|
7050
|
+
include_failed_runs: rest.include_failed_runs ?? includeFailedRuns,
|
|
7051
|
+
interval_ms: rest.interval_ms ?? intervalMs,
|
|
7052
|
+
max_polls: rest.max_polls ?? maxPolls,
|
|
7053
|
+
timeout_ms: rest.timeout_ms ?? timeoutMs,
|
|
7054
|
+
include_results: rest.include_results ?? includeResults
|
|
7055
|
+
};
|
|
7056
|
+
}
|
|
5699
7057
|
function buildOpsDebugOptions(params) {
|
|
5700
7058
|
const {
|
|
5701
7059
|
opId,
|
|
@@ -5773,6 +7131,8 @@ function normalizeOpsSinkRequest(sink) {
|
|
|
5773
7131
|
nangoAction,
|
|
5774
7132
|
proxyPath,
|
|
5775
7133
|
nangoProxyPath,
|
|
7134
|
+
method,
|
|
7135
|
+
httpMethod,
|
|
5776
7136
|
fieldMap,
|
|
5777
7137
|
requiredFields,
|
|
5778
7138
|
writeConfirmed,
|
|
@@ -5791,6 +7151,7 @@ function normalizeOpsSinkRequest(sink) {
|
|
|
5791
7151
|
const nango_action = rest.nango_action ?? nangoAction;
|
|
5792
7152
|
const proxy_path = rest.proxy_path ?? proxyPath;
|
|
5793
7153
|
const nango_proxy_path = rest.nango_proxy_path ?? nangoProxyPath;
|
|
7154
|
+
const http_method = rest.http_method ?? httpMethod;
|
|
5794
7155
|
const field_map = rest.field_map ?? fieldMap;
|
|
5795
7156
|
const required_fields = rest.required_fields ?? requiredFields;
|
|
5796
7157
|
const write_confirmed = rest.write_confirmed ?? writeConfirmed;
|
|
@@ -5805,6 +7166,9 @@ function normalizeOpsSinkRequest(sink) {
|
|
|
5805
7166
|
if (nango_action !== void 0 && normalizedConfig.nango_action === void 0) normalizedConfig.nango_action = nango_action;
|
|
5806
7167
|
if (proxy_path !== void 0 && normalizedConfig.proxy_path === void 0) normalizedConfig.proxy_path = proxy_path;
|
|
5807
7168
|
if (nango_proxy_path !== void 0 && normalizedConfig.nango_proxy_path === void 0) normalizedConfig.nango_proxy_path = nango_proxy_path;
|
|
7169
|
+
if (method !== void 0 && normalizedConfig.method === void 0) normalizedConfig.method = method;
|
|
7170
|
+
if (http_method !== void 0 && normalizedConfig.http_method === void 0) normalizedConfig.http_method = http_method;
|
|
7171
|
+
if (normalizedConfig.method === void 0 && http_method !== void 0) normalizedConfig.method = http_method;
|
|
5808
7172
|
if (field_map !== void 0 && normalizedConfig.field_map === void 0) normalizedConfig.field_map = field_map;
|
|
5809
7173
|
if (required_fields !== void 0 && normalizedConfig.required_fields === void 0) normalizedConfig.required_fields = required_fields;
|
|
5810
7174
|
if (write_confirmed !== void 0 && normalizedConfig.write_confirmed === void 0) normalizedConfig.write_confirmed = write_confirmed;
|
|
@@ -5824,6 +7188,8 @@ function normalizeOpsSinkRequest(sink) {
|
|
|
5824
7188
|
nango_action,
|
|
5825
7189
|
proxy_path,
|
|
5826
7190
|
nango_proxy_path,
|
|
7191
|
+
method,
|
|
7192
|
+
http_method,
|
|
5827
7193
|
field_map,
|
|
5828
7194
|
required_fields,
|
|
5829
7195
|
write_confirmed,
|
|
@@ -5831,6 +7197,10 @@ function normalizeOpsSinkRequest(sink) {
|
|
|
5831
7197
|
config: normalizedConfig
|
|
5832
7198
|
};
|
|
5833
7199
|
}
|
|
7200
|
+
function normalizeOpsDestinationRequest(destination) {
|
|
7201
|
+
if (!destination || typeof destination !== "object" || Array.isArray(destination)) return destination;
|
|
7202
|
+
return normalizeOpsSinkRequest(destination);
|
|
7203
|
+
}
|
|
5834
7204
|
function normalizeOpsSinkConfigRequest(config) {
|
|
5835
7205
|
const out = { ...config ?? {} };
|
|
5836
7206
|
if (out.connection_id === void 0 && out.connectionId !== void 0) out.connection_id = out.connectionId;
|
|
@@ -5844,6 +7214,8 @@ function normalizeOpsSinkConfigRequest(config) {
|
|
|
5844
7214
|
if (out.nango_action === void 0 && out.nangoAction !== void 0) out.nango_action = out.nangoAction;
|
|
5845
7215
|
if (out.proxy_path === void 0 && out.proxyPath !== void 0) out.proxy_path = out.proxyPath;
|
|
5846
7216
|
if (out.nango_proxy_path === void 0 && out.nangoProxyPath !== void 0) out.nango_proxy_path = out.nangoProxyPath;
|
|
7217
|
+
if (out.http_method === void 0 && out.httpMethod !== void 0) out.http_method = out.httpMethod;
|
|
7218
|
+
if (out.method === void 0 && out.http_method !== void 0) out.method = out.http_method;
|
|
5847
7219
|
if (out.field_map === void 0 && out.fieldMap !== void 0) out.field_map = out.fieldMap;
|
|
5848
7220
|
if (out.required_fields === void 0 && out.requiredFields !== void 0) out.required_fields = out.requiredFields;
|
|
5849
7221
|
if (out.write_confirmed === void 0 && out.writeConfirmed !== void 0) out.write_confirmed = out.writeConfirmed;
|
|
@@ -5917,7 +7289,6 @@ function toSnakeConfig(params) {
|
|
|
5917
7289
|
return {
|
|
5918
7290
|
system_prompt: params.systemPrompt || params.system_prompt || "You are a senior business research analyst. Use multi-model evidence carefully and return concise structured enrichment.",
|
|
5919
7291
|
user_template: params.userTemplate || params.user_template || params.prompt,
|
|
5920
|
-
model: params.model,
|
|
5921
7292
|
temperature: params.temperature,
|
|
5922
7293
|
max_concurrency: params.maxConcurrency || params.max_concurrency,
|
|
5923
7294
|
max_tokens: params.maxTokens || params.max_tokens,
|
|
@@ -5941,13 +7312,10 @@ var Ai = class {
|
|
|
5941
7312
|
/**
|
|
5942
7313
|
* Run Custom AI Enrichment - Multi Model.
|
|
5943
7314
|
*
|
|
5944
|
-
* Uses
|
|
5945
|
-
*
|
|
7315
|
+
* Uses the hosted default model with bounded synthesis, then returns the
|
|
7316
|
+
* requested structured output fields.
|
|
5946
7317
|
*/
|
|
5947
7318
|
async multiModel(params) {
|
|
5948
|
-
if (!params.model) {
|
|
5949
|
-
throw new Error('model is required. Use an OpenRouter id such as "anthropic/claude-sonnet-4" or "google/gemini-2.5-flash".');
|
|
5950
|
-
}
|
|
5951
7319
|
if (!params.prompt && !params.userTemplate && !params.user_template) {
|
|
5952
7320
|
throw new Error("prompt or userTemplate is required.");
|
|
5953
7321
|
}
|
|
@@ -6164,6 +7532,10 @@ var GtmKernel = class {
|
|
|
6164
7532
|
days: options.days,
|
|
6165
7533
|
network_days: options.networkDays,
|
|
6166
7534
|
min_sample_size: options.minSampleSize,
|
|
7535
|
+
holdout_min_sample_size: options.holdoutMinSampleSize,
|
|
7536
|
+
predictive_min_labeled_outcomes: options.predictiveMinLabeledOutcomes,
|
|
7537
|
+
predictive_min_positive_outcomes: options.predictiveMinPositiveOutcomes,
|
|
7538
|
+
predictive_min_memory_sample_size: options.predictiveMinMemorySampleSize,
|
|
6167
7539
|
min_workspace_count: options.minWorkspaceCount,
|
|
6168
7540
|
min_privacy_k: options.minPrivacyK,
|
|
6169
7541
|
include_memory: options.includeMemory,
|
|
@@ -6230,9 +7602,11 @@ var GtmKernel = class {
|
|
|
6230
7602
|
write_routine_outcomes: input.writeRoutineOutcomes
|
|
6231
7603
|
});
|
|
6232
7604
|
}
|
|
6233
|
-
/** Start a background Instantly webhook-events pull and route results into the GTM feedback loop. */
|
|
7605
|
+
/** Start a background Instantly webhook-events or email-history pull and route results into the GTM feedback loop. */
|
|
6234
7606
|
async pullInstantlyFeedback(input) {
|
|
6235
7607
|
return this.callMcp("gtm_instantly_feedback_pull", {
|
|
7608
|
+
source: input.source,
|
|
7609
|
+
instantly_profile: input.instantlyProfile,
|
|
6236
7610
|
campaign_id: input.campaignId,
|
|
6237
7611
|
campaign_build_id: input.campaignBuildId,
|
|
6238
7612
|
provider_link_id: input.providerLinkId,
|
|
@@ -6244,6 +7618,9 @@ var GtmKernel = class {
|
|
|
6244
7618
|
to: input.to,
|
|
6245
7619
|
limit: input.limit,
|
|
6246
7620
|
max_pages: input.maxPages,
|
|
7621
|
+
email_type: input.emailType,
|
|
7622
|
+
mode: input.mode,
|
|
7623
|
+
sort_order: input.sortOrder,
|
|
6247
7624
|
create_memory: input.createMemory,
|
|
6248
7625
|
write_routine_outcomes: input.writeRoutineOutcomes,
|
|
6249
7626
|
dry_run: input.dryRun,
|
|
@@ -6373,6 +7750,7 @@ var GtmKernel = class {
|
|
|
6373
7750
|
days: input.days,
|
|
6374
7751
|
network_days: input.networkDays,
|
|
6375
7752
|
min_sample_size: input.minSampleSize,
|
|
7753
|
+
holdout_min_sample_size: input.holdoutMinSampleSize,
|
|
6376
7754
|
min_workspace_count: input.minWorkspaceCount,
|
|
6377
7755
|
min_privacy_k: input.minPrivacyK,
|
|
6378
7756
|
include_memory: input.includeMemory,
|
|
@@ -6393,6 +7771,7 @@ var GtmKernel = class {
|
|
|
6393
7771
|
days: input.days,
|
|
6394
7772
|
network_days: input.networkDays,
|
|
6395
7773
|
min_sample_size: input.minSampleSize,
|
|
7774
|
+
holdout_min_sample_size: input.holdoutMinSampleSize,
|
|
6396
7775
|
min_workspace_count: input.minWorkspaceCount,
|
|
6397
7776
|
min_privacy_k: input.minPrivacyK,
|
|
6398
7777
|
include_memory: input.includeMemory,
|
|
@@ -6517,6 +7896,29 @@ var GtmKernel = class {
|
|
|
6517
7896
|
include_details: options.includeDetails
|
|
6518
7897
|
});
|
|
6519
7898
|
}
|
|
7899
|
+
/** Search the Agency Autopilot safe-action catalog for agency-style lead lists, Clay tables, and GTM motions. */
|
|
7900
|
+
async agencyAutopilotCapabilityCatalog(options = {}) {
|
|
7901
|
+
return this.callMcp("gtm_agency_autopilot_capability_catalog", {
|
|
7902
|
+
query: options.query,
|
|
7903
|
+
family: options.family,
|
|
7904
|
+
phase: options.phase,
|
|
7905
|
+
account_label: options.accountLabel,
|
|
7906
|
+
workspace_label: options.workspaceLabel,
|
|
7907
|
+
target_count: options.targetCount,
|
|
7908
|
+
limit: options.limit,
|
|
7909
|
+
include_agent_prompts: options.includeAgentPrompts
|
|
7910
|
+
});
|
|
7911
|
+
}
|
|
7912
|
+
/** Search agency operating playbooks Agency Autopilot can use for lead lists, Clay tables, GTM motions, and proof gates. */
|
|
7913
|
+
async agencyAutopilotPlaybookCatalog(options = {}) {
|
|
7914
|
+
return this.callMcp("gtm_agency_autopilot_playbook_catalog", {
|
|
7915
|
+
query: options.query,
|
|
7916
|
+
playbook_slug: options.playbookSlug,
|
|
7917
|
+
outcome_type: options.outcomeType,
|
|
7918
|
+
limit: options.limit,
|
|
7919
|
+
include_required_fields: options.includeRequiredFields
|
|
7920
|
+
});
|
|
7921
|
+
}
|
|
6520
7922
|
/** Build the read-only Memory, Brain, risk, and provider-route runbook needed before planning a campaign. */
|
|
6521
7923
|
async campaignStartContext(input = {}) {
|
|
6522
7924
|
return this.callMcp("gtm_campaign_start_context", {
|
|
@@ -6875,6 +8277,35 @@ var GtmKernel = class {
|
|
|
6875
8277
|
user_display_name: input.userDisplayName
|
|
6876
8278
|
});
|
|
6877
8279
|
}
|
|
8280
|
+
/** Prepare the full Nango provider search, connect, pull/export, Ops, and campaign-route flow. */
|
|
8281
|
+
async prepareNangoIntegrationFlow(input = {}) {
|
|
8282
|
+
return this.callMcp("nango_integration_flow_prepare", {
|
|
8283
|
+
query: input.query,
|
|
8284
|
+
search: input.search,
|
|
8285
|
+
provider_id: input.providerId,
|
|
8286
|
+
provider: input.provider,
|
|
8287
|
+
integration_id: input.integrationId,
|
|
8288
|
+
provider_config_key: input.providerConfigKey,
|
|
8289
|
+
workspace_connection_id: input.workspaceConnectionId,
|
|
8290
|
+
connection_id: input.connectionId,
|
|
8291
|
+
nango_connection_id: input.nangoConnectionId,
|
|
8292
|
+
intent: input.intent,
|
|
8293
|
+
action_name: input.actionName,
|
|
8294
|
+
tool_name: input.toolName,
|
|
8295
|
+
proxy_path: input.proxyPath,
|
|
8296
|
+
method: input.method,
|
|
8297
|
+
input: input.input,
|
|
8298
|
+
cadence: input.cadence,
|
|
8299
|
+
field_map: input.fieldMap,
|
|
8300
|
+
required_fields: input.requiredFields,
|
|
8301
|
+
confirm_spend: input.confirmSpend,
|
|
8302
|
+
write_confirmed: input.writeConfirmed,
|
|
8303
|
+
layer: input.layer,
|
|
8304
|
+
campaign_id: input.campaignId,
|
|
8305
|
+
limit: input.limit,
|
|
8306
|
+
include_provider_catalog: input.includeProviderCatalog
|
|
8307
|
+
});
|
|
8308
|
+
}
|
|
6878
8309
|
/** List Nango-backed action tools for a workspace connection without executing them. */
|
|
6879
8310
|
async listNangoTools(options = {}) {
|
|
6880
8311
|
return this.callMcp("nango_mcp_tools_list", {
|
|
@@ -6897,6 +8328,12 @@ var GtmKernel = class {
|
|
|
6897
8328
|
nango_connection_id: input.nangoConnectionId,
|
|
6898
8329
|
action_name: input.actionName,
|
|
6899
8330
|
tool_name: input.toolName,
|
|
8331
|
+
delivery_mode: input.deliveryMode,
|
|
8332
|
+
proxy_path: input.proxyPath,
|
|
8333
|
+
nango_proxy_path: input.nangoProxyPath,
|
|
8334
|
+
method: input.method,
|
|
8335
|
+
http_method: input.httpMethod,
|
|
8336
|
+
proxy_headers: input.proxyHeaders,
|
|
6900
8337
|
input: input.input,
|
|
6901
8338
|
async: input.async,
|
|
6902
8339
|
max_retries: input.maxRetries,
|
|
@@ -7046,6 +8483,7 @@ function compact2(value) {
|
|
|
7046
8483
|
}
|
|
7047
8484
|
|
|
7048
8485
|
// src/index.ts
|
|
8486
|
+
var MCP_TOOL_CACHE_TTL_MS = 3e4;
|
|
7049
8487
|
function inferMcpToolCategory(toolName) {
|
|
7050
8488
|
if (typeof toolName !== "string" || !toolName) return void 0;
|
|
7051
8489
|
if (toolName.startsWith("ops_") || toolName === "get_ops_readiness" || toolName === "get_gtm_ops_readiness" || toolName.startsWith("gtm_") || [
|
|
@@ -7177,6 +8615,21 @@ var Signaliz = class {
|
|
|
7177
8615
|
}
|
|
7178
8616
|
/** List all available MCP tools */
|
|
7179
8617
|
async listTools() {
|
|
8618
|
+
const now = Date.now();
|
|
8619
|
+
if (this.toolListCache && this.toolListCache.expiresAt > now) {
|
|
8620
|
+
return this.toolListCache.promise;
|
|
8621
|
+
}
|
|
8622
|
+
const promise = this.fetchTools().catch((error) => {
|
|
8623
|
+
if (this.toolListCache?.promise === promise) this.toolListCache = void 0;
|
|
8624
|
+
throw error;
|
|
8625
|
+
});
|
|
8626
|
+
this.toolListCache = {
|
|
8627
|
+
expiresAt: now + MCP_TOOL_CACHE_TTL_MS,
|
|
8628
|
+
promise
|
|
8629
|
+
};
|
|
8630
|
+
return promise;
|
|
8631
|
+
}
|
|
8632
|
+
async fetchTools() {
|
|
7180
8633
|
try {
|
|
7181
8634
|
const manifest = await this.client.mcp("tools/call", {
|
|
7182
8635
|
name: "get_tool_manifest",
|