@signaliz/sdk 1.0.14 → 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 +15 -0
- package/dist/{chunk-EVFQETTN.mjs → chunk-6OZWMAV3.mjs} +211 -0
- package/dist/cli.js +264 -2
- package/dist/cli.mjs +57 -4
- package/dist/index.d.mts +54 -1
- package/dist/index.d.ts +54 -1
- package/dist/index.js +212 -0
- package/dist/index.mjs +3 -1
- package/dist/mcp-config.js +312 -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",
|
|
@@ -1728,6 +1736,9 @@ var CampaignBuilderAgent = class {
|
|
|
1728
1736
|
});
|
|
1729
1737
|
return createCampaignBuilderProofReceipt(plan, result);
|
|
1730
1738
|
}
|
|
1739
|
+
buildKit(options = {}) {
|
|
1740
|
+
return createCampaignBuilderBuildKit(options);
|
|
1741
|
+
}
|
|
1731
1742
|
async commitPlan(plan, options = {}) {
|
|
1732
1743
|
const writeMode = options.confirm === true && options.dryRun === false;
|
|
1733
1744
|
if (writeMode && !options.approvedBy) {
|
|
@@ -2306,6 +2317,307 @@ function applyCampaignBuilderStrategyTemplate(request) {
|
|
|
2306
2317
|
agencyContext: mergeAgencyContext(template.agencyContext, request.agencyContext)
|
|
2307
2318
|
};
|
|
2308
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
|
+
}
|
|
2309
2621
|
function normalizeTemplateKey(value) {
|
|
2310
2622
|
return String(value || "").trim().toLowerCase().replace(/[_\s]+/g, "-");
|
|
2311
2623
|
}
|
package/dist/mcp-config.mjs
CHANGED