@signaliz/sdk 1.0.15 → 1.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -212,25 +212,31 @@ var HttpClient = class {
212
212
  async getToken() {
213
213
  if (this.apiKey) return this.apiKey;
214
214
  if (this.accessToken) return this.accessToken;
215
- const res = await fetch("https://api.signaliz.com/token", {
216
- method: "POST",
217
- headers: { "Content-Type": "application/json" },
218
- body: JSON.stringify({
219
- grant_type: "client_credentials",
220
- client_id: this.clientId,
221
- client_secret: this.clientSecret
222
- })
223
- });
224
- if (!res.ok) {
225
- throw new SignalizError({
226
- code: "AUTH_FAILED",
227
- message: "Failed to obtain access token",
228
- errorType: "auth_expired"
215
+ if (this.accessTokenPromise) return this.accessTokenPromise;
216
+ this.accessTokenPromise = (async () => {
217
+ const res = await fetch("https://api.signaliz.com/token", {
218
+ method: "POST",
219
+ headers: { "Content-Type": "application/json" },
220
+ body: JSON.stringify({
221
+ grant_type: "client_credentials",
222
+ client_id: this.clientId,
223
+ client_secret: this.clientSecret
224
+ })
229
225
  });
230
- }
231
- const data = await res.json();
232
- this.accessToken = data.access_token;
233
- return this.accessToken;
226
+ if (!res.ok) {
227
+ throw new SignalizError({
228
+ code: "AUTH_FAILED",
229
+ message: "Failed to obtain access token",
230
+ errorType: "auth_expired"
231
+ });
232
+ }
233
+ const data = await res.json();
234
+ this.accessToken = data.access_token;
235
+ return this.accessToken;
236
+ })().finally(() => {
237
+ this.accessTokenPromise = void 0;
238
+ });
239
+ return this.accessTokenPromise;
234
240
  }
235
241
  };
236
242
  function sleep(ms) {
@@ -479,7 +485,6 @@ var Signals = class {
479
485
  if (params.online !== void 0) args.online = params.online;
480
486
  if (params.targetSignalCount) args.target_signal_count = params.targetSignalCount;
481
487
  if (params.lookbackDays) args.lookback_days = params.lookbackDays;
482
- if (params.model) args.model = params.model;
483
488
  if (params.enableDeepSearch) args.enable_deep_search = params.enableDeepSearch;
484
489
  if (params.enableOutreachIntelligence) args.enable_outreach_intelligence = params.enableOutreachIntelligence;
485
490
  if (params.enablePredictiveIntelligence) args.enable_predictive_intelligence = params.enablePredictiveIntelligence;
@@ -774,6 +779,10 @@ var Campaigns = class {
774
779
  async artifacts(campaignBuildId) {
775
780
  return this.listCampaignBuildArtifacts(campaignBuildId);
776
781
  }
782
+ /** Generate fresh signed URLs for a downloadable campaign artifact. */
783
+ async downloadArtifact(campaignBuildId, options) {
784
+ return this.downloadCampaignArtifact(campaignBuildId, options);
785
+ }
777
786
  /** Cancel a queued or running build. */
778
787
  async cancel(campaignBuildId, reason) {
779
788
  return this.cancelCampaignBuild(campaignBuildId, reason);
@@ -818,12 +827,16 @@ var Campaigns = class {
818
827
  dryRun: isDryRun,
819
828
  requestedTargetCount: data.requested_target_count,
820
829
  plannedTargetCount: data.planned_target_count,
830
+ acquisitionMode: data.acquisition_mode,
831
+ acquisitionSource: data.acquisition_source,
832
+ cacheReusePolicy: data.cache_reuse_policy,
821
833
  estimatedCredits: data.estimated_credits,
822
834
  estimatedDurationSeconds: data.estimated_duration_seconds,
823
835
  targetLimitApplied: data.target_limit_applied,
824
836
  targetLimitReason: data.target_limit_reason,
825
837
  maxSupportedTargetCount: data.max_supported_target_count,
826
838
  brainContext: data.brain_context ?? {},
839
+ learningHoldout: data.learning_holdout ?? {},
827
840
  providerRoute: mapProviderRoute(data)
828
841
  };
829
842
  }
@@ -839,14 +852,24 @@ var Campaigns = class {
839
852
  });
840
853
  return (data.artifacts ?? []).map(mapArtifact);
841
854
  }
855
+ async downloadCampaignArtifact(campaignBuildId, options) {
856
+ const args = { campaign_build_id: campaignBuildId };
857
+ if (options?.format) args.format = options.format;
858
+ const data = await this.callMcp("download_campaign_artifact", args);
859
+ return mapArtifactDownloadResult(data);
860
+ }
842
861
  async getCampaignBuildRows(campaignBuildId, options) {
843
862
  const args = { campaign_build_id: campaignBuildId };
844
863
  if (options?.limit) args.page_size = options.limit;
845
864
  if (options?.cursor) args.cursor = options.cursor;
865
+ if (options?.includeData !== void 0) args.include_data = options.includeData;
866
+ if (options?.includeRaw !== void 0) args.include_raw = options.includeRaw;
846
867
  const filters = {};
847
868
  if (options?.segment) filters.segment = options.segment;
848
869
  if (options?.rowStatus) filters.row_status = options.rowStatus;
849
870
  if (options?.qualified !== void 0) filters.qualified = options.qualified;
871
+ if (options?.cached !== void 0) filters.cached = options.cached;
872
+ if (options?.exportReady !== void 0) filters.export_ready = options.exportReady;
850
873
  if (Object.keys(filters).length > 0) args.filters = filters;
851
874
  const data = await this.callMcp("get_campaign_build_rows", args);
852
875
  return {
@@ -871,6 +894,7 @@ var Campaigns = class {
871
894
  };
872
895
  if (options?.destinationId) args.destination_id = options.destinationId;
873
896
  if (options?.destinationConfig) args.destination_config = options.destinationConfig;
897
+ if (options?.allowPartialDelivery === true) args.allow_partial_delivery = true;
874
898
  const data = await this.callMcp("approve_campaign_delivery", args);
875
899
  return {
876
900
  campaignBuildId: data.campaign_build_id,
@@ -879,7 +903,10 @@ var Campaigns = class {
879
903
  message: data.message ?? "",
880
904
  deliveryId: data.delivery_id,
881
905
  deliveryIds: data.delivery_ids,
882
- approvedCount: data.approved_count
906
+ approvedCount: data.approved_count,
907
+ partialDelivery: data.partial_delivery,
908
+ effectiveTargetCount: data.effective_target_count,
909
+ requestedTargetCount: data.requested_target_count
883
910
  };
884
911
  }
885
912
  async cancelCampaignBuild(campaignBuildId, reason) {
@@ -932,17 +959,50 @@ function mapStatus(data) {
932
959
  warnings: diagnosticMessages(data.warnings),
933
960
  errors: diagnosticMessages(data.errors),
934
961
  artifactCount: data.artifact_count ?? 0,
962
+ artifactDownloads: Array.isArray(data.artifact_downloads) ? data.artifact_downloads.map(mapArtifactDownload) : [],
963
+ customerRowCounts: mapCustomerRowCounts(data.customer_row_counts),
964
+ phaseAttemptTotals: recordOrNull(data.phase_attempt_totals) ?? void 0,
935
965
  providerRoute: mapProviderRoute(data),
936
966
  triggerRunId: typeof data.trigger_run_id === "string" ? data.trigger_run_id : null,
937
967
  staleRunningPhase: data.stale_running_phase === true,
938
968
  phaseAgeSeconds: numberOrNull(data.phase_age_seconds),
939
969
  diagnostics: recordOrNull(data.diagnostics) ?? {},
940
970
  nextAction: formatNextAction(data.next_action),
971
+ approvalAction: formatNextAction(data.approval_action),
941
972
  createdAt: data.created_at,
942
973
  updatedAt: data.updated_at,
943
974
  completedAt: data.completed_at
944
975
  };
945
976
  }
977
+ function mapCustomerRowCounts(value) {
978
+ const record = recordOrNull(value);
979
+ if (!record) return void 0;
980
+ return {
981
+ requestedTarget: numberOrNull(record.requested_target),
982
+ acquiredRows: numberOrNull(record.acquired_rows) ?? void 0,
983
+ acceptedRows: numberOrNull(record.accepted_rows) ?? void 0,
984
+ usableRows: numberOrNull(record.usable_rows) ?? void 0,
985
+ copiedRows: numberOrNull(record.copied_rows) ?? void 0,
986
+ approvalReadyRows: numberOrNull(record.approval_ready_rows) ?? void 0,
987
+ qaReadyRows: numberOrNull(record.qa_ready_rows) ?? void 0,
988
+ deliveredRows: numberOrNull(record.delivered_rows) ?? void 0,
989
+ disqualifiedRows: numberOrNull(record.disqualified_rows) ?? void 0,
990
+ reviewableRows: numberOrNull(record.reviewable_rows) ?? void 0,
991
+ rowFailures: numberOrNull(record.row_failures) ?? void 0,
992
+ acceptedShortfall: numberOrNull(record.accepted_shortfall),
993
+ usableShortfall: numberOrNull(record.usable_shortfall),
994
+ qaReadyShortfall: numberOrNull(record.qa_ready_shortfall),
995
+ deliveryShortfall: numberOrNull(record.delivery_shortfall),
996
+ fillRatio: numberOrNull(record.fill_ratio),
997
+ qaReadyFillRatio: numberOrNull(record.qa_ready_fill_ratio),
998
+ deliveredFillRatio: numberOrNull(record.delivered_fill_ratio),
999
+ terminalReason: typeof record.terminal_reason === "string" ? record.terminal_reason : null,
1000
+ acceptedShortfallReason: typeof record.accepted_shortfall_reason === "string" ? record.accepted_shortfall_reason : null,
1001
+ usableShortfallReason: typeof record.usable_shortfall_reason === "string" ? record.usable_shortfall_reason : null,
1002
+ qaReadyShortfallReason: typeof record.qa_ready_shortfall_reason === "string" ? record.qa_ready_shortfall_reason : null,
1003
+ deliveryShortfallReason: typeof record.delivery_shortfall_reason === "string" ? record.delivery_shortfall_reason : null
1004
+ };
1005
+ }
946
1006
  function mapProviderRoute(data) {
947
1007
  const brainContext = recordOrNull(data?.brain_context);
948
1008
  const plan = recordOrNull(data?.provider_route_plan) ?? recordOrNull(brainContext?.provider_route_plan);
@@ -1020,13 +1080,56 @@ function mapArtifact(a) {
1020
1080
  artifactType: a.artifact_type,
1021
1081
  destination: a.destination,
1022
1082
  storagePath: a.storage_path,
1083
+ format: a.format ?? null,
1023
1084
  signedUrl: a.signed_url,
1085
+ downloadUrl: a.download_url ?? null,
1086
+ manifestUrl: a.manifest_url ?? null,
1087
+ expiresAt: a.expires_at ?? null,
1024
1088
  rowCount: a.row_count ?? 0,
1025
1089
  checksum: a.checksum,
1026
1090
  metadata: a.metadata ?? {},
1027
1091
  createdAt: a.created_at
1028
1092
  };
1029
1093
  }
1094
+ function mapArtifactDownload(data) {
1095
+ return {
1096
+ id: data.id,
1097
+ artifactType: data.artifact_type ?? null,
1098
+ format: data.format ?? null,
1099
+ rowCount: data.row_count ?? 0,
1100
+ signedUrl: data.signed_url ?? null,
1101
+ downloadUrl: data.download_url ?? null,
1102
+ manifestUrl: data.manifest_url ?? null,
1103
+ expiresAt: data.expires_at ?? null
1104
+ };
1105
+ }
1106
+ function mapArtifactDownloadResult(data) {
1107
+ return {
1108
+ campaignBuildId: data.campaign_build_id,
1109
+ artifactId: data.artifact_id,
1110
+ format: data.format,
1111
+ rowCount: data.row_count ?? 0,
1112
+ byteSize: numberOrNull(data.byte_size),
1113
+ partCount: data.part_count ?? 0,
1114
+ checksum: data.checksum ?? null,
1115
+ signedUrl: data.signed_url ?? null,
1116
+ downloadUrl: data.download_url ?? null,
1117
+ manifestUrl: data.manifest_url ?? null,
1118
+ expiresAt: data.expires_at ?? null,
1119
+ parts: Array.isArray(data.parts) ? data.parts.map(mapArtifactDownloadPart) : [],
1120
+ downloadCommands: recordOrNull(data.download_commands) ?? {},
1121
+ expiresInSeconds: numberOrNull(data.expires_in_seconds)
1122
+ };
1123
+ }
1124
+ function mapArtifactDownloadPart(data) {
1125
+ return {
1126
+ partIndex: data.part_index ?? 0,
1127
+ rowCount: data.row_count ?? 0,
1128
+ byteSize: numberOrNull(data.byte_size),
1129
+ checksum: data.checksum ?? null,
1130
+ signedUrl: data.signed_url ?? null
1131
+ };
1132
+ }
1030
1133
  function mapScope(data) {
1031
1134
  return {
1032
1135
  campaignScopeId: data.campaign_scope_id,
@@ -1080,8 +1183,29 @@ function buildArgs(request) {
1080
1183
  if (request.allowDownscale !== void 0) args.allow_downscale = request.allowDownscale;
1081
1184
  if (request.confirmSpend !== void 0) args.confirm_spend = request.confirmSpend;
1082
1185
  if (request.dedupKeys) args.dedup_keys = request.dedupKeys;
1186
+ if (request.acquisitionMode) args.acquisition_mode = request.acquisitionMode;
1187
+ if (request.cacheReusePolicy) {
1188
+ args.cache_reuse_policy = {
1189
+ allow_verified_cache: request.cacheReusePolicy.allowVerifiedCache,
1190
+ suppress_prior_campaign_ids: request.cacheReusePolicy.suppressPriorCampaignIds,
1191
+ suppress_prior_list_ids: request.cacheReusePolicy.suppressPriorListIds,
1192
+ uniqueness: request.cacheReusePolicy.uniqueness,
1193
+ require_usage_metadata: request.cacheReusePolicy.requireUsageMetadata
1194
+ };
1195
+ }
1083
1196
  if (request.brainPreflight) args.brain_preflight = request.brainPreflight;
1084
1197
  if (request.brainDefaults) args.brain_defaults = request.brainDefaults;
1198
+ if (request.learningHoldout) {
1199
+ args.learning_holdout = {
1200
+ enabled: request.learningHoldout.enabled,
1201
+ control_percentage: request.learningHoldout.controlPercentage,
1202
+ min_control_size: request.learningHoldout.minControlSize,
1203
+ experiment_key: request.learningHoldout.experimentKey,
1204
+ source_campaign_id: request.learningHoldout.sourceCampaignId,
1205
+ primary_metric: request.learningHoldout.primaryMetric
1206
+ };
1207
+ }
1208
+ if (request.campaignStrategyContext) args.campaign_strategy_context = request.campaignStrategyContext;
1085
1209
  if (request.deliveryRisk) args.delivery_risk = request.deliveryRisk;
1086
1210
  if (request.icp) {
1087
1211
  args.icp = {
@@ -1123,7 +1247,17 @@ function buildArgs(request) {
1123
1247
  max_body_words: request.copy.maxBodyWords,
1124
1248
  sender_context: request.copy.senderContext,
1125
1249
  offer_context: request.copy.offerContext,
1126
- model: request.copy.model
1250
+ model: request.copy.model,
1251
+ style_source: request.copy.styleSource ? {
1252
+ sample_text: request.copy.styleSource.sampleText,
1253
+ campaign_ids: request.copy.styleSource.campaignIds,
1254
+ artifact_ids: request.copy.styleSource.artifactIds
1255
+ } : void 0,
1256
+ sequence_steps: request.copy.sequenceSteps,
1257
+ copy_schema: request.copy.copySchema,
1258
+ banned_phrases: request.copy.bannedPhrases,
1259
+ approval_required: request.copy.approvalRequired,
1260
+ quality_tier: request.copy.qualityTier
1127
1261
  };
1128
1262
  }
1129
1263
  if (request.delivery) {
@@ -1186,6 +1320,8 @@ var DEFAULT_SIGNALIZ_CAMPAIGN_BUILDER_DEFAULTS = {
1186
1320
  }
1187
1321
  };
1188
1322
  var DEFAULT_CAMPAIGN_BUILDER_BUILT_INS = [
1323
+ "company_discovery",
1324
+ "people_discovery",
1189
1325
  "lead_generation",
1190
1326
  "email_finding",
1191
1327
  "email_verification",
@@ -1194,6 +1330,8 @@ var DEFAULT_CAMPAIGN_BUILDER_BUILT_INS = [
1194
1330
  var CAMPAIGN_BUILDER_BUILT_IN_ROUTE_IDS = {
1195
1331
  lead_generation: "signaliz-lead-generation",
1196
1332
  local_leads: "signaliz-local-leads",
1333
+ company_discovery: "signaliz-company-discovery",
1334
+ people_discovery: "signaliz-people-discovery",
1197
1335
  email_finding: "signaliz-email-finding",
1198
1336
  email_verification: "signaliz-email-verification",
1199
1337
  signals: "signaliz-signals"
@@ -1211,8 +1349,8 @@ var CAMPAIGN_BUILDER_OPERATING_PLAYBOOKS = [
1211
1349
  slug: "cache-first-large-list",
1212
1350
  label: "Cache-First Large List",
1213
1351
  whenToUse: [
1214
- "The target count is high and reusable workspace lead or cache coverage may exist.",
1215
- "The deliverable is a verified list or top-up rather than a deeply custom one-off workflow."
1352
+ "The operator explicitly references a previous campaign, prior list, seed list, or suppression baseline.",
1353
+ "The deliverable is a top-up, continuation, or backfill where prior campaign context should guide reuse."
1216
1354
  ],
1217
1355
  sequence: [
1218
1356
  "Inventory reusable cache before paid sourcing.",
@@ -1418,7 +1556,7 @@ var CAMPAIGN_BUILDER_STRATEGY_TEMPLATES = [
1418
1556
  ],
1419
1557
  requireVerifiedEmail: true
1420
1558
  },
1421
- builtIns: ["lead_generation", "email_finding", "email_verification", "signals"],
1559
+ builtIns: ["company_discovery", "people_discovery", "lead_generation", "email_finding", "email_verification", "signals"],
1422
1560
  preferredProviders: ["signaliz_native"],
1423
1561
  memoryQueries: [{
1424
1562
  query: "industrial OT net-new prior email suppression verified manufacturing embedded systems field service cyber resilience business continuity",
@@ -1492,7 +1630,7 @@ var CAMPAIGN_BUILDER_STRATEGY_TEMPLATES = [
1492
1630
  ],
1493
1631
  requireVerifiedEmail: true
1494
1632
  },
1495
- builtIns: ["lead_generation", "local_leads", "email_finding", "email_verification", "signals"],
1633
+ builtIns: ["company_discovery", "people_discovery", "lead_generation", "local_leads", "email_finding", "email_verification", "signals"],
1496
1634
  preferredProviders: ["signaliz_native", "octave", "clay_webhook", "apify"],
1497
1635
  memoryQueries: [{
1498
1636
  query: "mature non-medical home care agencies billable hours franchise caregiver recruiting proof gate qualification export approval",
@@ -1558,7 +1696,7 @@ var CAMPAIGN_BUILDER_STRATEGY_TEMPLATES = [
1558
1696
  exclusions: ["enterprise holding company", "staffing", "recruiting", "software-only vendor", "freelancer-only profile"],
1559
1697
  requireVerifiedEmail: true
1560
1698
  },
1561
- builtIns: ["lead_generation", "email_finding", "email_verification", "signals"],
1699
+ builtIns: ["company_discovery", "people_discovery", "lead_generation", "email_finding", "email_verification", "signals"],
1562
1700
  preferredProviders: ["signaliz_native", "octave"],
1563
1701
  memoryQueries: [{
1564
1702
  query: "agency founder owner CEO marketing services suppression domain pool email verification final approval gate",
@@ -1640,7 +1778,7 @@ var CAMPAIGN_BUILDER_STRATEGY_TEMPLATES = [
1640
1778
  ],
1641
1779
  requireVerifiedEmail: true
1642
1780
  },
1643
- builtIns: ["lead_generation", "email_finding", "email_verification", "signals"],
1781
+ builtIns: ["company_discovery", "people_discovery", "lead_generation", "email_finding", "email_verification", "signals"],
1644
1782
  preferredProviders: ["signaliz_native", "octave"],
1645
1783
  memoryQueries: [{
1646
1784
  query: "cloud hosting infrastructure VMware Broadcom qualification verified email persona trigger SKU mapping",
@@ -1673,25 +1811,21 @@ var CampaignBuilderAgent = class {
1673
1811
  async createPlan(request, options = {}) {
1674
1812
  const resolvedRequest = applyCampaignBuilderStrategyTemplate(request);
1675
1813
  const warnings = [];
1676
- const workspaceContext = resolvedRequest.workspaceContext ?? await this.getWorkspaceContext(warnings);
1677
- const scopeResult = options.scopeCampaign === false ? void 0 : await this.scopeCampaign(resolvedRequest, warnings);
1678
- if (options.discoverCapabilities !== false) {
1679
- await this.discoverPlannedRoutes(resolvedRequest, warnings);
1680
- }
1814
+ const [workspaceContext, scopeResult] = await Promise.all([
1815
+ resolvedRequest.workspaceContext ? Promise.resolve(resolvedRequest.workspaceContext) : this.getWorkspaceContext(warnings),
1816
+ options.scopeCampaign === false ? Promise.resolve(void 0) : this.scopeCampaign(resolvedRequest, warnings),
1817
+ options.discoverCapabilities === false ? Promise.resolve(void 0) : this.discoverPlannedRoutes(resolvedRequest, warnings)
1818
+ ]);
1681
1819
  const plan = createCampaignBuilderAgentPlan(resolvedRequest, {
1682
1820
  workspaceContext,
1683
1821
  scopeBuildArgs: asRecord(scopeResult?.build_campaign_args ?? scopeResult?.buildCampaignArgs),
1684
1822
  warnings
1685
1823
  });
1686
- if (options.includeStrategyMemoryStatus !== false) {
1687
- await this.attachStrategyMemoryStatus(plan, warnings);
1688
- }
1689
- if (options.includeKernelPlan !== false) {
1690
- await this.attachKernelCampaignBuildPlan(plan, warnings);
1691
- }
1692
- if (options.includeDeliveryRisk !== false) {
1693
- await this.attachDeliveryRiskPreflight(plan, warnings);
1694
- }
1824
+ await Promise.all([
1825
+ options.includeStrategyMemoryStatus === false ? Promise.resolve() : this.attachStrategyMemoryStatus(plan, warnings),
1826
+ options.includeKernelPlan === false ? Promise.resolve() : this.attachKernelCampaignBuildPlan(plan, warnings),
1827
+ options.includeDeliveryRisk === false ? Promise.resolve() : this.attachDeliveryRiskPreflight(plan, warnings)
1828
+ ]);
1695
1829
  return plan;
1696
1830
  }
1697
1831
  async readiness(request, options = {}) {
@@ -1708,6 +1842,9 @@ var CampaignBuilderAgent = class {
1708
1842
  buildKit(options = {}) {
1709
1843
  return createCampaignBuilderBuildKit(options);
1710
1844
  }
1845
+ memoryKit(options = {}) {
1846
+ return createCampaignBuilderMemoryKit(options);
1847
+ }
1711
1848
  async commitPlan(plan, options = {}) {
1712
1849
  const writeMode = options.confirm === true && options.dryRun === false;
1713
1850
  if (writeMode && !options.approvedBy) {
@@ -1736,6 +1873,7 @@ var CampaignBuilderAgent = class {
1736
1873
  },
1737
1874
  brain_defaults: plan.buildRequest.brainDefaults,
1738
1875
  brain_preflight: plan.buildRequest.brainPreflight,
1876
+ campaign_strategy_context: plan.buildRequest.campaignStrategyContext,
1739
1877
  delivery_risk_preflight: plan.buildRequest.deliveryRisk,
1740
1878
  delivery_risk: plan.buildRequest.deliveryRisk
1741
1879
  }),
@@ -1857,7 +1995,8 @@ var CampaignBuilderAgent = class {
1857
1995
  const destinationType = options.deliveryDestinationType ?? plan.buildRequest.delivery?.destinationType ?? "json";
1858
1996
  result.deliveryApproval = await this.approveCampaignDelivery(campaignBuildId, destinationType, {
1859
1997
  destinationId: options.deliveryDestinationId,
1860
- destinationConfig: options.deliveryDestinationConfig ?? plan.buildRequest.delivery?.destinationConfig
1998
+ destinationConfig: options.deliveryDestinationConfig ?? plan.buildRequest.delivery?.destinationConfig,
1999
+ allowPartialDelivery: options.allowPartialDelivery
1861
2000
  });
1862
2001
  finalStatus = await this.waitForCampaignBuildStatus(
1863
2002
  campaignBuildId,
@@ -1880,8 +2019,12 @@ var CampaignBuilderAgent = class {
1880
2019
  const args = compact({
1881
2020
  campaign_build_id: campaignBuildId,
1882
2021
  page_size: options.limit,
1883
- cursor: options.cursor
2022
+ cursor: options.cursor,
2023
+ include_data: options.includeData,
2024
+ include_raw: options.includeRaw
1884
2025
  });
2026
+ if (options.cached !== void 0) filters.cached = options.cached;
2027
+ if (options.exportReady !== void 0) filters.export_ready = options.exportReady;
1885
2028
  if (Object.keys(filters).length > 0) args.filters = filters;
1886
2029
  const data = await this.callMcp("get_campaign_build_rows", args);
1887
2030
  return mapAgentCampaignRowsResult(data);
@@ -1896,12 +2039,14 @@ var CampaignBuilderAgent = class {
1896
2039
  return this.approveCampaignDelivery(campaignBuildId, destinationType, options);
1897
2040
  }
1898
2041
  async reviewBuild(campaignBuildId, options = {}) {
1899
- const status = await this.getBuildStatus(campaignBuildId);
1900
- const rows = await this.getBuildRows(campaignBuildId, {
1901
- ...options,
1902
- limit: options.limit ?? 100
1903
- });
1904
- const artifacts = await this.listBuildArtifacts(campaignBuildId);
2042
+ const [status, rows, artifacts] = await Promise.all([
2043
+ this.getBuildStatus(campaignBuildId),
2044
+ this.getBuildRows(campaignBuildId, {
2045
+ ...options,
2046
+ limit: options.limit ?? 100
2047
+ }),
2048
+ this.listBuildArtifacts(campaignBuildId)
2049
+ ]);
1905
2050
  return createCampaignBuilderBuildReview(status, rows, artifacts);
1906
2051
  }
1907
2052
  async getCampaignBuildStatus(campaignBuildId) {
@@ -1929,7 +2074,8 @@ var CampaignBuilderAgent = class {
1929
2074
  campaign_build_id: campaignBuildId,
1930
2075
  destination_type: destinationType,
1931
2076
  destination_id: options?.destinationId,
1932
- destination_config: options?.destinationConfig
2077
+ destination_config: options?.destinationConfig,
2078
+ allow_partial_delivery: options?.allowPartialDelivery === true ? true : void 0
1933
2079
  });
1934
2080
  const data = await this.callMcp("approve_campaign_delivery", args);
1935
2081
  return {
@@ -1939,7 +2085,10 @@ var CampaignBuilderAgent = class {
1939
2085
  message: data.message ?? "",
1940
2086
  deliveryId: data.delivery_id,
1941
2087
  deliveryIds: data.delivery_ids,
1942
- approvedCount: data.approved_count
2088
+ approvedCount: data.approved_count,
2089
+ partialDelivery: data.partial_delivery,
2090
+ effectiveTargetCount: data.effective_target_count,
2091
+ requestedTargetCount: data.requested_target_count
1943
2092
  };
1944
2093
  }
1945
2094
  async getWorkspaceContext(warnings) {
@@ -1975,15 +2124,19 @@ var CampaignBuilderAgent = class {
1975
2124
  const providers = new Set(
1976
2125
  [...request.integrations ?? [], ...routesFromCustomerTools(request.customerTools ?? [])].filter((route) => route.provider !== "signaliz").map((route) => route.provider)
1977
2126
  );
1978
- for (const provider of providers) {
2127
+ const warningsByProvider = await Promise.all(Array.from(providers, async (provider) => {
1979
2128
  try {
1980
2129
  await this.callMcp("discover_capabilities", {
1981
2130
  query: `campaign builder ${provider} ${request.goal}`,
1982
2131
  category: "campaign"
1983
2132
  });
2133
+ return void 0;
1984
2134
  } catch (error) {
1985
- warnings.push(`Capability discovery for ${provider} failed: ${errorMessage(error)}`);
2135
+ return `Capability discovery for ${provider} failed: ${errorMessage(error)}`;
1986
2136
  }
2137
+ }));
2138
+ for (const warning of warningsByProvider) {
2139
+ if (warning) warnings.push(warning);
1987
2140
  }
1988
2141
  }
1989
2142
  async attachStrategyMemoryStatus(plan, warnings) {
@@ -2007,8 +2160,24 @@ var CampaignBuilderAgent = class {
2007
2160
  const kernelPlan = await this.callMcp("gtm_campaign_build_plan", asRecord(plannerStep.arguments));
2008
2161
  plan.kernelPlan = asRecord(kernelPlan);
2009
2162
  const brainDefaults = asRecord(plan.kernelPlan.brain_defaults ?? plan.kernelPlan.brainDefaults);
2163
+ const corpusContext = asRecord(plan.kernelPlan.corpus_context ?? plan.kernelPlan.corpusContext);
2164
+ const campaignStrategyContext = asRecord(plan.kernelPlan.campaign_strategy_context ?? plan.kernelPlan.campaignStrategyContext);
2165
+ const memoryExamples = Array.isArray(plan.kernelPlan.memory_examples) ? plan.kernelPlan.memory_examples.map((item) => asRecord(item)).filter((item) => Object.keys(item).length > 0).slice(0, 15) : [];
2010
2166
  if (Object.keys(brainDefaults).length > 0 && Object.keys(asRecord(plan.buildRequest.brainDefaults)).length === 0) {
2011
2167
  plan.buildRequest.brainDefaults = brainDefaults;
2168
+ }
2169
+ if (Object.keys(campaignStrategyContext).length > 0) {
2170
+ plan.buildRequest.campaignStrategyContext = campaignStrategyContext;
2171
+ }
2172
+ if (Object.keys(corpusContext).length > 0 || memoryExamples.length > 0 || Object.keys(brainDefaults).length > 0 || Object.keys(campaignStrategyContext).length > 0) {
2173
+ plan.buildRequest.brainPreflight = compact({
2174
+ ...asRecord(plan.buildRequest.brainPreflight),
2175
+ corpus_context: Object.keys(corpusContext).length > 0 ? corpusContext : void 0,
2176
+ memory_examples: memoryExamples.length > 0 ? memoryExamples : void 0,
2177
+ brain_defaults: Object.keys(brainDefaults).length > 0 ? brainDefaults : void 0,
2178
+ campaign_strategy_context: Object.keys(campaignStrategyContext).length > 0 ? campaignStrategyContext : void 0
2179
+ });
2180
+ plan.brainPreflight = asRecord(plan.buildRequest.brainPreflight);
2012
2181
  refreshBuildStepArguments(plan);
2013
2182
  }
2014
2183
  } catch (error) {
@@ -2189,6 +2358,9 @@ function createCampaignBuilderProofReceipt(plan, result) {
2189
2358
  campaign_build_id: dryRunResult.campaignBuildId ?? dryRunResult.campaign_build_id ?? null
2190
2359
  }
2191
2360
  ];
2361
+ const learnBackPlan = summarizeCampaignBuilderProofLearnBack(
2362
+ asRecord(asRecord(plan.buildRequest.brainPreflight).learn_back_plan ?? asRecord(plan.brainPreflight).learn_back_plan)
2363
+ );
2192
2364
  return {
2193
2365
  receipt_version: "campaign-agent-proof.v1",
2194
2366
  source: "signaliz.campaignBuilderAgent.proof",
@@ -2211,6 +2383,7 @@ function createCampaignBuilderProofReceipt(plan, result) {
2211
2383
  gates,
2212
2384
  strategy_memory_status: summarizeCampaignBuilderProofStrategyMemory(strategyMemory),
2213
2385
  dry_run_result: summarizeCampaignBuilderProofDryRun(dryRunResult),
2386
+ learn_back_plan: learnBackPlan,
2214
2387
  recommended_next_actions: [
2215
2388
  "Review the plan, approvals, and dry-run result.",
2216
2389
  "Use campaign-agent commit-plan --confirm-write only after review.",
@@ -2428,6 +2601,12 @@ function createCampaignBuilderBuildKit(input = {}) {
2428
2601
  command: `${cliBase} campaign-agent init${strategyFlag}${targetFlag}${localLeadsFlag} --output-file ${shellArg(requestFile)}`,
2429
2602
  safety: "local file only; no MCP calls, credits, provider writes, sender loads, exports, or sends"
2430
2603
  },
2604
+ {
2605
+ id: "memory_kit",
2606
+ label: "Inspect memory readiness and seed runner",
2607
+ command: `${sdkCliBase} campaign-agent memory-kit${strategyFlag}${targetFlag}${localLeadsFlag} --request-file ${shellArg(requestFile)} --json`,
2608
+ safety: "read-only memory readiness packet plus local seed dry-run commands"
2609
+ },
2431
2610
  {
2432
2611
  id: "proof_shortcut",
2433
2612
  label: "Run no-spend campaign-builder proof",
@@ -2522,6 +2701,147 @@ function createCampaignBuilderBuildKit(input = {}) {
2522
2701
  ]
2523
2702
  };
2524
2703
  }
2704
+ function createCampaignBuilderMemoryKit(input = {}) {
2705
+ const requestFile = input.requestFile || "campaign-request.json";
2706
+ const seedManifestFile = input.seedManifestFile || ".gtm-kernel-import-state/campaign-memory-dry-run.json";
2707
+ const cliPackage = input.cliPackage || "@signaliz/cli";
2708
+ const sdkPackage = input.sdkPackage || "@signaliz/sdk";
2709
+ const request = createCampaignBuilderAgentRequestTemplate(input);
2710
+ const strategyTemplate = stringValue(request.strategyTemplate) ?? null;
2711
+ const strategyFlag = strategyTemplate ? ` --strategy-template ${shellArg(strategyTemplate)}` : "";
2712
+ const targetFlag = request.targetCount ? ` --target-count ${request.targetCount}` : "";
2713
+ const localLeadsFlag = request.builtIns?.includes("local_leads") ? " --use-local-leads" : "";
2714
+ const cliBase = `npx ${cliPackage}`;
2715
+ const sdkCliBase = `npx ${sdkPackage}`;
2716
+ const source = campaignBuilderMemoryKitSource(input.source);
2717
+ const workspaceId = input.workspaceId || "your-workspace-id";
2718
+ const brief = request.goal || "Build a strategy-template campaign for the target ICP.";
2719
+ const statusArgs = compact({
2720
+ strategy_template: strategyTemplate,
2721
+ campaign_brief: brief,
2722
+ target_icp: request.icp,
2723
+ include_sources: true,
2724
+ include_samples: false,
2725
+ days: 90,
2726
+ limit: 25
2727
+ });
2728
+ const searchArgs = compact({
2729
+ query: request.memory?.queries?.[0]?.query || brief,
2730
+ layers: ["lead_generation", "email_finding", "email_verification", "company_enrichment", "copy_enrichment"],
2731
+ limit: 10
2732
+ });
2733
+ return {
2734
+ kit_version: "campaign-memory-kit.v1",
2735
+ source: "signaliz.campaignBuilderAgent.memoryKit",
2736
+ read_only: true,
2737
+ no_spend: true,
2738
+ no_provider_writes: true,
2739
+ client_names_allowed: false,
2740
+ request_file: requestFile,
2741
+ seed_manifest_file: seedManifestFile,
2742
+ request,
2743
+ strategy_template: strategyTemplate,
2744
+ operating_playbooks: getCampaignBuilderOperatingPlaybooksForRequest(request).map((playbook) => playbook.slug),
2745
+ memory_sources: source.memorySources,
2746
+ seed_runner: {
2747
+ local_script: "scripts/gtm-kernel/seed-import-runner.mjs",
2748
+ dry_run_command: [
2749
+ "node scripts/gtm-kernel/seed-import-runner.mjs",
2750
+ `--source ${source.seedSource}`,
2751
+ "--dry-run",
2752
+ `--workspace-id ${shellArg(input.workspaceId || "00000000-0000-4000-8000-000000000000")}`,
2753
+ `--manifest ${shellArg(seedManifestFile)}`,
2754
+ "--reset"
2755
+ ].join(" "),
2756
+ verify_manifest_command: source.verifyScript ? `node ${source.verifyScript} ${shellArg(seedManifestFile)}` : null,
2757
+ write_command: `GTM_KERNEL_WORKSPACE_ID=${shellArg(workspaceId)} node scripts/gtm-kernel/seed-import-runner.mjs --source ${source.seedSource} --write`,
2758
+ write_requires: ["SUPABASE_URL", "SUPABASE_SERVICE_ROLE_KEY", "GTM_KERNEL_WORKSPACE_ID", "explicit operator approval"]
2759
+ },
2760
+ cli_commands: [
2761
+ {
2762
+ id: "memory_status",
2763
+ label: "Check strategy memory readiness",
2764
+ command: `${sdkCliBase} gtm strategy-memory${strategyFlag} --brief ${shellArg(brief)} --json`,
2765
+ safety: "read-only MCP memory readiness; no credits, provider writes, sender loads, exports, or sends"
2766
+ },
2767
+ {
2768
+ id: "memory_search",
2769
+ label: "Search ranked campaign memory",
2770
+ command: `${sdkCliBase} gtm memory search --query ${shellArg(String(searchArgs.query || brief))} --limit 10 --json`,
2771
+ safety: "read-only ranked memory lookup"
2772
+ },
2773
+ {
2774
+ id: "seed_dry_run",
2775
+ label: "Dry-run private memory seed import",
2776
+ command: [
2777
+ "node scripts/gtm-kernel/seed-import-runner.mjs",
2778
+ `--source ${source.seedSource}`,
2779
+ "--dry-run",
2780
+ `--workspace-id ${shellArg(input.workspaceId || "00000000-0000-4000-8000-000000000000")}`,
2781
+ `--manifest ${shellArg(seedManifestFile)}`,
2782
+ "--reset"
2783
+ ].join(" "),
2784
+ safety: "local extraction and manifest only; no database writes"
2785
+ },
2786
+ {
2787
+ id: "write_request",
2788
+ label: "Write reusable campaign request JSON",
2789
+ command: `${cliBase} campaign-agent init${strategyFlag}${targetFlag}${localLeadsFlag} --output-file ${shellArg(requestFile)}`,
2790
+ safety: "local file only; no MCP calls, credits, provider writes, sender loads, exports, or sends"
2791
+ },
2792
+ {
2793
+ id: "proof",
2794
+ label: "Run campaign proof after memory check",
2795
+ command: `${cliBase} campaign-agent proof --request-file ${shellArg(requestFile)} --json`,
2796
+ safety: "read-only planning plus forced build_campaign dry-run with confirm_spend=false"
2797
+ }
2798
+ ],
2799
+ mcp_calls: [
2800
+ {
2801
+ id: "strategy_memory_status",
2802
+ tool: "gtm_campaign_strategy_memory_status",
2803
+ arguments: statusArgs,
2804
+ safety: "read-only strategy/workflow memory readiness with sources and no raw samples"
2805
+ },
2806
+ {
2807
+ id: "memory_search",
2808
+ tool: "gtm_memory_search",
2809
+ arguments: searchArgs,
2810
+ safety: "read-only ranked memory lookup"
2811
+ },
2812
+ {
2813
+ id: "campaign_agent_plan",
2814
+ tool: "gtm_campaign_agent_plan",
2815
+ arguments: campaignBuilderBuildKitMcpArgs(request),
2816
+ safety: "read-only campaign-agent plan using built-in Signaliz lanes, memory, Brain, Nango, and BYO routes"
2817
+ },
2818
+ {
2819
+ id: "campaign_agent_proof",
2820
+ tool: "gtm_campaign_agent_proof",
2821
+ arguments: { ...campaignBuilderBuildKitMcpArgs(request), idempotency_key: "campaign-agent-memory-proof-001" },
2822
+ safety: "forces build_campaign dry_run=true and confirm_spend=false after readiness"
2823
+ }
2824
+ ],
2825
+ sdk_example: {
2826
+ language: "typescript",
2827
+ code: campaignBuilderMemoryKitSdkExample(request, seedManifestFile)
2828
+ },
2829
+ privacy: {
2830
+ client_names_allowed: false,
2831
+ notes: [
2832
+ "Use strategy templates, operating playbooks, memory dimensions, and anonymized campaign patterns instead of client names.",
2833
+ "Do not expose raw leads, private replies, domains, secrets, provider payloads, or customer account labels in kit output.",
2834
+ "Seed writes are workspace-private and require explicit operator approval plus Supabase service credentials."
2835
+ ]
2836
+ },
2837
+ next_actions: [
2838
+ "Run memory_status before plan/proof so missing strategy coverage is visible.",
2839
+ `Run seed_dry_run and inspect ${seedManifestFile} before any memory write.`,
2840
+ "Use write_request to save the reusable campaign request, then run proof with no spend.",
2841
+ "Add BYO tools through campaign-agent --custom-tool only after route setup is reviewed."
2842
+ ]
2843
+ };
2844
+ }
2525
2845
  function createCampaignBuilderToolRoute(input) {
2526
2846
  return {
2527
2847
  provider: input.provider ?? "custom_mcp",
@@ -2591,6 +2911,96 @@ function campaignBuilderBuildKitSdkExample(request, requestFile) {
2591
2911
  "}"
2592
2912
  ].join("\n");
2593
2913
  }
2914
+ function campaignBuilderMemoryKitSdkExample(request, seedManifestFile) {
2915
+ const input = {
2916
+ goal: request.goal,
2917
+ strategyTemplate: request.strategyTemplate,
2918
+ targetCount: request.targetCount,
2919
+ builtIns: request.builtIns
2920
+ };
2921
+ return [
2922
+ "import { Signaliz, createCampaignBuilderMemoryKit } from '@signaliz/sdk';",
2923
+ "",
2924
+ `const kit = createCampaignBuilderMemoryKit({ seedManifestFile: ${JSON.stringify(seedManifestFile)}, ...${JSON.stringify(input, null, 2)} });`,
2925
+ "console.log(kit.cli_commands.find((command) => command.id === 'memory_status')?.command);",
2926
+ "",
2927
+ "const signaliz = new Signaliz({ apiKey: process.env.SIGNALIZ_API_KEY! });",
2928
+ "const status = await signaliz.gtm.campaignStrategyMemoryStatus({",
2929
+ " strategyTemplate: kit.request.strategyTemplate,",
2930
+ " campaignBrief: kit.request.goal,",
2931
+ " includeSources: true,",
2932
+ " includeSamples: false,",
2933
+ "});",
2934
+ "",
2935
+ "if (status?.ready === false) {",
2936
+ " throw new Error('Strategy memory is not ready for this campaign request');",
2937
+ "}"
2938
+ ].join("\n");
2939
+ }
2940
+ function campaignBuilderMemoryKitSource(source) {
2941
+ const normalized = normalizeTemplateKey(source || "agency");
2942
+ const catalog = {
2943
+ northStar: {
2944
+ id: "north_star_campaign_builder",
2945
+ label: "North Star campaign-builder acceptance patterns",
2946
+ seed_source: "north-star",
2947
+ scope: "redacted_acceptance_seed_packs",
2948
+ privacy: "redacted aggregate counts, QA gates, and fixture shape only"
2949
+ },
2950
+ agency: {
2951
+ id: "agency_campaign_builder",
2952
+ label: "Agency campaign-builder strategy patterns",
2953
+ seed_source: "agency",
2954
+ scope: "private_strategy_docs",
2955
+ privacy: "workspace-private sanitized docs and abstracted campaign summaries"
2956
+ },
2957
+ workflow: {
2958
+ id: "workflow_pattern_corpus",
2959
+ label: "Workflow and table-build pattern corpus",
2960
+ seed_source: "building-clay",
2961
+ scope: "read_only_workflow_docs",
2962
+ privacy: "sanitized operating model and workflow patterns"
2963
+ },
2964
+ feedback: {
2965
+ id: "campaign_feedback",
2966
+ label: "Campaign feedback and reply patterns",
2967
+ seed_source: "instantly",
2968
+ scope: "workspace_private_feedback",
2969
+ privacy: "aggregate feedback, reply, and sequence performance memory"
2970
+ }
2971
+ };
2972
+ const sourceMap = {
2973
+ agency: "agency",
2974
+ "campaign-builder": "agency",
2975
+ "north-star": "northStar",
2976
+ northstar: "northStar",
2977
+ "campaign-builder-north-star": "northStar",
2978
+ acceptance: "northStar",
2979
+ "strategy-memory": "agency",
2980
+ "workflow-patterns": "workflow",
2981
+ workflow: "workflow",
2982
+ "building-clay": "workflow",
2983
+ clay: "workflow",
2984
+ "instantly-feedback": "feedback",
2985
+ instantly: "feedback",
2986
+ feedback: "feedback",
2987
+ all: "all"
2988
+ };
2989
+ const selected = sourceMap[normalized] || "agency";
2990
+ if (selected === "all") {
2991
+ return {
2992
+ seedSource: "all",
2993
+ verifyScript: null,
2994
+ memorySources: [catalog.northStar, catalog.agency, catalog.workflow, catalog.feedback]
2995
+ };
2996
+ }
2997
+ const item = catalog[selected];
2998
+ return {
2999
+ seedSource: item.seed_source,
3000
+ verifyScript: item.seed_source === "north-star" ? "scripts/gtm-kernel/verify-north-star-import-manifest.mjs" : item.seed_source === "agency" ? "scripts/gtm-kernel/verify-agency-import-manifest.mjs" : item.seed_source === "building-clay" ? "scripts/gtm-kernel/verify-building-clay-import-manifest.mjs" : null,
3001
+ memorySources: [item]
3002
+ };
3003
+ }
2594
3004
  function shellArg(value) {
2595
3005
  return `'${value.replace(/'/g, "'\\''")}'`;
2596
3006
  }
@@ -2767,11 +3177,11 @@ function builtInRoutesFor(request) {
2767
3177
  routes.push({
2768
3178
  id: "signaliz-lead-generation",
2769
3179
  layer: "source",
2770
- gtmLayers: ["find_company", "find_people", "lead_generation"],
3180
+ gtmLayer: "lead_generation",
2771
3181
  provider: "signaliz",
2772
3182
  mode: "required",
2773
3183
  toolName: "generate_leads",
2774
- rationale: "Use Signaliz fresh workspace acquisition as the default source of truth."
3184
+ rationale: "Inventory verified cache first, then use Signaliz fresh workspace acquisition for the remaining approved gap."
2775
3185
  });
2776
3186
  }
2777
3187
  if (builtIns.has("local_leads")) {
@@ -2785,6 +3195,28 @@ function builtInRoutesFor(request) {
2785
3195
  rationale: "Use Signaliz local-leads sourcing for geography-bound local business campaigns."
2786
3196
  });
2787
3197
  }
3198
+ if (builtIns.has("company_discovery")) {
3199
+ routes.push({
3200
+ id: "signaliz-company-discovery",
3201
+ layer: "source",
3202
+ gtmLayer: "find_company",
3203
+ provider: "signaliz",
3204
+ mode: "if_available",
3205
+ toolName: "find_companies_signaliz",
3206
+ rationale: "Find and qualify company domains before people/email fill for account-led campaigns."
3207
+ });
3208
+ }
3209
+ if (builtIns.has("people_discovery")) {
3210
+ routes.push({
3211
+ id: "signaliz-people-discovery",
3212
+ layer: "source",
3213
+ gtmLayer: "find_people",
3214
+ provider: "signaliz",
3215
+ mode: "if_available",
3216
+ toolName: "find_people_signaliz",
3217
+ rationale: "Find people directly when the brief is contact research or LinkedIn-style prospecting."
3218
+ });
3219
+ }
2788
3220
  if (builtIns.has("email_finding")) {
2789
3221
  routes.push({
2790
3222
  id: "signaliz-email-finding",
@@ -2829,7 +3261,7 @@ function normalizeBuiltIns(request) {
2829
3261
  return [...builtIns].filter(isCampaignBuilderBuiltInTool);
2830
3262
  }
2831
3263
  function isCampaignBuilderBuiltInTool(value) {
2832
- return ["lead_generation", "local_leads", "email_finding", "email_verification", "signals"].includes(String(value));
3264
+ return ["lead_generation", "local_leads", "company_discovery", "people_discovery", "email_finding", "email_verification", "signals"].includes(String(value));
2833
3265
  }
2834
3266
  function looksLikeLocalLeadCampaign(request) {
2835
3267
  const text = [
@@ -2884,7 +3316,11 @@ function createBuildRequest(request, defaults, targetCount, campaignName, scopeB
2884
3316
  qualification: defaults.qualification,
2885
3317
  copy: defaults.copy,
2886
3318
  delivery: defaults.delivery,
2887
- enhancers: enhancerConfig(request)
3319
+ enhancers: enhancerConfig(request),
3320
+ sourceRouting: request.sourceRouting ?? {
3321
+ mode: looksLikeLocalLeadCampaign(request) ? "local_leads" : "auto",
3322
+ fillPolicy: "aggressive"
3323
+ }
2888
3324
  };
2889
3325
  const scoped = asRecord(scopeBuildArgs);
2890
3326
  buildRequest.gtmCampaignId = request.gtmCampaignId ?? stringValue(scoped.gtm_campaign_id ?? scoped.gtmCampaignId);
@@ -2966,9 +3402,132 @@ function createBrainPreflight(request, buildRequest, routes, memory) {
2966
3402
  { tool: "gtm_brain_learning_cycle_plan", purpose: "Plan the Brain learning loop for this campaign.", arguments: learningArgs },
2967
3403
  { tool: "gtm_brain_seed_defaults", purpose: "Seed campaign defaults from workspace memory and safe aggregate patterns.", arguments: defaultsArgs },
2968
3404
  { tool: "gtm_brain_delivery_risk", purpose: "Check deliverability risk before launch or external writes.", arguments: riskArgs }
2969
- ]
3405
+ ],
3406
+ learn_back_plan: createCampaignBuilderLearnBackPlan(request, buildRequest)
3407
+ };
3408
+ }
3409
+ function createCampaignBuilderLearnBackPlan(request, buildRequest) {
3410
+ const instantlyFeedbackContext = campaignBuilderProviderFeedbackContext(request, buildRequest, "instantly");
3411
+ const postBuildSequence = [
3412
+ {
3413
+ tool: "get_campaign_build_status",
3414
+ approval_boundary: "read_only",
3415
+ arguments_template: { campaign_build_id: "<build_campaign.campaign_build_id>" },
3416
+ reason: "Wait for the Campaign Builder run to finish before deriving memory."
3417
+ },
3418
+ {
3419
+ tool: "gtm_campaign_build_backfill_preview",
3420
+ approval_boundary: "read_only",
3421
+ arguments_template: { campaign_build_id: "<build_campaign.campaign_build_id>", create_memory: true },
3422
+ reason: "Preview the provider-neutral Kernel import payload without writing rows."
3423
+ },
3424
+ {
3425
+ tool: "gtm_campaign_build_backfill_run",
3426
+ approval_boundary: "dry_run",
3427
+ arguments_template: { campaign_build_ids: ["<build_campaign.campaign_build_id>"], dry_run: true, create_memory: true, run_brain_cycle: false },
3428
+ reason: "Dry-run the Kernel history import before creating campaign memory."
3429
+ },
3430
+ {
3431
+ tool: "gtm_campaign_build_backfill_run",
3432
+ approval_boundary: "explicit_write_approval",
3433
+ arguments_template: { campaign_build_ids: ["<build_campaign.campaign_build_id>"], dry_run: false, create_memory: true, run_brain_cycle: true, brain_cycle_write_mode: "dry_run" },
3434
+ reason: "After review, queue the Kernel history import; Brain learning remains dry-run unless separately approved."
3435
+ }
3436
+ ];
3437
+ if (instantlyFeedbackContext) {
3438
+ postBuildSequence.push({
3439
+ tool: "gtm_instantly_feedback_pull",
3440
+ approval_boundary: "dry_run_first_explicit_write_approval",
3441
+ arguments_template: {
3442
+ campaign_id: buildRequest.gtmCampaignId || "<gtm_campaign_id_after_commit>",
3443
+ campaign_build_id: "<build_campaign.campaign_build_id>",
3444
+ source: "emails",
3445
+ email_type: "received",
3446
+ ...instantlyFeedbackContext,
3447
+ dry_run: true,
3448
+ create_memory: true,
3449
+ write_routine_outcomes: true,
3450
+ run_brain_cycle: true,
3451
+ brain_cycle_write_mode: "dry_run"
3452
+ },
3453
+ reason: "After Instantly delivery has live outcomes, pull reply and bounce history into private feedback memory before Brain learning."
3454
+ });
3455
+ }
3456
+ postBuildSequence.push(
3457
+ {
3458
+ tool: "gtm_campaign_learning_status",
3459
+ approval_boundary: "read_only",
3460
+ arguments_template: {
3461
+ campaign_id: buildRequest.gtmCampaignId || "<gtm_campaign_id_after_commit>",
3462
+ campaign_build_id: "<build_campaign.campaign_build_id>",
3463
+ write_mode: "dry_run"
3464
+ },
3465
+ reason: "Confirm feedback, memory, and Brain learning readiness after the import."
3466
+ },
3467
+ {
3468
+ tool: "gtm_memory_search",
3469
+ approval_boundary: "read_only",
3470
+ arguments_template: {
3471
+ query: request.goal,
3472
+ ...buildRequest.gtmCampaignId ? { campaign_id: buildRequest.gtmCampaignId } : {},
3473
+ limit: 10
3474
+ },
3475
+ reason: "Verify the new private memory is retrievable for future campaign planning."
3476
+ },
3477
+ {
3478
+ tool: "gtm_brain_learning_cycle_plan",
3479
+ approval_boundary: "read_only",
3480
+ arguments_template: {
3481
+ ...buildRequest.gtmCampaignId ? { campaign_id: buildRequest.gtmCampaignId } : {},
3482
+ include_memory: true,
3483
+ write_mode: "dry_run"
3484
+ },
3485
+ reason: "Plan the Brain phases from the imported outcomes before any pattern writes."
3486
+ }
3487
+ );
3488
+ return {
3489
+ source_tool: "campaign-builder-agent",
3490
+ gtm_campaign_id: buildRequest.gtmCampaignId ?? null,
3491
+ trigger: "After build_campaign returns a campaign_build_id and the build reaches a terminal reviewed state.",
3492
+ build_result_placeholders: {
3493
+ campaign_build_id: "<build_campaign.campaign_build_id>"
3494
+ },
3495
+ memory_write_policy: {
3496
+ target_tables: ["gtm_campaigns", "gtm_campaign_provider_links", "gtm_campaign_feedback_events", "gtm_memory_items", "gtm_brain_patterns"],
3497
+ gtm_memory_items: {
3498
+ shareable: false,
3499
+ allowed_redaction_states: ["redacted", "abstracted"],
3500
+ raw_private_fields_withheld: ["reply_text", "copy_body", "lead_email", "lead_domain", "company_domain", "provider_campaign_id", "provider_payload", "webhook_url", "secret"]
3501
+ },
3502
+ gtm_brain_patterns: "Workspace-scoped by default. Global promotion requires abstracted_only=true, shared opt-in, and privacy thresholds."
3503
+ },
3504
+ post_build_sequence: postBuildSequence.map((item, index) => ({ step: index + 1, ...item })),
3505
+ approval_policy: "This agent plan never writes learn-back rows. Backfill and provider-feedback writes require dry_run=false after review, and Brain writes require their own approved learning-cycle run.",
3506
+ privacy_policy: "Learn-back memory is workspace-private. Raw replies, copy bodies, leads, emails, domains, provider payloads, webhook URLs, secrets, private source paths, and raw client labels are withheld from memory rows and agent-visible outputs."
2970
3507
  };
2971
3508
  }
3509
+ function campaignBuilderProviderFeedbackContext(request, buildRequest, provider) {
3510
+ const normalizedProvider = String(provider).toLowerCase();
3511
+ const routes = [...request.integrations ?? [], ...routesFromCustomerTools(request.customerTools ?? [])];
3512
+ const providerRoute = routes.find((route) => String(route.provider).toLowerCase() === normalizedProvider);
3513
+ const routeConfig = asRecord(providerRoute?.config);
3514
+ const deliveryConfig = asRecord(buildRequest.delivery?.destinationConfig);
3515
+ const hasProviderContext = [
3516
+ ...request.preferredProviders ?? [],
3517
+ ...routes.map((route) => route.provider),
3518
+ stringValue(deliveryConfig.provider),
3519
+ stringValue(deliveryConfig.provider_id ?? deliveryConfig.providerId),
3520
+ stringValue(deliveryConfig.destination_provider ?? deliveryConfig.destinationProvider),
3521
+ stringValue(deliveryConfig.sink ?? deliveryConfig.sink_type ?? deliveryConfig.sinkType)
3522
+ ].some((value) => String(value).toLowerCase() === normalizedProvider);
3523
+ if (!hasProviderContext) return void 0;
3524
+ return compact({
3525
+ provider_link_id: stringValue(routeConfig.provider_link_id ?? routeConfig.providerLinkId ?? deliveryConfig.provider_link_id ?? deliveryConfig.providerLinkId),
3526
+ provider_campaign_id: stringValue(routeConfig.provider_campaign_id ?? routeConfig.providerCampaignId ?? routeConfig.instantly_campaign_id ?? routeConfig.instantlyCampaignId ?? deliveryConfig.provider_campaign_id ?? deliveryConfig.providerCampaignId ?? deliveryConfig.instantly_campaign_id ?? deliveryConfig.instantlyCampaignId),
3527
+ integration_id: stringValue(routeConfig.integration_id ?? routeConfig.integrationId ?? deliveryConfig.integration_id ?? deliveryConfig.integrationId),
3528
+ instantly_profile: stringValue(routeConfig.instantly_profile ?? routeConfig.instantlyProfile ?? routeConfig.profile ?? deliveryConfig.instantly_profile ?? deliveryConfig.instantlyProfile ?? deliveryConfig.profile)
3529
+ });
3530
+ }
2972
3531
  function gtmLayersForBuilderLayer(layer) {
2973
3532
  const map = {
2974
3533
  workspace_context: ["customer_data"],
@@ -3373,6 +3932,7 @@ function buildFallbackPlanSnapshot(plan) {
3373
3932
  target_count: plan.targetCount,
3374
3933
  approvals: plan.approvals,
3375
3934
  brain_preflight: plan.brainPreflight,
3935
+ campaign_strategy_context: plan.buildRequest.campaignStrategyContext,
3376
3936
  operating_playbooks: plan.operatingPlaybooks
3377
3937
  });
3378
3938
  }
@@ -3505,6 +4065,7 @@ function buildCampaignArgs(request) {
3505
4065
  if (request.dedupKeys) args.dedup_keys = request.dedupKeys;
3506
4066
  if (request.brainPreflight) args.brain_preflight = request.brainPreflight;
3507
4067
  if (request.brainDefaults) args.brain_defaults = request.brainDefaults;
4068
+ if (request.campaignStrategyContext) args.campaign_strategy_context = request.campaignStrategyContext;
3508
4069
  if (request.deliveryRisk) args.delivery_risk = request.deliveryRisk;
3509
4070
  if (request.icp) {
3510
4071
  args.icp = compact({
@@ -3524,6 +4085,15 @@ function buildCampaignArgs(request) {
3524
4085
  model: request.policy.model
3525
4086
  });
3526
4087
  }
4088
+ if (request.sourceRouting) {
4089
+ args.source_routing = compact({
4090
+ mode: request.sourceRouting.mode,
4091
+ fill_policy: request.sourceRouting.fillPolicy,
4092
+ shard_size: request.sourceRouting.shardSize,
4093
+ max_source_shard_size: request.sourceRouting.maxSourceShardSize,
4094
+ max_local_source_shard_size: request.sourceRouting.maxLocalSourceShardSize
4095
+ });
4096
+ }
3527
4097
  if (request.signals) {
3528
4098
  args.signals = compact({
3529
4099
  enabled: request.signals.enabled,
@@ -3595,7 +4165,8 @@ function buildExecutionPrepareArgs(request, dryRun, confirmSpend) {
3595
4165
  qualification: buildArgs2.qualification,
3596
4166
  copy: buildArgs2.copy,
3597
4167
  delivery: buildArgs2.delivery,
3598
- enhancers: buildArgs2.enhancers
4168
+ enhancers: buildArgs2.enhancers,
4169
+ source_routing: buildArgs2.source_routing
3599
4170
  });
3600
4171
  }
3601
4172
  function buildDeliveryApprovalArgs(request) {
@@ -3644,17 +4215,62 @@ function mapAgentCampaignBuildStatus(data) {
3644
4215
  warnings: diagnosticMessages2(data.warnings),
3645
4216
  errors: diagnosticMessages2(data.errors),
3646
4217
  artifactCount: numberOrUndefined2(data.artifact_count) ?? 0,
4218
+ artifactDownloads: Array.isArray(data.artifact_downloads) ? data.artifact_downloads.map(mapAgentCampaignArtifactDownload) : [],
4219
+ customerRowCounts: mapAgentCustomerRowCounts(data.customer_row_counts),
4220
+ phaseAttemptTotals: nullableRecord(data.phase_attempt_totals) ?? void 0,
3647
4221
  providerRoute: mapProviderRoute2(data),
3648
4222
  triggerRunId: stringValue(data.trigger_run_id) ?? null,
3649
4223
  staleRunningPhase: data.stale_running_phase === true,
3650
4224
  phaseAgeSeconds: numberOrNull2(data.phase_age_seconds),
3651
4225
  diagnostics: nullableRecord(data.diagnostics) ?? {},
3652
4226
  nextAction: formatAgentNextAction(data.next_action),
4227
+ approvalAction: formatAgentNextAction(data.approval_action),
3653
4228
  createdAt: stringValue(data.created_at) ?? "",
3654
4229
  updatedAt: stringValue(data.updated_at) ?? "",
3655
4230
  completedAt: stringValue(data.completed_at) ?? null
3656
4231
  };
3657
4232
  }
4233
+ function mapAgentCampaignArtifactDownload(data) {
4234
+ return {
4235
+ id: stringValue(data.id) ?? "",
4236
+ artifactType: stringValue(data.artifact_type) ?? null,
4237
+ format: stringValue(data.format) ?? null,
4238
+ rowCount: numberOrUndefined2(data.row_count) ?? 0,
4239
+ signedUrl: stringValue(data.signed_url) ?? null,
4240
+ downloadUrl: stringValue(data.download_url) ?? null,
4241
+ manifestUrl: stringValue(data.manifest_url) ?? null,
4242
+ expiresAt: stringValue(data.expires_at) ?? null
4243
+ };
4244
+ }
4245
+ function mapAgentCustomerRowCounts(value) {
4246
+ const record = nullableRecord(value);
4247
+ if (!record) return void 0;
4248
+ return {
4249
+ requestedTarget: numberOrNull2(record.requested_target),
4250
+ acquiredRows: numberOrUndefined2(record.acquired_rows),
4251
+ acceptedRows: numberOrUndefined2(record.accepted_rows),
4252
+ usableRows: numberOrUndefined2(record.usable_rows),
4253
+ copiedRows: numberOrUndefined2(record.copied_rows),
4254
+ approvalReadyRows: numberOrUndefined2(record.approval_ready_rows),
4255
+ qaReadyRows: numberOrUndefined2(record.qa_ready_rows),
4256
+ deliveredRows: numberOrUndefined2(record.delivered_rows),
4257
+ disqualifiedRows: numberOrUndefined2(record.disqualified_rows),
4258
+ reviewableRows: numberOrUndefined2(record.reviewable_rows),
4259
+ rowFailures: numberOrUndefined2(record.row_failures),
4260
+ acceptedShortfall: numberOrNull2(record.accepted_shortfall),
4261
+ usableShortfall: numberOrNull2(record.usable_shortfall),
4262
+ qaReadyShortfall: numberOrNull2(record.qa_ready_shortfall),
4263
+ deliveryShortfall: numberOrNull2(record.delivery_shortfall),
4264
+ fillRatio: numberOrNull2(record.fill_ratio),
4265
+ qaReadyFillRatio: numberOrNull2(record.qa_ready_fill_ratio),
4266
+ deliveredFillRatio: numberOrNull2(record.delivered_fill_ratio),
4267
+ terminalReason: stringValue(record.terminal_reason) ?? null,
4268
+ acceptedShortfallReason: stringValue(record.accepted_shortfall_reason) ?? null,
4269
+ usableShortfallReason: stringValue(record.usable_shortfall_reason) ?? null,
4270
+ qaReadyShortfallReason: stringValue(record.qa_ready_shortfall_reason) ?? null,
4271
+ deliveryShortfallReason: stringValue(record.delivery_shortfall_reason) ?? null
4272
+ };
4273
+ }
3658
4274
  function mapAgentCampaignRowsResult(data) {
3659
4275
  const rows = Array.isArray(data.rows) ? data.rows : [];
3660
4276
  return {
@@ -3682,7 +4298,11 @@ function mapAgentCampaignArtifact(data) {
3682
4298
  artifactType: stringValue(data.artifact_type) ?? "",
3683
4299
  destination: stringValue(data.destination) ?? "",
3684
4300
  storagePath: stringValue(data.storage_path) ?? "",
4301
+ format: stringValue(data.format) ?? null,
3685
4302
  signedUrl: stringValue(data.signed_url) ?? null,
4303
+ downloadUrl: stringValue(data.download_url) ?? null,
4304
+ manifestUrl: stringValue(data.manifest_url) ?? null,
4305
+ expiresAt: stringValue(data.expires_at) ?? null,
3686
4306
  rowCount: numberOrUndefined2(data.row_count) ?? 0,
3687
4307
  checksum: stringValue(data.checksum) ?? null,
3688
4308
  metadata: nullableRecord(data.metadata) ?? {},
@@ -3844,6 +4464,8 @@ function readinessLaneLabel(route, builtIn) {
3844
4464
  const labels = {
3845
4465
  lead_generation: "Signaliz lead generation",
3846
4466
  local_leads: "Signaliz local leads",
4467
+ company_discovery: "Signaliz company discovery",
4468
+ people_discovery: "Signaliz people discovery",
3847
4469
  email_finding: "Signaliz email finding",
3848
4470
  email_verification: "Signaliz email verification",
3849
4471
  signals: "Signaliz signals"
@@ -3928,6 +4550,35 @@ function summarizeCampaignBuilderProofDryRun(dryRunResult) {
3928
4550
  plannedTargetCount: dryRunResult.plannedTargetCount ?? dryRunResult.planned_target_count ?? null
3929
4551
  };
3930
4552
  }
4553
+ function summarizeCampaignBuilderProofLearnBack(plan) {
4554
+ if (Object.keys(plan).length === 0) return { ready: false };
4555
+ const memoryPolicy = asRecord(plan.memory_write_policy);
4556
+ const memoryItemsPolicy = asRecord(memoryPolicy.gtm_memory_items);
4557
+ const sequence = Array.isArray(plan.post_build_sequence) ? plan.post_build_sequence.map((step) => {
4558
+ const record = asRecord(step);
4559
+ return compact({
4560
+ step: record.step,
4561
+ tool: stringValue(record.tool),
4562
+ approval_boundary: stringValue(record.approval_boundary),
4563
+ reason: stringValue(record.reason)
4564
+ });
4565
+ }).filter((step) => typeof step.tool === "string") : [];
4566
+ return {
4567
+ ready: sequence.length > 0,
4568
+ source_tool: firstNonEmptyString(plan.source_tool, plan.sourceTool),
4569
+ post_build_sequence: sequence,
4570
+ memory_write_policy: {
4571
+ target_tables: Array.isArray(memoryPolicy.target_tables) ? memoryPolicy.target_tables : [],
4572
+ gtm_memory_items: {
4573
+ shareable: memoryItemsPolicy.shareable === false ? false : memoryItemsPolicy.shareable ?? null,
4574
+ allowed_redaction_states: Array.isArray(memoryItemsPolicy.allowed_redaction_states) ? memoryItemsPolicy.allowed_redaction_states : [],
4575
+ raw_private_fields_withheld: Array.isArray(memoryItemsPolicy.raw_private_fields_withheld) ? memoryItemsPolicy.raw_private_fields_withheld : []
4576
+ }
4577
+ },
4578
+ approval_policy: firstNonEmptyString(plan.approval_policy, plan.approvalPolicy),
4579
+ privacy_policy: firstNonEmptyString(plan.privacy_policy, plan.privacyPolicy)
4580
+ };
4581
+ }
3931
4582
  function firstNonEmptyString(...values) {
3932
4583
  for (const value of values) {
3933
4584
  if (typeof value === "string" && value.trim()) return value;
@@ -4410,14 +5061,87 @@ var Ops = class {
4410
5061
  const body = typeof params === "string" ? { prompt: params } : buildOpsCreateBody(params);
4411
5062
  return normalizeOpsCreateResult(withExecutionRefs(await this.call("ops_create", body)));
4412
5063
  }
5064
+ async schedule(params) {
5065
+ const createBody = typeof params === "string" ? { prompt: params, cadence: "daily" } : { ...buildOpsCreateBody(params), cadence: params.cadence ?? "daily" };
5066
+ const { activate: _activate, ...body } = createBody;
5067
+ return normalizeOpsCreateResult(withExecutionRefs(await this.call("ops_schedule", body)));
5068
+ }
5069
+ async scheduleAndWait(params) {
5070
+ const options = typeof params === "string" ? { schedule: { prompt: params, cadence: "daily" }, run: {}, wait: {} } : buildOpsScheduleAndWaitOptions(params);
5071
+ const raw = await this.call("ops_schedule_and_wait", buildOpsScheduleAndWaitBody(options));
5072
+ return normalizeOpsScheduleAndWaitCallResult(raw, options.wait, {
5073
+ approvalMessage: "ops.scheduleAndWait requires an approved schedulable Op. Retry with confirmSpend=true after reviewing approval details.",
5074
+ notCreatedMessage: "ops.scheduleAndWait requires ops_schedule_and_wait to create an op_id. Use ops.schedule for approval review flows."
5075
+ });
5076
+ }
5077
+ /** Schedule a recurring Op that delivers through a customer-owned Nango API connection. */
5078
+ async scheduleNangoAction(input) {
5079
+ return normalizeOpsCreateResult(withExecutionRefs(await this.call("ops_nango_schedule", buildOpsNangoScheduleBody(input))));
5080
+ }
5081
+ /** Schedule a recurring Nango-backed Op, run the first tick, and return result readback. */
5082
+ async scheduleNangoActionAndWait(input) {
5083
+ const options = buildOpsNangoScheduleAndWaitOptions(input);
5084
+ const raw = await this.call("ops_nango_schedule_and_wait", buildOpsNangoScheduleAndWaitBody(options));
5085
+ return normalizeOpsScheduleAndWaitCallResult(raw, options.wait, {
5086
+ approvalMessage: "ops.scheduleNangoActionAndWait requires an approved Nango-backed Op. Retry with confirmSpend=true after reviewing approval details.",
5087
+ notCreatedMessage: "ops.scheduleNangoActionAndWait requires ops_nango_schedule_and_wait to create an op_id. Use ops.scheduleNangoAction for approval review flows."
5088
+ });
5089
+ }
4413
5090
  async execute(params) {
4414
5091
  const body = typeof params === "string" ? { prompt: params } : buildOpsExecuteBody(params);
4415
5092
  return normalizeOpsExecuteResult(withExecutionRefs(await this.call("ops_execute", body)));
4416
5093
  }
5094
+ async executeAndWait(params) {
5095
+ const options = typeof params === "string" ? { execute: { prompt: params, auto_run: true }, wait: {} } : buildOpsExecuteAndWaitOptions(params);
5096
+ const execute = await this.execute(options.execute);
5097
+ if (execute.approval_required || execute.error_code === "APPROVAL_REQUIRED") {
5098
+ throw new SignalizError({
5099
+ code: "APPROVAL_REQUIRED",
5100
+ errorType: "validation",
5101
+ message: "ops.executeAndWait requires an approved executable Op. Retry with confirmSpend=true after reviewing approval details.",
5102
+ details: { execute }
5103
+ });
5104
+ }
5105
+ if (!execute.op_id) {
5106
+ throw new SignalizError({
5107
+ code: "OP_NOT_CREATED",
5108
+ errorType: "validation",
5109
+ message: "ops.executeAndWait requires ops_execute to create an op_id. Use ops.execute for dry runs or approval review flows.",
5110
+ details: { execute }
5111
+ });
5112
+ }
5113
+ const waited = await this.waitForResults({
5114
+ ...options.wait,
5115
+ op_id: execute.op_id
5116
+ });
5117
+ const runId = execute.run_id ?? execute.runId ?? waited.status.run_id ?? waited.status.runId ?? null;
5118
+ return {
5119
+ ...waited,
5120
+ execute,
5121
+ run_id: runId,
5122
+ runId,
5123
+ execution_refs: mergeExecutionRefsFrom([execute, waited])
5124
+ };
5125
+ }
4417
5126
  async run(params) {
4418
5127
  const body = typeof params === "string" ? { op_id: params } : buildOpsRunBody(params);
4419
5128
  return normalizeOpsRunResult(withExecutionRefs(await this.call("ops_run", body)));
4420
5129
  }
5130
+ async runAndWait(params) {
5131
+ const options = typeof params === "string" ? { op_id: params } : buildOpsRunAndWaitOptions(params);
5132
+ if (!options.op_id) throw new Error("ops.runAndWait requires op_id or opId");
5133
+ const run = await this.run({
5134
+ op_id: options.op_id,
5135
+ instruction: options.instruction,
5136
+ force: options.force
5137
+ });
5138
+ const waited = await this.waitForResults(options);
5139
+ return {
5140
+ ...waited,
5141
+ run,
5142
+ execution_refs: mergeExecutionRefsFrom([run, waited])
5143
+ };
5144
+ }
4421
5145
  async status(params) {
4422
5146
  const body = typeof params === "string" ? { op_id: params } : buildOpsStatusBody(params);
4423
5147
  return normalizeOpsStatusResult(withExecutionRefs(await this.call("ops_status", body)));
@@ -4426,77 +5150,250 @@ var Ops = class {
4426
5150
  const body = typeof params === "string" ? { op_id: params } : buildOpsResultsBody(params);
4427
5151
  return normalizeOpsResultsResult(withExecutionRefs(await this.call("ops_results", body)));
4428
5152
  }
4429
- async proof(params = {}) {
4430
- const data = await this.call("ops_proof", {
4431
- window_hours: params.windowHours,
4432
- output_format: "json"
5153
+ async waitForResults(params) {
5154
+ const options = typeof params === "string" ? { op_id: params } : buildOpsWaitForResultsOptions(params);
5155
+ if (!options.op_id) throw new Error("ops.waitForResults requires op_id or opId");
5156
+ const waitResult = await this.call("ops_wait", buildOpsWaitBody(options));
5157
+ return normalizeOpsWaitForResultsResult(waitResult, options);
5158
+ }
5159
+ /** Create a short-lived Nango Connect session from the Ops namespace. */
5160
+ async createNangoConnectSession(input) {
5161
+ return this.call("nango_connect_session_create", {
5162
+ provider_id: input.providerId,
5163
+ integration_id: input.integrationId,
5164
+ provider_display_name: input.providerDisplayName,
5165
+ integration_display_name: input.integrationDisplayName,
5166
+ allowed_integrations: input.allowedIntegrations,
5167
+ surface: input.surface,
5168
+ source: input.source,
5169
+ user_email: input.userEmail,
5170
+ user_display_name: input.userDisplayName
4433
5171
  });
4434
- return normalizeOpsProofResult(data);
4435
5172
  }
4436
- async debug(params) {
4437
- const options = typeof params === "string" ? { op_id: params } : buildOpsDebugOptions(params);
4438
- const diagnosticErrors = [];
4439
- const status = await this.status(options.op_id);
4440
- const refs = /* @__PURE__ */ new Map();
4441
- const addRefs = (items) => {
4442
- for (const ref of items ?? []) refs.set(`${ref.kind}:${ref.id}`, ref);
4443
- };
4444
- const recordError = (step, err) => {
4445
- diagnosticErrors.push({
4446
- step,
4447
- message: err instanceof Error ? err.message : String(err)
4448
- });
4449
- };
4450
- addRefs(status.execution_refs);
4451
- if (status.latest_run && typeof status.latest_run === "object") {
4452
- addRefs(collectExecutionReferences(status.latest_run));
4453
- }
4454
- const runRefs = Array.from(refs.values()).filter((ref) => ref.kind === "trigger_run" || ref.kind === "dataplane_run" || ref.kind === "replay_run");
4455
- const runStatuses = [];
4456
- for (const ref of runRefs) {
4457
- try {
4458
- const result = await this.getTriggerRunStatus(ref.id);
4459
- const runs = "runs" in result ? result.runs : [result];
4460
- runStatuses.push(...runs);
4461
- for (const run of runs) addRefs(run.execution_refs);
4462
- } catch (err) {
4463
- recordError(`run-status:${ref.id}`, err);
4464
- }
5173
+ /** Prepare the full Nango provider search, connect, pull/export, Ops, and route flow. */
5174
+ async prepareNangoIntegrationFlow(input = {}) {
5175
+ return this.call("nango_integration_flow_prepare", {
5176
+ query: input.query,
5177
+ search: input.search,
5178
+ provider_id: input.providerId,
5179
+ provider: input.provider,
5180
+ integration_id: input.integrationId,
5181
+ provider_config_key: input.providerConfigKey,
5182
+ workspace_connection_id: input.workspaceConnectionId,
5183
+ connection_id: input.connectionId,
5184
+ nango_connection_id: input.nangoConnectionId,
5185
+ intent: input.intent,
5186
+ action_name: input.actionName,
5187
+ tool_name: input.toolName,
5188
+ proxy_path: input.proxyPath,
5189
+ method: input.method,
5190
+ input: input.input,
5191
+ cadence: input.cadence,
5192
+ field_map: input.fieldMap,
5193
+ required_fields: input.requiredFields,
5194
+ confirm_spend: input.confirmSpend,
5195
+ write_confirmed: input.writeConfirmed,
5196
+ layer: input.layer,
5197
+ campaign_id: input.campaignId,
5198
+ limit: input.limit,
5199
+ include_provider_catalog: input.includeProviderCatalog
5200
+ });
5201
+ }
5202
+ /** List Nango-backed action tools for a workspace connection without executing them. */
5203
+ async listNangoTools(options = {}) {
5204
+ return this.call("nango_mcp_tools_list", {
5205
+ workspace_connection_id: options.workspaceConnectionId,
5206
+ connection_id: options.connectionId,
5207
+ provider_config_key: options.providerConfigKey,
5208
+ integration_id: options.integrationId,
5209
+ nango_connection_id: options.nangoConnectionId,
5210
+ format: options.format,
5211
+ include_raw: options.includeRaw
5212
+ });
5213
+ }
5214
+ /** Audit connected Nango rows, action/proxy readiness, and read/write proof gaps. */
5215
+ async proveNangoReadWrite(options = {}) {
5216
+ return this.call("nango_mcp_read_write_audit", {
5217
+ workspace_connection_id: options.workspaceConnectionId,
5218
+ connection_id: options.connectionId,
5219
+ provider_config_key: options.providerConfigKey,
5220
+ integration_id: options.integrationId,
5221
+ nango_connection_id: options.nangoConnectionId,
5222
+ limit: options.limit,
5223
+ include_raw: options.includeRaw,
5224
+ read_proxy_path: options.readProxyPath,
5225
+ write_proxy_path: options.writeProxyPath,
5226
+ method: options.method,
5227
+ execute_read_probe: options.executeReadProbe,
5228
+ execute_write_probe: options.executeWriteProbe,
5229
+ confirm: options.confirm,
5230
+ confirm_write: options.confirmWrite,
5231
+ input: options.input,
5232
+ write_input: options.writeInput
5233
+ });
5234
+ }
5235
+ /** Dry-run or execute a Nango-backed action tool through the approval-aware MCP bridge. */
5236
+ async callNangoTool(input) {
5237
+ return this.call("nango_mcp_tool_call", {
5238
+ workspace_connection_id: input.workspaceConnectionId,
5239
+ connection_id: input.connectionId,
5240
+ provider_config_key: input.providerConfigKey,
5241
+ integration_id: input.integrationId,
5242
+ nango_connection_id: input.nangoConnectionId,
5243
+ action_name: input.actionName,
5244
+ tool_name: input.toolName,
5245
+ delivery_mode: input.deliveryMode,
5246
+ proxy_path: input.proxyPath,
5247
+ nango_proxy_path: input.nangoProxyPath,
5248
+ method: input.method,
5249
+ http_method: input.httpMethod,
5250
+ proxy_headers: input.proxyHeaders,
5251
+ input: input.input,
5252
+ async: input.async,
5253
+ max_retries: input.maxRetries,
5254
+ dry_run: input.dryRun,
5255
+ confirm: input.confirm,
5256
+ confirm_write: input.confirmWrite
5257
+ });
5258
+ }
5259
+ /** Execute a Nango action and poll its async result when a status URL/action id is returned. */
5260
+ async callNangoToolAndWait(input) {
5261
+ const result = await this.call("nango_mcp_tool_call_and_wait", {
5262
+ workspace_connection_id: input.workspaceConnectionId,
5263
+ connection_id: input.connectionId,
5264
+ provider_config_key: input.providerConfigKey,
5265
+ integration_id: input.integrationId,
5266
+ nango_connection_id: input.nangoConnectionId,
5267
+ action_name: input.actionName,
5268
+ tool_name: input.toolName,
5269
+ delivery_mode: input.deliveryMode,
5270
+ proxy_path: input.proxyPath,
5271
+ nango_proxy_path: input.nangoProxyPath,
5272
+ method: input.method,
5273
+ http_method: input.httpMethod,
5274
+ proxy_headers: input.proxyHeaders,
5275
+ input: input.input,
5276
+ async: input.async ?? true,
5277
+ max_retries: input.maxRetries,
5278
+ dry_run: input.dryRun,
5279
+ confirm: input.confirm,
5280
+ confirm_write: input.confirmWrite,
5281
+ interval_ms: input.intervalMs,
5282
+ max_polls: input.maxPolls,
5283
+ timeout_ms: input.timeoutMs
5284
+ });
5285
+ const packet = asRecord2(result);
5286
+ const actionId = optionalString(packet.actionId) ?? optionalString(packet.action_id);
5287
+ const statusUrl = optionalString(packet.statusUrl) ?? optionalString(packet.status_url);
5288
+ const maxPolls = Number(packet.maxPolls ?? packet.max_polls ?? 0);
5289
+ const intervalMs = Number(packet.intervalMs ?? packet.interval_ms ?? 0);
5290
+ const timeoutMs = Number(packet.timeoutMs ?? packet.timeout_ms ?? 0);
5291
+ const timedOut = Boolean(packet.timedOut ?? packet.timed_out);
5292
+ return {
5293
+ ...packet,
5294
+ success: typeof packet.success === "boolean" ? packet.success : void 0,
5295
+ call: packet.call,
5296
+ result: packet.result,
5297
+ status: optionalString(packet.status),
5298
+ action_id: actionId,
5299
+ actionId,
5300
+ status_url: statusUrl,
5301
+ statusUrl,
5302
+ polls: Number(packet.polls ?? 0),
5303
+ max_polls: maxPolls,
5304
+ maxPolls,
5305
+ interval_ms: intervalMs,
5306
+ intervalMs,
5307
+ timeout_ms: timeoutMs,
5308
+ timeoutMs,
5309
+ timed_out: timedOut,
5310
+ timedOut
5311
+ };
5312
+ }
5313
+ /** Poll an async Nango action result by action id or status URL. */
5314
+ async getNangoActionResult(input) {
5315
+ return this.call("nango_mcp_action_result_get", {
5316
+ action_id: input.actionId,
5317
+ status_url: input.statusUrl
5318
+ });
5319
+ }
5320
+ async proof(params = {}) {
5321
+ const data = await this.call("ops_proof", {
5322
+ window_hours: params.windowHours,
5323
+ output_format: "json"
5324
+ });
5325
+ return normalizeOpsProofResult(data);
5326
+ }
5327
+ async debug(params) {
5328
+ const options = typeof params === "string" ? { op_id: params } : buildOpsDebugOptions(params);
5329
+ const diagnosticErrors = [];
5330
+ const status = await this.status(options.op_id);
5331
+ const refs = /* @__PURE__ */ new Map();
5332
+ const addRefs = (items) => {
5333
+ for (const ref of items ?? []) refs.set(`${ref.kind}:${ref.id}`, ref);
5334
+ };
5335
+ const recordError = (step, err) => {
5336
+ diagnosticErrors.push({
5337
+ step,
5338
+ message: err instanceof Error ? err.message : String(err)
5339
+ });
5340
+ };
5341
+ addRefs(status.execution_refs);
5342
+ if (status.latest_run && typeof status.latest_run === "object") {
5343
+ addRefs(collectExecutionReferences(status.latest_run));
4465
5344
  }
5345
+ const runRefs = Array.from(refs.values()).filter((ref) => ref.kind === "trigger_run" || ref.kind === "dataplane_run" || ref.kind === "replay_run");
5346
+ let runStatuses = [];
4466
5347
  let queue;
4467
- if (options.include_queue !== false) {
4468
- try {
4469
- queue = await this.getQueueStatus({ summary: true });
4470
- addRefs(queue.execution_refs);
4471
- } catch (err) {
4472
- recordError("queue", err);
4473
- }
4474
- }
4475
5348
  let dashboardRecent;
4476
- if (options.include_dashboard !== false) {
4477
- try {
4478
- dashboardRecent = await this.getDashboard({
4479
- section: "recent",
4480
- limit: options.dashboard_limit ?? 10,
4481
- timeRangeDays: options.time_range_days
4482
- });
4483
- } catch (err) {
4484
- recordError("dashboard:recent", err);
4485
- }
4486
- }
4487
5349
  let results;
4488
- if (options.include_results) {
4489
- try {
4490
- results = await this.results({
4491
- op_id: options.op_id,
4492
- limit: options.results_limit ?? 25,
4493
- include_failed_runs: true
4494
- });
4495
- addRefs(results.execution_refs);
4496
- } catch (err) {
4497
- recordError("results", err);
4498
- }
4499
- }
5350
+ await Promise.all([
5351
+ (async () => {
5352
+ if (runRefs.length === 0) return;
5353
+ try {
5354
+ const result = await this.getTriggerRunStatus({ run_ids: runRefs.map((ref) => ref.id) });
5355
+ const runs = "runs" in result ? result.runs : [result];
5356
+ runStatuses = runs;
5357
+ for (const run of runs) addRefs(run.execution_refs);
5358
+ } catch (err) {
5359
+ recordError(runRefs.length === 1 ? `run-status:${runRefs[0].id}` : "run-status:batch", err);
5360
+ }
5361
+ })(),
5362
+ (async () => {
5363
+ if (options.include_queue === false) return;
5364
+ try {
5365
+ queue = await this.getQueueStatus({ summary: true });
5366
+ addRefs(queue.execution_refs);
5367
+ } catch (err) {
5368
+ recordError("queue", err);
5369
+ }
5370
+ })(),
5371
+ (async () => {
5372
+ if (options.include_dashboard === false) return;
5373
+ try {
5374
+ dashboardRecent = await this.getDashboard({
5375
+ section: "recent",
5376
+ limit: options.dashboard_limit ?? 10,
5377
+ timeRangeDays: options.time_range_days
5378
+ });
5379
+ } catch (err) {
5380
+ recordError("dashboard:recent", err);
5381
+ }
5382
+ })(),
5383
+ (async () => {
5384
+ if (!options.include_results) return;
5385
+ try {
5386
+ results = await this.results({
5387
+ op_id: options.op_id,
5388
+ limit: options.results_limit ?? 25,
5389
+ include_failed_runs: true
5390
+ });
5391
+ addRefs(results.execution_refs);
5392
+ } catch (err) {
5393
+ recordError("results", err);
5394
+ }
5395
+ })()
5396
+ ]);
4500
5397
  const executionRefs = Array.from(refs.values());
4501
5398
  const replayCandidates = executionRefs.filter((ref) => ref.kind === "execution_event");
4502
5399
  const nextActions = buildDebugNextActions(status, executionRefs, diagnosticErrors);
@@ -4698,6 +5595,69 @@ function mergeExecutionRefs(result) {
4698
5595
  for (const ref of collectExecutionReferences(result)) add(ref);
4699
5596
  return Array.from(refs.values());
4700
5597
  }
5598
+ function mergeExecutionRefsFrom(results) {
5599
+ const refs = /* @__PURE__ */ new Map();
5600
+ for (const result of results) {
5601
+ if (!result) continue;
5602
+ for (const ref of mergeExecutionRefs(result)) refs.set(`${ref.kind}:${ref.id}`, ref);
5603
+ }
5604
+ return Array.from(refs.values());
5605
+ }
5606
+ function normalizeOpsScheduleAndWaitCallResult(raw, waitOptions, messages) {
5607
+ if (raw.approval_required || raw.approvalRequired || raw.error_code === "APPROVAL_REQUIRED" || raw.errorCode === "APPROVAL_REQUIRED") {
5608
+ throw new SignalizError({
5609
+ code: "APPROVAL_REQUIRED",
5610
+ errorType: "validation",
5611
+ message: messages.approvalMessage,
5612
+ details: { schedule: raw }
5613
+ });
5614
+ }
5615
+ const opId = stringValue2(raw.op_id ?? raw.opId);
5616
+ if (!opId) {
5617
+ throw new SignalizError({
5618
+ code: "OP_NOT_CREATED",
5619
+ errorType: "validation",
5620
+ message: messages.notCreatedMessage,
5621
+ details: { schedule: raw }
5622
+ });
5623
+ }
5624
+ const scheduleRaw = asRecord2(raw.schedule ?? raw.schedule_result ?? raw.scheduleResult);
5625
+ const runRaw = asRecord2(raw.run ?? raw.run_result ?? raw.runResult);
5626
+ const schedule = normalizeOpsCreateResult(withExecutionRefs(
5627
+ Object.keys(scheduleRaw).length > 0 ? scheduleRaw : {
5628
+ ...raw,
5629
+ op_id: opId,
5630
+ routine_id: raw.routine_id ?? raw.routineId ?? opId,
5631
+ status: "ready",
5632
+ phase: "scheduled",
5633
+ next_action: raw.next_action ?? raw.nextAction
5634
+ }
5635
+ ));
5636
+ const run = normalizeOpsRunResult(withExecutionRefs(
5637
+ Object.keys(runRaw).length > 0 ? runRaw : {
5638
+ success: raw.success !== false,
5639
+ op_id: opId,
5640
+ routine_id: raw.routine_id ?? raw.routineId ?? opId,
5641
+ run_id: raw.run_id ?? raw.runId ?? null,
5642
+ status: "running",
5643
+ phase: "queued",
5644
+ next_action: raw.next_action ?? raw.nextAction,
5645
+ results_count: 0,
5646
+ results_url: raw.results_url ?? raw.resultsUrl,
5647
+ delivery_status: raw.delivery_status ?? raw.deliveryStatus
5648
+ }
5649
+ ));
5650
+ const waited = normalizeOpsWaitForResultsResult(raw, { ...waitOptions, op_id: opId });
5651
+ const runId = run.run_id ?? run.runId ?? waited.run_id ?? waited.runId ?? waited.status.run_id ?? waited.status.runId ?? null;
5652
+ return {
5653
+ ...waited,
5654
+ schedule,
5655
+ run,
5656
+ run_id: runId,
5657
+ runId,
5658
+ execution_refs: mergeExecutionRefsFrom([schedule, run, waited])
5659
+ };
5660
+ }
4701
5661
  function normalizeOpsPrimitiveRetryPolicy(policy = {}) {
4702
5662
  return {
4703
5663
  ...policy,
@@ -4773,8 +5733,122 @@ function normalizeOpsPrimitive(primitive) {
4773
5733
  observability: normalizeOpsPrimitiveObservabilityPolicy(primitive.observability)
4774
5734
  };
4775
5735
  }
5736
+ function normalizeOpsExecutionToolCall(rawCall) {
5737
+ const call = asRecord2(rawCall);
5738
+ return {
5739
+ ...call,
5740
+ tool: stringValue2(call.tool),
5741
+ arguments: asRecord2(call.arguments),
5742
+ purpose: stringValue2(call.purpose)
5743
+ };
5744
+ }
5745
+ function normalizeOpsExecutionScheduleContract(rawSchedule) {
5746
+ const schedule = asRecord2(rawSchedule);
5747
+ const wakeOnEvents = Array.isArray(schedule.wake_on_events) ? schedule.wake_on_events.map(String) : Array.isArray(schedule.wakeOnEvents) ? schedule.wakeOnEvents.map(String) : [];
5748
+ return {
5749
+ ...schedule,
5750
+ create_tool: stringValue2(schedule.create_tool ?? schedule.createTool),
5751
+ createTool: stringValue2(schedule.createTool ?? schedule.create_tool),
5752
+ activate_tool: stringValue2(schedule.activate_tool ?? schedule.activateTool),
5753
+ activateTool: stringValue2(schedule.activateTool ?? schedule.activate_tool),
5754
+ cadence: stringValue2(schedule.cadence, "manual"),
5755
+ recurrence: stringValue2(schedule.recurrence),
5756
+ wake_on_events: wakeOnEvents,
5757
+ wakeOnEvents
5758
+ };
5759
+ }
5760
+ function normalizeOpsExecutionApprovalContract(rawApproval) {
5761
+ const approval = asRecord2(rawApproval);
5762
+ return {
5763
+ ...approval,
5764
+ required: Boolean(approval.required),
5765
+ tool: stringValue2(approval.tool),
5766
+ reason: stringValue2(approval.reason)
5767
+ };
5768
+ }
5769
+ function normalizeOpsExecutionMonitorContract(rawMonitor) {
5770
+ const monitor = asRecord2(rawMonitor);
5771
+ const pollAfterMs = numberValue(monitor.poll_after_ms ?? monitor.pollAfterMs);
5772
+ return {
5773
+ ...monitor,
5774
+ status_tool: stringValue2(monitor.status_tool ?? monitor.statusTool),
5775
+ statusTool: stringValue2(monitor.statusTool ?? monitor.status_tool),
5776
+ wait_tool: stringValue2(monitor.wait_tool ?? monitor.waitTool),
5777
+ waitTool: stringValue2(monitor.waitTool ?? monitor.wait_tool),
5778
+ results_tool: stringValue2(monitor.results_tool ?? monitor.resultsTool),
5779
+ resultsTool: stringValue2(monitor.resultsTool ?? monitor.results_tool),
5780
+ poll_after_ms: pollAfterMs,
5781
+ pollAfterMs
5782
+ };
5783
+ }
5784
+ function normalizeOpsExecutionResultContract(rawResult) {
5785
+ const result = asRecord2(rawResult);
5786
+ const shape = Array.isArray(result.shape) ? result.shape.map(String) : [];
5787
+ return {
5788
+ ...result,
5789
+ tool: stringValue2(result.tool),
5790
+ wait_tool: stringValue2(result.wait_tool ?? result.waitTool),
5791
+ waitTool: stringValue2(result.waitTool ?? result.wait_tool),
5792
+ shape,
5793
+ empty_result_recovery: stringValue2(result.empty_result_recovery ?? result.emptyResultRecovery),
5794
+ emptyResultRecovery: stringValue2(result.emptyResultRecovery ?? result.empty_result_recovery)
5795
+ };
5796
+ }
5797
+ function normalizeOpsExecutionNangoRouteContract(rawRoute) {
5798
+ if (!rawRoute || typeof rawRoute !== "object" || Array.isArray(rawRoute)) return void 0;
5799
+ const route = asRecord2(rawRoute);
5800
+ const requiredFields = Array.isArray(route.required_fields) ? route.required_fields.map(String) : Array.isArray(route.requiredFields) ? route.requiredFields.map(String) : [];
5801
+ return {
5802
+ ...route,
5803
+ enabled: route.enabled !== false,
5804
+ connect_tool: stringValue2(route.connect_tool ?? route.connectTool),
5805
+ connectTool: stringValue2(route.connectTool ?? route.connect_tool),
5806
+ discover_tool: stringValue2(route.discover_tool ?? route.discoverTool),
5807
+ discoverTool: stringValue2(route.discoverTool ?? route.discover_tool),
5808
+ dry_run_tool: stringValue2(route.dry_run_tool ?? route.dryRunTool),
5809
+ dryRunTool: stringValue2(route.dryRunTool ?? route.dry_run_tool),
5810
+ execute_tool: stringValue2(route.execute_tool ?? route.executeTool),
5811
+ executeTool: stringValue2(route.executeTool ?? route.execute_tool),
5812
+ execute_and_wait_tool: stringValue2(route.execute_and_wait_tool ?? route.executeAndWaitTool),
5813
+ executeAndWaitTool: stringValue2(route.executeAndWaitTool ?? route.execute_and_wait_tool),
5814
+ schedule_tool: stringValue2(route.schedule_tool ?? route.scheduleTool),
5815
+ scheduleTool: stringValue2(route.scheduleTool ?? route.schedule_tool),
5816
+ schedule_and_wait_tool: stringValue2(route.schedule_and_wait_tool ?? route.scheduleAndWaitTool),
5817
+ scheduleAndWaitTool: stringValue2(route.scheduleAndWaitTool ?? route.schedule_and_wait_tool),
5818
+ result_tool: stringValue2(route.result_tool ?? route.resultTool),
5819
+ resultTool: stringValue2(route.resultTool ?? route.result_tool),
5820
+ write_gate: stringValue2(route.write_gate ?? route.writeGate),
5821
+ writeGate: stringValue2(route.writeGate ?? route.write_gate),
5822
+ required_fields: requiredFields,
5823
+ requiredFields,
5824
+ schedule_arguments: asRecord2(route.schedule_arguments ?? route.scheduleArguments),
5825
+ scheduleArguments: asRecord2(route.scheduleArguments ?? route.schedule_arguments),
5826
+ schedule_and_wait_arguments: asRecord2(route.schedule_and_wait_arguments ?? route.scheduleAndWaitArguments),
5827
+ scheduleAndWaitArguments: asRecord2(route.scheduleAndWaitArguments ?? route.schedule_and_wait_arguments)
5828
+ };
5829
+ }
5830
+ function normalizeOpsExecutionContract(rawContract) {
5831
+ if (!rawContract || typeof rawContract !== "object" || Array.isArray(rawContract)) return void 0;
5832
+ const contract = asRecord2(rawContract);
5833
+ const nangoRoute = normalizeOpsExecutionNangoRouteContract(contract.nango_route ?? contract.nangoRoute);
5834
+ const sequence = Array.isArray(contract.sequence) ? contract.sequence.map(normalizeOpsExecutionToolCall) : [];
5835
+ return {
5836
+ ...contract,
5837
+ mode: stringValue2(contract.mode, "run_once"),
5838
+ run_now: normalizeOpsExecutionToolCall(contract.run_now ?? contract.runNow),
5839
+ runNow: normalizeOpsExecutionToolCall(contract.runNow ?? contract.run_now),
5840
+ schedule: normalizeOpsExecutionScheduleContract(contract.schedule),
5841
+ approval: normalizeOpsExecutionApprovalContract(contract.approval),
5842
+ monitor: normalizeOpsExecutionMonitorContract(contract.monitor),
5843
+ result_contract: normalizeOpsExecutionResultContract(contract.result_contract ?? contract.resultContract),
5844
+ resultContract: normalizeOpsExecutionResultContract(contract.resultContract ?? contract.result_contract),
5845
+ ...nangoRoute ? { nango_route: nangoRoute, nangoRoute } : {},
5846
+ sequence
5847
+ };
5848
+ }
4776
5849
  function normalizeOpsPlanResult(result) {
4777
5850
  const primitiveGraph = result.primitive_graph ?? result.primitiveGraph;
5851
+ const executionContract = normalizeOpsExecutionContract(result.execution_contract ?? result.executionContract);
4778
5852
  return {
4779
5853
  ...result,
4780
5854
  plan_id: result.plan_id ?? result.planId,
@@ -4798,7 +5872,8 @@ function normalizeOpsPlanResult(result) {
4798
5872
  destination_status: result.destination_status ?? result.destinationStatus,
4799
5873
  destinationStatus: result.destinationStatus ?? result.destination_status,
4800
5874
  primitive_graph: primitiveGraph?.map(normalizeOpsPrimitive),
4801
- primitiveGraph: primitiveGraph?.map(normalizeOpsPrimitive)
5875
+ primitiveGraph: primitiveGraph?.map(normalizeOpsPrimitive),
5876
+ ...executionContract ? { execution_contract: executionContract, executionContract } : {}
4802
5877
  };
4803
5878
  }
4804
5879
  function normalizeOpsCreateResult(result) {
@@ -4820,7 +5895,18 @@ function normalizeOpsCreateResult(result) {
4820
5895
  deliveryStatus: result.deliveryStatus ?? result.delivery_status,
4821
5896
  estimated_credits: result.estimated_credits ?? result.estimatedCredits,
4822
5897
  estimatedCredits: result.estimatedCredits ?? result.estimated_credits,
4823
- plan: result.plan ? normalizeOpsPlanResult(result.plan) : result.plan
5898
+ error_code: result.error_code ?? result.errorCode,
5899
+ errorCode: result.errorCode ?? result.error_code,
5900
+ approval_required: result.approval_required ?? result.approvalRequired,
5901
+ approvalRequired: result.approvalRequired ?? result.approval_required,
5902
+ retry_arguments: result.retry_arguments ?? result.retryArguments,
5903
+ retryArguments: result.retryArguments ?? result.retry_arguments,
5904
+ blockers: result.blockers,
5905
+ plan: result.plan ? normalizeOpsPlanResult(result.plan) : result.plan,
5906
+ next_step: result.next_step ?? result.nextStep,
5907
+ nextStep: result.nextStep ?? result.next_step,
5908
+ next_steps: result.next_steps ?? result.nextSteps,
5909
+ nextSteps: result.nextSteps ?? result.next_steps
4824
5910
  };
4825
5911
  }
4826
5912
  function normalizeOpsExecuteResult(result) {
@@ -4948,6 +6034,40 @@ function normalizeOpsStatusResult(result) {
4948
6034
  diagnosis: result.diagnosis ? normalizeOpsDebugDiagnosis(result.diagnosis) : void 0
4949
6035
  };
4950
6036
  }
6037
+ function normalizeOpsResultsSummary(value) {
6038
+ const summary = asRecord2(value);
6039
+ if (Object.keys(summary).length === 0) return void 0;
6040
+ const resultsTotal = summary.results_total ?? summary.resultsTotal;
6041
+ const nextCursor = summary.next_cursor ?? summary.nextCursor ?? null;
6042
+ const resultsUrl = summary.results_url ?? summary.resultsUrl;
6043
+ const nextAction = summary.next_action ?? summary.nextAction;
6044
+ const runId = summary.run_id ?? summary.runId ?? null;
6045
+ const creditsUsed = summary.credits_used ?? summary.creditsUsed;
6046
+ return {
6047
+ ...summary,
6048
+ label: optionalString(summary.label),
6049
+ status: optionalString(summary.status),
6050
+ phase: optionalString(summary.phase),
6051
+ results_count: numberValue(summary.results_count ?? summary.resultsCount),
6052
+ resultsCount: numberValue(summary.results_count ?? summary.resultsCount),
6053
+ results_total: resultsTotal === null || resultsTotal === void 0 ? resultsTotal : numberValue(resultsTotal),
6054
+ resultsTotal: resultsTotal === null || resultsTotal === void 0 ? resultsTotal : numberValue(resultsTotal),
6055
+ delivery_status: optionalString(summary.delivery_status ?? summary.deliveryStatus),
6056
+ deliveryStatus: optionalString(summary.delivery_status ?? summary.deliveryStatus),
6057
+ has_more: Boolean(summary.has_more ?? summary.hasMore),
6058
+ hasMore: Boolean(summary.has_more ?? summary.hasMore),
6059
+ next_cursor: nextCursor === null ? null : optionalString(nextCursor),
6060
+ nextCursor: nextCursor === null ? null : optionalString(nextCursor),
6061
+ results_url: optionalString(resultsUrl),
6062
+ resultsUrl: optionalString(resultsUrl),
6063
+ next_action: optionalString(nextAction),
6064
+ nextAction: optionalString(nextAction),
6065
+ run_id: runId === null ? null : optionalString(runId),
6066
+ runId: runId === null ? null : optionalString(runId),
6067
+ credits_used: creditsUsed === void 0 ? void 0 : numberValue(creditsUsed),
6068
+ creditsUsed: creditsUsed === void 0 ? void 0 : numberValue(creditsUsed)
6069
+ };
6070
+ }
4951
6071
  function normalizeOpsResultsResult(result) {
4952
6072
  const nextCursor = result.next_cursor ?? result.nextCursor ?? null;
4953
6073
  const hasMore = result.has_more ?? result.hasMore ?? false;
@@ -4972,7 +6092,104 @@ function normalizeOpsResultsResult(result) {
4972
6092
  results_url: result.results_url ?? result.resultsUrl,
4973
6093
  resultsUrl: result.resultsUrl ?? result.results_url,
4974
6094
  delivery_status: result.delivery_status ?? result.deliveryStatus,
4975
- deliveryStatus: result.deliveryStatus ?? result.delivery_status
6095
+ deliveryStatus: result.deliveryStatus ?? result.delivery_status,
6096
+ summary: normalizeOpsResultsSummary(result.summary)
6097
+ };
6098
+ }
6099
+ function normalizeOpsWaitForResultsPoll(value, fallbackPoll) {
6100
+ const raw = asRecord2(value);
6101
+ const checkedAt = stringValue2(raw.checked_at ?? raw.checkedAt);
6102
+ const resultsCount = raw.results_count ?? raw.resultsCount;
6103
+ const runId = raw.run_id ?? raw.runId ?? null;
6104
+ const nextAction = raw.next_action ?? raw.nextAction;
6105
+ return {
6106
+ ...raw,
6107
+ poll: numberValue(raw.poll) || fallbackPoll,
6108
+ checked_at: checkedAt,
6109
+ checkedAt,
6110
+ status: stringValue2(raw.status, "unknown"),
6111
+ phase: optionalString(raw.phase),
6112
+ results_count: resultsCount === void 0 ? void 0 : numberValue(resultsCount),
6113
+ resultsCount: resultsCount === void 0 ? void 0 : numberValue(resultsCount),
6114
+ run_id: runId === null ? null : optionalString(runId),
6115
+ runId: runId === null ? null : optionalString(runId),
6116
+ next_action: optionalString(nextAction),
6117
+ nextAction: optionalString(nextAction)
6118
+ };
6119
+ }
6120
+ function normalizeOpsWaitForResultsResult(result, options) {
6121
+ const opId = stringValue2(result.op_id ?? result.opId ?? options.op_id);
6122
+ const routineId = stringValue2(result.routine_id ?? result.routineId ?? opId);
6123
+ const runId = result.run_id ?? result.runId ?? null;
6124
+ const timedOut = Boolean(result.timed_out ?? result.timedOut);
6125
+ const statusRaw = asRecord2(result.status_result ?? result.statusResult);
6126
+ const resultsRaw = asRecord2(result.results_result ?? result.resultsResult);
6127
+ const historySource = Array.isArray(result.poll_history) ? result.poll_history : Array.isArray(result.history) ? result.history : [];
6128
+ const history = historySource.map((item, index) => normalizeOpsWaitForResultsPoll(item, index + 1));
6129
+ const status = normalizeOpsStatusResult(withExecutionRefs({
6130
+ success: result.success !== false,
6131
+ op_id: opId,
6132
+ routine_id: routineId,
6133
+ run_id: runId,
6134
+ status: stringValue2(result.status, "unknown"),
6135
+ phase: stringValue2(result.phase, "unknown"),
6136
+ next_action: stringValue2(result.next_action ?? result.nextAction),
6137
+ results_count: numberValue(result.results_count ?? result.resultsCount),
6138
+ results_url: optionalString(result.results_url ?? result.resultsUrl),
6139
+ delivery_status: optionalString(result.delivery_status ?? result.deliveryStatus),
6140
+ ...statusRaw
6141
+ }));
6142
+ const includeResults = options.include_results !== false && options.includeResults !== false;
6143
+ const hasResultsPacket = Object.keys(resultsRaw).length > 0 || Array.isArray(result.results);
6144
+ const results = includeResults && hasResultsPacket ? normalizeOpsResultsResult(withExecutionRefs({
6145
+ success: result.success !== false,
6146
+ op_id: opId,
6147
+ routine_id: routineId,
6148
+ run_id: runId,
6149
+ status: stringValue2(result.status, status.status),
6150
+ phase: stringValue2(result.phase, status.phase),
6151
+ results_count: numberValue(result.results_count ?? result.resultsCount),
6152
+ results_total: result.results_total ?? result.resultsTotal ?? null,
6153
+ results: Array.isArray(result.results) ? result.results : [],
6154
+ next_cursor: result.next_cursor ?? result.nextCursor ?? null,
6155
+ has_more: Boolean(result.has_more ?? result.hasMore),
6156
+ next_action: stringValue2(result.next_action ?? result.nextAction),
6157
+ results_url: optionalString(result.results_url ?? result.resultsUrl),
6158
+ delivery_status: optionalString(result.delivery_status ?? result.deliveryStatus),
6159
+ ...resultsRaw
6160
+ })) : void 0;
6161
+ const polls = numberValue(result.polls) || history.length;
6162
+ const maxPolls = result.max_polls ?? result.maxPolls;
6163
+ const intervalMs = result.interval_ms ?? result.intervalMs;
6164
+ const timeoutMs = result.timeout_ms ?? result.timeoutMs;
6165
+ const stopReason = result.stop_reason ?? result.stopReason;
6166
+ const nextAction = result.next_action ?? result.nextAction ?? results?.next_action ?? status.next_action;
6167
+ return {
6168
+ ...result,
6169
+ success: result.success !== false && !timedOut,
6170
+ op_id: opId,
6171
+ opId,
6172
+ routine_id: routineId,
6173
+ routineId,
6174
+ run_id: runId === null ? null : optionalString(runId),
6175
+ runId: runId === null ? null : optionalString(runId),
6176
+ status,
6177
+ results,
6178
+ timed_out: timedOut,
6179
+ timedOut,
6180
+ polls,
6181
+ max_polls: maxPolls === void 0 ? void 0 : numberValue(maxPolls),
6182
+ maxPolls: maxPolls === void 0 ? void 0 : numberValue(maxPolls),
6183
+ interval_ms: intervalMs === void 0 ? void 0 : numberValue(intervalMs),
6184
+ intervalMs: intervalMs === void 0 ? void 0 : numberValue(intervalMs),
6185
+ timeout_ms: timeoutMs === void 0 ? void 0 : numberValue(timeoutMs),
6186
+ timeoutMs: timeoutMs === void 0 ? void 0 : numberValue(timeoutMs),
6187
+ stop_reason: optionalString(stopReason),
6188
+ stopReason: optionalString(stopReason),
6189
+ history,
6190
+ next_action: optionalString(nextAction),
6191
+ nextAction: optionalString(nextAction),
6192
+ execution_refs: mergeExecutionRefsFrom([result, status, results, { history }])
4976
6193
  };
4977
6194
  }
4978
6195
  function normalizeOpsProofResult(data) {
@@ -5052,11 +6269,107 @@ function normalizeOpsProofResult(data) {
5052
6269
  raw: data
5053
6270
  };
5054
6271
  }
6272
+ function normalizeOpsAutopilotSchedulePacket(rawPacket) {
6273
+ const packet = asRecord2(rawPacket);
6274
+ return {
6275
+ ...packet,
6276
+ cadence: stringValue2(packet.cadence, "manual"),
6277
+ recurrence: stringValue2(packet.recurrence),
6278
+ activate_with: stringValue2(packet.activate_with ?? packet.activateWith),
6279
+ activateWith: stringValue2(packet.activate_with ?? packet.activateWith),
6280
+ run_now_with: stringValue2(packet.run_now_with ?? packet.runNowWith),
6281
+ runNowWith: stringValue2(packet.run_now_with ?? packet.runNowWith),
6282
+ monitor_with: stringValue2(packet.monitor_with ?? packet.monitorWith),
6283
+ monitorWith: stringValue2(packet.monitor_with ?? packet.monitorWith),
6284
+ retrieve_with: stringValue2(packet.retrieve_with ?? packet.retrieveWith),
6285
+ retrieveWith: stringValue2(packet.retrieve_with ?? packet.retrieveWith)
6286
+ };
6287
+ }
6288
+ function normalizeOpsAutopilotNangoRoutePacket(rawPacket) {
6289
+ if (!rawPacket || typeof rawPacket !== "object" || Array.isArray(rawPacket)) return void 0;
6290
+ const packet = asRecord2(rawPacket);
6291
+ const requiredFields = Array.isArray(packet.required_fields) ? packet.required_fields.map(String) : Array.isArray(packet.requiredFields) ? packet.requiredFields.map(String) : [];
6292
+ return {
6293
+ ...packet,
6294
+ enabled: packet.enabled !== false,
6295
+ route_label: stringValue2(packet.route_label ?? packet.routeLabel),
6296
+ routeLabel: stringValue2(packet.route_label ?? packet.routeLabel),
6297
+ connect_tool: stringValue2(packet.connect_tool ?? packet.connectTool),
6298
+ connectTool: stringValue2(packet.connect_tool ?? packet.connectTool),
6299
+ discover_tool: stringValue2(packet.discover_tool ?? packet.discoverTool),
6300
+ discoverTool: stringValue2(packet.discover_tool ?? packet.discoverTool),
6301
+ dry_run_tool: stringValue2(packet.dry_run_tool ?? packet.dryRunTool),
6302
+ dryRunTool: stringValue2(packet.dry_run_tool ?? packet.dryRunTool),
6303
+ execute_tool: stringValue2(packet.execute_tool ?? packet.executeTool),
6304
+ executeTool: stringValue2(packet.execute_tool ?? packet.executeTool),
6305
+ execute_and_wait_tool: stringValue2(packet.execute_and_wait_tool ?? packet.executeAndWaitTool),
6306
+ executeAndWaitTool: stringValue2(packet.execute_and_wait_tool ?? packet.executeAndWaitTool),
6307
+ schedule_tool: stringValue2(packet.schedule_tool ?? packet.scheduleTool),
6308
+ scheduleTool: stringValue2(packet.schedule_tool ?? packet.scheduleTool),
6309
+ schedule_and_wait_tool: stringValue2(packet.schedule_and_wait_tool ?? packet.scheduleAndWaitTool),
6310
+ scheduleAndWaitTool: stringValue2(packet.schedule_and_wait_tool ?? packet.scheduleAndWaitTool),
6311
+ result_tool: stringValue2(packet.result_tool ?? packet.resultTool),
6312
+ resultTool: stringValue2(packet.result_tool ?? packet.resultTool),
6313
+ write_gate: stringValue2(packet.write_gate ?? packet.writeGate),
6314
+ writeGate: stringValue2(packet.write_gate ?? packet.writeGate),
6315
+ required_fields: requiredFields,
6316
+ requiredFields,
6317
+ placeholders: asRecord2(packet.placeholders),
6318
+ dry_run_arguments: asRecord2(packet.dry_run_arguments ?? packet.dryRunArguments),
6319
+ dryRunArguments: asRecord2(packet.dry_run_arguments ?? packet.dryRunArguments),
6320
+ execute_arguments: asRecord2(packet.execute_arguments ?? packet.executeArguments),
6321
+ executeArguments: asRecord2(packet.execute_arguments ?? packet.executeArguments),
6322
+ execute_and_wait_arguments: asRecord2(packet.execute_and_wait_arguments ?? packet.executeAndWaitArguments),
6323
+ executeAndWaitArguments: asRecord2(packet.execute_and_wait_arguments ?? packet.executeAndWaitArguments),
6324
+ schedule_arguments: asRecord2(packet.schedule_arguments ?? packet.scheduleArguments),
6325
+ scheduleArguments: asRecord2(packet.schedule_arguments ?? packet.scheduleArguments),
6326
+ schedule_and_wait_arguments: asRecord2(packet.schedule_and_wait_arguments ?? packet.scheduleAndWaitArguments),
6327
+ scheduleAndWaitArguments: asRecord2(packet.schedule_and_wait_arguments ?? packet.scheduleAndWaitArguments),
6328
+ result_arguments: asRecord2(packet.result_arguments ?? packet.resultArguments),
6329
+ resultArguments: asRecord2(packet.result_arguments ?? packet.resultArguments)
6330
+ };
6331
+ }
6332
+ function normalizeOpsAutopilotResultPacket(rawPacket) {
6333
+ const packet = asRecord2(rawPacket);
6334
+ const resultShape = Array.isArray(packet.result_shape) ? packet.result_shape.map(String) : Array.isArray(packet.resultShape) ? packet.resultShape.map(String) : [];
6335
+ const deliveryReceipts = Array.isArray(packet.delivery_receipts) ? packet.delivery_receipts.map(String) : Array.isArray(packet.deliveryReceipts) ? packet.deliveryReceipts.map(String) : [];
6336
+ return {
6337
+ ...packet,
6338
+ retrieve_tool: stringValue2(packet.retrieve_tool ?? packet.retrieveTool),
6339
+ retrieveTool: stringValue2(packet.retrieve_tool ?? packet.retrieveTool),
6340
+ result_shape: resultShape,
6341
+ resultShape,
6342
+ delivery_receipts: deliveryReceipts,
6343
+ deliveryReceipts,
6344
+ empty_result_recovery: stringValue2(packet.empty_result_recovery ?? packet.emptyResultRecovery),
6345
+ emptyResultRecovery: stringValue2(packet.empty_result_recovery ?? packet.emptyResultRecovery)
6346
+ };
6347
+ }
6348
+ function normalizeOpsAutopilotOperatingPacket(rawPacket) {
6349
+ if (!rawPacket || typeof rawPacket !== "object" || Array.isArray(rawPacket)) return void 0;
6350
+ const packet = asRecord2(rawPacket);
6351
+ const nangoRoute = normalizeOpsAutopilotNangoRoutePacket(packet.nango_route ?? packet.nangoRoute);
6352
+ const approvalBoundaries = Array.isArray(packet.approval_boundaries) ? packet.approval_boundaries.map(String) : Array.isArray(packet.approvalBoundaries) ? packet.approvalBoundaries.map(String) : [];
6353
+ return {
6354
+ ...packet,
6355
+ north_star: stringValue2(packet.north_star ?? packet.northStar),
6356
+ northStar: stringValue2(packet.north_star ?? packet.northStar),
6357
+ schedule: normalizeOpsAutopilotSchedulePacket(packet.schedule),
6358
+ ...nangoRoute ? { nango_route: nangoRoute, nangoRoute } : {},
6359
+ result_contract: normalizeOpsAutopilotResultPacket(packet.result_contract ?? packet.resultContract),
6360
+ resultContract: normalizeOpsAutopilotResultPacket(packet.result_contract ?? packet.resultContract),
6361
+ approval_boundaries: approvalBoundaries,
6362
+ approvalBoundaries,
6363
+ saved_command_hint: stringValue2(packet.saved_command_hint ?? packet.savedCommandHint),
6364
+ savedCommandHint: stringValue2(packet.saved_command_hint ?? packet.savedCommandHint)
6365
+ };
6366
+ }
5055
6367
  function normalizeOpsAutopilotMotion(rawMotion) {
5056
6368
  const motion = asRecord2(rawMotion);
5057
6369
  const targetCount = numberValue(motion.target_count ?? motion.targetCount);
5058
6370
  const estimatedCredits = numberValue(motion.estimated_credits ?? motion.estimatedCredits);
5059
6371
  const mcpSequence = Array.isArray(motion.mcp_sequence) ? motion.mcp_sequence : Array.isArray(motion.mcpSequence) ? motion.mcpSequence : [];
6372
+ const operatingPacket = normalizeOpsAutopilotOperatingPacket(motion.operating_packet ?? motion.operatingPacket);
5060
6373
  return {
5061
6374
  ...motion,
5062
6375
  id: stringValue2(motion.id),
@@ -5079,12 +6392,16 @@ function normalizeOpsAutopilotMotion(rawMotion) {
5079
6392
  cli_command: optionalString(motion.cli_command ?? motion.cliCommand),
5080
6393
  cliCommand: optionalString(motion.cli_command ?? motion.cliCommand),
5081
6394
  mcp_sequence: mcpSequence,
5082
- mcpSequence
6395
+ mcpSequence,
6396
+ ...operatingPacket ? { operating_packet: operatingPacket, operatingPacket } : {}
5083
6397
  };
5084
6398
  }
5085
6399
  function normalizeOpsAutopilotResult(result) {
5086
6400
  const primary = normalizeOpsAutopilotMotion(result.primary_motion ?? result.primaryMotion);
5087
6401
  const motions = Array.isArray(result.motions) ? result.motions.map(normalizeOpsAutopilotMotion) : [];
6402
+ const operatingPacket = normalizeOpsAutopilotOperatingPacket(
6403
+ result.operating_packet ?? result.operatingPacket ?? primary.operating_packet ?? primary.operatingPacket
6404
+ );
5088
6405
  const queryErrors = Array.isArray(result.query_errors) ? result.query_errors.map(String) : Array.isArray(result.queryErrors) ? result.queryErrors.map(String) : [];
5089
6406
  return {
5090
6407
  ...result,
@@ -5100,6 +6417,7 @@ function normalizeOpsAutopilotResult(result) {
5100
6417
  scaleRule: optionalString(result.scale_rule ?? result.scaleRule),
5101
6418
  agent_handoff: optionalString(result.agent_handoff ?? result.agentHandoff),
5102
6419
  agentHandoff: optionalString(result.agent_handoff ?? result.agentHandoff),
6420
+ ...operatingPacket ? { operating_packet: operatingPacket, operatingPacket } : {},
5103
6421
  proof_state: optionalString(result.proof_state ?? result.proofState),
5104
6422
  proofState: optionalString(result.proof_state ?? result.proofState),
5105
6423
  proof_summary: result.proof_summary ?? result.proofSummary,
@@ -5364,11 +6682,125 @@ function normalizeOpsRoutineTickItemsResult(result) {
5364
6682
  hasMore
5365
6683
  };
5366
6684
  }
6685
+ function buildOpsNangoScheduleBody(input) {
6686
+ const {
6687
+ workspaceConnectionId,
6688
+ workspace_connection_id,
6689
+ connectionId,
6690
+ connection_id,
6691
+ providerConfigKey,
6692
+ provider_config_key,
6693
+ integrationId,
6694
+ integration_id,
6695
+ nangoConnectionId,
6696
+ nango_connection_id,
6697
+ actionName,
6698
+ action_name,
6699
+ toolName,
6700
+ tool_name,
6701
+ proxyPath,
6702
+ proxy_path,
6703
+ nangoProxyPath,
6704
+ nango_proxy_path,
6705
+ method,
6706
+ httpMethod,
6707
+ http_method,
6708
+ input: nangoInput,
6709
+ arguments: nangoArguments,
6710
+ fieldMap,
6711
+ field_map,
6712
+ requiredFields,
6713
+ required_fields,
6714
+ writeConfirmed,
6715
+ write_confirmed,
6716
+ agentWriteConfirmed,
6717
+ agent_write_confirmed,
6718
+ config,
6719
+ destinations: _destinations,
6720
+ ...schedule
6721
+ } = input;
6722
+ return {
6723
+ ...buildOpsCreateBody({
6724
+ ...schedule,
6725
+ cadence: schedule.cadence ?? "daily"
6726
+ }),
6727
+ workspace_connection_id: workspace_connection_id ?? workspaceConnectionId,
6728
+ connection_id: connection_id ?? connectionId,
6729
+ provider_config_key: provider_config_key ?? providerConfigKey,
6730
+ integration_id: integration_id ?? integrationId,
6731
+ nango_connection_id: nango_connection_id ?? nangoConnectionId,
6732
+ action_name: action_name ?? actionName,
6733
+ tool_name: tool_name ?? toolName,
6734
+ proxy_path: proxy_path ?? proxyPath ?? nango_proxy_path ?? nangoProxyPath,
6735
+ nango_proxy_path: nango_proxy_path ?? nangoProxyPath,
6736
+ method: method ?? http_method ?? httpMethod,
6737
+ input: nangoInput ?? nangoArguments,
6738
+ field_map: field_map ?? fieldMap,
6739
+ required_fields: required_fields ?? requiredFields,
6740
+ write_confirmed: write_confirmed ?? writeConfirmed,
6741
+ agent_write_confirmed: agent_write_confirmed ?? agentWriteConfirmed,
6742
+ config
6743
+ };
6744
+ }
6745
+ function buildOpsNangoScheduleAndWaitOptions(params) {
6746
+ const {
6747
+ force,
6748
+ instruction,
6749
+ nextCursor,
6750
+ includeFailedRuns,
6751
+ intervalMs,
6752
+ maxPolls,
6753
+ timeoutMs,
6754
+ includeResults,
6755
+ cursor,
6756
+ state,
6757
+ limit,
6758
+ include_failed_runs,
6759
+ interval_ms,
6760
+ max_polls,
6761
+ timeout_ms,
6762
+ include_results,
6763
+ ...schedule
6764
+ } = params;
6765
+ return {
6766
+ schedule: {
6767
+ ...schedule,
6768
+ cadence: schedule.cadence ?? "daily"
6769
+ },
6770
+ run: {
6771
+ force,
6772
+ instruction
6773
+ },
6774
+ wait: {
6775
+ cursor: cursor ?? nextCursor,
6776
+ state,
6777
+ limit,
6778
+ include_failed_runs: include_failed_runs ?? includeFailedRuns,
6779
+ interval_ms: interval_ms ?? intervalMs,
6780
+ max_polls: max_polls ?? maxPolls,
6781
+ timeout_ms: timeout_ms ?? timeoutMs,
6782
+ include_results: include_results ?? includeResults
6783
+ }
6784
+ };
6785
+ }
6786
+ function buildOpsNangoScheduleAndWaitBody(options) {
6787
+ const waitBody = buildOpsWaitBody(options.wait);
6788
+ const { op_id: _opId, ...waitWithoutOp } = waitBody;
6789
+ return {
6790
+ ...buildOpsNangoScheduleBody(options.schedule),
6791
+ ...waitWithoutOp,
6792
+ instruction: options.run.instruction,
6793
+ force: options.run.force
6794
+ };
6795
+ }
5367
6796
  function buildOpsPlanBody(params) {
5368
- const { targetCount, companyDomains, customAiPrompt, signalPrompt, outputPrompt, ...rest } = params;
6797
+ const { targetCount, wakeOnEvents, companyDomains, customAiPrompt, signalPrompt, outputPrompt, ...rest } = params;
6798
+ const destinations = Array.isArray(rest.destinations) ? rest.destinations.map(normalizeOpsDestinationRequest) : rest.destinations;
5369
6799
  return {
5370
6800
  ...rest,
6801
+ destinations,
5371
6802
  target_count: rest.target_count ?? targetCount,
6803
+ wake_on_events: rest.wake_on_events ?? wakeOnEvents,
5372
6804
  company_domains: rest.company_domains ?? companyDomains,
5373
6805
  custom_ai_prompt: rest.custom_ai_prompt ?? customAiPrompt,
5374
6806
  signal_prompt: rest.signal_prompt ?? signalPrompt,
@@ -5391,6 +6823,95 @@ function buildOpsExecuteBody(params) {
5391
6823
  output_format: rest.output_format ?? outputFormat
5392
6824
  };
5393
6825
  }
6826
+ function buildOpsExecuteAndWaitOptions(params) {
6827
+ const {
6828
+ nextCursor,
6829
+ includeFailedRuns,
6830
+ intervalMs,
6831
+ maxPolls,
6832
+ timeoutMs,
6833
+ includeResults,
6834
+ cursor,
6835
+ state,
6836
+ limit,
6837
+ include_failed_runs,
6838
+ interval_ms,
6839
+ max_polls,
6840
+ timeout_ms,
6841
+ include_results,
6842
+ ...execute
6843
+ } = params;
6844
+ return {
6845
+ execute: {
6846
+ ...execute,
6847
+ auto_run: execute.auto_run ?? execute.autoRun ?? true
6848
+ },
6849
+ wait: {
6850
+ cursor: cursor ?? nextCursor,
6851
+ state,
6852
+ limit,
6853
+ include_failed_runs: include_failed_runs ?? includeFailedRuns,
6854
+ interval_ms: interval_ms ?? intervalMs,
6855
+ max_polls: max_polls ?? maxPolls,
6856
+ timeout_ms: timeout_ms ?? timeoutMs,
6857
+ include_results: include_results ?? includeResults
6858
+ }
6859
+ };
6860
+ }
6861
+ function buildOpsScheduleAndWaitOptions(params) {
6862
+ const {
6863
+ force,
6864
+ instruction,
6865
+ nextCursor,
6866
+ includeFailedRuns,
6867
+ intervalMs,
6868
+ maxPolls,
6869
+ timeoutMs,
6870
+ includeResults,
6871
+ cursor,
6872
+ state,
6873
+ limit,
6874
+ include_failed_runs,
6875
+ interval_ms,
6876
+ max_polls,
6877
+ timeout_ms,
6878
+ include_results,
6879
+ ...schedule
6880
+ } = params;
6881
+ return {
6882
+ schedule: {
6883
+ ...schedule,
6884
+ cadence: schedule.cadence ?? "daily"
6885
+ },
6886
+ run: {
6887
+ force,
6888
+ instruction
6889
+ },
6890
+ wait: {
6891
+ cursor: cursor ?? nextCursor,
6892
+ state,
6893
+ limit,
6894
+ include_failed_runs: include_failed_runs ?? includeFailedRuns,
6895
+ interval_ms: interval_ms ?? intervalMs,
6896
+ max_polls: max_polls ?? maxPolls,
6897
+ timeout_ms: timeout_ms ?? timeoutMs,
6898
+ include_results: include_results ?? includeResults
6899
+ }
6900
+ };
6901
+ }
6902
+ function buildOpsScheduleAndWaitBody(options) {
6903
+ const waitBody = buildOpsWaitBody(options.wait);
6904
+ const { op_id: _opId, ...waitWithoutOp } = waitBody;
6905
+ return {
6906
+ ...buildOpsCreateBody({
6907
+ ...options.schedule,
6908
+ cadence: options.schedule.cadence ?? "daily"
6909
+ }),
6910
+ ...waitWithoutOp,
6911
+ instruction: options.run.instruction,
6912
+ force: options.run.force
6913
+ };
6914
+ }
5394
6915
  function buildOpsRunBody(params) {
5395
6916
  const { opId, ...rest } = params;
5396
6917
  return {
@@ -5398,6 +6919,28 @@ function buildOpsRunBody(params) {
5398
6919
  op_id: rest.op_id ?? opId
5399
6920
  };
5400
6921
  }
6922
+ function buildOpsRunAndWaitOptions(params) {
6923
+ const {
6924
+ opId,
6925
+ nextCursor,
6926
+ includeFailedRuns,
6927
+ intervalMs,
6928
+ maxPolls,
6929
+ timeoutMs,
6930
+ includeResults,
6931
+ ...rest
6932
+ } = params;
6933
+ return {
6934
+ ...rest,
6935
+ op_id: rest.op_id ?? opId,
6936
+ cursor: rest.cursor ?? nextCursor,
6937
+ include_failed_runs: rest.include_failed_runs ?? includeFailedRuns,
6938
+ interval_ms: rest.interval_ms ?? intervalMs,
6939
+ max_polls: rest.max_polls ?? maxPolls,
6940
+ timeout_ms: rest.timeout_ms ?? timeoutMs,
6941
+ include_results: rest.include_results ?? includeResults
6942
+ };
6943
+ }
5401
6944
  function buildOpsStatusBody(params) {
5402
6945
  const { opId, ...rest } = params;
5403
6946
  return {
@@ -5414,6 +6957,50 @@ function buildOpsResultsBody(params) {
5414
6957
  include_failed_runs: rest.include_failed_runs ?? includeFailedRuns
5415
6958
  };
5416
6959
  }
6960
+ function buildOpsWaitForResultsOptions(params) {
6961
+ const {
6962
+ opId,
6963
+ nextCursor,
6964
+ includeFailedRuns,
6965
+ intervalMs,
6966
+ maxPolls,
6967
+ timeoutMs,
6968
+ includeResults,
6969
+ ...rest
6970
+ } = params;
6971
+ return {
6972
+ ...rest,
6973
+ op_id: rest.op_id ?? opId,
6974
+ cursor: rest.cursor ?? nextCursor,
6975
+ include_failed_runs: rest.include_failed_runs ?? includeFailedRuns,
6976
+ interval_ms: rest.interval_ms ?? intervalMs,
6977
+ max_polls: rest.max_polls ?? maxPolls,
6978
+ timeout_ms: rest.timeout_ms ?? timeoutMs,
6979
+ include_results: rest.include_results ?? includeResults
6980
+ };
6981
+ }
6982
+ function buildOpsWaitBody(params) {
6983
+ const {
6984
+ opId,
6985
+ nextCursor,
6986
+ includeFailedRuns,
6987
+ intervalMs,
6988
+ maxPolls,
6989
+ timeoutMs,
6990
+ includeResults,
6991
+ ...rest
6992
+ } = params;
6993
+ return {
6994
+ ...rest,
6995
+ op_id: rest.op_id ?? opId,
6996
+ cursor: rest.cursor ?? nextCursor,
6997
+ include_failed_runs: rest.include_failed_runs ?? includeFailedRuns,
6998
+ interval_ms: rest.interval_ms ?? intervalMs,
6999
+ max_polls: rest.max_polls ?? maxPolls,
7000
+ timeout_ms: rest.timeout_ms ?? timeoutMs,
7001
+ include_results: rest.include_results ?? includeResults
7002
+ };
7003
+ }
5417
7004
  function buildOpsDebugOptions(params) {
5418
7005
  const {
5419
7006
  opId,
@@ -5491,6 +7078,8 @@ function normalizeOpsSinkRequest(sink) {
5491
7078
  nangoAction,
5492
7079
  proxyPath,
5493
7080
  nangoProxyPath,
7081
+ method,
7082
+ httpMethod,
5494
7083
  fieldMap,
5495
7084
  requiredFields,
5496
7085
  writeConfirmed,
@@ -5509,6 +7098,7 @@ function normalizeOpsSinkRequest(sink) {
5509
7098
  const nango_action = rest.nango_action ?? nangoAction;
5510
7099
  const proxy_path = rest.proxy_path ?? proxyPath;
5511
7100
  const nango_proxy_path = rest.nango_proxy_path ?? nangoProxyPath;
7101
+ const http_method = rest.http_method ?? httpMethod;
5512
7102
  const field_map = rest.field_map ?? fieldMap;
5513
7103
  const required_fields = rest.required_fields ?? requiredFields;
5514
7104
  const write_confirmed = rest.write_confirmed ?? writeConfirmed;
@@ -5523,6 +7113,9 @@ function normalizeOpsSinkRequest(sink) {
5523
7113
  if (nango_action !== void 0 && normalizedConfig.nango_action === void 0) normalizedConfig.nango_action = nango_action;
5524
7114
  if (proxy_path !== void 0 && normalizedConfig.proxy_path === void 0) normalizedConfig.proxy_path = proxy_path;
5525
7115
  if (nango_proxy_path !== void 0 && normalizedConfig.nango_proxy_path === void 0) normalizedConfig.nango_proxy_path = nango_proxy_path;
7116
+ if (method !== void 0 && normalizedConfig.method === void 0) normalizedConfig.method = method;
7117
+ if (http_method !== void 0 && normalizedConfig.http_method === void 0) normalizedConfig.http_method = http_method;
7118
+ if (normalizedConfig.method === void 0 && http_method !== void 0) normalizedConfig.method = http_method;
5526
7119
  if (field_map !== void 0 && normalizedConfig.field_map === void 0) normalizedConfig.field_map = field_map;
5527
7120
  if (required_fields !== void 0 && normalizedConfig.required_fields === void 0) normalizedConfig.required_fields = required_fields;
5528
7121
  if (write_confirmed !== void 0 && normalizedConfig.write_confirmed === void 0) normalizedConfig.write_confirmed = write_confirmed;
@@ -5542,6 +7135,8 @@ function normalizeOpsSinkRequest(sink) {
5542
7135
  nango_action,
5543
7136
  proxy_path,
5544
7137
  nango_proxy_path,
7138
+ method,
7139
+ http_method,
5545
7140
  field_map,
5546
7141
  required_fields,
5547
7142
  write_confirmed,
@@ -5549,6 +7144,10 @@ function normalizeOpsSinkRequest(sink) {
5549
7144
  config: normalizedConfig
5550
7145
  };
5551
7146
  }
7147
+ function normalizeOpsDestinationRequest(destination) {
7148
+ if (!destination || typeof destination !== "object" || Array.isArray(destination)) return destination;
7149
+ return normalizeOpsSinkRequest(destination);
7150
+ }
5552
7151
  function normalizeOpsSinkConfigRequest(config) {
5553
7152
  const out = { ...config ?? {} };
5554
7153
  if (out.connection_id === void 0 && out.connectionId !== void 0) out.connection_id = out.connectionId;
@@ -5562,6 +7161,8 @@ function normalizeOpsSinkConfigRequest(config) {
5562
7161
  if (out.nango_action === void 0 && out.nangoAction !== void 0) out.nango_action = out.nangoAction;
5563
7162
  if (out.proxy_path === void 0 && out.proxyPath !== void 0) out.proxy_path = out.proxyPath;
5564
7163
  if (out.nango_proxy_path === void 0 && out.nangoProxyPath !== void 0) out.nango_proxy_path = out.nangoProxyPath;
7164
+ if (out.http_method === void 0 && out.httpMethod !== void 0) out.http_method = out.httpMethod;
7165
+ if (out.method === void 0 && out.http_method !== void 0) out.method = out.http_method;
5565
7166
  if (out.field_map === void 0 && out.fieldMap !== void 0) out.field_map = out.fieldMap;
5566
7167
  if (out.required_fields === void 0 && out.requiredFields !== void 0) out.required_fields = out.requiredFields;
5567
7168
  if (out.write_confirmed === void 0 && out.writeConfirmed !== void 0) out.write_confirmed = out.writeConfirmed;
@@ -5635,7 +7236,6 @@ function toSnakeConfig(params) {
5635
7236
  return {
5636
7237
  system_prompt: params.systemPrompt || params.system_prompt || "You are a senior business research analyst. Use multi-model evidence carefully and return concise structured enrichment.",
5637
7238
  user_template: params.userTemplate || params.user_template || params.prompt,
5638
- model: params.model,
5639
7239
  temperature: params.temperature,
5640
7240
  max_concurrency: params.maxConcurrency || params.max_concurrency,
5641
7241
  max_tokens: params.maxTokens || params.max_tokens,
@@ -5659,13 +7259,10 @@ var Ai = class {
5659
7259
  /**
5660
7260
  * Run Custom AI Enrichment - Multi Model.
5661
7261
  *
5662
- * Uses OpenRouter Fusion for multi-model analysis with web search/fetch enabled
5663
- * inside Fusion, then synthesizes the requested structured output fields.
7262
+ * Uses the hosted default model with bounded synthesis, then returns the
7263
+ * requested structured output fields.
5664
7264
  */
5665
7265
  async multiModel(params) {
5666
- if (!params.model) {
5667
- throw new Error('model is required. Use an OpenRouter id such as "anthropic/claude-sonnet-4" or "google/gemini-2.5-flash".');
5668
- }
5669
7266
  if (!params.prompt && !params.userTemplate && !params.user_template) {
5670
7267
  throw new Error("prompt or userTemplate is required.");
5671
7268
  }
@@ -5882,6 +7479,10 @@ var GtmKernel = class {
5882
7479
  days: options.days,
5883
7480
  network_days: options.networkDays,
5884
7481
  min_sample_size: options.minSampleSize,
7482
+ holdout_min_sample_size: options.holdoutMinSampleSize,
7483
+ predictive_min_labeled_outcomes: options.predictiveMinLabeledOutcomes,
7484
+ predictive_min_positive_outcomes: options.predictiveMinPositiveOutcomes,
7485
+ predictive_min_memory_sample_size: options.predictiveMinMemorySampleSize,
5885
7486
  min_workspace_count: options.minWorkspaceCount,
5886
7487
  min_privacy_k: options.minPrivacyK,
5887
7488
  include_memory: options.includeMemory,
@@ -5948,9 +7549,11 @@ var GtmKernel = class {
5948
7549
  write_routine_outcomes: input.writeRoutineOutcomes
5949
7550
  });
5950
7551
  }
5951
- /** Start a background Instantly webhook-events pull and route results into the GTM feedback loop. */
7552
+ /** Start a background Instantly webhook-events or email-history pull and route results into the GTM feedback loop. */
5952
7553
  async pullInstantlyFeedback(input) {
5953
7554
  return this.callMcp("gtm_instantly_feedback_pull", {
7555
+ source: input.source,
7556
+ instantly_profile: input.instantlyProfile,
5954
7557
  campaign_id: input.campaignId,
5955
7558
  campaign_build_id: input.campaignBuildId,
5956
7559
  provider_link_id: input.providerLinkId,
@@ -5962,6 +7565,9 @@ var GtmKernel = class {
5962
7565
  to: input.to,
5963
7566
  limit: input.limit,
5964
7567
  max_pages: input.maxPages,
7568
+ email_type: input.emailType,
7569
+ mode: input.mode,
7570
+ sort_order: input.sortOrder,
5965
7571
  create_memory: input.createMemory,
5966
7572
  write_routine_outcomes: input.writeRoutineOutcomes,
5967
7573
  dry_run: input.dryRun,
@@ -6091,6 +7697,7 @@ var GtmKernel = class {
6091
7697
  days: input.days,
6092
7698
  network_days: input.networkDays,
6093
7699
  min_sample_size: input.minSampleSize,
7700
+ holdout_min_sample_size: input.holdoutMinSampleSize,
6094
7701
  min_workspace_count: input.minWorkspaceCount,
6095
7702
  min_privacy_k: input.minPrivacyK,
6096
7703
  include_memory: input.includeMemory,
@@ -6111,6 +7718,7 @@ var GtmKernel = class {
6111
7718
  days: input.days,
6112
7719
  network_days: input.networkDays,
6113
7720
  min_sample_size: input.minSampleSize,
7721
+ holdout_min_sample_size: input.holdoutMinSampleSize,
6114
7722
  min_workspace_count: input.minWorkspaceCount,
6115
7723
  min_privacy_k: input.minPrivacyK,
6116
7724
  include_memory: input.includeMemory,
@@ -6235,6 +7843,29 @@ var GtmKernel = class {
6235
7843
  include_details: options.includeDetails
6236
7844
  });
6237
7845
  }
7846
+ /** Search the Agency Autopilot safe-action catalog for agency-style lead lists, Clay tables, and GTM motions. */
7847
+ async agencyAutopilotCapabilityCatalog(options = {}) {
7848
+ return this.callMcp("gtm_agency_autopilot_capability_catalog", {
7849
+ query: options.query,
7850
+ family: options.family,
7851
+ phase: options.phase,
7852
+ account_label: options.accountLabel,
7853
+ workspace_label: options.workspaceLabel,
7854
+ target_count: options.targetCount,
7855
+ limit: options.limit,
7856
+ include_agent_prompts: options.includeAgentPrompts
7857
+ });
7858
+ }
7859
+ /** Search agency operating playbooks Agency Autopilot can use for lead lists, Clay tables, GTM motions, and proof gates. */
7860
+ async agencyAutopilotPlaybookCatalog(options = {}) {
7861
+ return this.callMcp("gtm_agency_autopilot_playbook_catalog", {
7862
+ query: options.query,
7863
+ playbook_slug: options.playbookSlug,
7864
+ outcome_type: options.outcomeType,
7865
+ limit: options.limit,
7866
+ include_required_fields: options.includeRequiredFields
7867
+ });
7868
+ }
6238
7869
  /** Build the read-only Memory, Brain, risk, and provider-route runbook needed before planning a campaign. */
6239
7870
  async campaignStartContext(input = {}) {
6240
7871
  return this.callMcp("gtm_campaign_start_context", {
@@ -6593,6 +8224,35 @@ var GtmKernel = class {
6593
8224
  user_display_name: input.userDisplayName
6594
8225
  });
6595
8226
  }
8227
+ /** Prepare the full Nango provider search, connect, pull/export, Ops, and campaign-route flow. */
8228
+ async prepareNangoIntegrationFlow(input = {}) {
8229
+ return this.callMcp("nango_integration_flow_prepare", {
8230
+ query: input.query,
8231
+ search: input.search,
8232
+ provider_id: input.providerId,
8233
+ provider: input.provider,
8234
+ integration_id: input.integrationId,
8235
+ provider_config_key: input.providerConfigKey,
8236
+ workspace_connection_id: input.workspaceConnectionId,
8237
+ connection_id: input.connectionId,
8238
+ nango_connection_id: input.nangoConnectionId,
8239
+ intent: input.intent,
8240
+ action_name: input.actionName,
8241
+ tool_name: input.toolName,
8242
+ proxy_path: input.proxyPath,
8243
+ method: input.method,
8244
+ input: input.input,
8245
+ cadence: input.cadence,
8246
+ field_map: input.fieldMap,
8247
+ required_fields: input.requiredFields,
8248
+ confirm_spend: input.confirmSpend,
8249
+ write_confirmed: input.writeConfirmed,
8250
+ layer: input.layer,
8251
+ campaign_id: input.campaignId,
8252
+ limit: input.limit,
8253
+ include_provider_catalog: input.includeProviderCatalog
8254
+ });
8255
+ }
6596
8256
  /** List Nango-backed action tools for a workspace connection without executing them. */
6597
8257
  async listNangoTools(options = {}) {
6598
8258
  return this.callMcp("nango_mcp_tools_list", {
@@ -6615,6 +8275,12 @@ var GtmKernel = class {
6615
8275
  nango_connection_id: input.nangoConnectionId,
6616
8276
  action_name: input.actionName,
6617
8277
  tool_name: input.toolName,
8278
+ delivery_mode: input.deliveryMode,
8279
+ proxy_path: input.proxyPath,
8280
+ nango_proxy_path: input.nangoProxyPath,
8281
+ method: input.method,
8282
+ http_method: input.httpMethod,
8283
+ proxy_headers: input.proxyHeaders,
6618
8284
  input: input.input,
6619
8285
  async: input.async,
6620
8286
  max_retries: input.maxRetries,
@@ -6764,6 +8430,7 @@ function compact2(value) {
6764
8430
  }
6765
8431
 
6766
8432
  // src/index.ts
8433
+ var MCP_TOOL_CACHE_TTL_MS = 3e4;
6767
8434
  function inferMcpToolCategory(toolName) {
6768
8435
  if (typeof toolName !== "string" || !toolName) return void 0;
6769
8436
  if (toolName.startsWith("ops_") || toolName === "get_ops_readiness" || toolName === "get_gtm_ops_readiness" || toolName.startsWith("gtm_") || [
@@ -6895,6 +8562,21 @@ var Signaliz = class {
6895
8562
  }
6896
8563
  /** List all available MCP tools */
6897
8564
  async listTools() {
8565
+ const now = Date.now();
8566
+ if (this.toolListCache && this.toolListCache.expiresAt > now) {
8567
+ return this.toolListCache.promise;
8568
+ }
8569
+ const promise = this.fetchTools().catch((error) => {
8570
+ if (this.toolListCache?.promise === promise) this.toolListCache = void 0;
8571
+ throw error;
8572
+ });
8573
+ this.toolListCache = {
8574
+ expiresAt: now + MCP_TOOL_CACHE_TTL_MS,
8575
+ promise
8576
+ };
8577
+ return promise;
8578
+ }
8579
+ async fetchTools() {
6898
8580
  try {
6899
8581
  const manifest = await this.client.mcp("tools/call", {
6900
8582
  name: "get_tool_manifest",
@@ -6954,6 +8636,7 @@ export {
6954
8636
  applyCampaignBuilderStrategyTemplate,
6955
8637
  createCampaignBuilderAgentRequestTemplate,
6956
8638
  createCampaignBuilderBuildKit,
8639
+ createCampaignBuilderMemoryKit,
6957
8640
  createCampaignBuilderToolRoute,
6958
8641
  Icps,
6959
8642
  normalizeExecutionReference,