@signaliz/sdk 1.0.7 → 1.0.9

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.
@@ -1815,6 +1815,79 @@ var CampaignBuilderAgent = class {
1815
1815
  const data = await this.callMcp("build_campaign", args);
1816
1816
  return mapBuildResult(data, false);
1817
1817
  }
1818
+ async runApprovedPlan(plan, approval, options = {}) {
1819
+ const build = await this.buildApprovedPlan(plan, approval, options);
1820
+ const campaignBuildId = build.campaignBuildId;
1821
+ if (!campaignBuildId) {
1822
+ if (options.wait || options.approveDelivery) {
1823
+ throw new Error("Campaign builder approved run did not return a campaignBuildId to poll");
1824
+ }
1825
+ return { build };
1826
+ }
1827
+ const shouldWait = options.wait === true || options.approveDelivery === true;
1828
+ if (!shouldWait) return { build };
1829
+ let finalStatus = await this.waitForCampaignBuildStatus(
1830
+ campaignBuildId,
1831
+ options,
1832
+ ["completed", "failed", "canceled", "pending_approval"]
1833
+ );
1834
+ const result = { build, finalStatus };
1835
+ if (options.approveDelivery === true) {
1836
+ if (finalStatus.status !== "pending_approval") {
1837
+ throw new Error(`Campaign build ${campaignBuildId} reached ${finalStatus.status}; delivery approval was not available`);
1838
+ }
1839
+ const destinationType = options.deliveryDestinationType ?? plan.buildRequest.delivery?.destinationType ?? "json";
1840
+ result.deliveryApproval = await this.approveCampaignDelivery(campaignBuildId, destinationType, {
1841
+ destinationId: options.deliveryDestinationId,
1842
+ destinationConfig: options.deliveryDestinationConfig ?? plan.buildRequest.delivery?.destinationConfig
1843
+ });
1844
+ finalStatus = await this.waitForCampaignBuildStatus(
1845
+ campaignBuildId,
1846
+ options,
1847
+ ["completed", "failed", "canceled"]
1848
+ );
1849
+ result.finalStatus = finalStatus;
1850
+ }
1851
+ return result;
1852
+ }
1853
+ async getCampaignBuildStatus(campaignBuildId) {
1854
+ const data = await this.callMcp("get_campaign_build_status", {
1855
+ campaign_build_id: campaignBuildId
1856
+ });
1857
+ return mapAgentCampaignBuildStatus(data);
1858
+ }
1859
+ async waitForCampaignBuildStatus(campaignBuildId, options, stopStatuses) {
1860
+ const interval = options.waitIntervalMs ?? 5e3;
1861
+ const timeout = options.waitTimeoutMs ?? 6e5;
1862
+ const startedAt = Date.now();
1863
+ while (true) {
1864
+ const status = await this.getCampaignBuildStatus(campaignBuildId);
1865
+ options.onStatus?.(status);
1866
+ if (stopStatuses.includes(status.status)) return status;
1867
+ if (Date.now() - startedAt > timeout) {
1868
+ throw new Error(`Campaign build ${campaignBuildId} timed out after ${timeout}ms (status: ${status.status})`);
1869
+ }
1870
+ await new Promise((resolve) => setTimeout(resolve, interval));
1871
+ }
1872
+ }
1873
+ async approveCampaignDelivery(campaignBuildId, destinationType, options) {
1874
+ const args = compact({
1875
+ campaign_build_id: campaignBuildId,
1876
+ destination_type: destinationType,
1877
+ destination_id: options?.destinationId,
1878
+ destination_config: options?.destinationConfig
1879
+ });
1880
+ const data = await this.callMcp("approve_campaign_delivery", args);
1881
+ return {
1882
+ campaignBuildId: data.campaign_build_id,
1883
+ destinationType: data.destination_type ?? destinationType,
1884
+ status: data.status ?? "approved",
1885
+ message: data.message ?? "",
1886
+ deliveryId: data.delivery_id,
1887
+ deliveryIds: data.delivery_ids,
1888
+ approvedCount: data.approved_count
1889
+ };
1890
+ }
1818
1891
  async getWorkspaceContext(warnings) {
1819
1892
  try {
1820
1893
  const workspace = await this.callMcp("get_workspace", {});
@@ -2760,6 +2833,17 @@ function createMcpFlow(request, buildRequest, routes, memory, approvals) {
2760
2833
  readOnly: false,
2761
2834
  approvalRequired: approvals.some((approval) => approval.blocking)
2762
2835
  });
2836
+ const deliveryApprovalArgs = buildDeliveryApprovalArgs(buildRequest);
2837
+ if (deliveryApprovalArgs) {
2838
+ steps.push({
2839
+ id: "delivery-approval",
2840
+ phase: "delivery",
2841
+ tool: "approve_campaign_delivery",
2842
+ arguments: deliveryApprovalArgs,
2843
+ readOnly: false,
2844
+ approvalRequired: true
2845
+ });
2846
+ }
2763
2847
  return steps.map((step) => ({ ...step, arguments: compact(step.arguments) }));
2764
2848
  }
2765
2849
  function shouldPrepareProviderRoute(route) {
@@ -3102,6 +3186,14 @@ function buildExecutionPrepareArgs(request, dryRun, confirmSpend) {
3102
3186
  enhancers: buildArgs2.enhancers
3103
3187
  });
3104
3188
  }
