@signaliz/sdk 1.0.13 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -0
- package/dist/{chunk-DJVOGXVD.mjs → chunk-6OZWMAV3.mjs} +351 -0
- package/dist/cli.js +406 -137
- package/dist/cli.mjs +60 -139
- package/dist/index.d.mts +84 -1
- package/dist/index.d.ts +84 -1
- package/dist/index.js +353 -0
- package/dist/index.mjs +5 -1
- package/dist/mcp-config.js +451 -0
- package/dist/mcp-config.mjs +1 -1
- package/package.json +1 -1
package/dist/mcp-config.js
CHANGED
|
@@ -1229,6 +1229,14 @@ var CAMPAIGN_BUILDER_BUILT_IN_ROUTE_IDS = {
|
|
|
1229
1229
|
email_verification: "signaliz-email-verification",
|
|
1230
1230
|
signals: "signaliz-signals"
|
|
1231
1231
|
};
|
|
1232
|
+
var DEFAULT_CAMPAIGN_BUILDER_APPROVAL_TYPES = [
|
|
1233
|
+
"memory_retrieval",
|
|
1234
|
+
"spend",
|
|
1235
|
+
"customer_tool",
|
|
1236
|
+
"external_write",
|
|
1237
|
+
"delivery",
|
|
1238
|
+
"launch"
|
|
1239
|
+
];
|
|
1232
1240
|
var CAMPAIGN_BUILDER_OPERATING_PLAYBOOKS = [
|
|
1233
1241
|
{
|
|
1234
1242
|
slug: "cache-first-large-list",
|
|
@@ -1721,6 +1729,16 @@ var CampaignBuilderAgent = class {
|
|
|
1721
1729
|
const plan = await this.createPlan(request, options);
|
|
1722
1730
|
return createCampaignBuilderReadiness(plan);
|
|
1723
1731
|
}
|
|
1732
|
+
async proof(request, options = {}) {
|
|
1733
|
+
const plan = await this.createPlan(request, options);
|
|
1734
|
+
const result = await this.dryRunPlan(plan, {
|
|
1735
|
+
idempotencyKey: options.idempotencyKey
|
|
1736
|
+
});
|
|
1737
|
+
return createCampaignBuilderProofReceipt(plan, result);
|
|
1738
|
+
}
|
|
1739
|
+
buildKit(options = {}) {
|
|
1740
|
+
return createCampaignBuilderBuildKit(options);
|
|
1741
|
+
}
|
|
1724
1742
|
async commitPlan(plan, options = {}) {
|
|
1725
1743
|
const writeMode = options.confirm === true && options.dryRun === false;
|
|
1726
1744
|
if (writeMode && !options.approvedBy) {
|
|
@@ -2166,6 +2184,72 @@ function createCampaignBuilderReadiness(plan) {
|
|
|
2166
2184
|
nextActions: campaignReadinessNextActions(plan, ready, customRoutes.length)
|
|
2167
2185
|
};
|
|
2168
2186
|
}
|
|
2187
|
+
function createCampaignBuilderProofReceipt(plan, result) {
|
|
2188
|
+
const strategyMemory = asRecord(plan.strategyMemoryStatus);
|
|
2189
|
+
const dryRunResult = asRecord(result);
|
|
2190
|
+
const memoryReady = plan.strategyMemoryStatus ? strategyMemory.ready !== false : false;
|
|
2191
|
+
const dryRunCompleted = dryRunResult.dryRun === true || dryRunResult.dry_run === true || dryRunResult.status === "dry_run";
|
|
2192
|
+
const noLaunch = dryRunCompleted && !dryRunResult.campaignBuildId && !dryRunResult.campaign_build_id;
|
|
2193
|
+
const gates = [
|
|
2194
|
+
{
|
|
2195
|
+
id: "strategy_memory_ready",
|
|
2196
|
+
passed: memoryReady,
|
|
2197
|
+
ready: strategyMemory.ready ?? null,
|
|
2198
|
+
blocker_count: Array.isArray(strategyMemory.blockers) ? strategyMemory.blockers.length : 0
|
|
2199
|
+
},
|
|
2200
|
+
{
|
|
2201
|
+
id: "campaign_plan_ready",
|
|
2202
|
+
passed: Boolean(plan.planId && plan.mcpFlow.length > 0),
|
|
2203
|
+
plan_id: plan.planId,
|
|
2204
|
+
flow_steps: plan.mcpFlow.length
|
|
2205
|
+
},
|
|
2206
|
+
{
|
|
2207
|
+
id: "approval_gates_present",
|
|
2208
|
+
passed: plan.approvals.length > 0,
|
|
2209
|
+
approval_types: plan.approvals.map((approval) => approval.type)
|
|
2210
|
+
},
|
|
2211
|
+
{
|
|
2212
|
+
id: "dry_run_completed",
|
|
2213
|
+
passed: dryRunCompleted,
|
|
2214
|
+
status: dryRunResult.status ?? null,
|
|
2215
|
+
current_phase: dryRunResult.currentPhase ?? dryRunResult.current_phase ?? null
|
|
2216
|
+
},
|
|
2217
|
+
{
|
|
2218
|
+
id: "no_spendful_launch",
|
|
2219
|
+
passed: noLaunch,
|
|
2220
|
+
campaign_build_id: dryRunResult.campaignBuildId ?? dryRunResult.campaign_build_id ?? null
|
|
2221
|
+
}
|
|
2222
|
+
];
|
|
2223
|
+
return {
|
|
2224
|
+
receipt_version: "campaign-agent-proof.v1",
|
|
2225
|
+
source: "signaliz.campaignBuilderAgent.proof",
|
|
2226
|
+
success: gates.every((gate) => gate.passed),
|
|
2227
|
+
safety: {
|
|
2228
|
+
spendful_tools_called: false,
|
|
2229
|
+
external_writes_called: false,
|
|
2230
|
+
sender_loads_called: false,
|
|
2231
|
+
email_sends_called: false,
|
|
2232
|
+
dry_run_only: true
|
|
2233
|
+
},
|
|
2234
|
+
campaign: {
|
|
2235
|
+
plan_id: plan.planId,
|
|
2236
|
+
campaign_name: plan.campaignName,
|
|
2237
|
+
strategy_template: campaignBuilderProofStrategyTemplate(plan),
|
|
2238
|
+
target_count: plan.targetCount,
|
|
2239
|
+
estimated_credits: plan.estimatedCredits,
|
|
2240
|
+
operating_playbooks: plan.operatingPlaybooks.map((playbook) => playbook.slug)
|
|
2241
|
+
},
|
|
2242
|
+
gates,
|
|
2243
|
+
strategy_memory_status: summarizeCampaignBuilderProofStrategyMemory(strategyMemory),
|
|
2244
|
+
dry_run_result: summarizeCampaignBuilderProofDryRun(dryRunResult),
|
|
2245
|
+
recommended_next_actions: [
|
|
2246
|
+
"Review the plan, approvals, and dry-run result.",
|
|
2247
|
+
"Use campaign-agent commit-plan --confirm-write only after review.",
|
|
2248
|
+
"Use campaign-agent build-approved only with --confirm-launch, approval identity, approval types, and spend limit.",
|
|
2249
|
+
"When an approved build reaches pending_approval, review rows and approve delivery through the Campaigns SDK."
|
|
2250
|
+
]
|
|
2251
|
+
};
|
|
2252
|
+
}
|
|
2169
2253
|
function getMissingCampaignBuilderApprovals(plan, approval) {
|
|
2170
2254
|
if (approval.planId !== plan.planId) {
|
|
2171
2255
|
return plan.approvals;
|
|
@@ -2233,6 +2317,307 @@ function applyCampaignBuilderStrategyTemplate(request) {
|
|
|
2233
2317
|
agencyContext: mergeAgencyContext(template.agencyContext, request.agencyContext)
|
|
2234
2318
|
};
|
|
2235
2319
|
}
|
|
2320
|
+
function createCampaignBuilderAgentRequestTemplate(input = {}) {
|
|
2321
|
+
const builtIns = new Set(input.builtIns ?? DEFAULT_CAMPAIGN_BUILDER_BUILT_INS);
|
|
2322
|
+
if (input.includeLocalLeads) builtIns.add("local_leads");
|
|
2323
|
+
const integrations = input.integrations ?? (input.includeCustomToolPlaceholder ? [createCampaignBuilderToolRoute({
|
|
2324
|
+
provider: "custom_mcp",
|
|
2325
|
+
layer: "enrichment",
|
|
2326
|
+
gtmLayers: ["company_enrichment"],
|
|
2327
|
+
toolName: "workspace_enrich",
|
|
2328
|
+
mcpServerName: "workspace-mcp",
|
|
2329
|
+
label: "Workspace enrichment MCP",
|
|
2330
|
+
mode: "if_available",
|
|
2331
|
+
approvalRequired: true
|
|
2332
|
+
})] : void 0);
|
|
2333
|
+
const preferredProviders = uniqueStrings([
|
|
2334
|
+
...input.preferredProviders ?? [],
|
|
2335
|
+
...input.includeNango === false ? [] : ["nango"]
|
|
2336
|
+
]);
|
|
2337
|
+
const templated = applyCampaignBuilderStrategyTemplate({
|
|
2338
|
+
goal: input.goal || "Build a strategy-template campaign for mature operators in the target ICP.",
|
|
2339
|
+
strategyTemplate: input.strategyTemplate || "non-medical-home-care",
|
|
2340
|
+
campaignName: input.campaignName,
|
|
2341
|
+
accountLabel: input.accountLabel || "Workspace Campaign",
|
|
2342
|
+
accountContext: input.accountContext || "Use private workspace memory, current suppression rules, verified-email quality gates, and approval-gated provider routes.",
|
|
2343
|
+
targetCount: input.targetCount,
|
|
2344
|
+
icp: input.icp ?? {
|
|
2345
|
+
personas: ["Operations leader", "Founder", "Revenue leader"],
|
|
2346
|
+
industries: ["B2B services", "Vertical software", "Local operators"],
|
|
2347
|
+
geographies: ["United States"],
|
|
2348
|
+
keywords: ["growth", "operations", "customer acquisition"],
|
|
2349
|
+
requireVerifiedEmail: true
|
|
2350
|
+
},
|
|
2351
|
+
builtIns: [...builtIns],
|
|
2352
|
+
integrations,
|
|
2353
|
+
customerTools: input.customerTools,
|
|
2354
|
+
preferredProviders,
|
|
2355
|
+
constraints: input.constraints,
|
|
2356
|
+
workspaceContext: input.workspaceContext,
|
|
2357
|
+
brainDefaults: input.brainDefaults,
|
|
2358
|
+
deliveryRisk: input.deliveryRisk,
|
|
2359
|
+
gtmCampaignId: input.gtmCampaignId
|
|
2360
|
+
});
|
|
2361
|
+
return compact({
|
|
2362
|
+
...templated,
|
|
2363
|
+
memory: mergeMemoryPlan({
|
|
2364
|
+
enabled: true,
|
|
2365
|
+
useWorkspaceHistory: true,
|
|
2366
|
+
useNetworkPatterns: false,
|
|
2367
|
+
privacyMode: "anonymized_patterns",
|
|
2368
|
+
queries: [{
|
|
2369
|
+
query: `${templated.strategyTemplate || "strategy-template"} campaign reply patterns, objections, qualification gates, and verified-email QA`,
|
|
2370
|
+
scopes: ["workspace", "operator_notes"],
|
|
2371
|
+
topK: 10,
|
|
2372
|
+
required: true,
|
|
2373
|
+
rationale: "Load approved private strategy and workflow patterns before campaign planning."
|
|
2374
|
+
}]
|
|
2375
|
+
}, input.memory),
|
|
2376
|
+
agencyContext: mergeAgencyContext({
|
|
2377
|
+
strategyModel: "strategy_template",
|
|
2378
|
+
includeStrategyPatterns: true,
|
|
2379
|
+
includeWorkflowPatterns: true,
|
|
2380
|
+
includeNangoCatalog: true,
|
|
2381
|
+
partnerEcosystem: input.includeNango === false ? ["signaliz"] : ["signaliz", "nango"]
|
|
2382
|
+
}, input.agencyContext),
|
|
2383
|
+
signalizDefaults: mergeSignalizDefaultOverrides({
|
|
2384
|
+
maxCredits: input.signalizDefaults?.maxCredits,
|
|
2385
|
+
delivery: {
|
|
2386
|
+
enabled: true,
|
|
2387
|
+
destinationType: input.signalizDefaults?.delivery?.destinationType ?? "json",
|
|
2388
|
+
approvalRequired: true
|
|
2389
|
+
}
|
|
2390
|
+
}, input.signalizDefaults),
|
|
2391
|
+
approvalPolicy: {
|
|
2392
|
+
requireHumanApproval: true,
|
|
2393
|
+
maxCreditsWithoutApproval: 0,
|
|
2394
|
+
requireApprovalFor: DEFAULT_CAMPAIGN_BUILDER_APPROVAL_TYPES,
|
|
2395
|
+
...input.approvalPolicy
|
|
2396
|
+
}
|
|
2397
|
+
});
|
|
2398
|
+
}
|
|
2399
|
+
function createCampaignBuilderBuildKit(input = {}) {
|
|
2400
|
+
const requestFile = input.requestFile || "campaign-request.json";
|
|
2401
|
+
const cliPackage = input.cliPackage || "@signaliz/cli";
|
|
2402
|
+
const sdkPackage = input.sdkPackage || "@signaliz/sdk";
|
|
2403
|
+
const request = createCampaignBuilderAgentRequestTemplate(input);
|
|
2404
|
+
const strategyTemplate = stringValue(request.strategyTemplate) ?? null;
|
|
2405
|
+
const builtIns = request.builtIns ?? DEFAULT_CAMPAIGN_BUILDER_BUILT_INS;
|
|
2406
|
+
const useLocalLeads = builtIns.includes("local_leads");
|
|
2407
|
+
const customRoutes = [
|
|
2408
|
+
...request.integrations ?? [],
|
|
2409
|
+
...routesFromCustomerTools(request.customerTools ?? [])
|
|
2410
|
+
].filter((route) => route.provider !== "signaliz");
|
|
2411
|
+
const strategyFlag = strategyTemplate ? ` --strategy-template ${shellArg(strategyTemplate)}` : "";
|
|
2412
|
+
const targetFlag = request.targetCount ? ` --target-count ${request.targetCount}` : "";
|
|
2413
|
+
const localLeadsFlag = useLocalLeads ? " --use-local-leads" : "";
|
|
2414
|
+
const cliBase = `npx ${cliPackage}`;
|
|
2415
|
+
const sdkCliBase = `npx ${sdkPackage}`;
|
|
2416
|
+
const brief = request.goal || "Build a strategy-template campaign for the target ICP.";
|
|
2417
|
+
const mcpArgs = campaignBuilderBuildKitMcpArgs(request);
|
|
2418
|
+
return {
|
|
2419
|
+
kit_version: "campaign-builder-kit.v1",
|
|
2420
|
+
source: "signaliz.campaignBuilderAgent.buildKit",
|
|
2421
|
+
request_file: requestFile,
|
|
2422
|
+
request,
|
|
2423
|
+
strategy_template: strategyTemplate,
|
|
2424
|
+
built_in_lanes: builtIns,
|
|
2425
|
+
operating_playbooks: getCampaignBuilderOperatingPlaybooksForRequest(request).map((playbook) => playbook.slug),
|
|
2426
|
+
custom_routes: customRoutes.map((route) => ({
|
|
2427
|
+
provider: String(route.provider),
|
|
2428
|
+
layer: String(route.layer),
|
|
2429
|
+
tool: firstNonEmptyString(route.toolName),
|
|
2430
|
+
mcp_server: firstNonEmptyString(route.mcpServerName),
|
|
2431
|
+
mode: route.mode ?? "if_available",
|
|
2432
|
+
approval_required: route.approvalRequired === true || route.mode === "required"
|
|
2433
|
+
})),
|
|
2434
|
+
approval_boundaries: request.approvalPolicy?.requireApprovalFor ?? DEFAULT_CAMPAIGN_BUILDER_APPROVAL_TYPES,
|
|
2435
|
+
byo_tool_pattern: {
|
|
2436
|
+
cli_flag: "--custom-tool provider:layer:tool[:mcp]",
|
|
2437
|
+
request_fragment: createCampaignBuilderToolRoute({
|
|
2438
|
+
provider: "workspace_mcp",
|
|
2439
|
+
layer: "enrichment",
|
|
2440
|
+
gtmLayers: ["company_enrichment"],
|
|
2441
|
+
toolName: "workspace_account_enrich",
|
|
2442
|
+
mcpServerName: "workspace-mcp",
|
|
2443
|
+
label: "Workspace account enrichment",
|
|
2444
|
+
mode: "required",
|
|
2445
|
+
approvalRequired: true
|
|
2446
|
+
})
|
|
2447
|
+
},
|
|
2448
|
+
cli_commands: [
|
|
2449
|
+
{
|
|
2450
|
+
id: "write_request",
|
|
2451
|
+
label: "Write reusable request JSON",
|
|
2452
|
+
command: `${cliBase} campaign-agent init${strategyFlag}${targetFlag}${localLeadsFlag} --output-file ${shellArg(requestFile)}`,
|
|
2453
|
+
safety: "local file only; no MCP calls, credits, provider writes, sender loads, exports, or sends"
|
|
2454
|
+
},
|
|
2455
|
+
{
|
|
2456
|
+
id: "proof_shortcut",
|
|
2457
|
+
label: "Run no-spend campaign-builder proof",
|
|
2458
|
+
command: `${cliBase} build ${shellArg(brief)}${strategyFlag}${targetFlag}${localLeadsFlag} --json`,
|
|
2459
|
+
safety: "strategy memory, Kernel plan, approvals, and forced build_campaign dry-run only"
|
|
2460
|
+
},
|
|
2461
|
+
{
|
|
2462
|
+
id: "plan",
|
|
2463
|
+
label: "Inspect the full campaign-agent plan",
|
|
2464
|
+
command: `${sdkCliBase} campaign-agent plan --request-file ${shellArg(requestFile)} --json`,
|
|
2465
|
+
safety: "read-only MCP planning and provider-route dry-runs"
|
|
2466
|
+
},
|
|
2467
|
+
{
|
|
2468
|
+
id: "doctor",
|
|
2469
|
+
label: "Check readiness gates",
|
|
2470
|
+
command: `${sdkCliBase} campaign-agent doctor --request-file ${shellArg(requestFile)} --json`,
|
|
2471
|
+
safety: "read-only readiness checks for Memory, Brain, built-ins, BYO routes, and approvals"
|
|
2472
|
+
},
|
|
2473
|
+
{
|
|
2474
|
+
id: "commit_preview",
|
|
2475
|
+
label: "Preview GTM campaign object commit",
|
|
2476
|
+
command: `${sdkCliBase} campaign-agent commit-plan --request-file ${shellArg(requestFile)} --json`,
|
|
2477
|
+
safety: "dry-run commit; writes only with --confirm-write and --approved-by"
|
|
2478
|
+
},
|
|
2479
|
+
{
|
|
2480
|
+
id: "approved_launch",
|
|
2481
|
+
label: "Launch after explicit approval",
|
|
2482
|
+
command: `${sdkCliBase} campaign-agent build-approved --request-file ${shellArg(requestFile)} --confirm-launch --approve-all --approved-by operator@example.com --spend-limit ${request.signalizDefaults?.maxCredits ?? 0} --json`,
|
|
2483
|
+
safety: "spendful path; requires human approval identity, approval types, and spend limit"
|
|
2484
|
+
}
|
|
2485
|
+
],
|
|
2486
|
+
mcp_calls: [
|
|
2487
|
+
{
|
|
2488
|
+
id: "request_template",
|
|
2489
|
+
tool: "gtm_campaign_agent_request_template",
|
|
2490
|
+
arguments: mcpArgs,
|
|
2491
|
+
safety: "read-only reusable request generation"
|
|
2492
|
+
},
|
|
2493
|
+
{
|
|
2494
|
+
id: "readiness",
|
|
2495
|
+
tool: "gtm_campaign_agent_readiness",
|
|
2496
|
+
arguments: mcpArgs,
|
|
2497
|
+
safety: "read-only preflight across strategy memory, Kernel plan, lanes, routes, and approvals"
|
|
2498
|
+
},
|
|
2499
|
+
{
|
|
2500
|
+
id: "proof",
|
|
2501
|
+
tool: "gtm_campaign_agent_proof",
|
|
2502
|
+
arguments: { ...mcpArgs, idempotency_key: "campaign-agent-proof-001" },
|
|
2503
|
+
safety: "forces build_campaign dry_run=true and confirm_spend=false"
|
|
2504
|
+
},
|
|
2505
|
+
{
|
|
2506
|
+
id: "plan",
|
|
2507
|
+
tool: "gtm_campaign_agent_plan",
|
|
2508
|
+
arguments: mcpArgs,
|
|
2509
|
+
safety: "read-only one-call campaign-agent runbook"
|
|
2510
|
+
},
|
|
2511
|
+
{
|
|
2512
|
+
id: "commit_preview",
|
|
2513
|
+
tool: "gtm_campaign_build_plan_commit",
|
|
2514
|
+
arguments: {
|
|
2515
|
+
name: request.campaignName,
|
|
2516
|
+
campaign_brief: request.goal,
|
|
2517
|
+
lead_count: request.targetCount,
|
|
2518
|
+
dry_run: true,
|
|
2519
|
+
confirm: false
|
|
2520
|
+
},
|
|
2521
|
+
safety: "dry-run commit preview only"
|
|
2522
|
+
}
|
|
2523
|
+
],
|
|
2524
|
+
sdk_example: {
|
|
2525
|
+
language: "typescript",
|
|
2526
|
+
code: campaignBuilderBuildKitSdkExample(request, requestFile)
|
|
2527
|
+
},
|
|
2528
|
+
verification: [
|
|
2529
|
+
`${cliBase} campaign-agent proof --request-file ${shellArg(requestFile)} --json`,
|
|
2530
|
+
`${cliBase} campaign-agent doctor --request-file ${shellArg(requestFile)} --json`,
|
|
2531
|
+
"Confirm proof.success is true and dry_run_result.status is dry_run before any approved launch.",
|
|
2532
|
+
"Confirm no campaign_build_id exists in a proof receipt before moving to approved launch."
|
|
2533
|
+
],
|
|
2534
|
+
privacy: {
|
|
2535
|
+
client_names_allowed: false,
|
|
2536
|
+
notes: [
|
|
2537
|
+
"Use strategy templates, operating playbooks, and anonymized workflow patterns instead of client names.",
|
|
2538
|
+
"Do not include raw leads, private replies, domains, secrets, or customer account labels in public kit output."
|
|
2539
|
+
]
|
|
2540
|
+
},
|
|
2541
|
+
next_actions: [
|
|
2542
|
+
`Write or review ${requestFile}.`,
|
|
2543
|
+
"Run the proof command before spending credits or activating provider writes.",
|
|
2544
|
+
"Add BYO integrations with --custom-tool provider:layer:tool[:mcp] or the request_fragment shape.",
|
|
2545
|
+
"Use build-approved only after human approval, spend limit, and delivery review policy are set."
|
|
2546
|
+
]
|
|
2547
|
+
};
|
|
2548
|
+
}
|
|
2549
|
+
function createCampaignBuilderToolRoute(input) {
|
|
2550
|
+
return {
|
|
2551
|
+
provider: input.provider ?? "custom_mcp",
|
|
2552
|
+
layer: input.layer,
|
|
2553
|
+
toolName: input.toolName,
|
|
2554
|
+
mcpServerName: input.mcpServerName,
|
|
2555
|
+
label: input.label,
|
|
2556
|
+
mode: input.mode ?? "if_available",
|
|
2557
|
+
gtmLayer: input.gtmLayer,
|
|
2558
|
+
gtmLayers: input.gtmLayers,
|
|
2559
|
+
approvalRequired: input.approvalRequired ?? input.mode === "required",
|
|
2560
|
+
config: input.config,
|
|
2561
|
+
rationale: `${input.label ?? input.provider ?? "Custom tool"} is a user-provided campaign-builder route for ${input.layer}.`
|
|
2562
|
+
};
|
|
2563
|
+
}
|
|
2564
|
+
function campaignBuilderBuildKitMcpArgs(request) {
|
|
2565
|
+
return compact({
|
|
2566
|
+
goal: request.goal,
|
|
2567
|
+
campaign_brief: request.goal,
|
|
2568
|
+
campaign_name: request.campaignName,
|
|
2569
|
+
account_label: request.accountLabel,
|
|
2570
|
+
account_context: request.accountContext,
|
|
2571
|
+
strategy_template: request.strategyTemplate,
|
|
2572
|
+
operating_playbooks: request.operatingPlaybooks,
|
|
2573
|
+
target_icp: request.icp,
|
|
2574
|
+
target_count: request.targetCount,
|
|
2575
|
+
builtins: request.builtIns,
|
|
2576
|
+
include_local_leads: request.builtIns?.includes("local_leads") || void 0,
|
|
2577
|
+
preferred_providers: request.preferredProviders,
|
|
2578
|
+
custom_tools: request.integrations?.map((route) => compact({
|
|
2579
|
+
provider: route.provider,
|
|
2580
|
+
layer: route.layer,
|
|
2581
|
+
gtm_layers: route.gtmLayers ?? (route.gtmLayer ? [route.gtmLayer] : void 0),
|
|
2582
|
+
tool: route.toolName,
|
|
2583
|
+
mcp: route.mcpServerName,
|
|
2584
|
+
mode: route.mode,
|
|
2585
|
+
approval_required: route.approvalRequired
|
|
2586
|
+
})),
|
|
2587
|
+
include_nango_catalog: request.agencyContext?.includeNangoCatalog,
|
|
2588
|
+
include_memory: request.memory?.enabled,
|
|
2589
|
+
include_brain: true,
|
|
2590
|
+
include_provider_routes: true,
|
|
2591
|
+
include_delivery_risk: true
|
|
2592
|
+
});
|
|
2593
|
+
}
|
|
2594
|
+
function campaignBuilderBuildKitSdkExample(request, requestFile) {
|
|
2595
|
+
const proofRequest = {
|
|
2596
|
+
goal: request.goal,
|
|
2597
|
+
strategyTemplate: request.strategyTemplate,
|
|
2598
|
+
targetCount: request.targetCount,
|
|
2599
|
+
builtIns: request.builtIns,
|
|
2600
|
+
integrations: request.integrations
|
|
2601
|
+
};
|
|
2602
|
+
return [
|
|
2603
|
+
"import { Signaliz, createCampaignBuilderBuildKit } from '@signaliz/sdk';",
|
|
2604
|
+
"",
|
|
2605
|
+
`const kit = createCampaignBuilderBuildKit({ requestFile: ${JSON.stringify(requestFile)}, ...${JSON.stringify(proofRequest, null, 2)} });`,
|
|
2606
|
+
"console.log(kit.cli_commands.find((command) => command.id === 'proof_shortcut')?.command);",
|
|
2607
|
+
"",
|
|
2608
|
+
"const signaliz = new Signaliz({ apiKey: process.env.SIGNALIZ_API_KEY! });",
|
|
2609
|
+
"const proof = await signaliz.campaignBuilderAgent.proof(kit.request, {",
|
|
2610
|
+
" idempotencyKey: `campaign-agent-proof-${Date.now()}`,",
|
|
2611
|
+
"});",
|
|
2612
|
+
"",
|
|
2613
|
+
'if (!proof.success || proof.dry_run_result?.status !== "dry_run") {',
|
|
2614
|
+
" throw new Error('Campaign proof failed or launched work unexpectedly');",
|
|
2615
|
+
"}"
|
|
2616
|
+
].join("\n");
|
|
2617
|
+
}
|
|
2618
|
+
function shellArg(value) {
|
|
2619
|
+
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
2620
|
+
}
|
|
2236
2621
|
function normalizeTemplateKey(value) {
|
|
2237
2622
|
return String(value || "").trim().toLowerCase().replace(/[_\s]+/g, "-");
|
|
2238
2623
|
}
|
|
@@ -3507,6 +3892,72 @@ function campaignReadinessNextActions(plan, ready, customRouteCount) {
|
|
|
3507
3892
|
];
|
|
3508
3893
|
return actions.filter((item) => Boolean(item));
|
|
3509
3894
|
}
|
|
3895
|
+
function campaignBuilderProofStrategyTemplate(plan) {
|
|
3896
|
+
const buildRequest = asRecord(plan.buildRequest);
|
|
3897
|
+
const strategyMemory = asRecord(plan.strategyMemoryStatus);
|
|
3898
|
+
const statusTemplate = strategyMemory.strategy_template ?? strategyMemory.strategyTemplate;
|
|
3899
|
+
const statusTemplateRecord = asRecord(statusTemplate);
|
|
3900
|
+
const flowTemplate = plan.mcpFlow.map((step) => asRecord(step.arguments).strategy_template ?? asRecord(step.arguments).strategyTemplate).find((value) => typeof value === "string" && value.trim());
|
|
3901
|
+
return firstNonEmptyString(
|
|
3902
|
+
buildRequest.strategyTemplate,
|
|
3903
|
+
buildRequest.strategy_template,
|
|
3904
|
+
statusTemplate,
|
|
3905
|
+
statusTemplateRecord.slug,
|
|
3906
|
+
statusTemplateRecord.id,
|
|
3907
|
+
flowTemplate
|
|
3908
|
+
);
|
|
3909
|
+
}
|
|
3910
|
+
function summarizeCampaignBuilderProofStrategyMemory(strategyMemory) {
|
|
3911
|
+
if (Object.keys(strategyMemory).length === 0) return { ready: false };
|
|
3912
|
+
const template = strategyMemory.strategy_template ?? strategyMemory.strategyTemplate;
|
|
3913
|
+
const templateRecord = asRecord(template);
|
|
3914
|
+
const coverage = asRecord(strategyMemory.coverage);
|
|
3915
|
+
const rawSourceGroups = Array.isArray(strategyMemory.source_groups) ? strategyMemory.source_groups : Array.isArray(strategyMemory.sourceGroups) ? strategyMemory.sourceGroups : [];
|
|
3916
|
+
const sourceGroups = rawSourceGroups.map((group) => {
|
|
3917
|
+
const sourceGroup = asRecord(group);
|
|
3918
|
+
return {
|
|
3919
|
+
id: sourceGroup.id ?? null,
|
|
3920
|
+
required: sourceGroup.required ?? null,
|
|
3921
|
+
ready: sourceGroup.ready ?? null,
|
|
3922
|
+
counts: asRecord(sourceGroup.counts)
|
|
3923
|
+
};
|
|
3924
|
+
});
|
|
3925
|
+
return {
|
|
3926
|
+
ready: strategyMemory.ready ?? null,
|
|
3927
|
+
read_only: strategyMemory.read_only ?? strategyMemory.readOnly ?? null,
|
|
3928
|
+
source_tool: firstNonEmptyString(strategyMemory.source_tool, strategyMemory.sourceTool),
|
|
3929
|
+
strategy_template: {
|
|
3930
|
+
slug: firstNonEmptyString(template, templateRecord.slug, templateRecord.id),
|
|
3931
|
+
label: firstNonEmptyString(templateRecord.label)
|
|
3932
|
+
},
|
|
3933
|
+
coverage: {
|
|
3934
|
+
required_groups_ready: coverage.required_groups_ready ?? coverage.requiredGroupsReady ?? null,
|
|
3935
|
+
required_groups_total: coverage.required_groups_total ?? coverage.requiredGroupsTotal ?? null,
|
|
3936
|
+
source_groups_ready: coverage.source_groups_ready ?? coverage.sourceGroupsReady ?? null,
|
|
3937
|
+
source_groups_total: coverage.source_groups_total ?? coverage.sourceGroupsTotal ?? null,
|
|
3938
|
+
knowledge_docs: coverage.knowledge_docs ?? coverage.knowledgeDocs ?? null,
|
|
3939
|
+
memories: coverage.memories ?? null
|
|
3940
|
+
},
|
|
3941
|
+
source_groups: sourceGroups,
|
|
3942
|
+
blocker_count: Array.isArray(strategyMemory.blockers) ? strategyMemory.blockers.length : 0,
|
|
3943
|
+
warning_count: Array.isArray(strategyMemory.warnings) ? strategyMemory.warnings.length : 0
|
|
3944
|
+
};
|
|
3945
|
+
}
|
|
3946
|
+
function summarizeCampaignBuilderProofDryRun(dryRunResult) {
|
|
3947
|
+
return {
|
|
3948
|
+
dryRun: dryRunResult.dryRun ?? dryRunResult.dry_run ?? null,
|
|
3949
|
+
status: dryRunResult.status ?? null,
|
|
3950
|
+
currentPhase: dryRunResult.currentPhase ?? dryRunResult.current_phase ?? null,
|
|
3951
|
+
campaignBuildId: dryRunResult.campaignBuildId ?? dryRunResult.campaign_build_id ?? null,
|
|
3952
|
+
plannedTargetCount: dryRunResult.plannedTargetCount ?? dryRunResult.planned_target_count ?? null
|
|
3953
|
+
};
|
|
3954
|
+
}
|
|
3955
|
+
function firstNonEmptyString(...values) {
|
|
3956
|
+
for (const value of values) {
|
|
3957
|
+
if (typeof value === "string" && value.trim()) return value;
|
|
3958
|
+
}
|
|
3959
|
+
return null;
|
|
3960
|
+
}
|
|
3510
3961
|
function diagnosticMessages2(value) {
|
|
3511
3962
|
if (!Array.isArray(value)) return [];
|
|
3512
3963
|
return value.map((item) => {
|
package/dist/mcp-config.mjs
CHANGED