@signaliz/sdk 1.0.20 → 1.0.22
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 +39 -706
- package/dist/chunk-UBQDPJGW.mjs +593 -0
- package/dist/index.d.mts +81 -4754
- package/dist/index.d.ts +81 -4754
- package/dist/index.js +188 -9744
- package/dist/index.mjs +3 -59
- package/dist/mcp-config.js +191 -9684
- package/dist/mcp-config.mjs +6 -6
- package/package.json +5 -6
- package/dist/chunk-PBJFIO72.mjs +0 -10121
- package/dist/cli.d.mts +0 -1
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +0 -11954
- package/dist/cli.mjs +0 -1694
package/dist/cli.mjs
DELETED
|
@@ -1,1694 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/cli.ts
|
|
4
|
-
import { readFileSync, writeFileSync } from "fs";
|
|
5
|
-
var apiKey = process.env.SIGNALIZ_API_KEY;
|
|
6
|
-
var baseUrl = process.env.SIGNALIZ_BASE_URL || process.env.SIGNALIZ_API_URL;
|
|
7
|
-
var sdkModulePromise;
|
|
8
|
-
function loadSdk() {
|
|
9
|
-
sdkModulePromise ?? (sdkModulePromise = import("./index.mjs"));
|
|
10
|
-
return sdkModulePromise;
|
|
11
|
-
}
|
|
12
|
-
async function createSignalizClient() {
|
|
13
|
-
const { Signaliz } = await loadSdk();
|
|
14
|
-
return new Signaliz({ apiKey: apiKey || "offline", baseUrl });
|
|
15
|
-
}
|
|
16
|
-
async function main() {
|
|
17
|
-
const command = process.argv[2];
|
|
18
|
-
if (!command || command === "help" || command === "--help" || command === "-h") {
|
|
19
|
-
printHelp();
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const offlineCampaignAgentTemplate = (command === "campaign-agent" || command === "campaign-builder") && ["init", "template", "request-template", "new", "kit", "build-kit", "blueprint", "memory-kit", "seed-kit", "memory"].includes(String(process.argv[3] || ""));
|
|
23
|
-
if (!apiKey && !offlineCampaignAgentTemplate) {
|
|
24
|
-
console.error("\u274C SIGNALIZ_API_KEY environment variable is required.");
|
|
25
|
-
console.error(" Set it with: export SIGNALIZ_API_KEY=sk_...");
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
switch (command) {
|
|
29
|
-
case "test": {
|
|
30
|
-
const signaliz = await createSignalizClient();
|
|
31
|
-
try {
|
|
32
|
-
const ws = await signaliz.getWorkspace();
|
|
33
|
-
console.log(`\u2705 Connected to workspace: ${ws.name} (${ws.creditsRemaining.toLocaleString()} credits remaining)`);
|
|
34
|
-
} catch (e) {
|
|
35
|
-
console.error(`\u274C Connection failed: ${e.message}`);
|
|
36
|
-
process.exit(1);
|
|
37
|
-
}
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
case "tools": {
|
|
41
|
-
const signaliz = await createSignalizClient();
|
|
42
|
-
try {
|
|
43
|
-
const tools = await signaliz.listTools();
|
|
44
|
-
console.log(`
|
|
45
|
-
\u{1F4CB} Available tools (${tools.length}):
|
|
46
|
-
`);
|
|
47
|
-
console.log("Name".padEnd(40) + "Category".padEnd(15) + "Credits".padEnd(10) + "Description");
|
|
48
|
-
console.log("\u2500".repeat(100));
|
|
49
|
-
for (const t of tools) {
|
|
50
|
-
console.log(
|
|
51
|
-
(t.name ?? "").padEnd(40) + (t.category ?? "-").padEnd(15) + String(t.costCredits ?? "-").padEnd(10) + (t.description ?? "").slice(0, 60)
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
} catch (e) {
|
|
55
|
-
console.error(`\u274C Failed to list tools: ${e.message}`);
|
|
56
|
-
process.exit(1);
|
|
57
|
-
}
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
case "gtm": {
|
|
61
|
-
const signaliz = await createSignalizClient();
|
|
62
|
-
await handleGtmCommand(signaliz, process.argv.slice(3));
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
case "public-data":
|
|
66
|
-
case "ground-truth":
|
|
67
|
-
case "public-ground-truth": {
|
|
68
|
-
const signaliz = await createSignalizClient();
|
|
69
|
-
await handlePublicGroundTruthCommand(signaliz, process.argv.slice(3));
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
case "campaign-agent":
|
|
73
|
-
case "campaign-builder": {
|
|
74
|
-
await handleCampaignAgentCommand(createSignalizClient, process.argv.slice(3));
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
default:
|
|
78
|
-
printHelp();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
async function handlePublicGroundTruthCommand(signaliz, argv) {
|
|
82
|
-
const subcommand = argv[0] && !argv[0].startsWith("--") ? argv[0] : "search";
|
|
83
|
-
if (!subcommand || subcommand === "help" || subcommand === "--help" || subcommand === "-h") {
|
|
84
|
-
printPublicGroundTruthHelp();
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
if (subcommand === "sources" || subcommand === "list-sources") {
|
|
88
|
-
const flags2 = parseFlags(argv.slice(subcommand === argv[0] ? 1 : 0));
|
|
89
|
-
const result2 = await signaliz.publicGroundTruth.listSources({
|
|
90
|
-
query: stringFlag(flags2, "query", "q", "search"),
|
|
91
|
-
status: stringFlag(flags2, "status"),
|
|
92
|
-
limit: numberFlag(flags2, "limit")
|
|
93
|
-
});
|
|
94
|
-
if (booleanFlag(flags2, "json")) {
|
|
95
|
-
printJson(result2);
|
|
96
|
-
} else {
|
|
97
|
-
printPublicGroundTruthSources(result2);
|
|
98
|
-
}
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
if (subcommand !== "search") {
|
|
102
|
-
throw new Error(`Unknown public-data command: ${subcommand}`);
|
|
103
|
-
}
|
|
104
|
-
const flags = parseFlags(argv.slice(subcommand === argv[0] ? 1 : 0));
|
|
105
|
-
const query = stringFlag(flags, "query", "q", "search");
|
|
106
|
-
const sourceId = stringFlag(flags, "source-id", "sourceId");
|
|
107
|
-
const entityType = stringFlag(flags, "entity-type", "entityType");
|
|
108
|
-
const filters = publicGroundTruthFiltersFromFlags(flags);
|
|
109
|
-
if (!query && !sourceId && !entityType && Object.keys(filters).length === 0) {
|
|
110
|
-
throw new Error("public-data search requires --query or at least one filter");
|
|
111
|
-
}
|
|
112
|
-
const result = await signaliz.publicGroundTruth.search({
|
|
113
|
-
query,
|
|
114
|
-
sourceId,
|
|
115
|
-
entityType,
|
|
116
|
-
...filters,
|
|
117
|
-
limit: numberFlag(flags, "limit"),
|
|
118
|
-
offset: numberFlag(flags, "offset")
|
|
119
|
-
});
|
|
120
|
-
if (booleanFlag(flags, "json")) {
|
|
121
|
-
printJson(result);
|
|
122
|
-
} else {
|
|
123
|
-
printPublicGroundTruthSearch(result);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
async function handleGtmCommand(signaliz, argv) {
|
|
127
|
-
const subcommand = argv[0];
|
|
128
|
-
if (!subcommand || subcommand === "help" || subcommand === "--help" || subcommand === "-h") {
|
|
129
|
-
printGtmHelp();
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
if (subcommand === "context") {
|
|
133
|
-
const flags = parseFlags(argv.slice(1));
|
|
134
|
-
const result = await signaliz.gtm.context({
|
|
135
|
-
includeCampaigns: booleanFlag(flags, "include-campaigns"),
|
|
136
|
-
includeMemory: booleanFlag(flags, "include-memory"),
|
|
137
|
-
includeBrain: booleanFlag(flags, "include-brain"),
|
|
138
|
-
includeConnections: booleanFlag(flags, "include-connections"),
|
|
139
|
-
limit: numberFlag(flags, "limit")
|
|
140
|
-
});
|
|
141
|
-
printResult(result, flags);
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
if (subcommand === "bootstrap") {
|
|
145
|
-
const flags = parseFlags(argv.slice(1));
|
|
146
|
-
const result = await signaliz.gtm.bootstrapStatus({
|
|
147
|
-
campaignId: stringFlag(flags, "campaign-id"),
|
|
148
|
-
days: numberFlag(flags, "days"),
|
|
149
|
-
minSampleSize: numberFlag(flags, "min-sample-size"),
|
|
150
|
-
includeConnections: booleanFlag(flags, "include-connections"),
|
|
151
|
-
includeSamples: booleanFlag(flags, "include-samples"),
|
|
152
|
-
limit: numberFlag(flags, "limit")
|
|
153
|
-
});
|
|
154
|
-
printResult(result, flags);
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
if (subcommand === "memory" && argv[1] === "search") {
|
|
158
|
-
const flags = parseFlags(argv.slice(2));
|
|
159
|
-
const query = stringFlag(flags, "query", "q");
|
|
160
|
-
if (!query) throw new Error("gtm memory search requires --query");
|
|
161
|
-
const options = {
|
|
162
|
-
query,
|
|
163
|
-
campaignId: stringFlag(flags, "campaign-id"),
|
|
164
|
-
memoryType: stringFlag(flags, "memory-type"),
|
|
165
|
-
keywords: csvFlag(flags, "keywords"),
|
|
166
|
-
outcomeType: stringFlag(flags, "outcome-type"),
|
|
167
|
-
layers: csvFlag(flags, "layers"),
|
|
168
|
-
providerChain: csvFlag(flags, "provider-chain", "providers"),
|
|
169
|
-
days: numberFlag(flags, "days"),
|
|
170
|
-
limit: numberFlag(flags, "limit")
|
|
171
|
-
};
|
|
172
|
-
const result = await signaliz.gtm.searchMemory(options);
|
|
173
|
-
printResult(result, flags);
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
if (subcommand === "learning" && argv[1] === "status" || subcommand === "learning-status") {
|
|
177
|
-
const flags = parseFlags(argv.slice(subcommand === "learning" ? 2 : 1));
|
|
178
|
-
const campaignId = stringFlag(flags, "campaign-id");
|
|
179
|
-
const campaignBuildId = stringFlag(flags, "campaign-build-id", "build-id");
|
|
180
|
-
if (!campaignId && !campaignBuildId) {
|
|
181
|
-
throw new Error("gtm learning status requires --campaign-id or --campaign-build-id");
|
|
182
|
-
}
|
|
183
|
-
const result = await signaliz.gtm.campaignLearningStatus({
|
|
184
|
-
campaignId,
|
|
185
|
-
campaignBuildId,
|
|
186
|
-
days: numberFlag(flags, "days"),
|
|
187
|
-
networkDays: numberFlag(flags, "network-days"),
|
|
188
|
-
minSampleSize: numberFlag(flags, "min-sample-size"),
|
|
189
|
-
minWorkspaceCount: numberFlag(flags, "min-workspace-count"),
|
|
190
|
-
minPrivacyK: numberFlag(flags, "min-privacy-k"),
|
|
191
|
-
includeMemory: !booleanFlag(flags, "no-memory"),
|
|
192
|
-
includeNetwork: !booleanFlag(flags, "no-network"),
|
|
193
|
-
writeMode: stringFlag(flags, "write-mode"),
|
|
194
|
-
limit: numberFlag(flags, "limit")
|
|
195
|
-
});
|
|
196
|
-
printResult(result, flags);
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
if (subcommand === "feedback") {
|
|
200
|
-
const feedbackCommand = argv[1];
|
|
201
|
-
if (!feedbackCommand || feedbackCommand === "help" || feedbackCommand === "--help" || feedbackCommand === "-h") {
|
|
202
|
-
printGtmHelp();
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
if (feedbackCommand === "instantly-pull" || feedbackCommand === "pull-instantly") {
|
|
206
|
-
const flags = parseFlags(argv.slice(2));
|
|
207
|
-
const confirmWrite = booleanFlag(flags, "confirm-write");
|
|
208
|
-
const input = {
|
|
209
|
-
source: stringFlag(flags, "source", "pull-source"),
|
|
210
|
-
instantlyProfile: stringFlag(flags, "instantly-profile", "profile"),
|
|
211
|
-
campaignId: stringFlag(flags, "campaign-id"),
|
|
212
|
-
campaignBuildId: stringFlag(flags, "campaign-build-id", "build-id"),
|
|
213
|
-
providerLinkId: stringFlag(flags, "provider-link-id"),
|
|
214
|
-
providerCampaignId: stringFlag(flags, "provider-campaign-id", "instantly-campaign-id"),
|
|
215
|
-
instantlyCampaignId: stringFlag(flags, "instantly-campaign-id"),
|
|
216
|
-
integrationId: stringFlag(flags, "integration-id"),
|
|
217
|
-
cursor: stringFlag(flags, "cursor"),
|
|
218
|
-
from: stringFlag(flags, "from", "since"),
|
|
219
|
-
to: stringFlag(flags, "to", "until"),
|
|
220
|
-
limit: numberFlag(flags, "limit"),
|
|
221
|
-
maxPages: numberFlag(flags, "max-pages"),
|
|
222
|
-
emailType: stringFlag(flags, "email-type"),
|
|
223
|
-
mode: stringFlag(flags, "mode"),
|
|
224
|
-
sortOrder: stringFlag(flags, "sort-order"),
|
|
225
|
-
createMemory: !booleanFlag(flags, "no-create-memory"),
|
|
226
|
-
writeRoutineOutcomes: !booleanFlag(flags, "no-routine-outcomes"),
|
|
227
|
-
dryRun: !confirmWrite || booleanFlag(flags, "dry-run"),
|
|
228
|
-
runBrainCycle: optionalBooleanFlag(flags, "run-brain-cycle", "no-brain-cycle"),
|
|
229
|
-
brainCycleWriteMode: stringFlag(flags, "brain-cycle-write-mode", "write-mode"),
|
|
230
|
-
brainCyclePhases: csvFlag(flags, "brain-cycle-phases", "phases"),
|
|
231
|
-
brainCycleMinIngested: numberFlag(flags, "brain-cycle-min-ingested"),
|
|
232
|
-
brainCycleMinIntervalMinutes: numberFlag(flags, "brain-cycle-min-interval-minutes")
|
|
233
|
-
};
|
|
234
|
-
if (input.dryRun === false && !input.campaignId && !input.campaignBuildId && !input.providerLinkId && !input.providerCampaignId) {
|
|
235
|
-
throw new Error("gtm feedback instantly-pull --confirm-write requires --campaign-id, --campaign-build-id, --provider-link-id, or --provider-campaign-id");
|
|
236
|
-
}
|
|
237
|
-
const result = await signaliz.gtm.pullInstantlyFeedback(input);
|
|
238
|
-
printResult({
|
|
239
|
-
...asRecord(result),
|
|
240
|
-
cli_policy: input.dryRun ? "CLI defaulted to dry_run. Re-run with --confirm-write to write feedback, memory, cursors, and optional Brain-cycle dispatch." : "Confirmed internal write: feedback/memory/cursor writes are enabled for this pull."
|
|
241
|
-
}, flags);
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
if (feedbackCommand === "instantly-webhook-prepare" || feedbackCommand === "prepare-instantly-webhook") {
|
|
245
|
-
const flags = parseFlags(argv.slice(2));
|
|
246
|
-
if (!booleanFlag(flags, "confirm-write")) {
|
|
247
|
-
throw new Error("gtm feedback instantly-webhook-prepare writes provider-link webhook metadata; pass --confirm-write after review");
|
|
248
|
-
}
|
|
249
|
-
const input = {
|
|
250
|
-
campaignId: stringFlag(flags, "campaign-id"),
|
|
251
|
-
campaignBuildId: stringFlag(flags, "campaign-build-id", "build-id"),
|
|
252
|
-
providerLinkId: stringFlag(flags, "provider-link-id"),
|
|
253
|
-
providerCampaignId: stringFlag(flags, "provider-campaign-id", "instantly-campaign-id"),
|
|
254
|
-
instantlyCampaignId: stringFlag(flags, "instantly-campaign-id"),
|
|
255
|
-
integrationId: stringFlag(flags, "integration-id"),
|
|
256
|
-
providerWorkspaceId: stringFlag(flags, "provider-workspace-id"),
|
|
257
|
-
providerAccountId: stringFlag(flags, "provider-account-id"),
|
|
258
|
-
rotateSecret: booleanFlag(flags, "rotate-secret"),
|
|
259
|
-
runBrainCycle: optionalBooleanFlag(flags, "run-brain-cycle", "no-brain-cycle"),
|
|
260
|
-
brainCycleWriteMode: stringFlag(flags, "brain-cycle-write-mode", "write-mode"),
|
|
261
|
-
brainCyclePhases: csvFlag(flags, "brain-cycle-phases", "phases"),
|
|
262
|
-
brainCycleMinIngested: numberFlag(flags, "brain-cycle-min-ingested"),
|
|
263
|
-
brainCycleMinIntervalMinutes: numberFlag(flags, "brain-cycle-min-interval-minutes")
|
|
264
|
-
};
|
|
265
|
-
const result = await signaliz.gtm.prepareInstantlyFeedbackWebhook(input);
|
|
266
|
-
printResult(result, flags);
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
throw new Error(`Unknown gtm feedback command "${feedbackCommand}". Use instantly-pull or instantly-webhook-prepare.`);
|
|
270
|
-
}
|
|
271
|
-
if (subcommand === "templates" || subcommand === "strategy-templates") {
|
|
272
|
-
const flags = parseFlags(argv.slice(1));
|
|
273
|
-
const result = await signaliz.gtm.campaignStrategyTemplates({
|
|
274
|
-
strategyTemplate: stringFlag(flags, "strategy-template", "template"),
|
|
275
|
-
query: stringFlag(flags, "query", "q"),
|
|
276
|
-
includeDetails: !booleanFlag(flags, "summary")
|
|
277
|
-
});
|
|
278
|
-
printResult(result, flags);
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
if (subcommand === "start-context" || subcommand === "start") {
|
|
282
|
-
const flags = parseFlags(argv.slice(1));
|
|
283
|
-
const campaignBrief = stringFlag(flags, "brief", "campaign-brief", "goal");
|
|
284
|
-
const strategyTemplate = stringFlag(flags, "strategy-template", "template");
|
|
285
|
-
const targetIcp = jsonObjectFlag(flags, "target-icp", "icp");
|
|
286
|
-
if (!campaignBrief && !stringFlag(flags, "campaign-id") && !stringFlag(flags, "campaign-build-id") && !strategyTemplate && !targetIcp) {
|
|
287
|
-
throw new Error("gtm start-context requires --brief, --campaign-id, --campaign-build-id, --strategy-template, or --target-icp");
|
|
288
|
-
}
|
|
289
|
-
const input = {
|
|
290
|
-
campaignId: stringFlag(flags, "campaign-id"),
|
|
291
|
-
campaignBuildId: stringFlag(flags, "campaign-build-id"),
|
|
292
|
-
campaignBrief,
|
|
293
|
-
strategyTemplate,
|
|
294
|
-
targetIcp,
|
|
295
|
-
leadCount: numberFlag(flags, "lead-count", "target-count"),
|
|
296
|
-
layers: csvFlag(flags, "layers"),
|
|
297
|
-
preferredProviders: csvFlag(flags, "preferred-providers", "providers"),
|
|
298
|
-
memoryDimensionFilters: jsonObjectFlag(flags, "memory-dimension-filters"),
|
|
299
|
-
requireMemoryDimensionMatch: booleanFlag(flags, "require-memory-dimension-match"),
|
|
300
|
-
includeMemory: booleanFlag(flags, "include-memory", true),
|
|
301
|
-
includeBrain: booleanFlag(flags, "include-brain", true),
|
|
302
|
-
includeProviderRoutes: booleanFlag(flags, "include-provider-routes", true),
|
|
303
|
-
includeFailurePatterns: booleanFlag(flags, "include-failure-patterns", true),
|
|
304
|
-
includeDeliveryRisk: booleanFlag(flags, "include-delivery-risk", true),
|
|
305
|
-
includeGlobalBrain: booleanFlag(flags, "include-global-brain", true),
|
|
306
|
-
includePlannedProviders: booleanFlag(flags, "include-planned-providers", true),
|
|
307
|
-
days: numberFlag(flags, "days"),
|
|
308
|
-
minConfidence: numberFlag(flags, "min-confidence"),
|
|
309
|
-
minSampleSize: numberFlag(flags, "min-sample-size"),
|
|
310
|
-
limit: numberFlag(flags, "limit")
|
|
311
|
-
};
|
|
312
|
-
const result = await signaliz.gtm.campaignStartContext(input);
|
|
313
|
-
printResult(result, flags);
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
if (subcommand === "strategy-memory" || subcommand === "memory-status" || subcommand === "strategy-memory-status") {
|
|
317
|
-
const flags = parseFlags(argv.slice(1));
|
|
318
|
-
const input = {
|
|
319
|
-
strategyTemplate: stringFlag(flags, "strategy-template", "template"),
|
|
320
|
-
query: stringFlag(flags, "query", "goal", "q"),
|
|
321
|
-
campaignBrief: stringFlag(flags, "brief", "campaign-brief"),
|
|
322
|
-
targetIcp: jsonObjectFlag(flags, "target-icp", "icp"),
|
|
323
|
-
memoryDimensionFilters: jsonObjectFlag(flags, "memory-dimension-filters"),
|
|
324
|
-
requireMemoryDimensionMatch: booleanFlag(flags, "require-memory-dimension-match"),
|
|
325
|
-
includeSamples: booleanFlag(flags, "include-samples"),
|
|
326
|
-
includeSources: !booleanFlag(flags, "no-sources"),
|
|
327
|
-
days: numberFlag(flags, "days"),
|
|
328
|
-
limit: numberFlag(flags, "limit")
|
|
329
|
-
};
|
|
330
|
-
const result = await signaliz.gtm.campaignStrategyMemoryStatus(input);
|
|
331
|
-
printResult(result, flags);
|
|
332
|
-
return;
|
|
333
|
-
}
|
|
334
|
-
if (subcommand === "plan") {
|
|
335
|
-
const flags = parseFlags(argv.slice(1));
|
|
336
|
-
const campaignBrief = stringFlag(flags, "brief", "campaign-brief", "goal");
|
|
337
|
-
if (!campaignBrief && !stringFlag(flags, "campaign-id") && !stringFlag(flags, "campaign-build-id")) {
|
|
338
|
-
throw new Error("gtm plan requires --brief, --campaign-id, or --campaign-build-id");
|
|
339
|
-
}
|
|
340
|
-
const input = {
|
|
341
|
-
campaignId: stringFlag(flags, "campaign-id"),
|
|
342
|
-
campaignBuildId: stringFlag(flags, "campaign-build-id"),
|
|
343
|
-
campaignBrief,
|
|
344
|
-
strategyTemplate: stringFlag(flags, "strategy-template", "template"),
|
|
345
|
-
targetIcp: jsonObjectFlag(flags, "target-icp", "icp"),
|
|
346
|
-
leadCount: numberFlag(flags, "lead-count", "target-count"),
|
|
347
|
-
layers: csvFlag(flags, "layers"),
|
|
348
|
-
preferredProviders: csvFlag(flags, "preferred-providers", "providers"),
|
|
349
|
-
strategyModel: stringFlag(flags, "strategy-model"),
|
|
350
|
-
includeStrategyPatterns: !booleanFlag(flags, "no-strategy-patterns") && !booleanFlag(flags, "no-agency-patterns"),
|
|
351
|
-
includeWorkflowPatterns: !booleanFlag(flags, "no-workflow-patterns") && !booleanFlag(flags, "no-clay-patterns"),
|
|
352
|
-
includeNangoCatalog: !booleanFlag(flags, "no-nango-catalog"),
|
|
353
|
-
partnerEcosystem: csvFlag(flags, "partner-ecosystem", "partners"),
|
|
354
|
-
includeMemory: booleanFlag(flags, "include-memory", true),
|
|
355
|
-
includeBrain: booleanFlag(flags, "include-brain", true),
|
|
356
|
-
includeProviderRoutes: booleanFlag(flags, "include-provider-routes", true),
|
|
357
|
-
includeFailurePatterns: booleanFlag(flags, "include-failure-patterns", true),
|
|
358
|
-
includePlannedProviders: booleanFlag(flags, "include-planned-providers", true),
|
|
359
|
-
days: numberFlag(flags, "days"),
|
|
360
|
-
limit: numberFlag(flags, "limit")
|
|
361
|
-
};
|
|
362
|
-
const result = await signaliz.gtm.campaignBuildPlan(input);
|
|
363
|
-
printResult(result, flags);
|
|
364
|
-
return;
|
|
365
|
-
}
|
|
366
|
-
if (subcommand === "agent-plan" || subcommand === "campaign-agent-plan") {
|
|
367
|
-
const flags = parseFlags(argv.slice(1));
|
|
368
|
-
const goal = stringFlag(flags, "goal", "brief", "campaign-brief");
|
|
369
|
-
if (!goal && !stringFlag(flags, "campaign-id") && !stringFlag(flags, "campaign-build-id") && !stringFlag(flags, "strategy-template", "template")) {
|
|
370
|
-
throw new Error("gtm agent-plan requires --goal, --campaign-id, --campaign-build-id, or --strategy-template");
|
|
371
|
-
}
|
|
372
|
-
const input = {
|
|
373
|
-
goal,
|
|
374
|
-
campaignName: stringFlag(flags, "campaign-name", "name"),
|
|
375
|
-
campaignId: stringFlag(flags, "campaign-id"),
|
|
376
|
-
campaignBuildId: stringFlag(flags, "campaign-build-id", "build-id"),
|
|
377
|
-
strategyTemplate: stringFlag(flags, "strategy-template", "template"),
|
|
378
|
-
operatingPlaybooks: csvFlag(flags, "operating-playbooks", "playbooks"),
|
|
379
|
-
accountContext: stringFlag(flags, "account-context", "workspace-context"),
|
|
380
|
-
targetIcp: jsonObjectFlag(flags, "target-icp", "icp"),
|
|
381
|
-
targetCount: numberFlag(flags, "target-count", "lead-count"),
|
|
382
|
-
builtIns: campaignAgentBuiltInsFromFlags(flags),
|
|
383
|
-
useLocalLeads: booleanFlag(flags, "use-local-leads") || void 0,
|
|
384
|
-
layers: csvFlag(flags, "layers"),
|
|
385
|
-
preferredProviders: csvFlag(flags, "preferred-providers", "providers"),
|
|
386
|
-
customTools: campaignAgentCustomToolRoutesFromFlags(flags),
|
|
387
|
-
strategyModel: stringFlag(flags, "strategy-model"),
|
|
388
|
-
includeStrategyPatterns: !booleanFlag(flags, "no-strategy-patterns"),
|
|
389
|
-
includeWorkflowPatterns: !booleanFlag(flags, "no-workflow-patterns"),
|
|
390
|
-
includeNangoCatalog: !booleanFlag(flags, "no-nango-catalog"),
|
|
391
|
-
partnerEcosystem: csvFlag(flags, "partner-ecosystem", "partners"),
|
|
392
|
-
includeMemory: !booleanFlag(flags, "no-memory"),
|
|
393
|
-
includeBrain: !booleanFlag(flags, "no-brain"),
|
|
394
|
-
includeProviderRoutes: !booleanFlag(flags, "no-provider-routes"),
|
|
395
|
-
includeFailurePatterns: !booleanFlag(flags, "no-failure-patterns"),
|
|
396
|
-
includeDeliveryRisk: !booleanFlag(flags, "no-delivery-risk"),
|
|
397
|
-
includePlannedProviders: !booleanFlag(flags, "no-planned-providers"),
|
|
398
|
-
days: numberFlag(flags, "days"),
|
|
399
|
-
limit: numberFlag(flags, "limit")
|
|
400
|
-
};
|
|
401
|
-
const result = await signaliz.gtm.campaignAgentPlan(input);
|
|
402
|
-
printResult(result, flags);
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
if (subcommand === "agent-template" || subcommand === "campaign-agent-template" || subcommand === "request-template") {
|
|
406
|
-
const flags = parseFlags(argv.slice(1));
|
|
407
|
-
const input = {
|
|
408
|
-
goal: stringFlag(flags, "goal", "brief", "campaign-brief"),
|
|
409
|
-
campaignName: stringFlag(flags, "campaign-name", "name"),
|
|
410
|
-
accountLabel: stringFlag(flags, "workspace-label", "account-label"),
|
|
411
|
-
accountContext: stringFlag(flags, "account-context", "workspace-context"),
|
|
412
|
-
strategyTemplate: stringFlag(flags, "strategy-template", "template"),
|
|
413
|
-
operatingPlaybooks: csvFlag(flags, "operating-playbooks", "playbooks"),
|
|
414
|
-
targetIcp: jsonObjectFlag(flags, "target-icp", "icp"),
|
|
415
|
-
targetCount: numberFlag(flags, "target-count", "lead-count"),
|
|
416
|
-
builtIns: campaignAgentBuiltInsFromFlags(flags),
|
|
417
|
-
includeLocalLeads: booleanFlag(flags, "use-local-leads") || booleanFlag(flags, "include-local-leads") || void 0,
|
|
418
|
-
includeByoPlaceholder: booleanFlag(flags, "with-byo-placeholder") || booleanFlag(flags, "include-byo-placeholder") || void 0,
|
|
419
|
-
includeNangoCatalog: !booleanFlag(flags, "no-nango-catalog"),
|
|
420
|
-
preferredProviders: csvFlag(flags, "preferred-providers", "providers"),
|
|
421
|
-
privacyMode: stringFlag(flags, "privacy-mode"),
|
|
422
|
-
destinationType: stringFlag(flags, "destination", "destination-type")
|
|
423
|
-
};
|
|
424
|
-
const result = await signaliz.gtm.campaignAgentRequestTemplate(input);
|
|
425
|
-
printResult(result, flags);
|
|
426
|
-
return;
|
|
427
|
-
}
|
|
428
|
-
if (subcommand === "provider-prepare" || subcommand === "prepare-provider" || subcommand === "recipe-prepare" || subcommand === "prepare-recipe") {
|
|
429
|
-
const flags = parseFlags(argv.slice(1));
|
|
430
|
-
const providerId = stringFlag(flags, "provider-id", "provider") || argv[1];
|
|
431
|
-
if (!providerId) {
|
|
432
|
-
throw new Error("gtm provider-prepare requires --provider-id or provider id");
|
|
433
|
-
}
|
|
434
|
-
const input = {
|
|
435
|
-
providerId,
|
|
436
|
-
providerName: stringFlag(flags, "provider-name", "name"),
|
|
437
|
-
description: stringFlag(flags, "description"),
|
|
438
|
-
layerCapabilities: csvFlag(flags, "layer-capabilities", "layers"),
|
|
439
|
-
invocationType: stringFlag(flags, "invocation-type"),
|
|
440
|
-
authStrategy: stringFlag(flags, "auth-strategy"),
|
|
441
|
-
endpointUrl: stringFlag(flags, "endpoint-url"),
|
|
442
|
-
httpMethod: stringFlag(flags, "http-method") || void 0,
|
|
443
|
-
secretRef: stringFlag(flags, "secret-ref"),
|
|
444
|
-
workspaceIntegrationId: stringFlag(flags, "workspace-integration-id"),
|
|
445
|
-
workspaceMcpServerId: stringFlag(flags, "workspace-mcp-server-id"),
|
|
446
|
-
workspaceConnectionId: stringFlag(flags, "workspace-connection-id"),
|
|
447
|
-
requestTemplate: jsonObjectFlag(flags, "request-template"),
|
|
448
|
-
responseMapping: jsonObjectFlag(flags, "response-mapping"),
|
|
449
|
-
inputSchema: jsonObjectFlag(flags, "input-schema"),
|
|
450
|
-
outputSchema: jsonObjectFlag(flags, "output-schema"),
|
|
451
|
-
readiness: jsonObjectFlag(flags, "readiness"),
|
|
452
|
-
metadata: jsonObjectFlag(flags, "metadata"),
|
|
453
|
-
layer: stringFlag(flags, "layer"),
|
|
454
|
-
campaignId: stringFlag(flags, "campaign-id"),
|
|
455
|
-
useSignalizFallback: !booleanFlag(flags, "no-signaliz-fallback"),
|
|
456
|
-
priority: numberFlag(flags, "priority"),
|
|
457
|
-
status: stringFlag(flags, "status"),
|
|
458
|
-
context: jsonObjectFlag(flags, "context")
|
|
459
|
-
};
|
|
460
|
-
const result = await signaliz.gtm.prepareProviderRecipe(input);
|
|
461
|
-
printResult(result, flags);
|
|
462
|
-
return;
|
|
463
|
-
}
|
|
464
|
-
if (subcommand === "activate-route" || subcommand === "route-activate") {
|
|
465
|
-
const flags = parseFlags(argv.slice(1));
|
|
466
|
-
const providerId = stringFlag(flags, "provider-id", "provider") || argv[1];
|
|
467
|
-
if (!providerId) {
|
|
468
|
-
throw new Error("gtm activate-route requires --provider-id or provider id");
|
|
469
|
-
}
|
|
470
|
-
const layers = csvFlag(flags, "layers");
|
|
471
|
-
const layer = stringFlag(flags, "layer");
|
|
472
|
-
if (!layer && !layers?.length) {
|
|
473
|
-
throw new Error("gtm activate-route requires --layer or --layers");
|
|
474
|
-
}
|
|
475
|
-
const confirm = booleanFlag(flags, "confirm");
|
|
476
|
-
const input = {
|
|
477
|
-
providerId,
|
|
478
|
-
providerName: stringFlag(flags, "provider-name", "name"),
|
|
479
|
-
description: stringFlag(flags, "description"),
|
|
480
|
-
campaignId: stringFlag(flags, "campaign-id"),
|
|
481
|
-
layer,
|
|
482
|
-
layers,
|
|
483
|
-
invocationType: stringFlag(flags, "invocation-type"),
|
|
484
|
-
authStrategy: stringFlag(flags, "auth-strategy"),
|
|
485
|
-
endpointUrl: stringFlag(flags, "endpoint-url"),
|
|
486
|
-
httpMethod: stringFlag(flags, "http-method") || void 0,
|
|
487
|
-
secretRef: stringFlag(flags, "secret-ref"),
|
|
488
|
-
workspaceIntegrationId: stringFlag(flags, "workspace-integration-id"),
|
|
489
|
-
workspaceMcpServerId: stringFlag(flags, "workspace-mcp-server-id"),
|
|
490
|
-
workspaceConnectionId: stringFlag(flags, "workspace-connection-id"),
|
|
491
|
-
useSignalizFallback: !booleanFlag(flags, "no-signaliz-fallback"),
|
|
492
|
-
priority: numberFlag(flags, "priority"),
|
|
493
|
-
routeConfig: jsonObjectFlag(flags, "route-config"),
|
|
494
|
-
requestTemplate: jsonObjectFlag(flags, "request-template"),
|
|
495
|
-
responseMapping: jsonObjectFlag(flags, "response-mapping"),
|
|
496
|
-
inputSchema: jsonObjectFlag(flags, "input-schema"),
|
|
497
|
-
outputSchema: jsonObjectFlag(flags, "output-schema"),
|
|
498
|
-
readiness: jsonObjectFlag(flags, "readiness"),
|
|
499
|
-
metadata: jsonObjectFlag(flags, "metadata"),
|
|
500
|
-
status: stringFlag(flags, "status"),
|
|
501
|
-
routeStatus: stringFlag(flags, "route-status"),
|
|
502
|
-
replaceExistingRoutes: !booleanFlag(flags, "keep-existing-routes"),
|
|
503
|
-
dryRun: !confirm,
|
|
504
|
-
confirm,
|
|
505
|
-
context: jsonObjectFlag(flags, "context")
|
|
506
|
-
};
|
|
507
|
-
const result = await signaliz.gtm.activateProviderRoute(input);
|
|
508
|
-
printResult(result, flags);
|
|
509
|
-
return;
|
|
510
|
-
}
|
|
511
|
-
printGtmHelp();
|
|
512
|
-
}
|
|
513
|
-
async function handleCampaignAgentCommand(signalizFactory, argv) {
|
|
514
|
-
const subcommand = argv[0];
|
|
515
|
-
if (!subcommand || subcommand === "help" || subcommand === "--help" || subcommand === "-h") {
|
|
516
|
-
printCampaignAgentHelp();
|
|
517
|
-
return;
|
|
518
|
-
}
|
|
519
|
-
if (["init", "template", "request-template", "new"].includes(subcommand)) {
|
|
520
|
-
const flags2 = parseFlags(argv.slice(1));
|
|
521
|
-
const request2 = await campaignAgentRequestTemplateFromFlags(flags2);
|
|
522
|
-
const outputFile = stringFlag(flags2, "output-file", "out");
|
|
523
|
-
if (outputFile) {
|
|
524
|
-
writeFileSync(outputFile, `${JSON.stringify(request2, null, 2)}
|
|
525
|
-
`, "utf8");
|
|
526
|
-
}
|
|
527
|
-
if (booleanFlag(flags2, "json") || !outputFile) {
|
|
528
|
-
printJson(request2);
|
|
529
|
-
} else {
|
|
530
|
-
console.log(`Campaign request template written: ${outputFile}`);
|
|
531
|
-
console.log(`Next: signaliz campaign-agent plan --request-file ${outputFile} --json`);
|
|
532
|
-
}
|
|
533
|
-
return;
|
|
534
|
-
}
|
|
535
|
-
if (["kit", "build-kit", "blueprint"].includes(subcommand)) {
|
|
536
|
-
const flags2 = parseFlags(argv.slice(1));
|
|
537
|
-
const { createCampaignBuilderBuildKit } = await loadSdk();
|
|
538
|
-
const requestFromFile2 = campaignAgentRequestFileFromFlags(flags2);
|
|
539
|
-
const fallbackGoal = stringFlag(flags2, "goal", "brief") || stringOrUndefined(requestFromFile2?.goal) || "Build a strategy-template campaign for mature operators in the target ICP.";
|
|
540
|
-
const request2 = requestFromFile2 ? mergeCampaignAgentRequests(
|
|
541
|
-
requestFromFile2,
|
|
542
|
-
campaignAgentRequestFromFlags(fallbackGoal, flags2, { includeDefaults: false })
|
|
543
|
-
) : await campaignAgentRequestTemplateFromFlags(flags2);
|
|
544
|
-
const kit = createCampaignBuilderBuildKit({
|
|
545
|
-
...request2,
|
|
546
|
-
includeLocalLeads: booleanFlag(flags2, "use-local-leads"),
|
|
547
|
-
includeCustomToolPlaceholder: booleanFlag(flags2, "with-byo-placeholder") || booleanFlag(flags2, "include-custom-tool-placeholder") || booleanFlag(flags2, "include-byo-placeholder"),
|
|
548
|
-
includeNango: !booleanFlag(flags2, "no-nango-catalog"),
|
|
549
|
-
requestFile: stringFlag(flags2, "request-output-file", "request-file-name") || stringFlag(flags2, "request-file") || "campaign-request.json",
|
|
550
|
-
cliPackage: stringFlag(flags2, "cli-package"),
|
|
551
|
-
sdkPackage: stringFlag(flags2, "sdk-package")
|
|
552
|
-
});
|
|
553
|
-
const outputFile = stringFlag(flags2, "output-file", "kit-file", "out");
|
|
554
|
-
if (outputFile) {
|
|
555
|
-
writeFileSync(outputFile, `${JSON.stringify(kit, null, 2)}
|
|
556
|
-
`, "utf8");
|
|
557
|
-
}
|
|
558
|
-
if (booleanFlag(flags2, "json")) {
|
|
559
|
-
printJson(kit);
|
|
560
|
-
} else if (!outputFile) {
|
|
561
|
-
printCampaignAgentBuildKit(kit);
|
|
562
|
-
} else {
|
|
563
|
-
console.log(`Campaign build kit written: ${outputFile}`);
|
|
564
|
-
console.log(`Next: ${kit.cli_commands.find((command) => command.id === "proof_shortcut")?.command}`);
|
|
565
|
-
}
|
|
566
|
-
return;
|
|
567
|
-
}
|
|
568
|
-
if (["memory-kit", "seed-kit", "memory"].includes(subcommand)) {
|
|
569
|
-
const flags2 = parseFlags(argv.slice(1));
|
|
570
|
-
const { createCampaignBuilderMemoryKit } = await loadSdk();
|
|
571
|
-
const requestFromFile2 = campaignAgentRequestFileFromFlags(flags2);
|
|
572
|
-
const fallbackGoal = stringFlag(flags2, "goal", "brief") || stringOrUndefined(requestFromFile2?.goal) || "Build a strategy-template campaign for mature operators in the target ICP.";
|
|
573
|
-
const request2 = requestFromFile2 ? mergeCampaignAgentRequests(
|
|
574
|
-
requestFromFile2,
|
|
575
|
-
campaignAgentRequestFromFlags(fallbackGoal, flags2, { includeDefaults: false })
|
|
576
|
-
) : await campaignAgentRequestTemplateFromFlags(flags2);
|
|
577
|
-
const kit = createCampaignBuilderMemoryKit({
|
|
578
|
-
...request2,
|
|
579
|
-
includeLocalLeads: booleanFlag(flags2, "use-local-leads"),
|
|
580
|
-
includeCustomToolPlaceholder: booleanFlag(flags2, "with-byo-placeholder") || booleanFlag(flags2, "include-custom-tool-placeholder") || booleanFlag(flags2, "include-byo-placeholder"),
|
|
581
|
-
includeNango: !booleanFlag(flags2, "no-nango-catalog"),
|
|
582
|
-
requestFile: stringFlag(flags2, "request-output-file", "request-file-name") || stringFlag(flags2, "request-file") || "campaign-request.json",
|
|
583
|
-
seedManifestFile: stringFlag(flags2, "seed-manifest-file", "manifest") || ".gtm-kernel-import-state/campaign-memory-dry-run.json",
|
|
584
|
-
source: stringFlag(flags2, "source", "memory-source", "seed-source"),
|
|
585
|
-
workspaceId: stringFlag(flags2, "workspace-id"),
|
|
586
|
-
cliPackage: stringFlag(flags2, "cli-package"),
|
|
587
|
-
sdkPackage: stringFlag(flags2, "sdk-package")
|
|
588
|
-
});
|
|
589
|
-
const outputFile = stringFlag(flags2, "output-file", "kit-file", "out");
|
|
590
|
-
if (outputFile) {
|
|
591
|
-
writeFileSync(outputFile, `${JSON.stringify(kit, null, 2)}
|
|
592
|
-
`, "utf8");
|
|
593
|
-
}
|
|
594
|
-
if (booleanFlag(flags2, "json")) {
|
|
595
|
-
printJson(kit);
|
|
596
|
-
} else if (!outputFile) {
|
|
597
|
-
printCampaignAgentMemoryKit(kit);
|
|
598
|
-
} else {
|
|
599
|
-
console.log(`Campaign memory kit written: ${outputFile}`);
|
|
600
|
-
console.log(`Next: ${kit.cli_commands.find((command) => command.id === "memory_status")?.command}`);
|
|
601
|
-
}
|
|
602
|
-
return;
|
|
603
|
-
}
|
|
604
|
-
const isReviewCommand = ["review", "status", "rows", "artifacts", "approve", "approve-delivery"].includes(subcommand);
|
|
605
|
-
const isPlanCommand = ["plan", "doctor", "readiness", "preflight", "proof", "smoke", "commit-plan", "dry-run", "build-approved", "launch-approved"].includes(subcommand);
|
|
606
|
-
if (!isReviewCommand && !isPlanCommand) {
|
|
607
|
-
printCampaignAgentHelp();
|
|
608
|
-
return;
|
|
609
|
-
}
|
|
610
|
-
const signaliz = await signalizFactory();
|
|
611
|
-
if (isReviewCommand) {
|
|
612
|
-
await handleCampaignAgentReviewCommand(signaliz, subcommand, argv.slice(1));
|
|
613
|
-
return;
|
|
614
|
-
}
|
|
615
|
-
const flags = parseFlags(argv.slice(1));
|
|
616
|
-
const isDoctor = subcommand === "doctor" || subcommand === "readiness" || subcommand === "preflight";
|
|
617
|
-
const requestFromFile = campaignAgentRequestFileFromFlags(flags);
|
|
618
|
-
const goal = stringFlag(flags, "goal", "brief") ?? stringOrUndefined(requestFromFile?.goal) ?? (isDoctor ? "Build a strategy-template campaign for the target ICP." : void 0);
|
|
619
|
-
if (!goal) throw new Error(`campaign-agent ${subcommand} requires --goal or a request file with goal`);
|
|
620
|
-
const isApprovedBuild = subcommand === "build-approved" || subcommand === "launch-approved";
|
|
621
|
-
const isCommitPlan = subcommand === "commit-plan";
|
|
622
|
-
const isConfirmedCommit = isCommitPlan && booleanFlag(flags, "confirm-write");
|
|
623
|
-
const approvedBy = stringFlag(flags, "approved-by");
|
|
624
|
-
if (isApprovedBuild) {
|
|
625
|
-
if (!booleanFlag(flags, "confirm-launch")) {
|
|
626
|
-
throw new Error(`campaign-agent ${subcommand} requires --confirm-launch`);
|
|
627
|
-
}
|
|
628
|
-
if (!approvedBy) throw new Error(`campaign-agent ${subcommand} requires --approved-by`);
|
|
629
|
-
}
|
|
630
|
-
if (isConfirmedCommit && !approvedBy) {
|
|
631
|
-
throw new Error("campaign-agent commit-plan --confirm-write requires --approved-by");
|
|
632
|
-
}
|
|
633
|
-
const request = mergeCampaignAgentRequests(
|
|
634
|
-
requestFromFile,
|
|
635
|
-
campaignAgentRequestFromFlags(goal, flags, { includeDefaults: !requestFromFile })
|
|
636
|
-
);
|
|
637
|
-
const planOptions = {
|
|
638
|
-
discoverCapabilities: !booleanFlag(flags, "skip-discovery"),
|
|
639
|
-
scopeCampaign: !booleanFlag(flags, "skip-scope"),
|
|
640
|
-
includeStrategyMemoryStatus: !booleanFlag(flags, "no-strategy-memory"),
|
|
641
|
-
includeKernelPlan: !booleanFlag(flags, "no-kernel-plan"),
|
|
642
|
-
includeDeliveryRisk: !booleanFlag(flags, "no-delivery-risk")
|
|
643
|
-
};
|
|
644
|
-
if (isDoctor) {
|
|
645
|
-
const readiness = await signaliz.campaignBuilderAgent.readiness(request, planOptions);
|
|
646
|
-
if (booleanFlag(flags, "json")) {
|
|
647
|
-
printJson(readiness);
|
|
648
|
-
} else {
|
|
649
|
-
printCampaignAgentReadiness(readiness);
|
|
650
|
-
}
|
|
651
|
-
if (!readiness.summary.ready) process.exitCode = 1;
|
|
652
|
-
return;
|
|
653
|
-
}
|
|
654
|
-
if (subcommand === "proof" || subcommand === "smoke") {
|
|
655
|
-
const proof = await signaliz.campaignBuilderAgent.proof(request, {
|
|
656
|
-
...planOptions,
|
|
657
|
-
idempotencyKey: stringFlag(flags, "idempotency-key")
|
|
658
|
-
});
|
|
659
|
-
if (booleanFlag(flags, "json")) {
|
|
660
|
-
printJson(proof);
|
|
661
|
-
} else {
|
|
662
|
-
printCampaignAgentProof(proof);
|
|
663
|
-
}
|
|
664
|
-
if (!proof.success) process.exitCode = 1;
|
|
665
|
-
return;
|
|
666
|
-
}
|
|
667
|
-
const plan = await signaliz.campaignBuilderAgent.createPlan(request, planOptions);
|
|
668
|
-
if (isCommitPlan) {
|
|
669
|
-
const result = await signaliz.campaignBuilderAgent.commitPlan(plan, {
|
|
670
|
-
confirm: isConfirmedCommit,
|
|
671
|
-
dryRun: !isConfirmedCommit,
|
|
672
|
-
approvedBy,
|
|
673
|
-
idempotencyKey: stringFlag(flags, "idempotency-key"),
|
|
674
|
-
rationale: stringFlag(flags, "rationale")
|
|
675
|
-
});
|
|
676
|
-
printCampaignAgentExecution({ plan, result }, flags);
|
|
677
|
-
return;
|
|
678
|
-
}
|
|
679
|
-
if (subcommand === "dry-run") {
|
|
680
|
-
const result = await signaliz.campaignBuilderAgent.dryRunPlan(plan, {
|
|
681
|
-
idempotencyKey: stringFlag(flags, "idempotency-key")
|
|
682
|
-
});
|
|
683
|
-
printCampaignAgentExecution({ plan, result }, flags);
|
|
684
|
-
return;
|
|
685
|
-
}
|
|
686
|
-
if (isApprovedBuild) {
|
|
687
|
-
const approvedTypes = approvedTypesFromFlags(plan, flags);
|
|
688
|
-
const { createCampaignBuilderApproval } = await loadSdk();
|
|
689
|
-
const approval = createCampaignBuilderApproval(plan, {
|
|
690
|
-
approvedBy,
|
|
691
|
-
approvedTypes,
|
|
692
|
-
spendLimitCredits: numberFlag(flags, "spend-limit", "spend-limit-credits", "max-credits"),
|
|
693
|
-
approvedRouteIds: approvedRouteIdsFromFlags(plan, flags),
|
|
694
|
-
notes: stringFlag(flags, "approval-notes", "notes")
|
|
695
|
-
});
|
|
696
|
-
const runApproved = booleanFlag(flags, "wait") || booleanFlag(flags, "approve-delivery");
|
|
697
|
-
const result = runApproved ? await signaliz.campaignBuilderAgent.runApprovedPlan(plan, approval, {
|
|
698
|
-
idempotencyKey: stringFlag(flags, "idempotency-key"),
|
|
699
|
-
commitBeforeLaunch: booleanFlag(flags, "commit-before-launch"),
|
|
700
|
-
wait: booleanFlag(flags, "wait"),
|
|
701
|
-
approveDelivery: booleanFlag(flags, "approve-delivery"),
|
|
702
|
-
deliveryDestinationType: stringFlag(flags, "delivery-destination-type", "destination-type"),
|
|
703
|
-
deliveryDestinationId: stringFlag(flags, "delivery-destination-id", "destination-id"),
|
|
704
|
-
deliveryDestinationConfig: jsonObjectFlag(flags, "delivery-config", "destination-config"),
|
|
705
|
-
waitIntervalMs: numberFlag(flags, "wait-interval-ms"),
|
|
706
|
-
waitTimeoutMs: numberFlag(flags, "wait-timeout-ms"),
|
|
707
|
-
onStatus: booleanFlag(flags, "json") ? void 0 : (status) => {
|
|
708
|
-
console.error(`campaign-agent build-approved: ${status.status} phase=${status.currentPhase ?? "N/A"} rows=${status.recordsSucceeded}/${status.recordsTotal} artifacts=${status.artifactCount}`);
|
|
709
|
-
}
|
|
710
|
-
}) : await signaliz.campaignBuilderAgent.buildApprovedPlan(plan, approval, {
|
|
711
|
-
idempotencyKey: stringFlag(flags, "idempotency-key"),
|
|
712
|
-
commitBeforeLaunch: booleanFlag(flags, "commit-before-launch")
|
|
713
|
-
});
|
|
714
|
-
printCampaignAgentExecution({ plan, approval, result }, flags);
|
|
715
|
-
return;
|
|
716
|
-
}
|
|
717
|
-
if (booleanFlag(flags, "json")) {
|
|
718
|
-
printJson(plan);
|
|
719
|
-
} else {
|
|
720
|
-
printCampaignAgentPlan(plan);
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
async function handleCampaignAgentReviewCommand(signaliz, subcommand, argv) {
|
|
724
|
-
const flags = parseFlags(argv);
|
|
725
|
-
const buildId = argv[0] && !argv[0].startsWith("--") ? argv[0] : stringFlag(flags, "campaign-build-id", "build-id");
|
|
726
|
-
if (!buildId) throw new Error(`campaign-agent ${subcommand} requires <campaign_build_id> or --campaign-build-id`);
|
|
727
|
-
if (subcommand === "review") {
|
|
728
|
-
const review = await signaliz.campaignBuilderAgent.reviewBuild(buildId, {
|
|
729
|
-
limit: numberFlag(flags, "limit") ?? 100,
|
|
730
|
-
cursor: stringFlag(flags, "cursor"),
|
|
731
|
-
segment: stringFlag(flags, "segment"),
|
|
732
|
-
rowStatus: stringFlag(flags, "row-status"),
|
|
733
|
-
includeData: optionalBooleanFlag(flags, "include-data"),
|
|
734
|
-
includeRaw: optionalBooleanFlag(flags, "include-raw"),
|
|
735
|
-
qualified: booleanFlag(flags, "qualified") ? true : booleanFlag(flags, "disqualified") ? false : void 0
|
|
736
|
-
});
|
|
737
|
-
const operatorReview = {
|
|
738
|
-
...review,
|
|
739
|
-
rows: {
|
|
740
|
-
...review.rows,
|
|
741
|
-
rows: formatCampaignAgentRows(review.rows.rows)
|
|
742
|
-
}
|
|
743
|
-
};
|
|
744
|
-
if (booleanFlag(flags, "json")) {
|
|
745
|
-
printJson(operatorReview);
|
|
746
|
-
} else {
|
|
747
|
-
printCampaignAgentBuildReview(operatorReview);
|
|
748
|
-
}
|
|
749
|
-
return;
|
|
750
|
-
}
|
|
751
|
-
if (subcommand === "status") {
|
|
752
|
-
const status = await signaliz.campaignBuilderAgent.getBuildStatus(buildId);
|
|
753
|
-
if (booleanFlag(flags, "json")) {
|
|
754
|
-
printJson(status);
|
|
755
|
-
} else {
|
|
756
|
-
printCampaignAgentBuildStatus(status);
|
|
757
|
-
}
|
|
758
|
-
return;
|
|
759
|
-
}
|
|
760
|
-
if (subcommand === "rows") {
|
|
761
|
-
const result2 = await signaliz.campaignBuilderAgent.getBuildRows(buildId, {
|
|
762
|
-
limit: numberFlag(flags, "limit"),
|
|
763
|
-
cursor: stringFlag(flags, "cursor"),
|
|
764
|
-
segment: stringFlag(flags, "segment"),
|
|
765
|
-
rowStatus: stringFlag(flags, "row-status"),
|
|
766
|
-
includeData: optionalBooleanFlag(flags, "include-data"),
|
|
767
|
-
includeRaw: optionalBooleanFlag(flags, "include-raw"),
|
|
768
|
-
qualified: booleanFlag(flags, "qualified") ? true : booleanFlag(flags, "disqualified") ? false : void 0
|
|
769
|
-
});
|
|
770
|
-
const operatorResult = {
|
|
771
|
-
...result2,
|
|
772
|
-
rows: formatCampaignAgentRows(result2.rows)
|
|
773
|
-
};
|
|
774
|
-
if (booleanFlag(flags, "json")) {
|
|
775
|
-
printJson(operatorResult);
|
|
776
|
-
} else {
|
|
777
|
-
printCampaignAgentRows(operatorResult);
|
|
778
|
-
}
|
|
779
|
-
return;
|
|
780
|
-
}
|
|
781
|
-
if (subcommand === "artifacts") {
|
|
782
|
-
const artifacts = await signaliz.campaignBuilderAgent.listBuildArtifacts(buildId);
|
|
783
|
-
if (booleanFlag(flags, "json")) {
|
|
784
|
-
printJson(artifacts);
|
|
785
|
-
} else if (artifacts.length === 0) {
|
|
786
|
-
console.log("No artifacts yet.");
|
|
787
|
-
console.log(`Next: signaliz campaign-agent status ${buildId}`);
|
|
788
|
-
} else {
|
|
789
|
-
for (const artifact of artifacts) {
|
|
790
|
-
console.log(`${artifact.artifactType || "artifact"}: ${artifact.rowCount} rows${artifact.signedUrl ? `
|
|
791
|
-
${artifact.signedUrl}` : ""}`);
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
return;
|
|
795
|
-
}
|
|
796
|
-
const destinationType = stringFlag(flags, "destination-type", "delivery-destination-type", "type");
|
|
797
|
-
if (!destinationType || !["json", "csv", "webhook"].includes(destinationType)) {
|
|
798
|
-
throw new Error("campaign-agent approve requires --destination-type json|csv|webhook");
|
|
799
|
-
}
|
|
800
|
-
const result = await signaliz.campaignBuilderAgent.approveDelivery(buildId, destinationType, {
|
|
801
|
-
destinationId: stringFlag(flags, "destination-id", "delivery-destination-id"),
|
|
802
|
-
destinationConfig: jsonObjectFlag(flags, "destination-config", "delivery-config")
|
|
803
|
-
});
|
|
804
|
-
if (booleanFlag(flags, "json")) {
|
|
805
|
-
printJson(result);
|
|
806
|
-
} else {
|
|
807
|
-
console.log(`Delivery ${result.status}: ${result.destinationType}`);
|
|
808
|
-
if (result.message) console.log(result.message);
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
async function campaignAgentRequestTemplateFromFlags(flags) {
|
|
812
|
-
const goal = stringFlag(flags, "goal", "brief") || "Build a strategy-template campaign for mature operators in the target ICP.";
|
|
813
|
-
const request = campaignAgentRequestFromFlags(goal, flags, { includeDefaults: true });
|
|
814
|
-
const options = {
|
|
815
|
-
...request,
|
|
816
|
-
includeLocalLeads: booleanFlag(flags, "use-local-leads"),
|
|
817
|
-
includeCustomToolPlaceholder: booleanFlag(flags, "with-byo-placeholder") || booleanFlag(flags, "include-custom-tool-placeholder") || booleanFlag(flags, "include-byo-placeholder"),
|
|
818
|
-
includeNango: !booleanFlag(flags, "no-nango-catalog")
|
|
819
|
-
};
|
|
820
|
-
const { createCampaignBuilderAgentRequestTemplate } = await loadSdk();
|
|
821
|
-
return createCampaignBuilderAgentRequestTemplate(options);
|
|
822
|
-
}
|
|
823
|
-
function campaignAgentRequestFileFromFlags(flags) {
|
|
824
|
-
const file = stringFlag(flags, "request-file", "input-file", "campaign-file");
|
|
825
|
-
if (!file) return void 0;
|
|
826
|
-
const parsed = JSON.parse(readFileSync(file, "utf8"));
|
|
827
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
828
|
-
throw new Error(`Expected JSON object for --request-file`);
|
|
829
|
-
}
|
|
830
|
-
return parsed;
|
|
831
|
-
}
|
|
832
|
-
function campaignAgentRequestFromFlags(goal, flags, options = {}) {
|
|
833
|
-
const builtIns = campaignAgentBuiltInsFromFlags(flags);
|
|
834
|
-
const integrations = campaignAgentCustomToolRoutesFromFlags(flags);
|
|
835
|
-
const includeDefaults = options.includeDefaults !== false;
|
|
836
|
-
const request = {
|
|
837
|
-
goal,
|
|
838
|
-
campaignName: stringFlag(flags, "campaign-name", "name"),
|
|
839
|
-
accountLabel: stringFlag(flags, "workspace-label", "account-label"),
|
|
840
|
-
strategyTemplate: stringFlag(flags, "strategy-template", "template"),
|
|
841
|
-
accountContext: stringFlag(flags, "account-context", "workspace-context"),
|
|
842
|
-
targetCount: numberFlag(flags, "target-count", "lead-count"),
|
|
843
|
-
gtmCampaignId: stringFlag(flags, "gtm-campaign-id", "campaign-id"),
|
|
844
|
-
icp: jsonObjectFlag(flags, "icp", "target-icp"),
|
|
845
|
-
brainDefaults: jsonObjectFlag(flags, "brain-defaults"),
|
|
846
|
-
deliveryRisk: jsonObjectFlag(flags, "delivery-risk"),
|
|
847
|
-
builtIns,
|
|
848
|
-
operatingPlaybooks: csvFlag(flags, "operating-playbooks", "playbooks"),
|
|
849
|
-
integrations,
|
|
850
|
-
preferredProviders: csvFlag(flags, "preferred-providers", "providers")
|
|
851
|
-
};
|
|
852
|
-
if (includeDefaults || flagValue(flags, "strategy-model", "no-strategy-patterns", "no-agency-patterns", "no-workflow-patterns", "no-clay-patterns", "no-nango-catalog", "partners", "revenue-motion") !== void 0) {
|
|
853
|
-
request.agencyContext = {
|
|
854
|
-
strategyModel: stringFlag(flags, "strategy-model"),
|
|
855
|
-
includeStrategyPatterns: !booleanFlag(flags, "no-strategy-patterns") && !booleanFlag(flags, "no-agency-patterns"),
|
|
856
|
-
includeWorkflowPatterns: !booleanFlag(flags, "no-workflow-patterns") && !booleanFlag(flags, "no-clay-patterns"),
|
|
857
|
-
includeNangoCatalog: !booleanFlag(flags, "no-nango-catalog"),
|
|
858
|
-
partnerEcosystem: csvFlag(flags, "partners"),
|
|
859
|
-
revenueMotion: stringFlag(flags, "revenue-motion")
|
|
860
|
-
};
|
|
861
|
-
}
|
|
862
|
-
if (includeDefaults || flagValue(flags, "no-memory", "no-workspace-history", "use-network-patterns", "privacy-mode") !== void 0) {
|
|
863
|
-
request.memory = {
|
|
864
|
-
enabled: !booleanFlag(flags, "no-memory"),
|
|
865
|
-
useWorkspaceHistory: !booleanFlag(flags, "no-workspace-history"),
|
|
866
|
-
useNetworkPatterns: booleanFlag(flags, "use-network-patterns"),
|
|
867
|
-
privacyMode: stringFlag(flags, "privacy-mode")
|
|
868
|
-
};
|
|
869
|
-
}
|
|
870
|
-
if (includeDefaults || flagValue(flags, "max-credits", "no-delivery", "destination") !== void 0) {
|
|
871
|
-
request.signalizDefaults = {
|
|
872
|
-
maxCredits: numberFlag(flags, "max-credits"),
|
|
873
|
-
delivery: {
|
|
874
|
-
enabled: !booleanFlag(flags, "no-delivery"),
|
|
875
|
-
destinationType: stringFlag(flags, "destination"),
|
|
876
|
-
approvalRequired: true
|
|
877
|
-
}
|
|
878
|
-
};
|
|
879
|
-
}
|
|
880
|
-
if (includeDefaults || flagValue(flags, "no-human-approval", "max-credits-without-approval") !== void 0) {
|
|
881
|
-
request.approvalPolicy = {
|
|
882
|
-
requireHumanApproval: !booleanFlag(flags, "no-human-approval"),
|
|
883
|
-
maxCreditsWithoutApproval: numberFlag(flags, "max-credits-without-approval"),
|
|
884
|
-
requireApprovalFor: ["memory_retrieval", "spend", "customer_tool", "external_write", "delivery", "launch"]
|
|
885
|
-
};
|
|
886
|
-
}
|
|
887
|
-
return compactRequest(request);
|
|
888
|
-
}
|
|
889
|
-
function mergeCampaignAgentRequests(base, override) {
|
|
890
|
-
if (!base) return override;
|
|
891
|
-
return compactRequest({
|
|
892
|
-
...base,
|
|
893
|
-
...override,
|
|
894
|
-
icp: mergeRecords(base.icp, override.icp),
|
|
895
|
-
memory: mergeRecords(base.memory, override.memory),
|
|
896
|
-
agencyContext: mergeRecords(base.agencyContext, override.agencyContext),
|
|
897
|
-
signalizDefaults: mergeRecords(base.signalizDefaults, override.signalizDefaults),
|
|
898
|
-
approvalPolicy: mergeRecords(base.approvalPolicy, override.approvalPolicy),
|
|
899
|
-
constraints: mergeRecords(base.constraints, override.constraints),
|
|
900
|
-
workspaceContext: mergeRecords(base.workspaceContext, override.workspaceContext),
|
|
901
|
-
builtIns: override.builtIns ?? base.builtIns,
|
|
902
|
-
operatingPlaybooks: override.operatingPlaybooks ?? base.operatingPlaybooks,
|
|
903
|
-
integrations: override.integrations ?? base.integrations,
|
|
904
|
-
customerTools: override.customerTools ?? base.customerTools,
|
|
905
|
-
preferredProviders: override.preferredProviders ?? base.preferredProviders
|
|
906
|
-
});
|
|
907
|
-
}
|
|
908
|
-
function mergeRecords(base, override) {
|
|
909
|
-
if (!base) return override;
|
|
910
|
-
if (!override) return base;
|
|
911
|
-
if (typeof base === "object" && typeof override === "object" && !Array.isArray(base) && !Array.isArray(override)) {
|
|
912
|
-
return { ...base, ...override };
|
|
913
|
-
}
|
|
914
|
-
return override;
|
|
915
|
-
}
|
|
916
|
-
function compactRequest(record) {
|
|
917
|
-
return Object.fromEntries(
|
|
918
|
-
Object.entries(record).filter(([, value]) => value !== void 0)
|
|
919
|
-
);
|
|
920
|
-
}
|
|
921
|
-
function campaignAgentBuiltInsFromFlags(flags) {
|
|
922
|
-
const explicit = csvFlag(flags, "builtins", "builtin-tools", "signaliz-tools");
|
|
923
|
-
const hasBuiltinFlag = Boolean(
|
|
924
|
-
explicit?.length || flagValue(flags, "use-local-leads") !== void 0 || flagValue(flags, "no-lead-generation") !== void 0 || flagValue(flags, "no-email-finding") !== void 0 || flagValue(flags, "no-verification") !== void 0 || flagValue(flags, "no-signals") !== void 0
|
|
925
|
-
);
|
|
926
|
-
if (!hasBuiltinFlag) return void 0;
|
|
927
|
-
const builtIns = new Set(
|
|
928
|
-
explicit?.length ? explicit : ["lead_generation", "email_finding", "email_verification", "signals"]
|
|
929
|
-
);
|
|
930
|
-
if (booleanFlag(flags, "use-local-leads")) builtIns.add("local_leads");
|
|
931
|
-
if (booleanFlag(flags, "no-lead-generation")) builtIns.delete("lead_generation");
|
|
932
|
-
if (booleanFlag(flags, "no-email-finding")) builtIns.delete("email_finding");
|
|
933
|
-
if (booleanFlag(flags, "no-verification")) builtIns.delete("email_verification");
|
|
934
|
-
if (booleanFlag(flags, "no-signals")) builtIns.delete("signals");
|
|
935
|
-
return [...builtIns];
|
|
936
|
-
}
|
|
937
|
-
function campaignAgentCustomToolRoutesFromFlags(flags) {
|
|
938
|
-
const values = repeatedStringFlag(flags, "custom-tool", "customer-tool", "byo-tool", "integration-route");
|
|
939
|
-
const routes = values.map(parseCampaignAgentCustomToolRoute);
|
|
940
|
-
return routes.length > 0 ? routes : void 0;
|
|
941
|
-
}
|
|
942
|
-
function parseCampaignAgentCustomToolRoute(raw) {
|
|
943
|
-
const record = raw.trim().startsWith("{") ? jsonObjectFromString(raw, "--custom-tool") : raw.includes("=") ? keyValueObject(raw) : colonRouteObject(raw);
|
|
944
|
-
const layer = normalizeCampaignBuilderLayer(String(record.layer ?? record.use_for_layer ?? record.useForLayer ?? "enrichment"));
|
|
945
|
-
const gtmLayers = stringArrayValue(record.gtm_layers ?? record.gtmLayers ?? record.capabilities);
|
|
946
|
-
const provider = String(record.provider ?? record.provider_id ?? record.providerId ?? "custom_mcp");
|
|
947
|
-
const toolName = stringOrUndefined(record.tool ?? record.tool_name ?? record.toolName);
|
|
948
|
-
const label = stringOrUndefined(record.label ?? record.name) ?? provider;
|
|
949
|
-
const mcpServerName = stringOrUndefined(record.mcp ?? record.server ?? record.mcp_server_name ?? record.mcpServerName);
|
|
950
|
-
const mode = normalizeRouteMode(String(record.mode ?? "required"));
|
|
951
|
-
return {
|
|
952
|
-
provider,
|
|
953
|
-
layer,
|
|
954
|
-
gtmLayers,
|
|
955
|
-
mode,
|
|
956
|
-
toolName,
|
|
957
|
-
mcpServerName,
|
|
958
|
-
label,
|
|
959
|
-
approvalRequired: optionalBoolean(record.approval_required ?? record.approvalRequired, true),
|
|
960
|
-
config: {
|
|
961
|
-
provider_id: record.provider_id ?? record.providerId,
|
|
962
|
-
available_tools: stringArrayValue(record.available_tools ?? record.availableTools ?? record.tools),
|
|
963
|
-
raw: raw.trim()
|
|
964
|
-
},
|
|
965
|
-
rationale: `${label} is a user-provided campaign-builder route declared from the CLI.`
|
|
966
|
-
};
|
|
967
|
-
}
|
|
968
|
-
function colonRouteObject(raw) {
|
|
969
|
-
const [provider, layer, tool, mcp] = raw.split(":").map((part) => part.trim()).filter(Boolean);
|
|
970
|
-
if (!provider || !layer) {
|
|
971
|
-
throw new Error("Expected --custom-tool provider:layer:tool[:mcp] or key=value pairs");
|
|
972
|
-
}
|
|
973
|
-
return { provider, layer, tool, mcp };
|
|
974
|
-
}
|
|
975
|
-
function keyValueObject(raw) {
|
|
976
|
-
const record = {};
|
|
977
|
-
for (const segment of raw.split(",")) {
|
|
978
|
-
const eq = segment.indexOf("=");
|
|
979
|
-
if (eq < 0) continue;
|
|
980
|
-
const key = segment.slice(0, eq).trim().replace(/-/g, "_");
|
|
981
|
-
const value = segment.slice(eq + 1).trim();
|
|
982
|
-
record[key] = value;
|
|
983
|
-
}
|
|
984
|
-
return record;
|
|
985
|
-
}
|
|
986
|
-
function normalizeCampaignBuilderLayer(value) {
|
|
987
|
-
const normalized = normalizeEnumValue(value);
|
|
988
|
-
const allowed = ["workspace_context", "memory", "source", "enrichment", "qualification", "copy", "delivery", "feedback", "approval"];
|
|
989
|
-
if (!allowed.includes(normalized)) {
|
|
990
|
-
throw new Error(`Unknown campaign-builder layer "${value}". Use source, enrichment, qualification, copy, delivery, feedback, or approval.`);
|
|
991
|
-
}
|
|
992
|
-
return normalized;
|
|
993
|
-
}
|
|
994
|
-
function normalizeRouteMode(value) {
|
|
995
|
-
const normalized = normalizeEnumValue(value);
|
|
996
|
-
return ["required", "if_available", "fallback", "disabled"].includes(normalized) ? normalized : "required";
|
|
997
|
-
}
|
|
998
|
-
function normalizeEnumValue(value) {
|
|
999
|
-
return value.trim().toLowerCase().replace(/-/g, "_");
|
|
1000
|
-
}
|
|
1001
|
-
function stringArrayValue(value) {
|
|
1002
|
-
const values = Array.isArray(value) ? value : value === void 0 ? [] : [value];
|
|
1003
|
-
const parsed = values.flatMap((item) => String(item).split(/[|,]/).map((part) => part.trim()).filter(Boolean));
|
|
1004
|
-
return parsed.length > 0 ? parsed : void 0;
|
|
1005
|
-
}
|
|
1006
|
-
function stringOrUndefined(value) {
|
|
1007
|
-
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
1008
|
-
}
|
|
1009
|
-
function optionalBoolean(value, defaultValue) {
|
|
1010
|
-
if (value === void 0) return defaultValue;
|
|
1011
|
-
if (typeof value === "boolean") return value;
|
|
1012
|
-
return parseBoolean(String(value), defaultValue);
|
|
1013
|
-
}
|
|
1014
|
-
function approvedTypesFromFlags(plan, flags) {
|
|
1015
|
-
const requested = csvFlag(flags, "approved-types", "approve-types");
|
|
1016
|
-
if (requested?.length) return requested;
|
|
1017
|
-
if (!booleanFlag(flags, "approve-all")) {
|
|
1018
|
-
throw new Error("campaign-agent build-approved requires --approve-all or --approved-types");
|
|
1019
|
-
}
|
|
1020
|
-
return [...new Set(plan.approvals.map((item) => item.type))];
|
|
1021
|
-
}
|
|
1022
|
-
function approvedRouteIdsFromFlags(plan, flags) {
|
|
1023
|
-
const requested = csvFlag(flags, "approved-route-ids", "route-ids");
|
|
1024
|
-
if (requested?.length) return requested;
|
|
1025
|
-
if (!booleanFlag(flags, "approve-all")) return void 0;
|
|
1026
|
-
const routeIds = plan.approvals.map((item) => item.routeId).filter((id) => Boolean(id));
|
|
1027
|
-
return routeIds.length > 0 ? routeIds : void 0;
|
|
1028
|
-
}
|
|
1029
|
-
function parseFlags(argv) {
|
|
1030
|
-
const flags = {};
|
|
1031
|
-
for (let i = 0; i < argv.length; i += 1) {
|
|
1032
|
-
const token = argv[i];
|
|
1033
|
-
if (!token.startsWith("--")) continue;
|
|
1034
|
-
const eq = token.indexOf("=");
|
|
1035
|
-
const key = normalizeFlagName(eq >= 0 ? token.slice(2, eq) : token.slice(2));
|
|
1036
|
-
const value = eq >= 0 ? token.slice(eq + 1) : argv[i + 1] && !argv[i + 1].startsWith("--") ? argv[++i] : true;
|
|
1037
|
-
const existing = flags[key];
|
|
1038
|
-
if (existing === void 0) {
|
|
1039
|
-
flags[key] = value;
|
|
1040
|
-
} else if (Array.isArray(existing)) {
|
|
1041
|
-
existing.push(String(value));
|
|
1042
|
-
} else {
|
|
1043
|
-
flags[key] = [String(existing), String(value)];
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
return flags;
|
|
1047
|
-
}
|
|
1048
|
-
function normalizeFlagName(name) {
|
|
1049
|
-
return name.replace(/_/g, "-");
|
|
1050
|
-
}
|
|
1051
|
-
function flagValue(flags, ...names) {
|
|
1052
|
-
for (const name of names.map(normalizeFlagName)) {
|
|
1053
|
-
if (flags[name] !== void 0) return flags[name];
|
|
1054
|
-
}
|
|
1055
|
-
return void 0;
|
|
1056
|
-
}
|
|
1057
|
-
function stringFlag(flags, ...names) {
|
|
1058
|
-
const value = flagValue(flags, ...names);
|
|
1059
|
-
if (Array.isArray(value)) return value.at(-1);
|
|
1060
|
-
if (value === void 0 || value === true || value === false) return void 0;
|
|
1061
|
-
const trimmed = String(value).trim();
|
|
1062
|
-
return trimmed || void 0;
|
|
1063
|
-
}
|
|
1064
|
-
function numberFlag(flags, ...names) {
|
|
1065
|
-
const value = stringFlag(flags, ...names);
|
|
1066
|
-
if (!value) return void 0;
|
|
1067
|
-
const parsed = Number(value);
|
|
1068
|
-
if (!Number.isFinite(parsed)) throw new Error(`Expected numeric value for --${names[0]}`);
|
|
1069
|
-
return parsed;
|
|
1070
|
-
}
|
|
1071
|
-
function booleanFlag(flags, name, defaultValue = false) {
|
|
1072
|
-
const value = flagValue(flags, name);
|
|
1073
|
-
if (value === void 0) return defaultValue;
|
|
1074
|
-
if (Array.isArray(value)) return value.length > 0 ? parseBoolean(value.at(-1), defaultValue) : defaultValue;
|
|
1075
|
-
return parseBoolean(value, defaultValue);
|
|
1076
|
-
}
|
|
1077
|
-
function optionalBooleanFlag(flags, trueName, falseName) {
|
|
1078
|
-
if (falseName && flagValue(flags, falseName) !== void 0) return false;
|
|
1079
|
-
if (flagValue(flags, trueName) === void 0) return void 0;
|
|
1080
|
-
return booleanFlag(flags, trueName);
|
|
1081
|
-
}
|
|
1082
|
-
function parseBoolean(value, defaultValue) {
|
|
1083
|
-
if (value === void 0) return defaultValue;
|
|
1084
|
-
if (typeof value === "boolean") return value;
|
|
1085
|
-
return !["0", "false", "no", "off"].includes(value.toLowerCase());
|
|
1086
|
-
}
|
|
1087
|
-
function csvFlag(flags, ...names) {
|
|
1088
|
-
const value = flagValue(flags, ...names);
|
|
1089
|
-
const values = Array.isArray(value) ? value : value === void 0 || typeof value === "boolean" ? [] : [value];
|
|
1090
|
-
const parsed = values.flatMap((item) => String(item).split(",").map((part) => part.trim()).filter(Boolean));
|
|
1091
|
-
return parsed.length > 0 ? parsed : void 0;
|
|
1092
|
-
}
|
|
1093
|
-
function repeatedStringFlag(flags, ...names) {
|
|
1094
|
-
const value = flagValue(flags, ...names);
|
|
1095
|
-
if (Array.isArray(value)) return value.map(String).map((item) => item.trim()).filter(Boolean);
|
|
1096
|
-
if (value === void 0 || typeof value === "boolean") return [];
|
|
1097
|
-
const trimmed = String(value).trim();
|
|
1098
|
-
return trimmed ? [trimmed] : [];
|
|
1099
|
-
}
|
|
1100
|
-
function jsonObjectFlag(flags, ...names) {
|
|
1101
|
-
const value = stringFlag(flags, ...names);
|
|
1102
|
-
if (!value) return void 0;
|
|
1103
|
-
return jsonObjectFromString(value, `--${names[0]}`);
|
|
1104
|
-
}
|
|
1105
|
-
function jsonObjectFromString(value, label) {
|
|
1106
|
-
const parsed = JSON.parse(value);
|
|
1107
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
1108
|
-
throw new Error(`Expected JSON object for ${label}`);
|
|
1109
|
-
}
|
|
1110
|
-
return parsed;
|
|
1111
|
-
}
|
|
1112
|
-
var PUBLIC_GROUND_TRUTH_CLI_FILTERS = [
|
|
1113
|
-
["industry", "industry"],
|
|
1114
|
-
["location", "location"],
|
|
1115
|
-
["nativeId", "native-id", "nativeId"],
|
|
1116
|
-
["entityName", "entity-name", "entityName"],
|
|
1117
|
-
["domain", "domain"],
|
|
1118
|
-
["websiteUrl", "website-url", "websiteUrl"],
|
|
1119
|
-
["phone", "phone"],
|
|
1120
|
-
["email", "email"],
|
|
1121
|
-
["city", "city"],
|
|
1122
|
-
["state", "state"],
|
|
1123
|
-
["postalCode", "postal-code", "postalCode"],
|
|
1124
|
-
["country", "country"],
|
|
1125
|
-
["sourceUrl", "source-url", "sourceUrl"],
|
|
1126
|
-
["naics", "naics"],
|
|
1127
|
-
["industryCode", "industry-code", "industryCode"],
|
|
1128
|
-
["industryType", "industry-type", "industryType"],
|
|
1129
|
-
["year", "year"],
|
|
1130
|
-
["quarter", "quarter"],
|
|
1131
|
-
["areaFips", "area-fips", "areaFips"],
|
|
1132
|
-
["geoId", "geo-id", "geoId"],
|
|
1133
|
-
["ownCode", "own-code", "ownCode"],
|
|
1134
|
-
["sourceUpdatedAfter", "source-updated-after", "sourceUpdatedAfter"],
|
|
1135
|
-
["sourceUpdatedBefore", "source-updated-before", "sourceUpdatedBefore"],
|
|
1136
|
-
["observedAfter", "observed-after", "observedAfter"],
|
|
1137
|
-
["observedBefore", "observed-before", "observedBefore"]
|
|
1138
|
-
];
|
|
1139
|
-
function objectFromKeyValueFlags(flags, keyValueNames, jsonNames) {
|
|
1140
|
-
const object = {};
|
|
1141
|
-
for (const jsonName of jsonNames) {
|
|
1142
|
-
const parsed = jsonObjectFlag(flags, jsonName);
|
|
1143
|
-
if (parsed) Object.assign(object, parsed);
|
|
1144
|
-
}
|
|
1145
|
-
for (const pair of repeatedStringFlag(flags, ...keyValueNames)) {
|
|
1146
|
-
const eq = pair.indexOf("=");
|
|
1147
|
-
if (eq <= 0) throw new Error(`Expected key=value for --${keyValueNames[0]}`);
|
|
1148
|
-
const key = pair.slice(0, eq).trim();
|
|
1149
|
-
const value = pair.slice(eq + 1).trim();
|
|
1150
|
-
if (!key) throw new Error(`Expected non-empty key for --${keyValueNames[0]}`);
|
|
1151
|
-
object[key] = value;
|
|
1152
|
-
}
|
|
1153
|
-
return Object.keys(object).length > 0 ? object : void 0;
|
|
1154
|
-
}
|
|
1155
|
-
function publicGroundTruthFiltersFromFlags(flags) {
|
|
1156
|
-
const filters = {};
|
|
1157
|
-
for (const [paramName, ...flagNames] of PUBLIC_GROUND_TRUTH_CLI_FILTERS) {
|
|
1158
|
-
const value = stringFlag(flags, ...flagNames);
|
|
1159
|
-
if (value) filters[paramName] = value;
|
|
1160
|
-
}
|
|
1161
|
-
const joinKeys = objectFromKeyValueFlags(
|
|
1162
|
-
flags,
|
|
1163
|
-
["join-key", "joinKey"],
|
|
1164
|
-
["join-keys-json", "joinKeysJson"]
|
|
1165
|
-
);
|
|
1166
|
-
const rowData = objectFromKeyValueFlags(
|
|
1167
|
-
flags,
|
|
1168
|
-
["row-data", "rowData"],
|
|
1169
|
-
["row-data-json", "rowDataJson"]
|
|
1170
|
-
);
|
|
1171
|
-
if (joinKeys) filters.joinKeys = joinKeys;
|
|
1172
|
-
if (rowData) filters.rowData = rowData;
|
|
1173
|
-
return filters;
|
|
1174
|
-
}
|
|
1175
|
-
function printResult(result, flags) {
|
|
1176
|
-
if (booleanFlag(flags, "json")) {
|
|
1177
|
-
printJson(result);
|
|
1178
|
-
return;
|
|
1179
|
-
}
|
|
1180
|
-
if (result && typeof result === "object") {
|
|
1181
|
-
const record = result;
|
|
1182
|
-
const title = record.summary || record.message || record.next_action || record.status;
|
|
1183
|
-
if (title) console.log(String(title));
|
|
1184
|
-
printJson(result);
|
|
1185
|
-
return;
|
|
1186
|
-
}
|
|
1187
|
-
console.log(String(result ?? ""));
|
|
1188
|
-
}
|
|
1189
|
-
function printCampaignAgentPlan(plan) {
|
|
1190
|
-
console.log(`Plan: ${plan.campaignName}`);
|
|
1191
|
-
console.log(`Plan ID: ${plan.planId}`);
|
|
1192
|
-
console.log(`Target: ${plan.targetCount}`);
|
|
1193
|
-
console.log(`Estimated credits: ${plan.estimatedCredits}`);
|
|
1194
|
-
console.log(`Memory: ${plan.memory.enabled ? plan.memory.privacyMode : "disabled"}`);
|
|
1195
|
-
console.log(`Playbooks: ${plan.operatingPlaybooks.map((item) => item.slug).join(", ") || "none"}`);
|
|
1196
|
-
console.log(`Strategy memory: ${plan.strategyMemoryStatus ? plan.strategyMemoryStatus.ready === false ? "needs seeding" : "ready" : "not loaded"}`);
|
|
1197
|
-
console.log(`Kernel plan: ${plan.kernelPlan ? "loaded" : "not loaded"}`);
|
|
1198
|
-
console.log(`Approvals: ${plan.approvals.map((item) => item.type).join(", ") || "none"}`);
|
|
1199
|
-
if (plan.warnings.length > 0) {
|
|
1200
|
-
console.log(`Warnings: ${plan.warnings.join("; ")}`);
|
|
1201
|
-
}
|
|
1202
|
-
console.log("\nMCP flow:");
|
|
1203
|
-
for (const step of plan.mcpFlow) {
|
|
1204
|
-
console.log(`- ${step.id}: ${step.tool}${step.approvalRequired ? " (approval required)" : ""}`);
|
|
1205
|
-
}
|
|
1206
|
-
}
|
|
1207
|
-
function printCampaignAgentBuildKit(kit) {
|
|
1208
|
-
console.log(`Campaign build kit: ${kit.strategy_template || "custom strategy"}`);
|
|
1209
|
-
console.log(`Request file: ${kit.request_file}`);
|
|
1210
|
-
console.log(`Built-ins: ${kit.built_in_lanes.join(", ") || "none"}`);
|
|
1211
|
-
console.log(`Playbooks: ${kit.operating_playbooks.join(", ") || "none"}`);
|
|
1212
|
-
console.log(`BYO routes: ${kit.custom_routes.length}`);
|
|
1213
|
-
console.log("\nCLI:");
|
|
1214
|
-
for (const command of kit.cli_commands.slice(0, 4)) {
|
|
1215
|
-
console.log(`- ${command.label}: ${command.command}`);
|
|
1216
|
-
}
|
|
1217
|
-
console.log("\nMCP:");
|
|
1218
|
-
for (const call of kit.mcp_calls.slice(0, 3)) {
|
|
1219
|
-
console.log(`- ${call.tool}: ${call.safety}`);
|
|
1220
|
-
}
|
|
1221
|
-
console.log("\nBYO tool pattern:");
|
|
1222
|
-
console.log(`- ${kit.byo_tool_pattern.cli_flag}`);
|
|
1223
|
-
console.log("\nNext:");
|
|
1224
|
-
for (const action of kit.next_actions.slice(0, 4)) console.log(`- ${action}`);
|
|
1225
|
-
}
|
|
1226
|
-
function printCampaignAgentMemoryKit(kit) {
|
|
1227
|
-
console.log(`Campaign memory kit: ${kit.strategy_template || "custom strategy"}`);
|
|
1228
|
-
console.log(`Request file: ${kit.request_file}`);
|
|
1229
|
-
console.log(`Seed manifest: ${kit.seed_manifest_file}`);
|
|
1230
|
-
console.log(`Sources: ${kit.memory_sources.map((source) => source.id).join(", ") || "none"}`);
|
|
1231
|
-
console.log(`Playbooks: ${kit.operating_playbooks.join(", ") || "none"}`);
|
|
1232
|
-
console.log("\nCLI:");
|
|
1233
|
-
for (const command of kit.cli_commands.slice(0, 4)) {
|
|
1234
|
-
console.log(`- ${command.label}: ${command.command}`);
|
|
1235
|
-
}
|
|
1236
|
-
console.log("\nMCP:");
|
|
1237
|
-
for (const call of kit.mcp_calls.slice(0, 3)) {
|
|
1238
|
-
console.log(`- ${call.tool}: ${call.safety}`);
|
|
1239
|
-
}
|
|
1240
|
-
console.log("\nSeed runner:");
|
|
1241
|
-
console.log(`- Dry run: ${kit.seed_runner.dry_run_command}`);
|
|
1242
|
-
if (kit.seed_runner.verify_manifest_command) console.log(`- Verify: ${kit.seed_runner.verify_manifest_command}`);
|
|
1243
|
-
console.log("\nNext:");
|
|
1244
|
-
for (const action of kit.next_actions.slice(0, 4)) console.log(`- ${action}`);
|
|
1245
|
-
}
|
|
1246
|
-
function printCampaignAgentExecution(payload, flags) {
|
|
1247
|
-
if (booleanFlag(flags, "json")) {
|
|
1248
|
-
printJson(payload);
|
|
1249
|
-
return;
|
|
1250
|
-
}
|
|
1251
|
-
printCampaignAgentOperatorVerdict(payload);
|
|
1252
|
-
printCampaignAgentPlan(payload.plan);
|
|
1253
|
-
console.log("\nResult:");
|
|
1254
|
-
printJson(payload.result);
|
|
1255
|
-
}
|
|
1256
|
-
function printCampaignAgentOperatorVerdict(payload) {
|
|
1257
|
-
const result = asRecord(payload.result);
|
|
1258
|
-
const build = hasRecordKeys(asRecord(result.build)) ? asRecord(result.build) : result;
|
|
1259
|
-
const finalStatus = asRecord(result.finalStatus);
|
|
1260
|
-
const deliveryApproval = asRecord(result.deliveryApproval);
|
|
1261
|
-
const status = textFromRecord(finalStatus, "status") ?? textFromRecord(build, "status") ?? "unknown";
|
|
1262
|
-
const dryRun = build.dryRun === true || build.dry_run === true || status === "dry_run";
|
|
1263
|
-
const campaignBuildId = textFromRecord(build, "campaignBuildId", "campaign_build_id") ?? textFromRecord(finalStatus, "campaignBuildId", "campaign_build_id");
|
|
1264
|
-
const campaignId = textFromRecord(build, "campaignId", "campaign_id") ?? textFromRecord(finalStatus, "campaignId", "campaign_id");
|
|
1265
|
-
if (dryRun) {
|
|
1266
|
-
console.log("Operator verdict: dry run complete; nothing launched.");
|
|
1267
|
-
console.log("Safety: Dry-run only. No spend, provider write, sender load, delivery, or launch ran.");
|
|
1268
|
-
} else if (textFromRecord(finalStatus, "status") === "completed") {
|
|
1269
|
-
console.log("Operator verdict: approved campaign build completed.");
|
|
1270
|
-
console.log("Safety: Approved build path. Review rows and artifacts before any delivery expansion.");
|
|
1271
|
-
} else {
|
|
1272
|
-
console.log(`Operator verdict: approved campaign build ${status}.`);
|
|
1273
|
-
console.log("Safety: Approved build path. Spend and provider writes require the supplied approval packet; delivery remains separately gated.");
|
|
1274
|
-
}
|
|
1275
|
-
console.log(`Approval state: ${campaignAgentApprovalState(payload)}`);
|
|
1276
|
-
if (campaignId) console.log(`Campaign ID: ${campaignId}`);
|
|
1277
|
-
if (campaignBuildId) console.log(`Campaign build ID: ${campaignBuildId}`);
|
|
1278
|
-
if (hasRecordKeys(finalStatus)) console.log(`Final status: ${textFromRecord(finalStatus, "status") ?? "unknown"}`);
|
|
1279
|
-
if (hasRecordKeys(deliveryApproval)) console.log(`Delivery approval: ${textFromRecord(deliveryApproval, "status") ?? "unknown"}`);
|
|
1280
|
-
console.log(`Next safe command: ${campaignAgentNextSafeCommand(payload.plan, dryRun, campaignBuildId)}`);
|
|
1281
|
-
console.log("");
|
|
1282
|
-
}
|
|
1283
|
-
function campaignAgentApprovalState(payload) {
|
|
1284
|
-
if (payload.approval) return "approval packet supplied";
|
|
1285
|
-
const required = payload.plan.approvals.map((item) => item.type);
|
|
1286
|
-
return required.length ? `missing ${required.join(", ")}` : "no explicit approvals required";
|
|
1287
|
-
}
|
|
1288
|
-
function campaignAgentNextSafeCommand(plan, dryRun, campaignBuildId) {
|
|
1289
|
-
if (campaignBuildId) return `signaliz campaign-agent review ${campaignBuildId} --limit 100`;
|
|
1290
|
-
if (!dryRun) return "signaliz campaign-agent status <campaign-build-id>";
|
|
1291
|
-
return [
|
|
1292
|
-
"signaliz campaign-agent build-approved",
|
|
1293
|
-
"--goal",
|
|
1294
|
-
shellQuote(plan.campaignName),
|
|
1295
|
-
"--target-count",
|
|
1296
|
-
String(plan.targetCount),
|
|
1297
|
-
"--confirm-launch",
|
|
1298
|
-
"--approve-all",
|
|
1299
|
-
"--approved-by <operator-email>",
|
|
1300
|
-
"--spend-limit",
|
|
1301
|
-
String(plan.estimatedCredits)
|
|
1302
|
-
].join(" ");
|
|
1303
|
-
}
|
|
1304
|
-
function printCampaignAgentReadiness(readiness) {
|
|
1305
|
-
const summary = asRecord(readiness.summary);
|
|
1306
|
-
const plan = readiness.plan;
|
|
1307
|
-
console.log(`Readiness: ${summary.ready === true ? "ready" : "blocked"} (${summary.score ?? 0}%)`);
|
|
1308
|
-
if (plan?.campaignName) console.log(`Campaign: ${plan.campaignName}`);
|
|
1309
|
-
if (summary.targetCount !== void 0) console.log(`Target: ${summary.targetCount}`);
|
|
1310
|
-
if (summary.estimatedCredits !== void 0) console.log(`Estimated credits: ${summary.estimatedCredits}`);
|
|
1311
|
-
console.log(`Built-ins: ${summary.builtInLanesReady ?? 0}/${summary.builtInLanesTotal ?? 0}`);
|
|
1312
|
-
console.log(`BYO routes: ${summary.customRoutesReady ?? 0}/${summary.customRoutesTotal ?? 0}`);
|
|
1313
|
-
console.log(`Approval gates: ${summary.approvalGateCount ?? 0}`);
|
|
1314
|
-
if (Array.isArray(readiness.gates) && readiness.gates.length > 0) {
|
|
1315
|
-
console.log("\nGates:");
|
|
1316
|
-
for (const gate of readiness.gates) {
|
|
1317
|
-
console.log(`- ${gate.passed ? "PASS" : "BLOCKED"} ${gate.label}: ${gate.detail}`);
|
|
1318
|
-
}
|
|
1319
|
-
}
|
|
1320
|
-
if (Array.isArray(readiness.lanes) && readiness.lanes.length > 0) {
|
|
1321
|
-
console.log("\nLanes:");
|
|
1322
|
-
for (const lane of readiness.lanes) {
|
|
1323
|
-
console.log(`- ${lane.ready ? "READY" : "BLOCKED"} ${lane.label}: ${lane.toolName || lane.provider}`);
|
|
1324
|
-
}
|
|
1325
|
-
}
|
|
1326
|
-
const blockers = Array.isArray(summary.blockers) ? summary.blockers : [];
|
|
1327
|
-
if (blockers.length > 0) {
|
|
1328
|
-
console.log("\nBlockers:");
|
|
1329
|
-
for (const blocker of blockers.slice(0, 8)) console.log(`- ${blocker}`);
|
|
1330
|
-
}
|
|
1331
|
-
const nextActions = Array.isArray(readiness.nextActions) ? readiness.nextActions : [];
|
|
1332
|
-
if (nextActions.length > 0) {
|
|
1333
|
-
console.log("\nNext:");
|
|
1334
|
-
for (const action of nextActions) console.log(`- ${action}`);
|
|
1335
|
-
}
|
|
1336
|
-
}
|
|
1337
|
-
function printCampaignAgentBuildStatus(status) {
|
|
1338
|
-
console.log(`Campaign: ${status.name || status.campaignBuildId}`);
|
|
1339
|
-
if (status.campaignId) console.log(`Campaign ID: ${status.campaignId}`);
|
|
1340
|
-
console.log(`Status: ${status.status}`);
|
|
1341
|
-
console.log(`Phase: ${status.currentPhase || "N/A"}`);
|
|
1342
|
-
const terminalState = asRecord(status.terminalState);
|
|
1343
|
-
if (terminalState.kind) {
|
|
1344
|
-
console.log(`Terminal state: ${terminalState.kind} (${terminalState.label || "no label"})`);
|
|
1345
|
-
if (terminalState.heartbeatAgeSeconds !== void 0 && terminalState.heartbeatAgeSeconds !== null) {
|
|
1346
|
-
console.log(`Heartbeat age: ${terminalState.heartbeatAgeSeconds}s`);
|
|
1347
|
-
}
|
|
1348
|
-
}
|
|
1349
|
-
console.log(`Rows: ${status.recordsSucceeded}/${status.recordsTotal} succeeded, ${status.recordsFailed} failed`);
|
|
1350
|
-
printCampaignCustomerRowCounts(status);
|
|
1351
|
-
console.log(`Artifacts: ${status.artifactCount}`);
|
|
1352
|
-
if (status.campaignBuildId) printCampaignArtifactDownload(status, status.campaignBuildId);
|
|
1353
|
-
if (status.triggerRunId) console.log(`Trigger: ${status.triggerRunId}`);
|
|
1354
|
-
if (Array.isArray(status.warnings) && status.warnings.length > 0) {
|
|
1355
|
-
console.log(`Warnings: ${status.warnings.slice(0, 3).join("; ")}`);
|
|
1356
|
-
}
|
|
1357
|
-
if (Array.isArray(status.errors) && status.errors.length > 0) {
|
|
1358
|
-
console.log(`Errors: ${status.errors.slice(0, 3).join("; ")}`);
|
|
1359
|
-
}
|
|
1360
|
-
if (status.status === "completed" && status.nextAction) {
|
|
1361
|
-
console.log(`Next: ${status.nextAction}`);
|
|
1362
|
-
} else if (status.status === "completed") {
|
|
1363
|
-
console.log(`Next: signaliz campaign-agent rows ${status.campaignBuildId} --limit 100`);
|
|
1364
|
-
} else if (status.status === "pending_approval" && status.approvalAction) {
|
|
1365
|
-
console.log(`Next: ${status.approvalAction}`);
|
|
1366
|
-
} else if (status.status === "pending_approval" && status.nextAction) {
|
|
1367
|
-
console.log(`Next: ${status.nextAction}`);
|
|
1368
|
-
} else if (status.status === "pending_approval") {
|
|
1369
|
-
console.log(`Next: signaliz campaign-agent approve ${status.campaignBuildId} --destination-type webhook`);
|
|
1370
|
-
} else if (terminalState.safeNextAction) {
|
|
1371
|
-
console.log(`Next: ${terminalState.safeNextAction}`);
|
|
1372
|
-
}
|
|
1373
|
-
}
|
|
1374
|
-
function printCampaignCustomerRowCounts(status) {
|
|
1375
|
-
const counts = status?.customerRowCounts || status?.customer_row_counts;
|
|
1376
|
-
if (!counts || typeof counts !== "object") return;
|
|
1377
|
-
const value = (camel, snake) => counts[camel] ?? counts[snake] ?? "n/a";
|
|
1378
|
-
const requested = value("requestedTarget", "requested_target");
|
|
1379
|
-
const copied = value("copiedRows", "copied_rows");
|
|
1380
|
-
const copySkipped = value("copySkippedRows", "copy_skipped_rows");
|
|
1381
|
-
const copyLabel = typeof copySkipped === "number" && copySkipped > 0 && (!copied || copied === "n/a") ? `copy-skipped ${copySkipped}` : `copied ${copied}`;
|
|
1382
|
-
console.log(`Customer rows: accepted ${value("acceptedRows", "accepted_rows")}/${requested}, ${copyLabel}, approval-ready ${value("approvalReadyRows", "approval_ready_rows")}, QA-ready ${value("qaReadyRows", "qa_ready_rows")}, delivered ${value("deliveredRows", "delivered_rows")}`);
|
|
1383
|
-
const shortfalls = [
|
|
1384
|
-
["accepted", value("acceptedShortfall", "accepted_shortfall")],
|
|
1385
|
-
["usable", value("usableShortfall", "usable_shortfall")],
|
|
1386
|
-
["QA-ready", value("qaReadyShortfall", "qa_ready_shortfall")],
|
|
1387
|
-
["delivery", value("deliveryShortfall", "delivery_shortfall")]
|
|
1388
|
-
].filter(([, count]) => typeof count === "number" && count > 0);
|
|
1389
|
-
if (shortfalls.length > 0) {
|
|
1390
|
-
console.log(`Shortfalls: ${shortfalls.map(([label, count]) => `${label} ${count}`).join(", ")}`);
|
|
1391
|
-
}
|
|
1392
|
-
}
|
|
1393
|
-
function printCampaignAgentBuildReview(review) {
|
|
1394
|
-
const summary = asRecord(review.summary);
|
|
1395
|
-
console.log(`Campaign: ${review.status?.name || review.campaignBuildId}`);
|
|
1396
|
-
console.log(`Status: ${summary.status || review.status?.status}`);
|
|
1397
|
-
console.log(`Phase: ${summary.phase || review.status?.currentPhase || "N/A"}`);
|
|
1398
|
-
console.log(`Terminal state: ${summary.terminalState || review.status?.terminalState?.kind || "unknown"}`);
|
|
1399
|
-
console.log(`Rows: ${summary.sampledRows || 0} sampled, ${summary.availableRows || 0} available`);
|
|
1400
|
-
console.log(`Qualified: ${summary.qualifiedRows || 0}`);
|
|
1401
|
-
console.log(`Emails: ${summary.rowsWithEmail || 0}`);
|
|
1402
|
-
console.log(`Copy ready: ${summary.copyReadyRows || 0}`);
|
|
1403
|
-
console.log(`Artifacts: ${summary.artifactCount || 0}`);
|
|
1404
|
-
printCampaignAgentNorthStarScorecard(review.northStarScorecard);
|
|
1405
|
-
if (review.campaignBuildId) printCampaignArtifactDownload(review.status, review.campaignBuildId);
|
|
1406
|
-
console.log(`Delivery approval ready: ${summary.readyForDeliveryApproval === true ? "yes" : "no"}`);
|
|
1407
|
-
if (Array.isArray(review.gates) && review.gates.length > 0) {
|
|
1408
|
-
console.log("\nGates:");
|
|
1409
|
-
for (const gate of review.gates) {
|
|
1410
|
-
const status = String(gate.status || (gate.passed ? "pass" : "blocked")).toUpperCase();
|
|
1411
|
-
console.log(`- ${status} ${gate.label}: ${gate.detail}`);
|
|
1412
|
-
}
|
|
1413
|
-
}
|
|
1414
|
-
const warnings = Array.isArray(summary.warnings) ? summary.warnings : [];
|
|
1415
|
-
if (warnings.length > 0) {
|
|
1416
|
-
console.log("\nWarnings:");
|
|
1417
|
-
for (const warning of warnings.slice(0, 5)) console.log(`- ${warning}`);
|
|
1418
|
-
}
|
|
1419
|
-
const nextActions = Array.isArray(review.nextActions) ? review.nextActions : [];
|
|
1420
|
-
if (nextActions.length > 0) {
|
|
1421
|
-
console.log("\nNext:");
|
|
1422
|
-
for (const action of nextActions) console.log(`- ${action}`);
|
|
1423
|
-
}
|
|
1424
|
-
}
|
|
1425
|
-
function printCampaignAgentNorthStarScorecard(scorecard) {
|
|
1426
|
-
const card = asRecord(scorecard);
|
|
1427
|
-
if (!card.version) return;
|
|
1428
|
-
const score = card.score === null || card.score === void 0 ? "pending" : `${card.score}%`;
|
|
1429
|
-
console.log(`North Star: ${String(card.status || "unknown")} (${score})`);
|
|
1430
|
-
if (card.moatState) console.log(`Moat state: ${card.moatState}`);
|
|
1431
|
-
const metrics = Array.isArray(card.metrics) ? card.metrics : [];
|
|
1432
|
-
if (metrics.length > 0) {
|
|
1433
|
-
console.log("\nNorth Star gates:");
|
|
1434
|
-
for (const metric of metrics.slice(0, 12)) {
|
|
1435
|
-
const item = asRecord(metric);
|
|
1436
|
-
console.log(`- ${String(item.status || "review").toUpperCase()} ${item.label || item.id}: ${item.detail || ""}`);
|
|
1437
|
-
}
|
|
1438
|
-
}
|
|
1439
|
-
}
|
|
1440
|
-
function formatCampaignAgentRows(rows) {
|
|
1441
|
-
return rows.map((row) => {
|
|
1442
|
-
const data = asRecord(row.data);
|
|
1443
|
-
const copyData = asRecord(data.copy);
|
|
1444
|
-
const rawCopy = asRecord(data.raw_copy);
|
|
1445
|
-
const copy = {
|
|
1446
|
-
subject: data.subject || copyData.subject || rawCopy.subject || null,
|
|
1447
|
-
opener: data.opener || copyData.opener || rawCopy.opener || null,
|
|
1448
|
-
body: data.body || copyData.body || rawCopy.body || null,
|
|
1449
|
-
cta: data.cta || copyData.cta || rawCopy.cta || null
|
|
1450
|
-
};
|
|
1451
|
-
const fallbackName = `${data.first_name || ""} ${data.last_name || ""}`.trim() || null;
|
|
1452
|
-
return {
|
|
1453
|
-
...row,
|
|
1454
|
-
email: data.email ?? null,
|
|
1455
|
-
name: data.full_name ?? fallbackName,
|
|
1456
|
-
title: data.title ?? null,
|
|
1457
|
-
company: data.company_name ?? null,
|
|
1458
|
-
domain: data.company_domain ?? null,
|
|
1459
|
-
score: data.overall_score ?? null,
|
|
1460
|
-
copy,
|
|
1461
|
-
has_copy: Boolean(copy.subject || copy.opener || copy.body || copy.cta)
|
|
1462
|
-
};
|
|
1463
|
-
});
|
|
1464
|
-
}
|
|
1465
|
-
function printCampaignAgentRows(result) {
|
|
1466
|
-
if (!Array.isArray(result.rows) || result.rows.length === 0) {
|
|
1467
|
-
console.log("No rows found.");
|
|
1468
|
-
return;
|
|
1469
|
-
}
|
|
1470
|
-
console.table(result.rows.map((row) => ({
|
|
1471
|
-
email: row.email || "",
|
|
1472
|
-
name: row.name || "",
|
|
1473
|
-
title: row.title || "",
|
|
1474
|
-
company: row.company || row.domain || "",
|
|
1475
|
-
status: row.status || "",
|
|
1476
|
-
segment: row.segment || "",
|
|
1477
|
-
score: row.score ?? ""
|
|
1478
|
-
})));
|
|
1479
|
-
printCampaignAgentCopySnippets(result.rows);
|
|
1480
|
-
console.log(`Showing ${result.rows.length} row(s)${result.hasMore ? " (more available)" : ""}`);
|
|
1481
|
-
if (result.nextCursor) console.log(`Next: signaliz campaign-agent rows ${result.campaignBuildId} --cursor ${result.nextCursor}`);
|
|
1482
|
-
}
|
|
1483
|
-
function printCampaignArtifactDownload(status, buildId) {
|
|
1484
|
-
const downloads = Array.isArray(status?.artifactDownloads) ? status.artifactDownloads : Array.isArray(status?.artifact_downloads) ? status.artifact_downloads : [];
|
|
1485
|
-
const download = downloads.find((item) => String(item?.format || item?.artifactType || item?.artifact_type || "").toLowerCase() === "csv") || downloads[0];
|
|
1486
|
-
const url = download?.downloadUrl || download?.download_url || download?.signedUrl || download?.signed_url;
|
|
1487
|
-
if (typeof url === "string" && url.trim()) {
|
|
1488
|
-
const format = download?.format || download?.artifactType || download?.artifact_type || "artifact";
|
|
1489
|
-
const rowCount = Number(download?.rowCount ?? download?.row_count ?? 0);
|
|
1490
|
-
console.log(`Download: ${format}${rowCount > 0 ? `, ${rowCount} rows` : ""}`);
|
|
1491
|
-
console.log(` ${url}`);
|
|
1492
|
-
} else if (Number(status?.artifactCount ?? status?.artifact_count ?? 0) > 0) {
|
|
1493
|
-
console.log(`Next: signaliz campaign download ${buildId} --format csv`);
|
|
1494
|
-
}
|
|
1495
|
-
}
|
|
1496
|
-
function printCampaignAgentCopySnippets(rows, limit = 5) {
|
|
1497
|
-
const rowsWithCopy = rows.filter((row) => {
|
|
1498
|
-
const copy = asRecord(row.copy);
|
|
1499
|
-
return Boolean(copy.subject || copy.opener || copy.body || copy.cta);
|
|
1500
|
-
});
|
|
1501
|
-
if (rowsWithCopy.length === 0) return;
|
|
1502
|
-
console.log("\nCopy:");
|
|
1503
|
-
for (const row of rowsWithCopy.slice(0, limit)) {
|
|
1504
|
-
const copy = asRecord(row.copy);
|
|
1505
|
-
const label = row.email || row.name || row.company || `row ${row.index ?? ""}`.trim();
|
|
1506
|
-
console.log(`- ${label}`);
|
|
1507
|
-
if (copy.subject) console.log(` Subject: ${copy.subject}`);
|
|
1508
|
-
if (copy.opener) console.log(` Opener: ${copy.opener}`);
|
|
1509
|
-
if (copy.body) console.log(` Body: ${copy.body}`);
|
|
1510
|
-
if (copy.cta) console.log(` CTA: ${copy.cta}`);
|
|
1511
|
-
}
|
|
1512
|
-
if (rowsWithCopy.length > limit) console.log(` ...${rowsWithCopy.length - limit} more row(s) with copy`);
|
|
1513
|
-
}
|
|
1514
|
-
function asRecord(value) {
|
|
1515
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
1516
|
-
}
|
|
1517
|
-
function hasRecordKeys(value) {
|
|
1518
|
-
return Object.keys(value).length > 0;
|
|
1519
|
-
}
|
|
1520
|
-
function textFromRecord(record, ...keys) {
|
|
1521
|
-
for (const key of keys) {
|
|
1522
|
-
const value = record[key];
|
|
1523
|
-
if (typeof value === "string" && value.trim()) return value.trim();
|
|
1524
|
-
if (typeof value === "number" && Number.isFinite(value)) return String(value);
|
|
1525
|
-
}
|
|
1526
|
-
return void 0;
|
|
1527
|
-
}
|
|
1528
|
-
function shellQuote(value) {
|
|
1529
|
-
return `'${String(value || "").replace(/'/g, `'\\''`)}'`;
|
|
1530
|
-
}
|
|
1531
|
-
function printCampaignAgentProof(proof) {
|
|
1532
|
-
console.log(`Campaign-agent proof: ${proof.success ? "passed" : "failed"}`);
|
|
1533
|
-
const campaign = asRecord(proof.campaign);
|
|
1534
|
-
if (campaign.plan_id) console.log(`Plan ID: ${campaign.plan_id}`);
|
|
1535
|
-
if (campaign.strategy_template) console.log(`Strategy template: ${campaign.strategy_template}`);
|
|
1536
|
-
if (campaign.target_count !== void 0) console.log(`Target: ${campaign.target_count}`);
|
|
1537
|
-
console.log("\nGates:");
|
|
1538
|
-
const gates = Array.isArray(proof.gates) ? proof.gates : [];
|
|
1539
|
-
for (const gate of gates) {
|
|
1540
|
-
const gateRecord = asRecord(gate);
|
|
1541
|
-
console.log(`- ${gateRecord.id}: ${gateRecord.passed ? "passed" : "failed"}`);
|
|
1542
|
-
}
|
|
1543
|
-
console.log("\nSafety: dry-run only; no spendful launch, external write, sender load, or email send.");
|
|
1544
|
-
}
|
|
1545
|
-
function printJson(value) {
|
|
1546
|
-
console.log(JSON.stringify(value, null, 2));
|
|
1547
|
-
}
|
|
1548
|
-
function truncateCell(value, width) {
|
|
1549
|
-
const text = String(value ?? "").replace(/\s+/g, " ").trim();
|
|
1550
|
-
return text.length > width ? `${text.slice(0, Math.max(width - 3, 0))}...` : text;
|
|
1551
|
-
}
|
|
1552
|
-
function printPublicGroundTruthSearch(result) {
|
|
1553
|
-
const records = Array.isArray(result.records) ? result.records : [];
|
|
1554
|
-
console.log(`Public data search: ${result.total_count ?? 0} matches (${records.length} returned)`);
|
|
1555
|
-
if (result.query) console.log(`Query: ${result.query}`);
|
|
1556
|
-
if (result.source_id) console.log(`Source: ${result.source_id}`);
|
|
1557
|
-
if (result.entity_type) console.log(`Entity type: ${result.entity_type}`);
|
|
1558
|
-
if (!records.length) {
|
|
1559
|
-
console.log("No records matched.");
|
|
1560
|
-
return;
|
|
1561
|
-
}
|
|
1562
|
-
console.log("");
|
|
1563
|
-
console.log("Source".padEnd(22) + "Native ID".padEnd(22) + "Name".padEnd(42) + "Industry".padEnd(28) + "Domain".padEnd(24) + "Loc".padEnd(12) + "Match");
|
|
1564
|
-
console.log("-".repeat(160));
|
|
1565
|
-
for (const record of records) {
|
|
1566
|
-
const loc = [record.city, record.state].filter(Boolean).join(", ");
|
|
1567
|
-
const industry = [record.industry_code, record.industry_name].filter(Boolean).join(" ");
|
|
1568
|
-
console.log(
|
|
1569
|
-
truncateCell(record.source_id, 21).padEnd(22) + truncateCell(record.native_id, 21).padEnd(22) + truncateCell(record.entity_name, 41).padEnd(42) + truncateCell(industry, 27).padEnd(28) + truncateCell(record.domain, 23).padEnd(24) + truncateCell(loc, 11).padEnd(12) + truncateCell(record.match_type, 16)
|
|
1570
|
-
);
|
|
1571
|
-
}
|
|
1572
|
-
if (result.next_offset !== null && result.next_offset !== void 0) {
|
|
1573
|
-
console.log(`
|
|
1574
|
-
Next page: --offset ${result.next_offset}`);
|
|
1575
|
-
}
|
|
1576
|
-
}
|
|
1577
|
-
function printPublicGroundTruthSources(result) {
|
|
1578
|
-
const sources = Array.isArray(result.sources) ? result.sources : [];
|
|
1579
|
-
console.log(`Public data sources: ${sources.length}/${result.total ?? sources.length}`);
|
|
1580
|
-
if (!sources.length) {
|
|
1581
|
-
console.log("No sources matched.");
|
|
1582
|
-
return;
|
|
1583
|
-
}
|
|
1584
|
-
console.log("");
|
|
1585
|
-
console.log("Source ID".padEnd(30) + "Status".padEnd(12) + "Rung".padEnd(7) + "Join key".padEnd(20) + "Cadence".padEnd(16) + "Name");
|
|
1586
|
-
console.log("-".repeat(120));
|
|
1587
|
-
for (const source of sources) {
|
|
1588
|
-
console.log(
|
|
1589
|
-
truncateCell(source.id, 29).padEnd(30) + truncateCell(source.ingestion_status, 11).padEnd(12) + String(source.ground_truth_rung ?? "").padEnd(7) + truncateCell(source.primary_join_key || source.join_key_quality, 19).padEnd(20) + truncateCell(source.update_cadence, 15).padEnd(16) + truncateCell(source.name, 40)
|
|
1590
|
-
);
|
|
1591
|
-
}
|
|
1592
|
-
}
|
|
1593
|
-
function printHelp() {
|
|
1594
|
-
console.log(`
|
|
1595
|
-
Signaliz CLI v1.0.0
|
|
1596
|
-
|
|
1597
|
-
Usage:
|
|
1598
|
-
signaliz test Verify API connectivity
|
|
1599
|
-
signaliz tools List all available MCP tools
|
|
1600
|
-
signaliz public-data search --query "swift transportation" --limit 10
|
|
1601
|
-
signaliz public-data sources --status ready
|
|
1602
|
-
signaliz gtm context --json Load GTM Kernel workspace context
|
|
1603
|
-
signaliz gtm bootstrap --json Inspect GTM Kernel readiness
|
|
1604
|
-
signaliz gtm templates --json List private-safe campaign strategy templates
|
|
1605
|
-
signaliz gtm start-context --strategy-template non-medical-home-care --json
|
|
1606
|
-
signaliz gtm strategy-memory --strategy-template non-medical-home-care --include-samples --json
|
|
1607
|
-
signaliz gtm agent-plan --goal "Build a strategy-template campaign" --strategy-template non-medical-home-care --target-count 500 --json
|
|
1608
|
-
signaliz gtm provider-prepare --provider-id customer_mcp --layer company_enrichment --invocation-type mcp_tool --json
|
|
1609
|
-
signaliz gtm memory search --query "proof-first vertical gate" --json
|
|
1610
|
-
signaliz gtm feedback instantly-pull --campaign-id <id> --source emails --email-type received --mode emode_all --sort-order asc --confirm-write --json
|
|
1611
|
-
signaliz gtm learning status --campaign-id <id> --json
|
|
1612
|
-
signaliz gtm plan --brief "Build 500 verified leads for..." --strategy-template non-medical-home-care --lead-count 500 --json
|
|
1613
|
-
signaliz campaign-agent init --strategy-template non-medical-home-care --target-count 250 --use-local-leads --json > campaign-request.json
|
|
1614
|
-
signaliz campaign-agent memory-kit --strategy-template non-medical-home-care --target-count 250 --use-local-leads --json
|
|
1615
|
-
signaliz campaign-agent doctor --request-file campaign-request.json --json
|
|
1616
|
-
signaliz campaign-agent plan --goal "Build a strategy-template campaign..." --strategy-template industrial-ot-resilience --target-count 500 --builtins lead_generation,email_finding,email_verification,signals
|
|
1617
|
-
signaliz campaign-agent proof --goal "Build a strategy-template campaign..." --strategy-template non-medical-home-care --target-count 100 --json
|
|
1618
|
-
signaliz campaign-agent plan --request-file examples/campaign-builder-agent-request.json --target-count 250 --json
|
|
1619
|
-
signaliz campaign-agent commit-plan --goal "Build a strategy-template campaign..." --json
|
|
1620
|
-
signaliz campaign-agent dry-run --goal "Build a strategy-template campaign..." --target-count 500 --use-local-leads --json
|
|
1621
|
-
signaliz campaign-agent build-approved --goal "Build a strategy-template campaign..." --confirm-launch --approve-all --approved-by you@example.com --spend-limit 500
|
|
1622
|
-
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
|
|
1623
|
-
signaliz campaign-agent review <campaign_build_id> --limit 100 --json
|
|
1624
|
-
signaliz campaign-agent status <campaign_build_id> --json
|
|
1625
|
-
signaliz campaign-agent rows <campaign_build_id> --limit 100 --json
|
|
1626
|
-
|
|
1627
|
-
Environment:
|
|
1628
|
-
SIGNALIZ_API_KEY Your API key (not required for campaign-agent init)
|
|
1629
|
-
SIGNALIZ_BASE_URL Optional API base URL override
|
|
1630
|
-
`);
|
|
1631
|
-
}
|
|
1632
|
-
function printPublicGroundTruthHelp() {
|
|
1633
|
-
console.log(`
|
|
1634
|
-
Signaliz public-data commands:
|
|
1635
|
-
|
|
1636
|
-
signaliz public-data search [--query TEXT] [--industry TEXT] [--location TEXT] [--source-id ID] [--domain DOMAIN] [--naics CODE] [--state ST] [--year YYYY] [--join-key k=v] [--row-data k=v] [--limit N] [--offset N] [--json]
|
|
1637
|
-
signaliz public-data sources [--query TEXT] [--status ready|partial|blocked|planned] [--limit N] [--json]
|
|
1638
|
-
|
|
1639
|
-
Aliases:
|
|
1640
|
-
signaliz ground-truth search ...
|
|
1641
|
-
|
|
1642
|
-
Examples:
|
|
1643
|
-
signaliz public-data search --query "swift transportation" --source-id fmcsa_company_census --limit 10
|
|
1644
|
-
signaliz public-data search --industry "software publishers" --location CA --limit 25 --json
|
|
1645
|
-
signaliz public-data search --source-id bls_qcew --naics 541511 --state CA --year 2025 --json
|
|
1646
|
-
signaliz public-data search --domain swifttrans.com --json
|
|
1647
|
-
signaliz public-data search --join-key ein=123456789 --json
|
|
1648
|
-
signaliz public-data sources --status ready --json
|
|
1649
|
-
`);
|
|
1650
|
-
}
|
|
1651
|
-
function printGtmHelp() {
|
|
1652
|
-
console.log(`
|
|
1653
|
-
Signaliz GTM commands:
|
|
1654
|
-
|
|
1655
|
-
signaliz gtm context [--include-campaigns] [--include-memory] [--include-brain] [--include-connections] [--limit N] [--json]
|
|
1656
|
-
signaliz gtm bootstrap [--campaign-id ID] [--days N] [--include-connections] [--include-samples] [--json]
|
|
1657
|
-
signaliz gtm templates [--query TEXT] [--strategy-template ID] [--summary] [--json]
|
|
1658
|
-
signaliz gtm start-context [--brief TEXT] [--strategy-template ID] [--target-count N] [--layers a,b] [--providers a,b] [--json]
|
|
1659
|
-
signaliz gtm strategy-memory [--query TEXT] [--strategy-template ID] [--include-samples] [--json]
|
|
1660
|
-
signaliz gtm provider-prepare --provider-id ID [--layer NAME] [--invocation-type webhook|mcp_tool|api] [--json]
|
|
1661
|
-
signaliz gtm activate-route --provider-id ID --layer NAME [--confirm] [--json]
|
|
1662
|
-
signaliz gtm memory search --query TEXT [--layers a,b] [--provider-chain a,b] [--limit N] [--json]
|
|
1663
|
-
signaliz gtm learning status (--campaign-id ID | --campaign-build-id ID) [--json]
|
|
1664
|
-
signaliz gtm feedback instantly-pull (--campaign-id ID | --provider-link-id ID | --provider-campaign-id ID) [--source webhook_events|emails] [--email-type received|sent|manual] [--mode emode_focused|emode_others|emode_all] [--sort-order asc|desc] [--instantly-profile PROFILE] [--confirm-write] [--json]
|
|
1665
|
-
signaliz gtm feedback instantly-webhook-prepare (--campaign-id ID | --provider-link-id ID) --confirm-write [--json]
|
|
1666
|
-
signaliz gtm plan --brief TEXT [--strategy-template industrial-ot-resilience|non-medical-home-care|agency-founder-led|cloud-infrastructure-displacement] [--lead-count N] [--layers a,b] [--providers a,b] [--partners clay,instantly,nango] [--target-icp JSON] [--json]
|
|
1667
|
-
`);
|
|
1668
|
-
}
|
|
1669
|
-
function printCampaignAgentHelp() {
|
|
1670
|
-
console.log(`
|
|
1671
|
-
Signaliz campaign-agent commands:
|
|
1672
|
-
|
|
1673
|
-
signaliz campaign-agent init [--goal TEXT] [--strategy-template ID] [--target-count N] [--use-local-leads] [--with-byo-placeholder] [--output-file FILE] [--json]
|
|
1674
|
-
signaliz campaign-agent kit [--goal TEXT | --request-file FILE] [--strategy-template ID] [--target-count N] [--use-local-leads] [--custom-tool provider:layer:tool[:mcp]] [--output-file FILE] [--json]
|
|
1675
|
-
signaliz campaign-agent memory-kit [--goal TEXT | --request-file FILE] [--strategy-template ID] [--source north-star|agency|workflow-patterns|instantly-feedback|all] [--seed-manifest-file FILE] [--json]
|
|
1676
|
-
signaliz campaign-agent doctor [--goal TEXT | --request-file FILE] [--strategy-template ID] [--target-count N] [--builtins lead_generation,email_finding,email_verification,signals,local_leads] [--custom-tool provider:layer:tool[:mcp]] [--json]
|
|
1677
|
-
signaliz campaign-agent plan (--goal TEXT | --request-file FILE) [--campaign-name NAME] [--workspace-label NAME] [--strategy-template industrial-ot-resilience|non-medical-home-care|agency-founder-led|cloud-infrastructure-displacement] [--operating-playbooks proof-first-vertical-gate,signal-led-copy-approval] [--target-count N] [--icp JSON] [--builtins lead_generation,email_finding,email_verification,signals,local_leads] [--use-local-leads] [--custom-tool provider:layer:tool[:mcp]] [--preferred-providers signaliz_native,octave] [--partners clay,instantly,nango] [--no-strategy-memory] [--no-kernel-plan] [--no-delivery-risk] [--json]
|
|
1678
|
-
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]
|
|
1679
|
-
signaliz campaign-agent commit-plan (--goal TEXT | --request-file FILE) [--confirm-write --approved-by EMAIL] [--idempotency-key KEY] [--json]
|
|
1680
|
-
signaliz campaign-agent dry-run (--goal TEXT | --request-file FILE) [--gtm-campaign-id ID] [--delivery-risk JSON] [--idempotency-key KEY] [--json]
|
|
1681
|
-
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]
|
|
1682
|
-
signaliz campaign-agent review <campaign_build_id> [--limit N] [--qualified|--disqualified] [--include-data] [--include-raw] [--json]
|
|
1683
|
-
signaliz campaign-agent status <campaign_build_id> [--json]
|
|
1684
|
-
signaliz campaign-agent rows <campaign_build_id> [--limit N] [--cursor CURSOR] [--qualified|--disqualified] [--include-data] [--include-raw] [--json]
|
|
1685
|
-
signaliz campaign-agent artifacts <campaign_build_id> [--json]
|
|
1686
|
-
signaliz campaign-agent approve <campaign_build_id> --destination-type json|csv|webhook [--destination-config JSON] [--json]
|
|
1687
|
-
|
|
1688
|
-
The init command emits a reusable JSON CampaignBuilderAgentRequest. Kit emits the full build packet: request JSON, exact CLI commands, MCP calls, SDK example, approval boundaries, and BYO integration pattern. Doctor returns a readiness packet for built-in lanes, BYO routes, Memory, Brain, Kernel planning, and approval gates. 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 webhook delivery after pending_approval. Use review to inspect status, sampled rows, artifacts, and delivery-readiness gates before approving delivery or routing rows to external tools.
|
|
1689
|
-
`);
|
|
1690
|
-
}
|
|
1691
|
-
main().catch((e) => {
|
|
1692
|
-
console.error(e);
|
|
1693
|
-
process.exit(1);
|
|
1694
|
-
});
|