@signaliz/sdk 1.0.10 → 1.0.12
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 +16 -0
- package/dist/{chunk-2EXN3RAX.mjs → chunk-XJQ6KGNQ.mjs} +184 -0
- package/dist/cli.js +362 -1
- package/dist/cli.mjs +179 -2
- package/dist/index.d.mts +40 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +184 -0
- package/dist/index.mjs +1 -1
- package/dist/mcp-config.js +184 -0
- package/dist/mcp-config.mjs +1 -1
- package/package.json +1 -1
package/dist/mcp-config.js
CHANGED
|
@@ -1870,6 +1870,42 @@ var CampaignBuilderAgent = class {
|
|
|
1870
1870
|
}
|
|
1871
1871
|
return result;
|
|
1872
1872
|
}
|
|
1873
|
+
async getBuildStatus(campaignBuildId) {
|
|
1874
|
+
return this.getCampaignBuildStatus(campaignBuildId);
|
|
1875
|
+
}
|
|
1876
|
+
async getBuildRows(campaignBuildId, options = {}) {
|
|
1877
|
+
const filters = compact({
|
|
1878
|
+
segment: options.segment,
|
|
1879
|
+
qualified: options.qualified,
|
|
1880
|
+
row_status: options.rowStatus
|
|
1881
|
+
});
|
|
1882
|
+
const args = compact({
|
|
1883
|
+
campaign_build_id: campaignBuildId,
|
|
1884
|
+
page_size: options.limit,
|
|
1885
|
+
cursor: options.cursor
|
|
1886
|
+
});
|
|
1887
|
+
if (Object.keys(filters).length > 0) args.filters = filters;
|
|
1888
|
+
const data = await this.callMcp("get_campaign_build_rows", args);
|
|
1889
|
+
return mapAgentCampaignRowsResult(data);
|
|
1890
|
+
}
|
|
1891
|
+
async listBuildArtifacts(campaignBuildId) {
|
|
1892
|
+
const data = await this.callMcp("list_campaign_build_artifacts", {
|
|
1893
|
+
campaign_build_id: campaignBuildId
|
|
1894
|
+
});
|
|
1895
|
+
return Array.isArray(data.artifacts) ? data.artifacts.map(mapAgentCampaignArtifact) : [];
|
|
1896
|
+
}
|
|
1897
|
+
async approveDelivery(campaignBuildId, destinationType, options) {
|
|
1898
|
+
return this.approveCampaignDelivery(campaignBuildId, destinationType, options);
|
|
1899
|
+
}
|
|
1900
|
+
async reviewBuild(campaignBuildId, options = {}) {
|
|
1901
|
+
const status = await this.getBuildStatus(campaignBuildId);
|
|
1902
|
+
const rows = await this.getBuildRows(campaignBuildId, {
|
|
1903
|
+
...options,
|
|
1904
|
+
limit: options.limit ?? 100
|
|
1905
|
+
});
|
|
1906
|
+
const artifacts = await this.listBuildArtifacts(campaignBuildId);
|
|
1907
|
+
return createCampaignBuilderBuildReview(status, rows, artifacts);
|
|
1908
|
+
}
|
|
1873
1909
|
async getCampaignBuildStatus(campaignBuildId) {
|
|
1874
1910
|
const data = await this.callMcp("get_campaign_build_status", {
|
|
1875
1911
|
campaign_build_id: campaignBuildId
|
|
@@ -3162,6 +3198,154 @@ function mapAgentCampaignBuildStatus(data) {
|
|
|
3162
3198
|
completedAt: stringValue(data.completed_at) ?? null
|
|
3163
3199
|
};
|
|
3164
3200
|
}
|
|
3201
|
+
function mapAgentCampaignRowsResult(data) {
|
|
3202
|
+
const rows = Array.isArray(data.rows) ? data.rows : [];
|
|
3203
|
+
return {
|
|
3204
|
+
campaignBuildId: stringValue(data.campaign_build_id) ?? "",
|
|
3205
|
+
rows: rows.map((row, index) => {
|
|
3206
|
+
const record = asRecord(row);
|
|
3207
|
+
return {
|
|
3208
|
+
index: numberOrUndefined2(record.index) ?? index,
|
|
3209
|
+
status: stringValue(record.status) ?? stringValue(record.row_status) ?? "unknown",
|
|
3210
|
+
qualified: record.qualified !== false,
|
|
3211
|
+
segment: stringValue(record.segment) ?? null,
|
|
3212
|
+
data: nullableRecord(record.data) ?? record
|
|
3213
|
+
};
|
|
3214
|
+
}),
|
|
3215
|
+
count: numberOrUndefined2(data.count) ?? rows.length,
|
|
3216
|
+
pageSize: numberOrUndefined2(data.page_size) ?? rows.length,
|
|
3217
|
+
nextCursor: stringValue(data.next_cursor) ?? null,
|
|
3218
|
+
hasMore: data.has_more === true
|
|
3219
|
+
};
|
|
3220
|
+
}
|
|
3221
|
+
function mapAgentCampaignArtifact(data) {
|
|
3222
|
+
return {
|
|
3223
|
+
id: stringValue(data.id) ?? "",
|
|
3224
|
+
campaignBuildId: stringValue(data.campaign_build_id) ?? "",
|
|
3225
|
+
artifactType: stringValue(data.artifact_type) ?? "",
|
|
3226
|
+
destination: stringValue(data.destination) ?? "",
|
|
3227
|
+
storagePath: stringValue(data.storage_path) ?? "",
|
|
3228
|
+
signedUrl: stringValue(data.signed_url) ?? null,
|
|
3229
|
+
rowCount: numberOrUndefined2(data.row_count) ?? 0,
|
|
3230
|
+
checksum: stringValue(data.checksum) ?? null,
|
|
3231
|
+
metadata: nullableRecord(data.metadata) ?? {},
|
|
3232
|
+
createdAt: stringValue(data.created_at) ?? ""
|
|
3233
|
+
};
|
|
3234
|
+
}
|
|
3235
|
+
function createCampaignBuilderBuildReview(status, rows, artifacts) {
|
|
3236
|
+
const sampledRows = rows.rows.length;
|
|
3237
|
+
const availableRows = rows.count || sampledRows;
|
|
3238
|
+
const qualifiedRows = rows.rows.filter((row) => row.qualified !== false).length;
|
|
3239
|
+
const rowsWithEmail = rows.rows.filter(campaignReviewRowHasEmail).length;
|
|
3240
|
+
const copyReadyRows = rows.rows.filter(campaignReviewRowHasCopy).length;
|
|
3241
|
+
const artifactCount = artifacts.length || status.artifactCount || 0;
|
|
3242
|
+
const gates = [
|
|
3243
|
+
{
|
|
3244
|
+
id: "build_completed",
|
|
3245
|
+
label: "Build completed",
|
|
3246
|
+
passed: status.status === "completed",
|
|
3247
|
+
detail: status.status === "completed" ? "The campaign build is completed." : `The campaign build is ${status.status}; review again after completion.`
|
|
3248
|
+
},
|
|
3249
|
+
{
|
|
3250
|
+
id: "rows_available",
|
|
3251
|
+
label: "Rows available",
|
|
3252
|
+
passed: sampledRows > 0,
|
|
3253
|
+
detail: sampledRows > 0 ? `${sampledRows} sampled row(s) are available for review.` : "No rows were returned for review."
|
|
3254
|
+
},
|
|
3255
|
+
{
|
|
3256
|
+
id: "qualified_sample",
|
|
3257
|
+
label: "Sample rows qualified",
|
|
3258
|
+
passed: sampledRows > 0 && qualifiedRows === sampledRows,
|
|
3259
|
+
detail: sampledRows > 0 ? `${qualifiedRows}/${sampledRows} sampled row(s) are marked qualified.` : "Qualification could not be checked without sampled rows."
|
|
3260
|
+
},
|
|
3261
|
+
{
|
|
3262
|
+
id: "email_coverage",
|
|
3263
|
+
label: "Email coverage",
|
|
3264
|
+
passed: sampledRows > 0 && rowsWithEmail === sampledRows,
|
|
3265
|
+
detail: sampledRows > 0 ? `${rowsWithEmail}/${sampledRows} sampled row(s) include an email.` : "Email coverage could not be checked without sampled rows."
|
|
3266
|
+
},
|
|
3267
|
+
{
|
|
3268
|
+
id: "artifact_available",
|
|
3269
|
+
label: "Artifact available",
|
|
3270
|
+
passed: artifactCount > 0,
|
|
3271
|
+
detail: artifactCount > 0 ? `${artifactCount} artifact(s) are available.` : "No delivery artifact is available yet."
|
|
3272
|
+
},
|
|
3273
|
+
{
|
|
3274
|
+
id: "no_failed_rows",
|
|
3275
|
+
label: "No failed rows",
|
|
3276
|
+
passed: status.recordsFailed === 0,
|
|
3277
|
+
detail: status.recordsFailed === 0 ? "The build reports zero failed rows." : `${status.recordsFailed} row(s) failed during the build.`
|
|
3278
|
+
}
|
|
3279
|
+
];
|
|
3280
|
+
const blockedReasons = gates.filter((gate) => !gate.passed).map((gate) => gate.detail);
|
|
3281
|
+
const warnings = [
|
|
3282
|
+
rows.hasMore ? "This review is based on a row sample; page through remaining rows before final approval." : void 0,
|
|
3283
|
+
sampledRows > 0 && copyReadyRows < sampledRows ? `${copyReadyRows}/${sampledRows} sampled row(s) include generated copy.` : void 0,
|
|
3284
|
+
...status.warnings
|
|
3285
|
+
].filter((item) => Boolean(item));
|
|
3286
|
+
const readyForDeliveryApproval = blockedReasons.length === 0;
|
|
3287
|
+
return {
|
|
3288
|
+
campaignBuildId: status.campaignBuildId || rows.campaignBuildId,
|
|
3289
|
+
status,
|
|
3290
|
+
rows,
|
|
3291
|
+
artifacts,
|
|
3292
|
+
gates,
|
|
3293
|
+
summary: {
|
|
3294
|
+
status: status.status,
|
|
3295
|
+
phase: status.currentPhase,
|
|
3296
|
+
sampledRows,
|
|
3297
|
+
availableRows,
|
|
3298
|
+
qualifiedRows,
|
|
3299
|
+
rowsWithEmail,
|
|
3300
|
+
copyReadyRows,
|
|
3301
|
+
artifactCount,
|
|
3302
|
+
readyForDeliveryApproval,
|
|
3303
|
+
blockedReasons,
|
|
3304
|
+
warnings
|
|
3305
|
+
},
|
|
3306
|
+
nextActions: campaignReviewNextActions(status, readyForDeliveryApproval)
|
|
3307
|
+
};
|
|
3308
|
+
}
|
|
3309
|
+
function campaignReviewNextActions(status, readyForDeliveryApproval) {
|
|
3310
|
+
const buildId = status.campaignBuildId;
|
|
3311
|
+
if (!buildId) return [];
|
|
3312
|
+
if (status.status === "completed" && readyForDeliveryApproval) {
|
|
3313
|
+
return [
|
|
3314
|
+
`signaliz campaign-agent approve ${buildId} --destination-type json`,
|
|
3315
|
+
`signaliz campaign-agent artifacts ${buildId}`
|
|
3316
|
+
];
|
|
3317
|
+
}
|
|
3318
|
+
if (status.status === "completed") {
|
|
3319
|
+
return [
|
|
3320
|
+
`signaliz campaign-agent rows ${buildId} --limit 100`,
|
|
3321
|
+
`signaliz campaign-agent artifacts ${buildId}`
|
|
3322
|
+
];
|
|
3323
|
+
}
|
|
3324
|
+
if (status.status === "pending_approval") {
|
|
3325
|
+
return [
|
|
3326
|
+
`signaliz campaign-agent rows ${buildId} --limit 100`,
|
|
3327
|
+
`signaliz campaign-agent approve ${buildId} --destination-type json`
|
|
3328
|
+
];
|
|
3329
|
+
}
|
|
3330
|
+
if ((status.status === "queued" || status.status === "running") && status.triggerRunId) {
|
|
3331
|
+
return [`signaliz ops run-status ${status.triggerRunId} --watch`];
|
|
3332
|
+
}
|
|
3333
|
+
return [`signaliz campaign-agent status ${buildId}`];
|
|
3334
|
+
}
|
|
3335
|
+
function campaignReviewRowHasEmail(row) {
|
|
3336
|
+
const data = asRecord(row.data);
|
|
3337
|
+
return Boolean(
|
|
3338
|
+
stringValue(data.email) || stringValue(data.work_email) || stringValue(data.workEmail)
|
|
3339
|
+
);
|
|
3340
|
+
}
|
|
3341
|
+
function campaignReviewRowHasCopy(row) {
|
|
3342
|
+
const data = asRecord(row.data);
|
|
3343
|
+
const copy = asRecord(data.copy);
|
|
3344
|
+
const rawCopy = asRecord(data.raw_copy ?? data.rawCopy);
|
|
3345
|
+
return row.status === "copy_ready" || data.copy_ready === true || Boolean(
|
|
3346
|
+
stringValue(data.subject) || stringValue(data.subject_line) || stringValue(data.subjectLine) || stringValue(data.opener) || stringValue(data.body) || stringValue(data.cta) || stringValue(copy.subject) || stringValue(copy.body) || stringValue(rawCopy.subject) || stringValue(rawCopy.body)
|
|
3347
|
+
);
|
|
3348
|
+
}
|
|
3165
3349
|
function diagnosticMessages2(value) {
|
|
3166
3350
|
if (!Array.isArray(value)) return [];
|
|
3167
3351
|
return value.map((item) => {
|
package/dist/mcp-config.mjs
CHANGED