3189
+ function buildDeliveryApprovalArgs(request) {
3190
+ if (request.delivery?.enabled === false || request.delivery?.approvalRequired === false) return void 0;
3191
+ return compact({
3192
+ campaign_build_id: "<campaign_build_id_from_approved_build>",
3193
+ destination_type: request.delivery?.destinationType ?? "json",
3194
+ destination_config: request.delivery?.destinationConfig
3195
+ });
3196
+ }
3105
3197
  function mapBuildResult(data, dryRun) {
3106
3198
  return {
3107
3199
  campaignBuildId: data.campaign_build_id ?? null,
@@ -3123,6 +3215,55 @@ function mapBuildResult(data, dryRun) {
3123
3215
  providerRoute: mapProviderRoute2(data)
3124
3216
  };
3125
3217
  }
3218
+ function mapAgentCampaignBuildStatus(data) {
3219
+ return {
3220
+ campaignBuildId: stringValue(data.campaign_build_id) ?? "",
3221
+ campaignId: stringValue(data.campaign_id) ?? null,
3222
+ campaignObject: nullableRecord(data.campaign_object),
3223
+ name: stringValue(data.name) ?? "",
3224
+ status: stringValue(data.status) ?? "unknown",
3225
+ currentPhase: stringValue(data.current_phase) ?? null,
3226
+ currentPhaseStatus: stringValue(data.current_phase_status) ?? null,
3227
+ phases: Array.isArray(data.phases) ? data.phases : [],
3228
+ recordsTotal: numberOrUndefined2(data.records_total) ?? 0,
3229
+ recordsProcessed: numberOrUndefined2(data.records_processed) ?? 0,
3230
+ recordsSucceeded: numberOrUndefined2(data.records_succeeded) ?? 0,
3231
+ recordsFailed: numberOrUndefined2(data.records_failed) ?? 0,
3232
+ warnings: diagnosticMessages2(data.warnings),
3233
+ errors: diagnosticMessages2(data.errors),
3234
+ artifactCount: numberOrUndefined2(data.artifact_count) ?? 0,
3235
+ providerRoute: mapProviderRoute2(data),
3236
+ triggerRunId: stringValue(data.trigger_run_id) ?? null,
3237
+ staleRunningPhase: data.stale_running_phase === true,
3238
+ phaseAgeSeconds: numberOrNull2(data.phase_age_seconds),
3239
+ diagnostics: nullableRecord(data.diagnostics) ?? {},
3240
+ nextAction: formatAgentNextAction(data.next_action),
3241
+ createdAt: stringValue(data.created_at) ?? "",
3242
+ updatedAt: stringValue(data.updated_at) ?? "",
3243
+ completedAt: stringValue(data.completed_at) ?? null
3244
+ };
3245
+ }
3246
+ function diagnosticMessages2(value) {
3247
+ if (!Array.isArray(value)) return [];
3248
+ return value.map((item) => {
3249
+ if (typeof item === "string") return item;
3250
+ const record = nullableRecord(item);
3251
+ return stringValue(record?.message);
3252
+ }).filter((item) => typeof item === "string" && item.length > 0);
3253
+ }
3254
+ function formatAgentNextAction(value) {
3255
+ if (!value) return "";
3256
+ if (typeof value === "string") return value;
3257
+ const record = nullableRecord(value);
3258
+ if (!record) return "";
3259
+ const tool = stringValue(record.tool);
3260
+ const type = stringValue(record.type);
3261
+ const reason = stringValue(record.reason);
3262
+ const args = nullableRecord(record.arguments);
3263
+ const argText = args && Object.keys(args).length > 0 ? ` ${JSON.stringify(args)}` : "";
3264
+ const action = tool ? `${tool}${argText}` : type ?? "";
3265
+ return [action, reason].filter(Boolean).join(" - ");
3266
+ }
3126
3267
  function mapProviderRoute2(data) {
3127
3268
  const brainContext = asRecord(data?.brain_context);
3128
3269
  const plan = nullableRecord(data?.provider_route_plan) ?? nullableRecord(brainContext.provider_route_plan);
package/dist/cli.js CHANGED
@@ -1821,6 +1821,79 @@ var CampaignBuilderAgent = class {
1821
1821
  const data = await this.callMcp("build_campaign", args);
1822
1822
  return mapBuildResult(data, false);
1823
1823
  }
1824
+ async runApprovedPlan(plan, approval, options = {}) {
1825
+ const build = await this.buildApprovedPlan(plan, approval, options);
1826
+ const campaignBuildId = build.campaignBuildId;
1827
+ if (!campaignBuildId) {
1828
+ if (options.wait || options.approveDelivery) {
1829
+ throw new Error("Campaign builder approved run did not return a campaignBuildId to poll");
1830
+ }
1831
+ return { build };
1832
+ }
1833
+ const shouldWait = options.wait === true || options.approveDelivery === true;
1834
+ if (!shouldWait) return { build };
1835
+ let finalStatus = await this.waitForCampaignBuildStatus(
1836
+ campaignBuildId,
1837
+ options,
1838
+ ["completed", "failed", "canceled", "pending_approval"]
1839
+ );
1840
+ const result = { build, finalStatus };
1841
+ if (options.approveDelivery === true) {
1842
+ if (finalStatus.status !== "pending_approval") {
1843
+ throw new Error(`Campaign build ${campaignBuildId} reached ${finalStatus.status}; delivery approval was not available`);
1844
+ }
1845
+ const destinationType = options.deliveryDestinationType ?? plan.buildRequest.delivery?.destinationType ?? "json";
1846
+ result.deliveryApproval = await this.approveCampaignDelivery(campaignBuildId, destinationType, {
1847
+ destinationId: options.deliveryDestinationId,
1848
+ destinationConfig: options.deliveryDestinationConfig ?? plan.buildRequest.delivery?.destinationConfig
1849
+ });
1850
+ finalStatus = await this.waitForCampaignBuildStatus(
1851
+ campaignBuildId,
1852
+ options,
1853
+ ["completed", "failed", "canceled"]
1854
+ );
1855
+ result.finalStatus = finalStatus;
1856
+ }
1857
+ return result;
1858
+ }
1859
+ async getCampaignBuildStatus(campaignBuildId) {
1860
+ const data = await this.callMcp("get_campaign_build_status", {
1861
+ campaign_build_id: campaignBuildId
1862
+ });
1863
+ return mapAgentCampaignBuildStatus(data);
1864
+ }
1865
+ async waitForCampaignBuildStatus(campaignBuildId, options, stopStatuses) {
1866
+ const interval = options.waitIntervalMs ?? 5e3;
1867
+ const timeout = options.waitTimeoutMs ?? 6e5;
1868
+ const startedAt = Date.now();
1869
+ while (true) {
1870
+ const status = await this.getCampaignBuildStatus(campaignBuildId);
1871
+ options.onStatus?.(status);
1872
+ if (stopStatuses.includes(status.status)) return status;
1873
+ if (Date.now() - startedAt > timeout) {
1874
+ throw new Error(`Campaign build ${campaignBuildId} timed out after ${timeout}ms (status: ${status.status})`);
1875
+ }
1876
+ await new Promise((resolve) => setTimeout(resolve, interval));
1877
+ }
1878
+ }
1879
+ async approveCampaignDelivery(campaignBuildId, destinationType, options) {
1880
+ const args = compact({
1881
+ campaign_build_id: campaignBuildId,
1882
+ destination_type: destinationType,
1883
+ destination_id: options?.destinationId,
1884
+ destination_config: options?.destinationConfig
1885
+ });
1886
+ const data = await this.callMcp("approve_campaign_delivery", args);
1887
+ return {
1888
+ campaignBuildId: data.campaign_build_id,
1889
+ destinationType: data.destination_type ?? destinationType,
1890
+ status: data.status ?? "approved",
1891
+ message: data.message ?? "",
1892
+ deliveryId: data.delivery_id,
1893
+ deliveryIds: data.delivery_ids,
1894
+ approvedCount: data.approved_count
1895
+ };
1896
+ }
1824
1897
  async getWorkspaceContext(warnings) {
1825
1898
  try {
1826
1899
  const workspace = await this.callMcp("get_workspace", {});
@@ -2766,6 +2839,17 @@ function createMcpFlow(request, buildRequest, routes, memory, approvals) {
2766
2839
  readOnly: false,
2767
2840
  approvalRequired: approvals.some((approval) => approval.blocking)
2768
2841
  });
2842
+ const deliveryApprovalArgs = buildDeliveryApprovalArgs(buildRequest);
2843
+ if (deliveryApprovalArgs) {
2844
+ steps.push({
2845
+ id: "delivery-approval",
2846
+ phase: "delivery",
2847
+ tool: "approve_campaign_delivery",
2848
+ arguments: deliveryApprovalArgs,
2849
+ readOnly: false,
2850
+ approvalRequired: true
2851
+ });
2852
+ }
2769
2853
  return steps.map((step) => ({ ...step, arguments: compact(step.arguments) }));
2770
2854
  }
2771
2855
  function shouldPrepareProviderRoute(route) {
@@ -3108,6 +3192,14 @@ function buildExecutionPrepareArgs(request, dryRun, confirmSpend) {
3108
3192
  enhancers: buildArgs2.enhancers
3109
3193
  });
3110
3194
  }
3195
+ function buildDeliveryApprovalArgs(request) {
3196
+ if (request.delivery?.enabled === false || request.delivery?.approvalRequired === false) return void 0;
3197
+ return compact({
3198
+ campaign_build_id: "<campaign_build_id_from_approved_build>",
3199
+ destination_type: request.delivery?.destinationType ?? "json",
3200
+ destination_config: request.delivery?.destinationConfig
3201
+ });
3202
+ }
3111
3203
  function mapBuildResult(data, dryRun) {
3112
3204
  return {
3113
3205
  campaignBuildId: data.campaign_build_id ?? null,
@@ -3129,6 +3221,55 @@ function mapBuildResult(data, dryRun) {
3129
3221
  providerRoute: mapProviderRoute2(data)
3130
3222
  };
3131
3223
  }
3224
+ function mapAgentCampaignBuildStatus(data) {
3225
+ return {
3226
+ campaignBuildId: stringValue(data.campaign_build_id) ?? "",
3227
+ campaignId: stringValue(data.campaign_id) ?? null,
3228
+ campaignObject: nullableRecord(data.campaign_object),
3229
+ name: stringValue(data.name) ?? "",
3230
+ status: stringValue(data.status) ?? "unknown",
3231
+ currentPhase: stringValue(data.current_phase) ?? null,
3232
+ currentPhaseStatus: stringValue(data.current_phase_status) ?? null,
3233
+ phases: Array.isArray(data.phases) ? data.phases : [],
3234
+ recordsTotal: numberOrUndefined2(data.records_total) ?? 0,
3235
+ recordsProcessed: numberOrUndefined2(data.records_processed) ?? 0,
3236
+ recordsSucceeded: numberOrUndefined2(data.records_succeeded) ?? 0,
3237
+ recordsFailed: numberOrUndefined2(data.records_failed) ?? 0,
3238
+ warnings: diagnosticMessages2(data.warnings),
3239
+ errors: diagnosticMessages2(data.errors),
3240
+ artifactCount: numberOrUndefined2(data.artifact_count) ?? 0,
3241
+ providerRoute: mapProviderRoute2(data),
3242
+ triggerRunId: stringValue(data.trigger_run_id) ?? null,
3243
+ staleRunningPhase: data.stale_running_phase === true,
3244
+ phaseAgeSeconds: numberOrNull2(data.phase_age_seconds),
3245
+ diagnostics: nullableRecord(data.diagnostics) ?? {},
3246
+ nextAction: formatAgentNextAction(data.next_action),
3247
+ createdAt: stringValue(data.created_at) ?? "",
3248
+ updatedAt: stringValue(data.updated_at) ?? "",
3249
+ completedAt: stringValue(data.completed_at) ?? null
3250
+ };
3251
+ }
3252
+ function diagnosticMessages2(value) {
3253
+ if (!Array.isArray(value)) return [];
3254
+ return value.map((item) => {
3255
+ if (typeof item === "string") return item;
3256
+ const record = nullableRecord(item);
3257
+ return stringValue(record?.message);
3258
+ }).filter((item) => typeof item === "string" && item.length > 0);
3259
+ }
3260
+ function formatAgentNextAction(value) {
3261
+ if (!value) return "";
3262
+ if (typeof value === "string") return value;
3263
+ const record = nullableRecord(value);
3264
+ if (!record) return "";
3265
+ const tool = stringValue(record.tool);
3266
+ const type = stringValue(record.type);
3267
+ const reason = stringValue(record.reason);
3268
+ const args = nullableRecord(record.arguments);
3269
+ const argText = args && Object.keys(args).length > 0 ? ` ${JSON.stringify(args)}` : "";
3270
+ const action = tool ? `${tool}${argText}` : type ?? "";
3271
+ return [action, reason].filter(Boolean).join(" - ");
3272
+ }
3132
3273
  function mapProviderRoute2(data) {
3133
3274
  const brainContext = asRecord(data?.brain_context);
3134
3275
  const plan = nullableRecord(data?.provider_route_plan) ?? nullableRecord(brainContext.provider_route_plan);
@@ -6553,7 +6694,21 @@ async function handleCampaignAgentCommand(signaliz, argv) {
6553
6694
  approvedRouteIds: approvedRouteIdsFromFlags(plan, flags),
6554
6695
  notes: stringFlag(flags, "approval-notes", "notes")
6555
6696
  });
6556
- const result = await signaliz.campaignBuilderAgent.buildApprovedPlan(plan, approval, {
6697
+ const runApproved = booleanFlag(flags, "wait") || booleanFlag(flags, "approve-delivery");
6698
+ const result = runApproved ? await signaliz.campaignBuilderAgent.runApprovedPlan(plan, approval, {
6699
+ idempotencyKey: stringFlag(flags, "idempotency-key"),
6700
+ commitBeforeLaunch: booleanFlag(flags, "commit-before-launch"),
6701
+ wait: booleanFlag(flags, "wait"),
6702
+ approveDelivery: booleanFlag(flags, "approve-delivery"),
6703
+ deliveryDestinationType: stringFlag(flags, "delivery-destination-type", "destination-type"),
6704
+ deliveryDestinationId: stringFlag(flags, "delivery-destination-id", "destination-id"),
6705
+ deliveryDestinationConfig: jsonObjectFlag(flags, "delivery-config", "destination-config"),
6706
+ waitIntervalMs: numberFlag(flags, "wait-interval-ms"),
6707
+ waitTimeoutMs: numberFlag(flags, "wait-timeout-ms"),
6708
+ onStatus: booleanFlag(flags, "json") ? void 0 : (status) => {
6709
+ console.error(`campaign-agent build-approved: ${status.status} phase=${status.currentPhase ?? "N/A"} rows=${status.recordsSucceeded}/${status.recordsTotal} artifacts=${status.artifactCount}`);
6710
+ }
6711
+ }) : await signaliz.campaignBuilderAgent.buildApprovedPlan(plan, approval, {
6557
6712
  idempotencyKey: stringFlag(flags, "idempotency-key"),
6558
6713
  commitBeforeLaunch: booleanFlag(flags, "commit-before-launch")
6559
6714
  });
@@ -6966,7 +7121,8 @@ function createCampaignAgentProofReceipt(plan, result) {
6966
7121
  recommended_next_actions: [
6967
7122
  "Review the plan, approvals, and dry-run result.",
6968
7123
  "Use campaign-agent commit-plan --confirm-write only after review.",
6969
- "Use campaign-agent build-approved only with --confirm-launch, approval identity, approval types, and spend limit."
7124
+ "Use campaign-agent build-approved only with --confirm-launch, approval identity, approval types, and spend limit.",
7125
+ "When an approved build reaches pending_approval, review rows and approve delivery through the Campaigns SDK."
6970
7126
  ]
6971
7127
  };
6972
7128
  }
@@ -7076,6 +7232,7 @@ Usage:
7076
7232
  signaliz campaign-agent commit-plan --goal "Build a strategy-template campaign..." --json
7077
7233
  signaliz campaign-agent dry-run --goal "Build a strategy-template campaign..." --target-count 500 --use-local-leads --json
7078
7234
  signaliz campaign-agent build-approved --goal "Build a strategy-template campaign..." --confirm-launch --approve-all --approved-by you@example.com --spend-limit 500
7235
+ signaliz campaign-agent build-approved --request-file campaign-request.json --confirm-launch --approve-all --approved-by you@example.com --spend-limit 500 --wait --approve-delivery --delivery-destination-type json
7079
7236
 
7080
7237
  Environment:
7081
7238
  SIGNALIZ_API_KEY Your API key (not required for campaign-agent init)
@@ -7106,9 +7263,9 @@ Signaliz campaign-agent commands:
7106
7263
  signaliz campaign-agent proof (--goal TEXT | --request-file FILE) [--strategy-template ID] [--target-count N] [--use-local-leads] [--custom-tool provider:layer:tool[:mcp]] [--idempotency-key KEY] [--json]
7107
7264
  signaliz campaign-agent commit-plan (--goal TEXT | --request-file FILE) [--confirm-write --approved-by EMAIL] [--idempotency-key KEY] [--json]
7108
7265
  signaliz campaign-agent dry-run (--goal TEXT | --request-file FILE) [--gtm-campaign-id ID] [--delivery-risk JSON] [--idempotency-key KEY] [--json]
7109
- signaliz campaign-agent build-approved (--goal TEXT | --request-file FILE) --confirm-launch --approved-by EMAIL (--approve-all | --approved-types a,b) [--commit-before-launch] [--spend-limit N] [--approved-route-ids a,b] [--idempotency-key KEY] [--json]
7266
+ signaliz campaign-agent build-approved (--goal TEXT | --request-file FILE) --confirm-launch --approved-by EMAIL (--approve-all | --approved-types a,b) [--commit-before-launch] [--spend-limit N] [--approved-route-ids a,b] [--wait] [--approve-delivery] [--delivery-destination-type json|csv|webhook] [--idempotency-key KEY] [--json]
7110
7267
 
7111
- The init command emits a reusable JSON CampaignBuilderAgentRequest. The plan command composes an approval-gated strategy-template MCP flow. Proof runs the same plan path plus build_campaign dry_run=true and returns a no-spend receipt. Use --request-file to load a reusable request, then override fields such as --target-count or --strategy-template from the command line. Use --strategy-template to merge a private-safe strategy pattern into the plan without exposing private account labels, and --operating-playbooks to add reusable build-loop gates such as proof-first vertical qualification, net-new suppression, cache-first inventory, and signal-led copy approval. Built-ins map to Signaliz-native tools: lead_generation -> generate_leads, local_leads -> generate_local_leads, email_finding -> find_and_verify_emails, email_verification -> verify_emails, signals -> enrich_company_signals. Add BYO tools with --custom-tool provider:layer:tool[:mcp] or key=value pairs such as provider=apollo,layer=source,tool=apollo_search,mcp=apollo. Use --no-strategy-patterns or --no-workflow-patterns to disable default private strategy memory hints. Commit-plan dry-runs by default and writes only with --confirm-write plus approval identity. Dry-run executes build_campaign with dry_run=true. Approved build requires explicit launch confirmation and approval metadata; add --commit-before-launch to persist the reviewed plan as a GTM campaign before launch.
7268
+ The init command emits a reusable JSON CampaignBuilderAgentRequest. The plan command composes an approval-gated strategy-template MCP flow. Proof runs the same plan path plus build_campaign dry_run=true and returns a no-spend receipt. Use --request-file to load a reusable request, then override fields such as --target-count or --strategy-template from the command line. Use --strategy-template to merge a private-safe strategy pattern into the plan without exposing private account labels, and --operating-playbooks to add reusable build-loop gates such as proof-first vertical qualification, net-new suppression, cache-first inventory, and signal-led copy approval. Built-ins map to Signaliz-native tools: lead_generation -> generate_leads, local_leads -> generate_local_leads, email_finding -> find_and_verify_emails, email_verification -> verify_emails, signals -> enrich_company_signals. Add BYO tools with --custom-tool provider:layer:tool[:mcp] or key=value pairs such as provider=apollo,layer=source,tool=apollo_search,mcp=apollo. Use --no-strategy-patterns or --no-workflow-patterns to disable default private strategy memory hints. Commit-plan dry-runs by default and writes only with --confirm-write plus approval identity. Dry-run executes build_campaign with dry_run=true. Approved build requires explicit launch confirmation and approval metadata; add --commit-before-launch to persist the reviewed plan as a GTM campaign before launch, --wait to poll until completion or pending approval, and --approve-delivery to approve reviewed JSON/CSV/webhook delivery after pending_approval.
7112
7269
  `);
7113
7270
  }
7114
7271
  main().catch((e) => {
package/dist/cli.mjs CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  Signaliz,
4
4
  createCampaignBuilderAgentRequestTemplate,
5
5
  createCampaignBuilderApproval
6
- } from "./chunk-BHL5NHVO.mjs";
6
+ } from "./chunk-EQZJFFS7.mjs";
7
7
 
8
8
  // src/cli.ts
9
9
  import { readFileSync, writeFileSync } from "fs";
@@ -451,7 +451,21 @@ async function handleCampaignAgentCommand(signaliz, argv) {
451
451
  approvedRouteIds: approvedRouteIdsFromFlags(plan, flags),
452
452
  notes: stringFlag(flags, "approval-notes", "notes")
453
453
  });
454
- const result = await signaliz.campaignBuilderAgent.buildApprovedPlan(plan, approval, {
454
+ const runApproved = booleanFlag(flags, "wait") || booleanFlag(flags, "approve-delivery");
455
+ const result = runApproved ? await signaliz.campaignBuilderAgent.runApprovedPlan(plan, approval, {
456
+ idempotencyKey: stringFlag(flags, "idempotency-key"),
457
+ commitBeforeLaunch: booleanFlag(flags, "commit-before-launch"),
458
+ wait: booleanFlag(flags, "wait"),
459
+ approveDelivery: booleanFlag(flags, "approve-delivery"),
460
+ deliveryDestinationType: stringFlag(flags, "delivery-destination-type", "destination-type"),
461
+ deliveryDestinationId: stringFlag(flags, "delivery-destination-id", "destination-id"),
462
+ deliveryDestinationConfig: jsonObjectFlag(flags, "delivery-config", "destination-config"),
463
+ waitIntervalMs: numberFlag(flags, "wait-interval-ms"),
464
+ waitTimeoutMs: numberFlag(flags, "wait-timeout-ms"),
465
+ onStatus: booleanFlag(flags, "json") ? void 0 : (status) => {
466
+ console.error(`campaign-agent build-approved: ${status.status} phase=${status.currentPhase ?? "N/A"} rows=${status.recordsSucceeded}/${status.recordsTotal} artifacts=${status.artifactCount}`);
467
+ }
468
+ }) : await signaliz.campaignBuilderAgent.buildApprovedPlan(plan, approval, {
455
469
  idempotencyKey: stringFlag(flags, "idempotency-key"),
456
470
  commitBeforeLaunch: booleanFlag(flags, "commit-before-launch")
457
471
  });
@@ -864,7 +878,8 @@ function createCampaignAgentProofReceipt(plan, result) {
864
878
  recommended_next_actions: [
865
879
  "Review the plan, approvals, and dry-run result.",
866
880
  "Use campaign-agent commit-plan --confirm-write only after review.",
867
- "Use campaign-agent build-approved only with --confirm-launch, approval identity, approval types, and spend limit."
881
+ "Use campaign-agent build-approved only with --confirm-launch, approval identity, approval types, and spend limit.",
882
+ "When an approved build reaches pending_approval, review rows and approve delivery through the Campaigns SDK."
868
883
  ]
869
884
  };
870
885
  }
@@ -974,6 +989,7 @@ Usage:
974
989
  signaliz campaign-agent commit-plan --goal "Build a strategy-template campaign..." --json
975
990
  signaliz campaign-agent dry-run --goal "Build a strategy-template campaign..." --target-count 500 --use-local-leads --json
976
991
  signaliz campaign-agent build-approved --goal "Build a strategy-template campaign..." --confirm-launch --approve-all --approved-by you@example.com --spend-limit 500
992
+ signaliz campaign-agent build-approved --request-file campaign-request.json --confirm-launch --approve-all --approved-by you@example.com --spend-limit 500 --wait --approve-delivery --delivery-destination-type json
977
993
 
978
994
  Environment:
979
995
  SIGNALIZ_API_KEY Your API key (not required for campaign-agent init)
@@ -1004,9 +1020,9 @@ Signaliz campaign-agent commands:
1004
1020
  signaliz campaign-agent proof (--goal TEXT | --request-file FILE) [--strategy-template ID] [--target-count N] [--use-local-leads] [--custom-tool provider:layer:tool[:mcp]] [--idempotency-key KEY] [--json]
1005
1021
  signaliz campaign-agent commit-plan (--goal TEXT | --request-file FILE) [--confirm-write --approved-by EMAIL] [--idempotency-key KEY] [--json]
1006
1022
  signaliz campaign-agent dry-run (--goal TEXT | --request-file FILE) [--gtm-campaign-id ID] [--delivery-risk JSON] [--idempotency-key KEY] [--json]
1007
- signaliz campaign-agent build-approved (--goal TEXT | --request-file FILE) --confirm-launch --approved-by EMAIL (--approve-all | --approved-types a,b) [--commit-before-launch] [--spend-limit N] [--approved-route-ids a,b] [--idempotency-key KEY] [--json]
1023
+ signaliz campaign-agent build-approved (--goal TEXT | --request-file FILE) --confirm-launch --approved-by EMAIL (--approve-all | --approved-types a,b) [--commit-before-launch] [--spend-limit N] [--approved-route-ids a,b] [--wait] [--approve-delivery] [--delivery-destination-type json|csv|webhook] [--idempotency-key KEY] [--json]
1008
1024
 
1009
- The init command emits a reusable JSON CampaignBuilderAgentRequest. The plan command composes an approval-gated strategy-template MCP flow. Proof runs the same plan path plus build_campaign dry_run=true and returns a no-spend receipt. Use --request-file to load a reusable request, then override fields such as --target-count or --strategy-template from the command line. Use --strategy-template to merge a private-safe strategy pattern into the plan without exposing private account labels, and --operating-playbooks to add reusable build-loop gates such as proof-first vertical qualification, net-new suppression, cache-first inventory, and signal-led copy approval. Built-ins map to Signaliz-native tools: lead_generation -> generate_leads, local_leads -> generate_local_leads, email_finding -> find_and_verify_emails, email_verification -> verify_emails, signals -> enrich_company_signals. Add BYO tools with --custom-tool provider:layer:tool[:mcp] or key=value pairs such as provider=apollo,layer=source,tool=apollo_search,mcp=apollo. Use --no-strategy-patterns or --no-workflow-patterns to disable default private strategy memory hints. Commit-plan dry-runs by default and writes only with --confirm-write plus approval identity. Dry-run executes build_campaign with dry_run=true. Approved build requires explicit launch confirmation and approval metadata; add --commit-before-launch to persist the reviewed plan as a GTM campaign before launch.
1025
+ The init command emits a reusable JSON CampaignBuilderAgentRequest. The plan command composes an approval-gated strategy-template MCP flow. Proof runs the same plan path plus build_campaign dry_run=true and returns a no-spend receipt. Use --request-file to load a reusable request, then override fields such as --target-count or --strategy-template from the command line. Use --strategy-template to merge a private-safe strategy pattern into the plan without exposing private account labels, and --operating-playbooks to add reusable build-loop gates such as proof-first vertical qualification, net-new suppression, cache-first inventory, and signal-led copy approval. Built-ins map to Signaliz-native tools: lead_generation -> generate_leads, local_leads -> generate_local_leads, email_finding -> find_and_verify_emails, email_verification -> verify_emails, signals -> enrich_company_signals. Add BYO tools with --custom-tool provider:layer:tool[:mcp] or key=value pairs such as provider=apollo,layer=source,tool=apollo_search,mcp=apollo. Use --no-strategy-patterns or --no-workflow-patterns to disable default private strategy memory hints. Commit-plan dry-runs by default and writes only with --confirm-write plus approval identity. Dry-run executes build_campaign with dry_run=true. Approved build requires explicit launch confirmation and approval metadata; add --commit-before-launch to persist the reviewed plan as a GTM campaign before launch, --wait to poll until completion or pending approval, and --approve-delivery to approve reviewed JSON/CSV/webhook delivery after pending_approval.
1010
1026
  `);
1011
1027
  }
1012
1028
  main().catch((e) => {
package/dist/index.d.mts CHANGED
@@ -1079,6 +1079,21 @@ interface CampaignBuilderPlanCommitResult {
1079
1079
  type CampaignBuilderBuildOptions = BuildOptions & {
1080
1080
  commitBeforeLaunch?: boolean;
1081
1081
  };
1082
+ type CampaignBuilderApprovedRunOptions = CampaignBuilderBuildOptions & {
1083
+ wait?: boolean;
1084
+ approveDelivery?: boolean;
1085
+ deliveryDestinationType?: CampaignDeliveryMode;
1086
+ deliveryDestinationId?: string;
1087
+ deliveryDestinationConfig?: UnknownRecord$1;
1088
+ waitIntervalMs?: number;
1089
+ waitTimeoutMs?: number;
1090
+ onStatus?: (status: CampaignBuildStatus) => void;
1091
+ };
1092
+ interface CampaignBuilderApprovedRunResult {
1093
+ build: CampaignBuildResult;
1094
+ finalStatus?: CampaignBuildStatus;
1095
+ deliveryApproval?: ApproveDeliveryResult;
1096
+ }
1082
1097
  declare const DEFAULT_SIGNALIZ_CAMPAIGN_BUILDER_DEFAULTS: Required<Pick<SignalizCampaignBuilderDefaults, 'requireVerifiedEmail' | 'dedupKeys' | 'allowDownscale'>> & SignalizCampaignBuilderDefaults;
1083
1098
  declare const DEFAULT_CAMPAIGN_BUILDER_BUILT_INS: CampaignBuilderBuiltInTool[];
1084
1099
  declare const DEFAULT_CAMPAIGN_BUILDER_APPROVAL_TYPES: CampaignBuilderApprovalType[];
@@ -1091,6 +1106,10 @@ declare class CampaignBuilderAgent {
1091
1106
  commitPlan(plan: CampaignBuilderAgentPlan, options?: CampaignBuilderPlanCommitOptions): Promise<CampaignBuilderPlanCommitResult>;
1092
1107
  dryRunPlan(plan: CampaignBuilderAgentPlan, options?: BuildOptions): Promise<CampaignBuildResult>;
1093
1108
  buildApprovedPlan(plan: CampaignBuilderAgentPlan, approval: CampaignBuilderApproval, options?: CampaignBuilderBuildOptions): Promise<CampaignBuildResult>;
1109
+ runApprovedPlan(plan: CampaignBuilderAgentPlan, approval: CampaignBuilderApproval, options?: CampaignBuilderApprovedRunOptions): Promise<CampaignBuilderApprovedRunResult>;
1110
+ private getCampaignBuildStatus;
1111
+ private waitForCampaignBuildStatus;
1112
+ private approveCampaignDelivery;
1094
1113
  private getWorkspaceContext;
1095
1114
  private scopeCampaign;
1096
1115
  private discoverPlannedRoutes;
@@ -3365,4 +3384,4 @@ declare class Signaliz {
3365
3384
  discover(query: string, category?: string): Promise<MCPToolInfo[]>;
3366
3385
  }
3367
3386
 
3368
- export { Ai, type ApproveDeliveryResult, type BuildOptions, CAMPAIGN_BUILDER_OPERATING_PLAYBOOKS, CAMPAIGN_BUILDER_STRATEGY_TEMPLATES, type CampaignArtifact, type CampaignBuildRequest$1 as CampaignBuildRequest, type CampaignBuildResult$1 as CampaignBuildResult, type CampaignBuildRow, type CampaignBuildStatus, CampaignBuilderAgent, type CampaignBuilderAgentPlan, type CampaignBuilderAgentProvider, type CampaignBuilderAgentRequest, type CampaignBuilderAgentRequestTemplateOptions, type CampaignBuilderApproval, type CampaignBuilderApprovalPolicy, type CampaignBuilderApprovalType, type CampaignBuilderBuildOptions, type CampaignBuilderBuiltInTool, type CampaignBuilderCustomerTool, type CampaignBuilderGtmLayer, type CampaignBuilderIntegrationRoute, type CampaignBuilderLayer, type CampaignBuilderMcpStep, type CampaignBuilderMemoryPlan, type CampaignBuilderMemoryQuery, type CampaignBuilderMemoryScope, type CampaignBuilderOperatingPlaybook, type CampaignBuilderOperatingPlaybookSlug, type CampaignBuilderPlanCommitOptions, type CampaignBuilderPlanCommitResult, type CampaignBuilderPlanOptions, type CampaignBuilderProvider, type CampaignBuilderRequiredApproval, type CampaignBuilderRouteMode, type CampaignBuilderStrategyTemplate, type CampaignBuilderStrategyTemplateSlug, type CampaignBuilderWorkspaceContext, type CampaignDeliveryMode, type CampaignProviderRouteReadback, type CampaignRowsOptions, type CampaignRowsResult, Campaigns, type CancelBuildResult, type CompanyIntelligenceParams, type CompanyIntelligenceResult, type CreateOutputSinkRequest, type CreateRoutineRequest, type CreateSystemParams, type CustomAiAttachment, type CustomAiFusionConfig, type CustomAiMultiModelParams, type CustomAiMultiModelResult, type CustomAiOutputField, DEFAULT_CAMPAIGN_BUILDER_APPROVAL_TYPES, DEFAULT_CAMPAIGN_BUILDER_BUILT_INS, DEFAULT_SIGNALIZ_CAMPAIGN_BUILDER_DEFAULTS, type EmailBatchJobResult, type EnrichSignalsParams, type EnrichSignalsResult, type ErrorType, type ExecutionReference, type ExecutionReferenceInput, type ExecutionReferenceKind, type FindAndVerifyEmailContact, type FindEmailParams, type FindEmailResult, type GenerateLeadsParams, type GenerateLocalLeadsParams, type GtmActorType, type GtmAuthStrategy, type GtmBrainAggregateCalibrationsInput, type GtmBrainAggregatePatternsInput, type GtmBrainCalibrateDeliverabilityInput, type GtmBrainDeliveryRiskInput, type GtmBrainDistillRunInput, type GtmBrainExtractPatternsInput, type GtmBrainFailurePatternsOptions, type GtmBrainLearningAction, type GtmBrainLearningCyclePhase, type GtmBrainLearningCyclePlanInput, type GtmBrainLearningCyclePlanResult, type GtmBrainLearningCycleRunInput, type GtmBrainLearningEvidenceCounts, type GtmBrainLearningLane, type GtmBrainLearningLaneId, type GtmBrainLearningLaneState, type GtmBrainLearningLaneSummary, type GtmBrainLearningPhaseReadiness, type GtmBrainLearningPhaseStatus, type GtmBrainLearningRecommendedToolCall, type GtmBrainPatternsOptions, type GtmBrainSeedDefaultsInput, type GtmCalibrationDimensionType, type GtmCampaignAgentPlanInput, type GtmCampaignAgentRequestTemplateInput, type GtmCampaignBuildPlanInput, type GtmCampaignCreateInput, type GtmCampaignGetOptions, type GtmCampaignHistoryCampaignInput, type GtmCampaignHistoryImportBatchInput, type GtmCampaignHistoryImportInput, type GtmCampaignHistoryImportRunInput, type GtmCampaignHistoryMemoryInput, type GtmCampaignLearningStatusResult, type GtmCampaignListOptions, type GtmCampaignLogInput, type GtmCampaignSource, type GtmCampaignStartContextInput, type GtmCampaignStatus, type GtmCampaignStrategyMemoryStatusInput, type GtmCampaignStrategyTemplateSlug, type GtmCampaignStrategyTemplatesOptions, type GtmCampaignUpdateInput, type GtmConnectionRegisterInput, type GtmConnectionsListOptions, type GtmExistingCampaignAuditBoundary, type GtmExistingCampaignAuditBySearchOptions, type GtmExistingCampaignAuditOptions, type GtmExistingCampaignAuditRecommendation, type GtmExistingCampaignAuditResult, type GtmExistingCampaignCompletenessStep, type GtmExistingCampaignDiscoverOptions, type GtmExistingCampaignDiscoveryResult, type GtmExistingCampaignMcpRequest, type GtmExistingCampaignOption, type GtmFeedbackIngestInput, type GtmIntegrationRecipeCreateInput, type GtmInvocationType, GtmKernel, type GtmKernelImportPreviewInput, type GtmKernelImportRunInput, type GtmLayer, type GtmLayerRouteSetInput, type GtmLayerRoutesGetOptions, type GtmMemorySearchOptions, type GtmMemoryType, type GtmPatternType, type GtmProviderLinkInput, type GtmProviderRecipePrepareInput, type GtmProviderRouteActivateInput, type GtmWebhookDeliverInput, type GtmWorkspaceBootstrapStatusOptions, type GtmWorkspaceContextOptions, type HttpRequestParams, type HttpRequestResult, type IcpDetail, type IcpSummary, Icps, type ImportOctaveResult, type LeadGenJobResult, type ListOutputSinksOptions, type MCPToolInfo, type NativeGtmCapabilityInfo, Ops, type OpsApproveRequest, type OpsApproveResult, type OpsBlueprint, type OpsCadence, type OpsCreateRequest, type OpsCreateResult, type OpsDashboardOptions, type OpsDashboardResult, type OpsDebugDiagnosticError, type OpsDebugOptions, type OpsDebugResult, type OpsPlanRequest, type OpsPlanResult, type OpsPrimitive, type OpsPrimitiveConcurrencyPolicy, type OpsPrimitiveDeadLetterPolicy, type OpsPrimitiveObservabilityPolicy, type OpsPrimitivePermissionLevel, type OpsPrimitiveRetryPolicy, type OpsPrimitiveWorkspaceScope, type OpsQueueStatus, type OpsQueueStatusOptions, type OpsQuickstartStep, type OpsQuickstartWorkflow, type OpsReadinessCheck, type OpsReadinessOptions, type OpsReadinessResult, type OpsReplayResult, type OpsResultsOptions, type OpsResultsResult, type OpsRoutine, type OpsRoutineDeleteResult, type OpsRoutineRunResult, type OpsRoutineSinkResult, type OpsRoutineStatus, type OpsRoutineTick, type OpsRoutineTickItem, type OpsRoutineTickItemsResult, type OpsRoutineTicksResult, type OpsRoutinesResult, type OpsRunOptions, type OpsRunResult, type OpsSink, type OpsSinkType, type OpsStatusOptions, type OpsStatusResult, type OpsTriggerBatchRunStatus, type OpsTriggerRunStatus, type OpsTriggerRunStatusOptions, type PlatformHealth, type RunNativeGtmCapabilityParams, type RunProgressEvent, type RunResult, type RunRoutineRequest, type RunSystemParams, type Signal, Signaliz, type SignalizCampaignBuilderDefaults, type SignalizConfig, SignalizError, type SignalizErrorData, type SimpleOpStatus, type SystemResult, type UpdateRoutineRequest, type VerifyEmailResult, type WaitOptions, type WorkspaceInfo, applyCampaignBuilderStrategyTemplate, collectExecutionReferences, createCampaignBuilderAgentPlan, createCampaignBuilderAgentRequestTemplate, createCampaignBuilderApproval, createCampaignBuilderToolRoute, getCampaignBuilderOperatingPlaybook, getCampaignBuilderOperatingPlaybooksForRequest, getCampaignBuilderStrategyTemplate, getMissingCampaignBuilderApprovals, normalizeExecutionReference };
3387
+ export { Ai, type ApproveDeliveryResult, type BuildOptions, CAMPAIGN_BUILDER_OPERATING_PLAYBOOKS, CAMPAIGN_BUILDER_STRATEGY_TEMPLATES, type CampaignArtifact, type CampaignBuildRequest$1 as CampaignBuildRequest, type CampaignBuildResult$1 as CampaignBuildResult, type CampaignBuildRow, type CampaignBuildStatus, CampaignBuilderAgent, type CampaignBuilderAgentPlan, type CampaignBuilderAgentProvider, type CampaignBuilderAgentRequest, type CampaignBuilderAgentRequestTemplateOptions, type CampaignBuilderApproval, type CampaignBuilderApprovalPolicy, type CampaignBuilderApprovalType, type CampaignBuilderApprovedRunOptions, type CampaignBuilderApprovedRunResult, type CampaignBuilderBuildOptions, type CampaignBuilderBuiltInTool, type CampaignBuilderCustomerTool, type CampaignBuilderGtmLayer, type CampaignBuilderIntegrationRoute, type CampaignBuilderLayer, type CampaignBuilderMcpStep, type CampaignBuilderMemoryPlan, type CampaignBuilderMemoryQuery, type CampaignBuilderMemoryScope, type CampaignBuilderOperatingPlaybook, type CampaignBuilderOperatingPlaybookSlug, type CampaignBuilderPlanCommitOptions, type CampaignBuilderPlanCommitResult, type CampaignBuilderPlanOptions, type CampaignBuilderProvider, type CampaignBuilderRequiredApproval, type CampaignBuilderRouteMode, type CampaignBuilderStrategyTemplate, type CampaignBuilderStrategyTemplateSlug, type CampaignBuilderWorkspaceContext, type CampaignDeliveryMode, type CampaignProviderRouteReadback, type CampaignRowsOptions, type CampaignRowsResult, Campaigns, type CancelBuildResult, type CompanyIntelligenceParams, type CompanyIntelligenceResult, type CreateOutputSinkRequest, type CreateRoutineRequest, type CreateSystemParams, type CustomAiAttachment, type CustomAiFusionConfig, type CustomAiMultiModelParams, type CustomAiMultiModelResult, type CustomAiOutputField, DEFAULT_CAMPAIGN_BUILDER_APPROVAL_TYPES, DEFAULT_CAMPAIGN_BUILDER_BUILT_INS, DEFAULT_SIGNALIZ_CAMPAIGN_BUILDER_DEFAULTS, type EmailBatchJobResult, type EnrichSignalsParams, type EnrichSignalsResult, type ErrorType, type ExecutionReference, type ExecutionReferenceInput, type ExecutionReferenceKind, type FindAndVerifyEmailContact, type FindEmailParams, type FindEmailResult, type GenerateLeadsParams, type GenerateLocalLeadsParams, type GtmActorType, type GtmAuthStrategy, type GtmBrainAggregateCalibrationsInput, type GtmBrainAggregatePatternsInput, type GtmBrainCalibrateDeliverabilityInput, type GtmBrainDeliveryRiskInput, type GtmBrainDistillRunInput, type GtmBrainExtractPatternsInput, type GtmBrainFailurePatternsOptions, type GtmBrainLearningAction, type GtmBrainLearningCyclePhase, type GtmBrainLearningCyclePlanInput, type GtmBrainLearningCyclePlanResult, type GtmBrainLearningCycleRunInput, type GtmBrainLearningEvidenceCounts, type GtmBrainLearningLane, type GtmBrainLearningLaneId, type GtmBrainLearningLaneState, type GtmBrainLearningLaneSummary, type GtmBrainLearningPhaseReadiness, type GtmBrainLearningPhaseStatus, type GtmBrainLearningRecommendedToolCall, type GtmBrainPatternsOptions, type GtmBrainSeedDefaultsInput, type GtmCalibrationDimensionType, type GtmCampaignAgentPlanInput, type GtmCampaignAgentRequestTemplateInput, type GtmCampaignBuildPlanInput, type GtmCampaignCreateInput, type GtmCampaignGetOptions, type GtmCampaignHistoryCampaignInput, type GtmCampaignHistoryImportBatchInput, type GtmCampaignHistoryImportInput, type GtmCampaignHistoryImportRunInput, type GtmCampaignHistoryMemoryInput, type GtmCampaignLearningStatusResult, type GtmCampaignListOptions, type GtmCampaignLogInput, type GtmCampaignSource, type GtmCampaignStartContextInput, type GtmCampaignStatus, type GtmCampaignStrategyMemoryStatusInput, type GtmCampaignStrategyTemplateSlug, type GtmCampaignStrategyTemplatesOptions, type GtmCampaignUpdateInput, type GtmConnectionRegisterInput, type GtmConnectionsListOptions, type GtmExistingCampaignAuditBoundary, type GtmExistingCampaignAuditBySearchOptions, type GtmExistingCampaignAuditOptions, type GtmExistingCampaignAuditRecommendation, type GtmExistingCampaignAuditResult, type GtmExistingCampaignCompletenessStep, type GtmExistingCampaignDiscoverOptions, type GtmExistingCampaignDiscoveryResult, type GtmExistingCampaignMcpRequest, type GtmExistingCampaignOption, type GtmFeedbackIngestInput, type GtmIntegrationRecipeCreateInput, type GtmInvocationType, GtmKernel, type GtmKernelImportPreviewInput, type GtmKernelImportRunInput, type GtmLayer, type GtmLayerRouteSetInput, type GtmLayerRoutesGetOptions, type GtmMemorySearchOptions, type GtmMemoryType, type GtmPatternType, type GtmProviderLinkInput, type GtmProviderRecipePrepareInput, type GtmProviderRouteActivateInput, type GtmWebhookDeliverInput, type GtmWorkspaceBootstrapStatusOptions, type GtmWorkspaceContextOptions, type HttpRequestParams, type HttpRequestResult, type IcpDetail, type IcpSummary, Icps, type ImportOctaveResult, type LeadGenJobResult, type ListOutputSinksOptions, type MCPToolInfo, type NativeGtmCapabilityInfo, Ops, type OpsApproveRequest, type OpsApproveResult, type OpsBlueprint, type OpsCadence, type OpsCreateRequest, type OpsCreateResult, type OpsDashboardOptions, type OpsDashboardResult, type OpsDebugDiagnosticError, type OpsDebugOptions, type OpsDebugResult, type OpsPlanRequest, type OpsPlanResult, type OpsPrimitive, type OpsPrimitiveConcurrencyPolicy, type OpsPrimitiveDeadLetterPolicy, type OpsPrimitiveObservabilityPolicy, type OpsPrimitivePermissionLevel, type OpsPrimitiveRetryPolicy, type OpsPrimitiveWorkspaceScope, type OpsQueueStatus, type OpsQueueStatusOptions, type OpsQuickstartStep, type OpsQuickstartWorkflow, type OpsReadinessCheck, type OpsReadinessOptions, type OpsReadinessResult, type OpsReplayResult, type OpsResultsOptions, type OpsResultsResult, type OpsRoutine, type OpsRoutineDeleteResult, type OpsRoutineRunResult, type OpsRoutineSinkResult, type OpsRoutineStatus, type OpsRoutineTick, type OpsRoutineTickItem, type OpsRoutineTickItemsResult, type OpsRoutineTicksResult, type OpsRoutinesResult, type OpsRunOptions, type OpsRunResult, type OpsSink, type OpsSinkType, type OpsStatusOptions, type OpsStatusResult, type OpsTriggerBatchRunStatus, type OpsTriggerRunStatus, type OpsTriggerRunStatusOptions, type PlatformHealth, type RunNativeGtmCapabilityParams, type RunProgressEvent, type RunResult, type RunRoutineRequest, type RunSystemParams, type Signal, Signaliz, type SignalizCampaignBuilderDefaults, type SignalizConfig, SignalizError, type SignalizErrorData, type SimpleOpStatus, type SystemResult, type UpdateRoutineRequest, type VerifyEmailResult, type WaitOptions, type WorkspaceInfo, applyCampaignBuilderStrategyTemplate, collectExecutionReferences, createCampaignBuilderAgentPlan, createCampaignBuilderAgentRequestTemplate, createCampaignBuilderApproval, createCampaignBuilderToolRoute, getCampaignBuilderOperatingPlaybook, getCampaignBuilderOperatingPlaybooksForRequest, getCampaignBuilderStrategyTemplate, getMissingCampaignBuilderApprovals, normalizeExecutionReference };
package/dist/index.d.ts CHANGED
@@ -1079,6 +1079,21 @@ interface CampaignBuilderPlanCommitResult {
1079
1079
  type CampaignBuilderBuildOptions = BuildOptions & {
1080
1080
  commitBeforeLaunch?: boolean;
1081
1081
  };
1082
+ type CampaignBuilderApprovedRunOptions = CampaignBuilderBuildOptions & {
1083
+ wait?: boolean;
1084
+ approveDelivery?: boolean;
1085
+ deliveryDestinationType?: CampaignDeliveryMode;
1086
+ deliveryDestinationId?: string;
1087
+ deliveryDestinationConfig?: UnknownRecord$1;
1088
+ waitIntervalMs?: number;
1089
+ waitTimeoutMs?: number;
1090
+ onStatus?: (status: CampaignBuildStatus) => void;
1091
+ };
1092
+ interface CampaignBuilderApprovedRunResult {
1093
+ build: CampaignBuildResult;
1094
+ finalStatus?: CampaignBuildStatus;
1095
+ deliveryApproval?: ApproveDeliveryResult;
1096
+ }
1082
1097
  declare const DEFAULT_SIGNALIZ_CAMPAIGN_BUILDER_DEFAULTS: Required<Pick<SignalizCampaignBuilderDefaults, 'requireVerifiedEmail' | 'dedupKeys' | 'allowDownscale'>> & SignalizCampaignBuilderDefaults;
1083
1098
  declare const DEFAULT_CAMPAIGN_BUILDER_BUILT_INS: CampaignBuilderBuiltInTool[];
1084
1099
  declare const DEFAULT_CAMPAIGN_BUILDER_APPROVAL_TYPES: CampaignBuilderApprovalType[];
@@ -1091,6 +1106,10 @@ declare class CampaignBuilderAgent {
1091
1106
  commitPlan(plan: CampaignBuilderAgentPlan, options?: CampaignBuilderPlanCommitOptions): Promise<CampaignBuilderPlanCommitResult>;
1092
1107
  dryRunPlan(plan: CampaignBuilderAgentPlan, options?: BuildOptions): Promise<CampaignBuildResult>;
1093
1108
  buildApprovedPlan(plan: CampaignBuilderAgentPlan, approval: CampaignBuilderApproval, options?: CampaignBuilderBuildOptions): Promise<CampaignBuildResult>;
1109
+ runApprovedPlan(plan: CampaignBuilderAgentPlan, approval: CampaignBuilderApproval, options?: CampaignBuilderApprovedRunOptions): Promise<CampaignBuilderApprovedRunResult>;
1110
+ private getCampaignBuildStatus;
1111
+ private waitForCampaignBuildStatus;
1112
+ private approveCampaignDelivery;
1094
1113
  private getWorkspaceContext;
1095
1114
  private scopeCampaign;
1096
1115
  private discoverPlannedRoutes;
@@ -3365,4 +3384,4 @@ declare class Signaliz {
3365
3384
  discover(query: string, category?: string): Promise<MCPToolInfo[]>;
3366
3385
  }
3367
3386
 
3368
- export { Ai, type ApproveDeliveryResult, type BuildOptions, CAMPAIGN_BUILDER_OPERATING_PLAYBOOKS, CAMPAIGN_BUILDER_STRATEGY_TEMPLATES, type CampaignArtifact, type CampaignBuildRequest$1 as CampaignBuildRequest, type CampaignBuildResult$1 as CampaignBuildResult, type CampaignBuildRow, type CampaignBuildStatus, CampaignBuilderAgent, type CampaignBuilderAgentPlan, type CampaignBuilderAgentProvider, type CampaignBuilderAgentRequest, type CampaignBuilderAgentRequestTemplateOptions, type CampaignBuilderApproval, type CampaignBuilderApprovalPolicy, type CampaignBuilderApprovalType, type CampaignBuilderBuildOptions, type CampaignBuilderBuiltInTool, type CampaignBuilderCustomerTool, type CampaignBuilderGtmLayer, type CampaignBuilderIntegrationRoute, type CampaignBuilderLayer, type CampaignBuilderMcpStep, type CampaignBuilderMemoryPlan, type CampaignBuilderMemoryQuery, type CampaignBuilderMemoryScope, type CampaignBuilderOperatingPlaybook, type CampaignBuilderOperatingPlaybookSlug, type CampaignBuilderPlanCommitOptions, type CampaignBuilderPlanCommitResult, type CampaignBuilderPlanOptions, type CampaignBuilderProvider, type CampaignBuilderRequiredApproval, type CampaignBuilderRouteMode, type CampaignBuilderStrategyTemplate, type CampaignBuilderStrategyTemplateSlug, type CampaignBuilderWorkspaceContext, type CampaignDeliveryMode, type CampaignProviderRouteReadback, type CampaignRowsOptions, type CampaignRowsResult, Campaigns, type CancelBuildResult, type CompanyIntelligenceParams, type CompanyIntelligenceResult, type CreateOutputSinkRequest, type CreateRoutineRequest, type CreateSystemParams, type CustomAiAttachment, type CustomAiFusionConfig, type CustomAiMultiModelParams, type CustomAiMultiModelResult, type CustomAiOutputField, DEFAULT_CAMPAIGN_BUILDER_APPROVAL_TYPES, DEFAULT_CAMPAIGN_BUILDER_BUILT_INS, DEFAULT_SIGNALIZ_CAMPAIGN_BUILDER_DEFAULTS, type EmailBatchJobResult, type EnrichSignalsParams, type EnrichSignalsResult, type ErrorType, type ExecutionReference, type ExecutionReferenceInput, type ExecutionReferenceKind, type FindAndVerifyEmailContact, type FindEmailParams, type FindEmailResult, type GenerateLeadsParams, type GenerateLocalLeadsParams, type GtmActorType, type GtmAuthStrategy, type GtmBrainAggregateCalibrationsInput, type GtmBrainAggregatePatternsInput, type GtmBrainCalibrateDeliverabilityInput, type GtmBrainDeliveryRiskInput, type GtmBrainDistillRunInput, type GtmBrainExtractPatternsInput, type GtmBrainFailurePatternsOptions, type GtmBrainLearningAction, type GtmBrainLearningCyclePhase, type GtmBrainLearningCyclePlanInput, type GtmBrainLearningCyclePlanResult, type GtmBrainLearningCycleRunInput, type GtmBrainLearningEvidenceCounts, type GtmBrainLearningLane, type GtmBrainLearningLaneId, type GtmBrainLearningLaneState, type GtmBrainLearningLaneSummary, type GtmBrainLearningPhaseReadiness, type GtmBrainLearningPhaseStatus, type GtmBrainLearningRecommendedToolCall, type GtmBrainPatternsOptions, type GtmBrainSeedDefaultsInput, type GtmCalibrationDimensionType, type GtmCampaignAgentPlanInput, type GtmCampaignAgentRequestTemplateInput, type GtmCampaignBuildPlanInput, type GtmCampaignCreateInput, type GtmCampaignGetOptions, type GtmCampaignHistoryCampaignInput, type GtmCampaignHistoryImportBatchInput, type GtmCampaignHistoryImportInput, type GtmCampaignHistoryImportRunInput, type GtmCampaignHistoryMemoryInput, type GtmCampaignLearningStatusResult, type GtmCampaignListOptions, type GtmCampaignLogInput, type GtmCampaignSource, type GtmCampaignStartContextInput, type GtmCampaignStatus, type GtmCampaignStrategyMemoryStatusInput, type GtmCampaignStrategyTemplateSlug, type GtmCampaignStrategyTemplatesOptions, type GtmCampaignUpdateInput, type GtmConnectionRegisterInput, type GtmConnectionsListOptions, type GtmExistingCampaignAuditBoundary, type GtmExistingCampaignAuditBySearchOptions, type GtmExistingCampaignAuditOptions, type GtmExistingCampaignAuditRecommendation, type GtmExistingCampaignAuditResult, type GtmExistingCampaignCompletenessStep, type GtmExistingCampaignDiscoverOptions, type GtmExistingCampaignDiscoveryResult, type GtmExistingCampaignMcpRequest, type GtmExistingCampaignOption, type GtmFeedbackIngestInput, type GtmIntegrationRecipeCreateInput, type GtmInvocationType, GtmKernel, type GtmKernelImportPreviewInput, type GtmKernelImportRunInput, type GtmLayer, type GtmLayerRouteSetInput, type GtmLayerRoutesGetOptions, type GtmMemorySearchOptions, type GtmMemoryType, type GtmPatternType, type GtmProviderLinkInput, type GtmProviderRecipePrepareInput, type GtmProviderRouteActivateInput, type GtmWebhookDeliverInput, type GtmWorkspaceBootstrapStatusOptions, type GtmWorkspaceContextOptions, type HttpRequestParams, type HttpRequestResult, type IcpDetail, type IcpSummary, Icps, type ImportOctaveResult, type LeadGenJobResult, type ListOutputSinksOptions, type MCPToolInfo, type NativeGtmCapabilityInfo, Ops, type OpsApproveRequest, type OpsApproveResult, type OpsBlueprint, type OpsCadence, type OpsCreateRequest, type OpsCreateResult, type OpsDashboardOptions, type OpsDashboardResult, type OpsDebugDiagnosticError, type OpsDebugOptions, type OpsDebugResult, type OpsPlanRequest, type OpsPlanResult, type OpsPrimitive, type OpsPrimitiveConcurrencyPolicy, type OpsPrimitiveDeadLetterPolicy, type OpsPrimitiveObservabilityPolicy, type OpsPrimitivePermissionLevel, type OpsPrimitiveRetryPolicy, type OpsPrimitiveWorkspaceScope, type OpsQueueStatus, type OpsQueueStatusOptions, type OpsQuickstartStep, type OpsQuickstartWorkflow, type OpsReadinessCheck, type OpsReadinessOptions, type OpsReadinessResult, type OpsReplayResult, type OpsResultsOptions, type OpsResultsResult, type OpsRoutine, type OpsRoutineDeleteResult, type OpsRoutineRunResult, type OpsRoutineSinkResult, type OpsRoutineStatus, type OpsRoutineTick, type OpsRoutineTickItem, type OpsRoutineTickItemsResult, type OpsRoutineTicksResult, type OpsRoutinesResult, type OpsRunOptions, type OpsRunResult, type OpsSink, type OpsSinkType, type OpsStatusOptions, type OpsStatusResult, type OpsTriggerBatchRunStatus, type OpsTriggerRunStatus, type OpsTriggerRunStatusOptions, type PlatformHealth, type RunNativeGtmCapabilityParams, type RunProgressEvent, type RunResult, type RunRoutineRequest, type RunSystemParams, type Signal, Signaliz, type SignalizCampaignBuilderDefaults, type SignalizConfig, SignalizError, type SignalizErrorData, type SimpleOpStatus, type SystemResult, type UpdateRoutineRequest, type VerifyEmailResult, type WaitOptions, type WorkspaceInfo, applyCampaignBuilderStrategyTemplate, collectExecutionReferences, createCampaignBuilderAgentPlan, createCampaignBuilderAgentRequestTemplate, createCampaignBuilderApproval, createCampaignBuilderToolRoute, getCampaignBuilderOperatingPlaybook, getCampaignBuilderOperatingPlaybooksForRequest, getCampaignBuilderStrategyTemplate, getMissingCampaignBuilderApprovals, normalizeExecutionReference };
3387
+ export { Ai, type ApproveDeliveryResult, type BuildOptions, CAMPAIGN_BUILDER_OPERATING_PLAYBOOKS, CAMPAIGN_BUILDER_STRATEGY_TEMPLATES, type CampaignArtifact, type CampaignBuildRequest$1 as CampaignBuildRequest, type CampaignBuildResult$1 as CampaignBuildResult, type CampaignBuildRow, type CampaignBuildStatus, CampaignBuilderAgent, type CampaignBuilderAgentPlan, type CampaignBuilderAgentProvider, type CampaignBuilderAgentRequest, type CampaignBuilderAgentRequestTemplateOptions, type CampaignBuilderApproval, type CampaignBuilderApprovalPolicy, type CampaignBuilderApprovalType, type CampaignBuilderApprovedRunOptions, type CampaignBuilderApprovedRunResult, type CampaignBuilderBuildOptions, type CampaignBuilderBuiltInTool, type CampaignBuilderCustomerTool, type CampaignBuilderGtmLayer, type CampaignBuilderIntegrationRoute, type CampaignBuilderLayer, type CampaignBuilderMcpStep, type CampaignBuilderMemoryPlan, type CampaignBuilderMemoryQuery, type CampaignBuilderMemoryScope, type CampaignBuilderOperatingPlaybook, type CampaignBuilderOperatingPlaybookSlug, type CampaignBuilderPlanCommitOptions, type CampaignBuilderPlanCommitResult, type CampaignBuilderPlanOptions, type CampaignBuilderProvider, type CampaignBuilderRequiredApproval, type CampaignBuilderRouteMode, type CampaignBuilderStrategyTemplate, type CampaignBuilderStrategyTemplateSlug, type CampaignBuilderWorkspaceContext, type CampaignDeliveryMode, type CampaignProviderRouteReadback, type CampaignRowsOptions, type CampaignRowsResult, Campaigns, type CancelBuildResult, type CompanyIntelligenceParams, type CompanyIntelligenceResult, type CreateOutputSinkRequest, type CreateRoutineRequest, type CreateSystemParams, type CustomAiAttachment, type CustomAiFusionConfig, type CustomAiMultiModelParams, type CustomAiMultiModelResult, type CustomAiOutputField, DEFAULT_CAMPAIGN_BUILDER_APPROVAL_TYPES, DEFAULT_CAMPAIGN_BUILDER_BUILT_INS, DEFAULT_SIGNALIZ_CAMPAIGN_BUILDER_DEFAULTS, type EmailBatchJobResult, type EnrichSignalsParams, type EnrichSignalsResult, type ErrorType, type ExecutionReference, type ExecutionReferenceInput, type ExecutionReferenceKind, type FindAndVerifyEmailContact, type FindEmailParams, type FindEmailResult, type GenerateLeadsParams, type GenerateLocalLeadsParams, type GtmActorType, type GtmAuthStrategy, type GtmBrainAggregateCalibrationsInput, type GtmBrainAggregatePatternsInput, type GtmBrainCalibrateDeliverabilityInput, type GtmBrainDeliveryRiskInput, type GtmBrainDistillRunInput, type GtmBrainExtractPatternsInput, type GtmBrainFailurePatternsOptions, type GtmBrainLearningAction, type GtmBrainLearningCyclePhase, type GtmBrainLearningCyclePlanInput, type GtmBrainLearningCyclePlanResult, type GtmBrainLearningCycleRunInput, type GtmBrainLearningEvidenceCounts, type GtmBrainLearningLane, type GtmBrainLearningLaneId, type GtmBrainLearningLaneState, type GtmBrainLearningLaneSummary, type GtmBrainLearningPhaseReadiness, type GtmBrainLearningPhaseStatus, type GtmBrainLearningRecommendedToolCall, type GtmBrainPatternsOptions, type GtmBrainSeedDefaultsInput, type GtmCalibrationDimensionType, type GtmCampaignAgentPlanInput, type GtmCampaignAgentRequestTemplateInput, type GtmCampaignBuildPlanInput, type GtmCampaignCreateInput, type GtmCampaignGetOptions, type GtmCampaignHistoryCampaignInput, type GtmCampaignHistoryImportBatchInput, type GtmCampaignHistoryImportInput, type GtmCampaignHistoryImportRunInput, type GtmCampaignHistoryMemoryInput, type GtmCampaignLearningStatusResult, type GtmCampaignListOptions, type GtmCampaignLogInput, type GtmCampaignSource, type GtmCampaignStartContextInput, type GtmCampaignStatus, type GtmCampaignStrategyMemoryStatusInput, type GtmCampaignStrategyTemplateSlug, type GtmCampaignStrategyTemplatesOptions, type GtmCampaignUpdateInput, type GtmConnectionRegisterInput, type GtmConnectionsListOptions, type GtmExistingCampaignAuditBoundary, type GtmExistingCampaignAuditBySearchOptions, type GtmExistingCampaignAuditOptions, type GtmExistingCampaignAuditRecommendation, type GtmExistingCampaignAuditResult, type GtmExistingCampaignCompletenessStep, type GtmExistingCampaignDiscoverOptions, type GtmExistingCampaignDiscoveryResult, type GtmExistingCampaignMcpRequest, type GtmExistingCampaignOption, type GtmFeedbackIngestInput, type GtmIntegrationRecipeCreateInput, type GtmInvocationType, GtmKernel, type GtmKernelImportPreviewInput, type GtmKernelImportRunInput, type GtmLayer, type GtmLayerRouteSetInput, type GtmLayerRoutesGetOptions, type GtmMemorySearchOptions, type GtmMemoryType, type GtmPatternType, type GtmProviderLinkInput, type GtmProviderRecipePrepareInput, type GtmProviderRouteActivateInput, type GtmWebhookDeliverInput, type GtmWorkspaceBootstrapStatusOptions, type GtmWorkspaceContextOptions, type HttpRequestParams, type HttpRequestResult, type IcpDetail, type IcpSummary, Icps, type ImportOctaveResult, type LeadGenJobResult, type ListOutputSinksOptions, type MCPToolInfo, type NativeGtmCapabilityInfo, Ops, type OpsApproveRequest, type OpsApproveResult, type OpsBlueprint, type OpsCadence, type OpsCreateRequest, type OpsCreateResult, type OpsDashboardOptions, type OpsDashboardResult, type OpsDebugDiagnosticError, type OpsDebugOptions, type OpsDebugResult, type OpsPlanRequest, type OpsPlanResult, type OpsPrimitive, type OpsPrimitiveConcurrencyPolicy, type OpsPrimitiveDeadLetterPolicy, type OpsPrimitiveObservabilityPolicy, type OpsPrimitivePermissionLevel, type OpsPrimitiveRetryPolicy, type OpsPrimitiveWorkspaceScope, type OpsQueueStatus, type OpsQueueStatusOptions, type OpsQuickstartStep, type OpsQuickstartWorkflow, type OpsReadinessCheck, type OpsReadinessOptions, type OpsReadinessResult, type OpsReplayResult, type OpsResultsOptions, type OpsResultsResult, type OpsRoutine, type OpsRoutineDeleteResult, type OpsRoutineRunResult, type OpsRoutineSinkResult, type OpsRoutineStatus, type OpsRoutineTick, type OpsRoutineTickItem, type OpsRoutineTickItemsResult, type OpsRoutineTicksResult, type OpsRoutinesResult, type OpsRunOptions, type OpsRunResult, type OpsSink, type OpsSinkType, type OpsStatusOptions, type OpsStatusResult, type OpsTriggerBatchRunStatus, type OpsTriggerRunStatus, type OpsTriggerRunStatusOptions, type PlatformHealth, type RunNativeGtmCapabilityParams, type RunProgressEvent, type RunResult, type RunRoutineRequest, type RunSystemParams, type Signal, Signaliz, type SignalizCampaignBuilderDefaults, type SignalizConfig, SignalizError, type SignalizErrorData, type SimpleOpStatus, type SystemResult, type UpdateRoutineRequest, type VerifyEmailResult, type WaitOptions, type WorkspaceInfo, applyCampaignBuilderStrategyTemplate, collectExecutionReferences, createCampaignBuilderAgentPlan, createCampaignBuilderAgentRequestTemplate, createCampaignBuilderApproval, createCampaignBuilderToolRoute, getCampaignBuilderOperatingPlaybook, getCampaignBuilderOperatingPlaybooksForRequest, getCampaignBuilderStrategyTemplate, getMissingCampaignBuilderApprovals, normalizeExecutionReference };
package/dist/index.js CHANGED
@@ -1864,6 +1864,79 @@ var CampaignBuilderAgent = class {
1864
1864
  const data = await this.callMcp("build_campaign", args);
1865
1865
  return mapBuildResult(data, false);
1866
1866
  }
1867
+ async runApprovedPlan(plan, approval, options = {}) {
1868
+ const build = await this.buildApprovedPlan(plan, approval, options);
1869
+ const campaignBuildId = build.campaignBuildId;
1870
+ if (!campaignBuildId) {
1871
+ if (options.wait || options.approveDelivery) {
1872
+ throw new Error("Campaign builder approved run did not return a campaignBuildId to poll");
1873
+ }
1874
+ return { build };
1875
+ }
1876
+ const shouldWait = options.wait === true || options.approveDelivery === true;
1877
+ if (!shouldWait) return { build };
1878
+ let finalStatus = await this.waitForCampaignBuildStatus(
1879
+ campaignBuildId,
1880
+ options,
1881
+ ["completed", "failed", "canceled", "pending_approval"]
1882
+ );
1883
+ const result = { build, finalStatus };
1884
+ if (options.approveDelivery === true) {
1885
+ if (finalStatus.status !== "pending_approval") {
1886
+ throw new Error(`Campaign build ${campaignBuildId} reached ${finalStatus.status}; delivery approval was not available`);
1887
+ }
1888
+ const destinationType = options.deliveryDestinationType ?? plan.buildRequest.delivery?.destinationType ?? "json";
1889
+ result.deliveryApproval = await this.approveCampaignDelivery(campaignBuildId, destinationType, {
1890
+ destinationId: options.deliveryDestinationId,
1891
+ destinationConfig: options.deliveryDestinationConfig ?? plan.buildRequest.delivery?.destinationConfig
1892
+ });
1893
+ finalStatus = await this.waitForCampaignBuildStatus(
1894
+ campaignBuildId,
1895
+ options,
1896
+ ["completed", "failed", "canceled"]
1897
+ );
1898
+ result.finalStatus = finalStatus;
1899
+ }
1900
+ return result;
1901
+ }
1902
+ async getCampaignBuildStatus(campaignBuildId) {
1903
+ const data = await this.callMcp("get_campaign_build_status", {
1904
+ campaign_build_id: campaignBuildId
1905
+ });
1906
+ return mapAgentCampaignBuildStatus(data);
1907
+ }
1908
+ async waitForCampaignBuildStatus(campaignBuildId, options, stopStatuses) {
1909
+ const interval = options.waitIntervalMs ?? 5e3;
1910
+ const timeout = options.waitTimeoutMs ?? 6e5;
1911
+ const startedAt = Date.now();
1912
+ while (true) {
1913
+ const status = await this.getCampaignBuildStatus(campaignBuildId);
1914
+ options.onStatus?.(status);
1915
+ if (stopStatuses.includes(status.status)) return status;
1916
+ if (Date.now() - startedAt > timeout) {
1917
+ throw new Error(`Campaign build ${campaignBuildId} timed out after ${timeout}ms (status: ${status.status})`);
1918
+ }
1919
+ await new Promise((resolve) => setTimeout(resolve, interval));
1920
+ }
1921
+ }
1922
+ async approveCampaignDelivery(campaignBuildId, destinationType, options) {
1923
+ const args = compact({
1924
+ campaign_build_id: campaignBuildId,
1925
+ destination_type: destinationType,
1926
+ destination_id: options?.destinationId,
1927
+ destination_config: options?.destinationConfig
1928
+ });
1929
+ const data = await this.callMcp("approve_campaign_delivery", args);
1930
+ return {
1931
+ campaignBuildId: data.campaign_build_id,
1932
+ destinationType: data.destination_type ?? destinationType,
1933
+ status: data.status ?? "approved",
1934
+ message: data.message ?? "",
1935
+ deliveryId: data.delivery_id,
1936
+ deliveryIds: data.delivery_ids,
1937
+ approvedCount: data.approved_count
1938
+ };
1939
+ }
1867
1940
  async getWorkspaceContext(warnings) {
1868
1941
  try {
1869
1942
  const workspace = await this.callMcp("get_workspace", {});
@@ -2809,6 +2882,17 @@ function createMcpFlow(request, buildRequest, routes, memory, approvals) {
2809
2882
  readOnly: false,
2810
2883
  approvalRequired: approvals.some((approval) => approval.blocking)
2811
2884
  });
2885
+ const deliveryApprovalArgs = buildDeliveryApprovalArgs(buildRequest);
2886
+ if (deliveryApprovalArgs) {
2887
+ steps.push({
2888
+ id: "delivery-approval",
2889
+ phase: "delivery",
2890
+ tool: "approve_campaign_delivery",
2891
+ arguments: deliveryApprovalArgs,
2892
+ readOnly: false,
2893
+ approvalRequired: true
2894
+ });
2895
+ }
2812
2896
  return steps.map((step) => ({ ...step, arguments: compact(step.arguments) }));
2813
2897
  }
2814
2898
  function shouldPrepareProviderRoute(route) {
@@ -3151,6 +3235,14 @@ function buildExecutionPrepareArgs(request, dryRun, confirmSpend) {
3151
3235
  enhancers: buildArgs2.enhancers
3152
3236
  });
3153
3237
  }
3238
+ function buildDeliveryApprovalArgs(request) {
3239
+ if (request.delivery?.enabled === false || request.delivery?.approvalRequired === false) return void 0;
3240
+ return compact({
3241
+ campaign_build_id: "<campaign_build_id_from_approved_build>",
3242
+ destination_type: request.delivery?.destinationType ?? "json",
3243
+ destination_config: request.delivery?.destinationConfig
3244
+ });
3245
+ }
3154
3246
  function mapBuildResult(data, dryRun) {
3155
3247
  return {
3156
3248
  campaignBuildId: data.campaign_build_id ?? null,
@@ -3172,6 +3264,55 @@ function mapBuildResult(data, dryRun) {
3172
3264
  providerRoute: mapProviderRoute2(data)
3173
3265
  };
3174
3266
  }
3267
+ function mapAgentCampaignBuildStatus(data) {
3268
+ return {
3269
+ campaignBuildId: stringValue(data.campaign_build_id) ?? "",
3270
+ campaignId: stringValue(data.campaign_id) ?? null,
3271
+ campaignObject: nullableRecord(data.campaign_object),
3272
+ name: stringValue(data.name) ?? "",
3273
+ status: stringValue(data.status) ?? "unknown",
3274
+ currentPhase: stringValue(data.current_phase) ?? null,
3275
+ currentPhaseStatus: stringValue(data.current_phase_status) ?? null,
3276
+ phases: Array.isArray(data.phases) ? data.phases : [],
3277
+ recordsTotal: numberOrUndefined2(data.records_total) ?? 0,
3278
+ recordsProcessed: numberOrUndefined2(data.records_processed) ?? 0,
3279
+ recordsSucceeded: numberOrUndefined2(data.records_succeeded) ?? 0,
3280
+ recordsFailed: numberOrUndefined2(data.records_failed) ?? 0,
3281
+ warnings: diagnosticMessages2(data.warnings),
3282
+ errors: diagnosticMessages2(data.errors),
3283
+ artifactCount: numberOrUndefined2(data.artifact_count) ?? 0,
3284
+ providerRoute: mapProviderRoute2(data),
3285
+ triggerRunId: stringValue(data.trigger_run_id) ?? null,
3286
+ staleRunningPhase: data.stale_running_phase === true,
3287
+ phaseAgeSeconds: numberOrNull2(data.phase_age_seconds),
3288
+ diagnostics: nullableRecord(data.diagnostics) ?? {},
3289
+ nextAction: formatAgentNextAction(data.next_action),
3290
+ createdAt: stringValue(data.created_at) ?? "",
3291
+ updatedAt: stringValue(data.updated_at) ?? "",
3292
+ completedAt: stringValue(data.completed_at) ?? null
3293
+ };
3294
+ }
3295
+ function diagnosticMessages2(value) {
3296
+ if (!Array.isArray(value)) return [];
3297
+ return value.map((item) => {
3298
+ if (typeof item === "string") return item;
3299
+ const record = nullableRecord(item);
3300
+ return stringValue(record?.message);
3301
+ }).filter((item) => typeof item === "string" && item.length > 0);
3302
+ }
3303
+ function formatAgentNextAction(value) {
3304
+ if (!value) return "";
3305
+ if (typeof value === "string") return value;
3306
+ const record = nullableRecord(value);
3307
+ if (!record) return "";
3308
+ const tool = stringValue(record.tool);
3309
+ const type = stringValue(record.type);
3310
+ const reason = stringValue(record.reason);
3311
+ const args = nullableRecord(record.arguments);
3312
+ const argText = args && Object.keys(args).length > 0 ? ` ${JSON.stringify(args)}` : "";
3313
+ const action = tool ? `${tool}${argText}` : type ?? "";
3314
+ return [action, reason].filter(Boolean).join(" - ");
3315
+ }
3175
3316
  function mapProviderRoute2(data) {
3176
3317
  const brainContext = asRecord(data?.brain_context);
3177
3318
  const plan = nullableRecord(data?.provider_route_plan) ?? nullableRecord(brainContext.provider_route_plan);
package/dist/index.mjs CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  getCampaignBuilderStrategyTemplate,
24
24
  getMissingCampaignBuilderApprovals,
25
25
  normalizeExecutionReference
26
- } from "./chunk-BHL5NHVO.mjs";
26
+ } from "./chunk-EQZJFFS7.mjs";
27
27
  export {
28
28
  Ai,
29
29
  CAMPAIGN_BUILDER_OPERATING_PLAYBOOKS,
@@ -1838,6 +1838,79 @@ var CampaignBuilderAgent = class {
1838
1838
  const data = await this.callMcp("build_campaign", args);
1839
1839
  return mapBuildResult(data, false);
1840
1840
  }
1841
+ async runApprovedPlan(plan, approval, options = {}) {
1842
+ const build = await this.buildApprovedPlan(plan, approval, options);
1843
+ const campaignBuildId = build.campaignBuildId;
1844
+ if (!campaignBuildId) {
1845
+ if (options.wait || options.approveDelivery) {
1846
+ throw new Error("Campaign builder approved run did not return a campaignBuildId to poll");
1847
+ }
1848
+ return { build };
1849
+ }
1850
+ const shouldWait = options.wait === true || options.approveDelivery === true;
1851
+ if (!shouldWait) return { build };
1852
+ let finalStatus = await this.waitForCampaignBuildStatus(
1853
+ campaignBuildId,
1854
+ options,
1855
+ ["completed", "failed", "canceled", "pending_approval"]
1856
+ );
1857
+ const result = { build, finalStatus };
1858
+ if (options.approveDelivery === true) {
1859
+ if (finalStatus.status !== "pending_approval") {
1860
+ throw new Error(`Campaign build ${campaignBuildId} reached ${finalStatus.status}; delivery approval was not available`);
1861
+ }
1862
+ const destinationType = options.deliveryDestinationType ?? plan.buildRequest.delivery?.destinationType ?? "json";
1863
+ result.deliveryApproval = await this.approveCampaignDelivery(campaignBuildId, destinationType, {
1864
+ destinationId: options.deliveryDestinationId,
1865
+ destinationConfig: options.deliveryDestinationConfig ?? plan.buildRequest.delivery?.destinationConfig
1866
+ });
1867
+ finalStatus = await this.waitForCampaignBuildStatus(
1868
+ campaignBuildId,
1869
+ options,
1870
+ ["completed", "failed", "canceled"]
1871
+ );
1872
+ result.finalStatus = finalStatus;
1873
+ }
1874
+ return result;
1875
+ }
1876
+ async getCampaignBuildStatus(campaignBuildId) {
1877
+ const data = await this.callMcp("get_campaign_build_status", {
1878
+ campaign_build_id: campaignBuildId
1879
+ });
1880
+ return mapAgentCampaignBuildStatus(data);
1881
+ }
1882
+ async waitForCampaignBuildStatus(campaignBuildId, options, stopStatuses) {
1883
+ const interval = options.waitIntervalMs ?? 5e3;
1884
+ const timeout = options.waitTimeoutMs ?? 6e5;
1885
+ const startedAt = Date.now();
1886
+ while (true) {
1887
+ const status = await this.getCampaignBuildStatus(campaignBuildId);
1888
+ options.onStatus?.(status);
1889
+ if (stopStatuses.includes(status.status)) return status;
1890
+ if (Date.now() - startedAt > timeout) {
1891
+ throw new Error(`Campaign build ${campaignBuildId} timed out after ${timeout}ms (status: ${status.status})`);
1892
+ }
1893
+ await new Promise((resolve) => setTimeout(resolve, interval));
1894
+ }
1895
+ }
1896
+ async approveCampaignDelivery(campaignBuildId, destinationType, options) {
1897
+ const args = compact({
1898
+ campaign_build_id: campaignBuildId,
1899
+ destination_type: destinationType,
1900
+ destination_id: options?.destinationId,
1901
+ destination_config: options?.destinationConfig
1902
+ });
1903
+ const data = await this.callMcp("approve_campaign_delivery", args);
1904
+ return {
1905
+ campaignBuildId: data.campaign_build_id,
1906
+ destinationType: data.destination_type ?? destinationType,
1907
+ status: data.status ?? "approved",
1908
+ message: data.message ?? "",
1909
+ deliveryId: data.delivery_id,
1910
+ deliveryIds: data.delivery_ids,
1911
+ approvedCount: data.approved_count
1912
+ };
1913
+ }
1841
1914
  async getWorkspaceContext(warnings) {
1842
1915
  try {
1843
1916
  const workspace = await this.callMcp("get_workspace", {});
@@ -2682,6 +2755,17 @@ function createMcpFlow(request, buildRequest, routes, memory, approvals) {
2682
2755
  readOnly: false,
2683
2756
  approvalRequired: approvals.some((approval) => approval.blocking)
2684
2757
  });
2758
+ const deliveryApprovalArgs = buildDeliveryApprovalArgs(buildRequest);
2759
+ if (deliveryApprovalArgs) {
2760
+ steps.push({
2761
+ id: "delivery-approval",
2762
+ phase: "delivery",
2763
+ tool: "approve_campaign_delivery",
2764
+ arguments: deliveryApprovalArgs,
2765
+ readOnly: false,
2766
+ approvalRequired: true
2767
+ });
2768
+ }
2685
2769
  return steps.map((step) => ({ ...step, arguments: compact(step.arguments) }));
2686
2770
  }
2687
2771
  function shouldPrepareProviderRoute(route) {
@@ -3024,6 +3108,14 @@ function buildExecutionPrepareArgs(request, dryRun, confirmSpend) {
3024
3108
  enhancers: buildArgs2.enhancers
3025
3109
  });
3026
3110
  }
3111
+ function buildDeliveryApprovalArgs(request) {
3112
+ if (request.delivery?.enabled === false || request.delivery?.approvalRequired === false) return void 0;
3113
+ return compact({
3114
+ campaign_build_id: "<campaign_build_id_from_approved_build>",
3115
+ destination_type: request.delivery?.destinationType ?? "json",
3116
+ destination_config: request.delivery?.destinationConfig
3117
+ });
3118
+ }
3027
3119
  function mapBuildResult(data, dryRun) {
3028
3120
  return {
3029
3121
  campaignBuildId: data.campaign_build_id ?? null,
@@ -3045,6 +3137,55 @@ function mapBuildResult(data, dryRun) {
3045
3137
  providerRoute: mapProviderRoute2(data)
3046
3138
  };
3047
3139
  }
3140
+ function mapAgentCampaignBuildStatus(data) {
3141
+ return {
3142
+ campaignBuildId: stringValue(data.campaign_build_id) ?? "",
3143
+ campaignId: stringValue(data.campaign_id) ?? null,
3144
+ campaignObject: nullableRecord(data.campaign_object),
3145
+ name: stringValue(data.name) ?? "",
3146
+ status: stringValue(data.status) ?? "unknown",
3147
+ currentPhase: stringValue(data.current_phase) ?? null,
3148
+ currentPhaseStatus: stringValue(data.current_phase_status) ?? null,
3149
+ phases: Array.isArray(data.phases) ? data.phases : [],
3150
+ recordsTotal: numberOrUndefined2(data.records_total) ?? 0,
3151
+ recordsProcessed: numberOrUndefined2(data.records_processed) ?? 0,
3152
+ recordsSucceeded: numberOrUndefined2(data.records_succeeded) ?? 0,
3153
+ recordsFailed: numberOrUndefined2(data.records_failed) ?? 0,
3154
+ warnings: diagnosticMessages2(data.warnings),
3155
+ errors: diagnosticMessages2(data.errors),
3156
+ artifactCount: numberOrUndefined2(data.artifact_count) ?? 0,
3157
+ providerRoute: mapProviderRoute2(data),
3158
+ triggerRunId: stringValue(data.trigger_run_id) ?? null,
3159
+ staleRunningPhase: data.stale_running_phase === true,
3160
+ phaseAgeSeconds: numberOrNull2(data.phase_age_seconds),
3161
+ diagnostics: nullableRecord(data.diagnostics) ?? {},
3162
+ nextAction: formatAgentNextAction(data.next_action),
3163
+ createdAt: stringValue(data.created_at) ?? "",
3164
+ updatedAt: stringValue(data.updated_at) ?? "",
3165
+ completedAt: stringValue(data.completed_at) ?? null
3166
+ };
3167
+ }
3168
+ function diagnosticMessages2(value) {
3169
+ if (!Array.isArray(value)) return [];
3170
+ return value.map((item) => {
3171
+ if (typeof item === "string") return item;
3172
+ const record = nullableRecord(item);
3173
+ return stringValue(record?.message);
3174
+ }).filter((item) => typeof item === "string" && item.length > 0);
3175
+ }
3176
+ function formatAgentNextAction(value) {
3177
+ if (!value) return "";
3178
+ if (typeof value === "string") return value;
3179
+ const record = nullableRecord(value);
3180
+ if (!record) return "";
3181
+ const tool = stringValue(record.tool);
3182
+ const type = stringValue(record.type);
3183
+ const reason = stringValue(record.reason);
3184
+ const args = nullableRecord(record.arguments);
3185
+ const argText = args && Object.keys(args).length > 0 ? ` ${JSON.stringify(args)}` : "";
3186
+ const action = tool ? `${tool}${argText}` : type ?? "";
3187
+ return [action, reason].filter(Boolean).join(" - ");
3188
+ }
3048
3189
  function mapProviderRoute2(data) {
3049
3190
  const brainContext = asRecord(data?.brain_context);
3050
3191
  const plan = nullableRecord(data?.provider_route_plan) ?? nullableRecord(brainContext.provider_route_plan);
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  Signaliz
4
- } from "./chunk-BHL5NHVO.mjs";
4
+ } from "./chunk-EQZJFFS7.mjs";
5
5
 
6
6
  // src/mcp-config.ts
7
7
  import * as fs from "fs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signaliz/sdk",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "Signaliz SDK — GTM Kernel, Nango routes, MCP, and enrichment for AI agents",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",