@signaliz/sdk 1.0.3 → 1.0.5
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 +79 -2
- package/dist/{chunk-L6XUFJJO.mjs → chunk-GF2T2X3W.mjs} +382 -47
- package/dist/cli.js +382 -47
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +233 -12
- package/dist/index.d.ts +233 -12
- package/dist/index.js +382 -47
- package/dist/index.mjs +1 -1
- package/dist/mcp-config.js +382 -47
- package/dist/mcp-config.mjs +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -210,13 +210,14 @@ var HttpClient = class {
|
|
|
210
210
|
details: { responseText: text.slice(0, 500) }
|
|
211
211
|
});
|
|
212
212
|
}
|
|
213
|
-
|
|
213
|
+
const responseError = isRecord(data) && isRecord(data.error) ? data.error : null;
|
|
214
|
+
if (responseError) {
|
|
214
215
|
const err = new SignalizError({
|
|
215
|
-
code:
|
|
216
|
-
message:
|
|
217
|
-
errorType: mapMcpErrorType(
|
|
218
|
-
retryAfter: data.
|
|
219
|
-
details: data.
|
|
216
|
+
code: firstString(responseError.code, isRecord(responseError.data) ? responseError.data.error_code : void 0) || "MCP_ERROR",
|
|
217
|
+
message: firstString(responseError.message) || "MCP request failed",
|
|
218
|
+
errorType: mapMcpErrorType(responseError),
|
|
219
|
+
retryAfter: isRecord(responseError.data) && typeof responseError.data.retry_after === "number" ? responseError.data.retry_after : void 0,
|
|
220
|
+
details: isRecord(responseError.data) ? responseError.data : void 0
|
|
220
221
|
});
|
|
221
222
|
if (err.isRetryable && attempt < this.maxRetries) {
|
|
222
223
|
lastError = err;
|
|
@@ -293,35 +294,63 @@ function normalizeMcpParams(method, params) {
|
|
|
293
294
|
}
|
|
294
295
|
};
|
|
295
296
|
}
|
|
297
|
+
function isRecord(value) {
|
|
298
|
+
return typeof value === "object" && value !== null;
|
|
299
|
+
}
|
|
300
|
+
function firstString(...values) {
|
|
301
|
+
const value = values.find((item) => typeof item === "string" && item.length > 0);
|
|
302
|
+
return typeof value === "string" ? value : void 0;
|
|
303
|
+
}
|
|
304
|
+
function firstPayloadError(payload) {
|
|
305
|
+
const errors = payload.errors;
|
|
306
|
+
const first = Array.isArray(errors) ? errors[0] : void 0;
|
|
307
|
+
return isRecord(first) ? first : {};
|
|
308
|
+
}
|
|
296
309
|
function unwrapMcpResponse(data) {
|
|
297
|
-
|
|
298
|
-
|
|
310
|
+
const result = isRecord(data) ? data.result : void 0;
|
|
311
|
+
if (isRecord(result) && result.structuredContent !== void 0) {
|
|
312
|
+
return unwrapMcpPayload(result.structuredContent);
|
|
299
313
|
}
|
|
300
|
-
const
|
|
314
|
+
const content = isRecord(result) ? result.content : void 0;
|
|
315
|
+
const firstContent = Array.isArray(content) ? content[0] : void 0;
|
|
316
|
+
const text = isRecord(firstContent) ? firstContent.text : void 0;
|
|
301
317
|
if (typeof text === "string") {
|
|
302
318
|
const parsed = safeJson(text);
|
|
303
319
|
return unwrapMcpPayload(parsed ?? text);
|
|
304
320
|
}
|
|
305
|
-
return unwrapMcpPayload(
|
|
321
|
+
return unwrapMcpPayload(result);
|
|
306
322
|
}
|
|
307
323
|
function unwrapMcpPayload(payload) {
|
|
308
|
-
if (payload
|
|
324
|
+
if (isRecord(payload)) {
|
|
309
325
|
if (payload.ok === true && Object.prototype.hasOwnProperty.call(payload, "result")) {
|
|
310
|
-
return payload.result;
|
|
326
|
+
return unwrapMcpPayload(payload.result);
|
|
327
|
+
}
|
|
328
|
+
if (payload.ok === false) {
|
|
329
|
+
const first = firstPayloadError(payload);
|
|
330
|
+
const code = firstString(first.code, payload.error_code, payload.code) || (payload.approval_required ? "APPROVAL_REQUIRED" : "MCP_ERROR");
|
|
331
|
+
throw new SignalizError({
|
|
332
|
+
code,
|
|
333
|
+
message: firstString(first.message, payload.message, payload.summary, payload.error) || "MCP request failed",
|
|
334
|
+
errorType: mapErrorTypeFromCode(code),
|
|
335
|
+
details: {
|
|
336
|
+
...payload,
|
|
337
|
+
...isRecord(first.details) ? first.details : {}
|
|
338
|
+
}
|
|
339
|
+
});
|
|
311
340
|
}
|
|
312
341
|
if (payload.success === true && Object.prototype.hasOwnProperty.call(payload, "data")) {
|
|
313
342
|
return payload.data;
|
|
314
343
|
}
|
|
315
344
|
if (payload.success === false) {
|
|
316
|
-
const first =
|
|
317
|
-
const code = first.code
|
|
345
|
+
const first = firstPayloadError(payload);
|
|
346
|
+
const code = firstString(first.code, payload.error_code) || (payload.approval_required ? "APPROVAL_REQUIRED" : "MCP_ERROR");
|
|
318
347
|
throw new SignalizError({
|
|
319
348
|
code,
|
|
320
|
-
message: first.message
|
|
349
|
+
message: firstString(first.message, payload.message, payload.summary) || "MCP request failed",
|
|
321
350
|
errorType: mapErrorTypeFromCode(code),
|
|
322
351
|
details: {
|
|
323
352
|
...payload,
|
|
324
|
-
...first.details
|
|
353
|
+
...isRecord(first.details) ? first.details : {}
|
|
325
354
|
}
|
|
326
355
|
});
|
|
327
356
|
}
|
|
@@ -329,8 +358,10 @@ function unwrapMcpPayload(payload) {
|
|
|
329
358
|
return payload;
|
|
330
359
|
}
|
|
331
360
|
function mapMcpErrorType(error) {
|
|
332
|
-
const
|
|
333
|
-
const
|
|
361
|
+
const errorRecord = isRecord(error) ? error : {};
|
|
362
|
+
const data = isRecord(errorRecord.data) ? errorRecord.data : {};
|
|
363
|
+
const code = String(data.error_code || errorRecord.code || "");
|
|
364
|
+
const message = String(errorRecord.message || "").toLowerCase();
|
|
334
365
|
if (code === "429" || message.includes("rate limit")) return "rate_limited";
|
|
335
366
|
if (code === "401" || code === "AUTH_001" || message.includes("auth")) return "auth_expired";
|
|
336
367
|
if (code === "400" || code === "-32602" || message.includes("invalid")) return "validation";
|
|
@@ -813,15 +844,17 @@ var Campaigns = class {
|
|
|
813
844
|
args.idempotency_key = options.idempotencyKey;
|
|
814
845
|
}
|
|
815
846
|
const data = await this.callMcp("build_campaign", args);
|
|
847
|
+
const isDryRun = request.dryRun === true || data.dry_run === true || data.status === "dry_run";
|
|
848
|
+
const message = data.message ?? data.summary ?? (isDryRun && data.planned_target_count !== void 0 && data.estimated_credits !== void 0 && data.estimated_duration_seconds !== void 0 ? `Dry-run plan: ${data.planned_target_count} fresh leads. ~${data.estimated_credits} credits, ~${data.estimated_duration_seconds}s.` : "");
|
|
816
849
|
return {
|
|
817
850
|
campaignBuildId: data.campaign_build_id ?? null,
|
|
818
851
|
campaignId: data.campaign_id ?? null,
|
|
819
852
|
campaignObject: data.campaign_object ?? null,
|
|
820
|
-
status:
|
|
821
|
-
currentPhase:
|
|
853
|
+
status: isDryRun ? "dry_run" : data.status ?? "queued",
|
|
854
|
+
currentPhase: isDryRun ? "plan" : data.current_phase ?? "acquisition",
|
|
822
855
|
nextPollAfterSeconds: data.next_poll_after_seconds ?? 10,
|
|
823
|
-
message
|
|
824
|
-
dryRun:
|
|
856
|
+
message,
|
|
857
|
+
dryRun: isDryRun,
|
|
825
858
|
requestedTargetCount: data.requested_target_count,
|
|
826
859
|
plannedTargetCount: data.planned_target_count,
|
|
827
860
|
estimatedCredits: data.estimated_credits,
|
|
@@ -935,8 +968,8 @@ function mapStatus(data) {
|
|
|
935
968
|
recordsProcessed: data.records_processed ?? 0,
|
|
936
969
|
recordsSucceeded: data.records_succeeded ?? 0,
|
|
937
970
|
recordsFailed: data.records_failed ?? 0,
|
|
938
|
-
warnings: data.warnings
|
|
939
|
-
errors: data.errors
|
|
971
|
+
warnings: diagnosticMessages(data.warnings),
|
|
972
|
+
errors: diagnosticMessages(data.errors),
|
|
940
973
|
artifactCount: data.artifact_count ?? 0,
|
|
941
974
|
providerRoute: mapProviderRoute(data),
|
|
942
975
|
nextAction: data.next_action ?? "",
|
|
@@ -971,6 +1004,14 @@ function recordOrNull(value) {
|
|
|
971
1004
|
function stringArray(value) {
|
|
972
1005
|
return Array.isArray(value) ? value.map((item) => String(item || "").trim()).filter(Boolean) : [];
|
|
973
1006
|
}
|
|
1007
|
+
function diagnosticMessages(value) {
|
|
1008
|
+
if (!Array.isArray(value)) return [];
|
|
1009
|
+
return value.map((item) => {
|
|
1010
|
+
if (typeof item === "string") return item;
|
|
1011
|
+
const record = recordOrNull(item);
|
|
1012
|
+
return typeof record?.message === "string" ? record.message : null;
|
|
1013
|
+
}).filter((item) => typeof item === "string" && item.length > 0);
|
|
1014
|
+
}
|
|
974
1015
|
function booleanOrNull(value) {
|
|
975
1016
|
return typeof value === "boolean" ? value : null;
|
|
976
1017
|
}
|
|
@@ -2298,22 +2339,22 @@ function queryFieldFor(kind) {
|
|
|
2298
2339
|
function statusCommandFor(kind, id) {
|
|
2299
2340
|
switch (kind) {
|
|
2300
2341
|
case "op":
|
|
2301
|
-
return `signaliz status ${id}`;
|
|
2342
|
+
return `signaliz ops status ${id}`;
|
|
2302
2343
|
case "trigger_run":
|
|
2303
2344
|
case "dataplane_run":
|
|
2304
2345
|
case "replay_run":
|
|
2305
|
-
return `signaliz
|
|
2346
|
+
return `signaliz ops run-status ${id} --watch`;
|
|
2306
2347
|
case "queue_job":
|
|
2307
|
-
return `signaliz queue --job-id ${id}`;
|
|
2348
|
+
return `signaliz ops queue --job-id ${id}`;
|
|
2308
2349
|
case "routine":
|
|
2309
|
-
return `signaliz routine ${id}`;
|
|
2350
|
+
return `signaliz ops routine ${id}`;
|
|
2310
2351
|
default:
|
|
2311
2352
|
return void 0;
|
|
2312
2353
|
}
|
|
2313
2354
|
}
|
|
2314
2355
|
function replayCommandFor(kind, id) {
|
|
2315
2356
|
if (kind !== "execution_event") return void 0;
|
|
2316
|
-
return `signaliz replay ${id}`;
|
|
2357
|
+
return `signaliz ops replay ${id}`;
|
|
2317
2358
|
}
|
|
2318
2359
|
|
|
2319
2360
|
// src/resources/ops.ts
|
|
@@ -2961,6 +3002,10 @@ function normalizeOpsProofResult(data) {
|
|
|
2961
3002
|
failed30d: numberValue(summary.failed_30d ?? summary.failed30d),
|
|
2962
3003
|
external_delivered_30d: numberValue(summary.external_delivered_30d ?? summary.externalDelivered30d),
|
|
2963
3004
|
externalDelivered30d: numberValue(summary.external_delivered_30d ?? summary.externalDelivered30d),
|
|
3005
|
+
nango_proofs_30d: numberValue(summary.nango_proofs_30d ?? summary.nangoProofs30d),
|
|
3006
|
+
nangoProofs30d: numberValue(summary.nango_proofs_30d ?? summary.nangoProofs30d),
|
|
3007
|
+
nango_failures_30d: numberValue(summary.nango_failures_30d ?? summary.nangoFailures30d),
|
|
3008
|
+
nangoFailures30d: numberValue(summary.nango_failures_30d ?? summary.nangoFailures30d),
|
|
2964
3009
|
airbyte_configured: numberValue(summary.airbyte_configured ?? summary.airbyteConfigured),
|
|
2965
3010
|
airbyteConfigured: numberValue(summary.airbyte_configured ?? summary.airbyteConfigured),
|
|
2966
3011
|
airbyte_proofs_30d: numberValue(summary.airbyte_proofs_30d ?? summary.airbyteProofs30d),
|
|
@@ -3375,9 +3420,10 @@ function buildOpsDebugOptions(params) {
|
|
|
3375
3420
|
}
|
|
3376
3421
|
function buildCreateRoutineBody(params) {
|
|
3377
3422
|
const { outputSinks, wakeOnEvents, ...rest } = params;
|
|
3423
|
+
const sinks = rest.output_sinks ?? outputSinks;
|
|
3378
3424
|
return {
|
|
3379
3425
|
...rest,
|
|
3380
|
-
output_sinks:
|
|
3426
|
+
output_sinks: Array.isArray(sinks) ? sinks.map(normalizeOpsSinkRequest) : sinks,
|
|
3381
3427
|
wake_on_events: rest.wake_on_events ?? wakeOnEvents
|
|
3382
3428
|
};
|
|
3383
3429
|
}
|
|
@@ -3411,6 +3457,97 @@ function buildCreateOutputSinkBody(params) {
|
|
|
3411
3457
|
webhook_url: rest.webhook_url ?? webhookUrl
|
|
3412
3458
|
};
|
|
3413
3459
|
}
|
|
3460
|
+
function normalizeOpsSinkRequest(sink) {
|
|
3461
|
+
const {
|
|
3462
|
+
sinkId,
|
|
3463
|
+
connectionId,
|
|
3464
|
+
connectorId,
|
|
3465
|
+
connectorName,
|
|
3466
|
+
deliveryMode,
|
|
3467
|
+
providerConfigKey,
|
|
3468
|
+
integrationId,
|
|
3469
|
+
nangoConnectionId,
|
|
3470
|
+
actionName,
|
|
3471
|
+
nangoAction,
|
|
3472
|
+
proxyPath,
|
|
3473
|
+
nangoProxyPath,
|
|
3474
|
+
fieldMap,
|
|
3475
|
+
requiredFields,
|
|
3476
|
+
writeConfirmed,
|
|
3477
|
+
agentWriteConfirmed,
|
|
3478
|
+
config,
|
|
3479
|
+
...rest
|
|
3480
|
+
} = sink;
|
|
3481
|
+
const normalizedConfig = normalizeOpsSinkConfigRequest(config);
|
|
3482
|
+
const connection_id = rest.connection_id ?? connectionId;
|
|
3483
|
+
const connector_id = rest.connector_id ?? connectorId;
|
|
3484
|
+
const delivery_mode = rest.delivery_mode ?? deliveryMode;
|
|
3485
|
+
const provider_config_key = rest.provider_config_key ?? providerConfigKey;
|
|
3486
|
+
const integration_id = rest.integration_id ?? integrationId;
|
|
3487
|
+
const nango_connection_id = rest.nango_connection_id ?? nangoConnectionId;
|
|
3488
|
+
const action_name = rest.action_name ?? actionName;
|
|
3489
|
+
const nango_action = rest.nango_action ?? nangoAction;
|
|
3490
|
+
const proxy_path = rest.proxy_path ?? proxyPath;
|
|
3491
|
+
const nango_proxy_path = rest.nango_proxy_path ?? nangoProxyPath;
|
|
3492
|
+
const field_map = rest.field_map ?? fieldMap;
|
|
3493
|
+
const required_fields = rest.required_fields ?? requiredFields;
|
|
3494
|
+
const write_confirmed = rest.write_confirmed ?? writeConfirmed;
|
|
3495
|
+
const agent_write_confirmed = rest.agent_write_confirmed ?? agentWriteConfirmed;
|
|
3496
|
+
if (connection_id !== void 0 && normalizedConfig.connection_id === void 0) normalizedConfig.connection_id = connection_id;
|
|
3497
|
+
if (connector_id !== void 0 && normalizedConfig.connector_id === void 0) normalizedConfig.connector_id = connector_id;
|
|
3498
|
+
if (delivery_mode !== void 0 && normalizedConfig.delivery_mode === void 0) normalizedConfig.delivery_mode = delivery_mode;
|
|
3499
|
+
if (provider_config_key !== void 0 && normalizedConfig.provider_config_key === void 0) normalizedConfig.provider_config_key = provider_config_key;
|
|
3500
|
+
if (integration_id !== void 0 && normalizedConfig.integration_id === void 0) normalizedConfig.integration_id = integration_id;
|
|
3501
|
+
if (nango_connection_id !== void 0 && normalizedConfig.nango_connection_id === void 0) normalizedConfig.nango_connection_id = nango_connection_id;
|
|
3502
|
+
if (action_name !== void 0 && normalizedConfig.action_name === void 0) normalizedConfig.action_name = action_name;
|
|
3503
|
+
if (nango_action !== void 0 && normalizedConfig.nango_action === void 0) normalizedConfig.nango_action = nango_action;
|
|
3504
|
+
if (proxy_path !== void 0 && normalizedConfig.proxy_path === void 0) normalizedConfig.proxy_path = proxy_path;
|
|
3505
|
+
if (nango_proxy_path !== void 0 && normalizedConfig.nango_proxy_path === void 0) normalizedConfig.nango_proxy_path = nango_proxy_path;
|
|
3506
|
+
if (field_map !== void 0 && normalizedConfig.field_map === void 0) normalizedConfig.field_map = field_map;
|
|
3507
|
+
if (required_fields !== void 0 && normalizedConfig.required_fields === void 0) normalizedConfig.required_fields = required_fields;
|
|
3508
|
+
if (write_confirmed !== void 0 && normalizedConfig.write_confirmed === void 0) normalizedConfig.write_confirmed = write_confirmed;
|
|
3509
|
+
if (agent_write_confirmed !== void 0 && normalizedConfig.agent_write_confirmed === void 0) normalizedConfig.agent_write_confirmed = agent_write_confirmed;
|
|
3510
|
+
if (sink.type === "nango" && normalizedConfig.integration_platform === void 0) normalizedConfig.integration_platform = "nango";
|
|
3511
|
+
return {
|
|
3512
|
+
...rest,
|
|
3513
|
+
sink_id: rest.sink_id ?? sinkId,
|
|
3514
|
+
connection_id,
|
|
3515
|
+
connector_id,
|
|
3516
|
+
connector_name: rest.connector_name ?? connectorName,
|
|
3517
|
+
delivery_mode,
|
|
3518
|
+
provider_config_key,
|
|
3519
|
+
integration_id,
|
|
3520
|
+
nango_connection_id,
|
|
3521
|
+
action_name,
|
|
3522
|
+
nango_action,
|
|
3523
|
+
proxy_path,
|
|
3524
|
+
nango_proxy_path,
|
|
3525
|
+
field_map,
|
|
3526
|
+
required_fields,
|
|
3527
|
+
write_confirmed,
|
|
3528
|
+
agent_write_confirmed,
|
|
3529
|
+
config: normalizedConfig
|
|
3530
|
+
};
|
|
3531
|
+
}
|
|
3532
|
+
function normalizeOpsSinkConfigRequest(config) {
|
|
3533
|
+
const out = { ...config ?? {} };
|
|
3534
|
+
if (out.connection_id === void 0 && out.connectionId !== void 0) out.connection_id = out.connectionId;
|
|
3535
|
+
if (out.connector_id === void 0 && out.connectorId !== void 0) out.connector_id = out.connectorId;
|
|
3536
|
+
if (out.connector_name === void 0 && out.connectorName !== void 0) out.connector_name = out.connectorName;
|
|
3537
|
+
if (out.delivery_mode === void 0 && out.deliveryMode !== void 0) out.delivery_mode = out.deliveryMode;
|
|
3538
|
+
if (out.provider_config_key === void 0 && out.providerConfigKey !== void 0) out.provider_config_key = out.providerConfigKey;
|
|
3539
|
+
if (out.integration_id === void 0 && out.integrationId !== void 0) out.integration_id = out.integrationId;
|
|
3540
|
+
if (out.nango_connection_id === void 0 && out.nangoConnectionId !== void 0) out.nango_connection_id = out.nangoConnectionId;
|
|
3541
|
+
if (out.action_name === void 0 && out.actionName !== void 0) out.action_name = out.actionName;
|
|
3542
|
+
if (out.nango_action === void 0 && out.nangoAction !== void 0) out.nango_action = out.nangoAction;
|
|
3543
|
+
if (out.proxy_path === void 0 && out.proxyPath !== void 0) out.proxy_path = out.proxyPath;
|
|
3544
|
+
if (out.nango_proxy_path === void 0 && out.nangoProxyPath !== void 0) out.nango_proxy_path = out.nangoProxyPath;
|
|
3545
|
+
if (out.field_map === void 0 && out.fieldMap !== void 0) out.field_map = out.fieldMap;
|
|
3546
|
+
if (out.required_fields === void 0 && out.requiredFields !== void 0) out.required_fields = out.requiredFields;
|
|
3547
|
+
if (out.write_confirmed === void 0 && out.writeConfirmed !== void 0) out.write_confirmed = out.writeConfirmed;
|
|
3548
|
+
if (out.agent_write_confirmed === void 0 && out.agentWriteConfirmed !== void 0) out.agent_write_confirmed = out.agentWriteConfirmed;
|
|
3549
|
+
return out;
|
|
3550
|
+
}
|
|
3414
3551
|
function buildApproveBody(params) {
|
|
3415
3552
|
const { tokenId, tokenIds, reviewerNotes, ...rest } = params;
|
|
3416
3553
|
return {
|
|
@@ -3559,6 +3696,57 @@ var GtmKernel = class {
|
|
|
3559
3696
|
limit: options.limit
|
|
3560
3697
|
});
|
|
3561
3698
|
}
|
|
3699
|
+
/** Discover existing provider campaigns, starting with live/Kernel-linked Instantly campaigns, before audit or import preview. */
|
|
3700
|
+
async discoverExistingCampaigns(options = {}) {
|
|
3701
|
+
return this.callMcp("gtm_existing_campaign_discover", {
|
|
3702
|
+
provider: options.provider,
|
|
3703
|
+
integration_id: options.integrationId,
|
|
3704
|
+
search: options.search,
|
|
3705
|
+
limit: options.limit,
|
|
3706
|
+
include_kernel_linked: options.includeKernelLinked,
|
|
3707
|
+
include_provider_live: options.includeProviderLive
|
|
3708
|
+
});
|
|
3709
|
+
}
|
|
3710
|
+
/** Run a read-only existing campaign audit with completeness, recommendations, safe next MCP JSON, and approval boundaries. */
|
|
3711
|
+
async auditExistingCampaign(options) {
|
|
3712
|
+
return this.callMcp("gtm_existing_campaign_audit", {
|
|
3713
|
+
campaign_id: options.campaignId,
|
|
3714
|
+
provider: options.provider,
|
|
3715
|
+
provider_campaign_id: options.providerCampaignId,
|
|
3716
|
+
campaign_name: options.campaignName,
|
|
3717
|
+
days: options.days,
|
|
3718
|
+
include_route_preview: options.includeRoutePreview,
|
|
3719
|
+
include_memory: options.includeMemory,
|
|
3720
|
+
include_brain: options.includeBrain
|
|
3721
|
+
});
|
|
3722
|
+
}
|
|
3723
|
+
/** Discover the first matching existing provider campaign, then run the same read-only audit against that match. */
|
|
3724
|
+
async auditExistingCampaignBySearch(options) {
|
|
3725
|
+
const discovery = await this.discoverExistingCampaigns({
|
|
3726
|
+
provider: options.provider,
|
|
3727
|
+
integrationId: options.integrationId,
|
|
3728
|
+
search: options.search,
|
|
3729
|
+
limit: 1,
|
|
3730
|
+
includeKernelLinked: options.includeKernelLinked,
|
|
3731
|
+
includeProviderLive: options.includeProviderLive
|
|
3732
|
+
});
|
|
3733
|
+
const match = discovery.campaigns?.[0];
|
|
3734
|
+
const campaignId = match?.linked_kernel_campaign_id || void 0;
|
|
3735
|
+
const providerCampaignId = match?.provider_campaign_id || void 0;
|
|
3736
|
+
if (!campaignId && !providerCampaignId) {
|
|
3737
|
+
throw new Error(`No existing ${options.provider || discovery.provider || "provider"} campaign matched "${options.search}"`);
|
|
3738
|
+
}
|
|
3739
|
+
return this.auditExistingCampaign({
|
|
3740
|
+
provider: options.provider || discovery.provider || match?.provider,
|
|
3741
|
+
campaignId,
|
|
3742
|
+
providerCampaignId,
|
|
3743
|
+
campaignName: match?.name || match?.linked_kernel_campaign_name || void 0,
|
|
3744
|
+
days: options.days,
|
|
3745
|
+
includeRoutePreview: options.includeRoutePreview,
|
|
3746
|
+
includeMemory: options.includeMemory,
|
|
3747
|
+
includeBrain: options.includeBrain
|
|
3748
|
+
});
|
|
3749
|
+
}
|
|
3562
3750
|
/** Create a first-class GTM campaign object in the current workspace. */
|
|
3563
3751
|
async createCampaign(input) {
|
|
3564
3752
|
return this.callMcp("gtm_campaign_create", campaignCreateArgs(input));
|
|
@@ -3764,6 +3952,47 @@ var GtmKernel = class {
|
|
|
3764
3952
|
brain_cycle_min_interval_minutes: input.brainCycleMinIntervalMinutes
|
|
3765
3953
|
});
|
|
3766
3954
|
}
|
|
3955
|
+
/** Preview anonymized Instantly workspace sources registered for Kernel import. */
|
|
3956
|
+
async previewKernelImport(input = {}) {
|
|
3957
|
+
return this.callMcp("gtm_kernel_import_preview", {
|
|
3958
|
+
source_ids: input.sourceIds,
|
|
3959
|
+
include_leads: input.includeLeads,
|
|
3960
|
+
include_replies: input.includeReplies,
|
|
3961
|
+
include_private_copy: input.includePrivateCopy,
|
|
3962
|
+
max_pages: input.maxPages,
|
|
3963
|
+
limit: input.limit
|
|
3964
|
+
});
|
|
3965
|
+
}
|
|
3966
|
+
/** Queue the read-only Instantly-to-GTM Kernel import. Live writes require writeApproved. */
|
|
3967
|
+
async runKernelImport(input = {}) {
|
|
3968
|
+
return this.callMcp("gtm_kernel_import_run", {
|
|
3969
|
+
source_ids: input.sourceIds,
|
|
3970
|
+
dry_run: input.dryRun,
|
|
3971
|
+
write_approved: input.writeApproved,
|
|
3972
|
+
include_leads: input.includeLeads,
|
|
3973
|
+
include_replies: input.includeReplies,
|
|
3974
|
+
include_private_copy: input.includePrivateCopy,
|
|
3975
|
+
private_copy_approved: input.privateCopyApproved,
|
|
3976
|
+
promote_global_patterns: input.promoteGlobalPatterns,
|
|
3977
|
+
min_global_privacy_k: input.minGlobalPrivacyK,
|
|
3978
|
+
max_pages: input.maxPages,
|
|
3979
|
+
limit: input.limit
|
|
3980
|
+
});
|
|
3981
|
+
}
|
|
3982
|
+
/** Queue Brain distillation over imported Instantly memory with abstracted-only outputs. */
|
|
3983
|
+
async runBrainDistillation(input = {}) {
|
|
3984
|
+
return this.callMcp("gtm_brain_distill_run", {
|
|
3985
|
+
source_ids: input.sourceIds,
|
|
3986
|
+
write_mode: input.writeMode,
|
|
3987
|
+
write_approved: input.writeApproved,
|
|
3988
|
+
brain_cycle_phases: input.brainCyclePhases,
|
|
3989
|
+
days: input.days,
|
|
3990
|
+
network_days: input.networkDays,
|
|
3991
|
+
min_sample_size: input.minSampleSize,
|
|
3992
|
+
min_workspace_count: input.minWorkspaceCount,
|
|
3993
|
+
min_privacy_k: input.minPrivacyK
|
|
3994
|
+
});
|
|
3995
|
+
}
|
|
3767
3996
|
/** Prepare a provider-agnostic feedback webhook URL for Smartlead, HeyReach, Airbyte, or custom sender events. */
|
|
3768
3997
|
async prepareFeedbackWebhook(input) {
|
|
3769
3998
|
return this.callMcp("gtm_feedback_webhook_prepare", {
|
|
@@ -4191,6 +4420,43 @@ var GtmKernel = class {
|
|
|
4191
4420
|
context: input.context
|
|
4192
4421
|
});
|
|
4193
4422
|
}
|
|
4423
|
+
/** List Nango-backed action tools for a workspace connection without executing them. */
|
|
4424
|
+
async listNangoTools(options = {}) {
|
|
4425
|
+
return this.callMcp("nango_mcp_tools_list", {
|
|
4426
|
+
workspace_connection_id: options.workspaceConnectionId,
|
|
4427
|
+
connection_id: options.connectionId,
|
|
4428
|
+
provider_config_key: options.providerConfigKey,
|
|
4429
|
+
integration_id: options.integrationId,
|
|
4430
|
+
nango_connection_id: options.nangoConnectionId,
|
|
4431
|
+
format: options.format,
|
|
4432
|
+
include_raw: options.includeRaw
|
|
4433
|
+
});
|
|
4434
|
+
}
|
|
4435
|
+
/** Dry-run or execute a Nango-backed action tool through the approval-aware MCP bridge. */
|
|
4436
|
+
async callNangoTool(input) {
|
|
4437
|
+
return this.callMcp("nango_mcp_tool_call", {
|
|
4438
|
+
workspace_connection_id: input.workspaceConnectionId,
|
|
4439
|
+
connection_id: input.connectionId,
|
|
4440
|
+
provider_config_key: input.providerConfigKey,
|
|
4441
|
+
integration_id: input.integrationId,
|
|
4442
|
+
nango_connection_id: input.nangoConnectionId,
|
|
4443
|
+
action_name: input.actionName,
|
|
4444
|
+
tool_name: input.toolName,
|
|
4445
|
+
input: input.input,
|
|
4446
|
+
async: input.async,
|
|
4447
|
+
max_retries: input.maxRetries,
|
|
4448
|
+
dry_run: input.dryRun,
|
|
4449
|
+
confirm: input.confirm,
|
|
4450
|
+
confirm_write: input.confirmWrite
|
|
4451
|
+
});
|
|
4452
|
+
}
|
|
4453
|
+
/** Poll an async Nango action result by action id or status URL. */
|
|
4454
|
+
async getNangoActionResult(input) {
|
|
4455
|
+
return this.callMcp("nango_mcp_action_result_get", {
|
|
4456
|
+
action_id: input.actionId,
|
|
4457
|
+
status_url: input.statusUrl
|
|
4458
|
+
});
|
|
4459
|
+
}
|
|
4194
4460
|
/** Deliver approved campaign-layer records to a webhook recipe, starting with Clay-style webhooks. */
|
|
4195
4461
|
async deliverWebhook(input) {
|
|
4196
4462
|
return this.callMcp("gtm_webhook_deliver", {
|
|
@@ -4325,6 +4591,82 @@ function compact2(value) {
|
|
|
4325
4591
|
}
|
|
4326
4592
|
|
|
4327
4593
|
// src/index.ts
|
|
4594
|
+
function inferMcpToolCategory(toolName) {
|
|
4595
|
+
if (typeof toolName !== "string" || !toolName) return void 0;
|
|
4596
|
+
if (toolName.startsWith("ops_") || toolName === "get_ops_readiness" || toolName === "get_gtm_ops_readiness" || toolName.startsWith("gtm_") || [
|
|
4597
|
+
"list_routines",
|
|
4598
|
+
"create_routine",
|
|
4599
|
+
"update_routine",
|
|
4600
|
+
"run_routine_now",
|
|
4601
|
+
"get_routine",
|
|
4602
|
+
"get_routine_ticks",
|
|
4603
|
+
"get_tick_items",
|
|
4604
|
+
"get_last_tick_items",
|
|
4605
|
+
"chain_routines",
|
|
4606
|
+
"get_chain_status",
|
|
4607
|
+
"launch_campaign",
|
|
4608
|
+
"quickstart_gtm_book",
|
|
4609
|
+
"list_campaigns",
|
|
4610
|
+
"campaign_performance",
|
|
4611
|
+
"tune_campaign",
|
|
4612
|
+
"emit_event",
|
|
4613
|
+
"approvals_list",
|
|
4614
|
+
"list_output_sinks",
|
|
4615
|
+
"create_output_sink",
|
|
4616
|
+
"update_output_sink",
|
|
4617
|
+
"delete_output_sink",
|
|
4618
|
+
"attach_sink_to_routine"
|
|
4619
|
+
].includes(toolName)) {
|
|
4620
|
+
return "ops";
|
|
4621
|
+
}
|
|
4622
|
+
if ([
|
|
4623
|
+
"find_emails_with_verification",
|
|
4624
|
+
"verify_email",
|
|
4625
|
+
"enrich_company_signals",
|
|
4626
|
+
"company_intelligence",
|
|
4627
|
+
"find_contacts_with_email",
|
|
4628
|
+
"execute_primitive"
|
|
4629
|
+
].includes(toolName)) {
|
|
4630
|
+
return "enrichment";
|
|
4631
|
+
}
|
|
4632
|
+
if (toolName.includes("icp")) return "icp";
|
|
4633
|
+
if (toolName.startsWith("ai_clean_")) return "data_cleaning";
|
|
4634
|
+
if (toolName.includes("system") || toolName.includes("workflow")) return "automation";
|
|
4635
|
+
if (toolName.includes("agent") || toolName.includes("platform_health") || toolName === "discover_capabilities") return "observability";
|
|
4636
|
+
return void 0;
|
|
4637
|
+
}
|
|
4638
|
+
function mapMcpToolInfo(t) {
|
|
4639
|
+
const annotations = asRecord3(t.annotations);
|
|
4640
|
+
const execution = asRecord3(t.execution);
|
|
4641
|
+
const schemas = asRecord3(t.schemas);
|
|
4642
|
+
const name = typeof t.name === "string" ? t.name : typeof t.id === "string" ? t.id : "";
|
|
4643
|
+
return {
|
|
4644
|
+
name,
|
|
4645
|
+
description: String(t.description ?? t.short_description ?? "").slice(0, 120),
|
|
4646
|
+
category: typeof t.category === "string" ? t.category : typeof annotations?.category === "string" ? annotations.category : inferMcpToolCategory(name),
|
|
4647
|
+
costCredits: typeof (execution?.cost_credits ?? annotations?.cost_credits) === "number" ? execution?.cost_credits ?? annotations?.cost_credits : void 0,
|
|
4648
|
+
contractVersion: typeof t.contract_version === "string" ? t.contract_version : typeof (annotations?.contract_version ?? annotations?.contract?.contract_version) === "string" ? annotations?.contract_version ?? annotations?.contract?.contract_version : void 0,
|
|
4649
|
+
permissionLevel: typeof (execution?.permission_level ?? annotations?.permission_level ?? annotations?.contract?.permission_level) === "string" ? execution?.permission_level ?? annotations?.permission_level ?? annotations?.contract?.permission_level : void 0,
|
|
4650
|
+
authScopes: asStringArray(execution?.auth_scopes ?? annotations?.auth_scopes ?? annotations?.contract?.auth_scopes),
|
|
4651
|
+
idempotent: typeof (execution?.idempotent ?? annotations?.idempotentHint ?? annotations?.idempotent ?? annotations?.contract?.idempotent) === "boolean" ? execution?.idempotent ?? annotations?.idempotentHint ?? annotations?.idempotent ?? annotations?.contract?.idempotent : void 0,
|
|
4652
|
+
destructive: typeof (execution?.destructive ?? annotations?.destructiveHint ?? annotations?.destructive ?? annotations?.contract?.destructive) === "boolean" ? execution?.destructive ?? annotations?.destructiveHint ?? annotations?.destructive ?? annotations?.contract?.destructive : void 0,
|
|
4653
|
+
retryable: typeof (execution?.retryable ?? annotations?.retryable ?? annotations?.contract?.retryable) === "boolean" ? execution?.retryable ?? annotations?.retryable ?? annotations?.contract?.retryable : void 0,
|
|
4654
|
+
rateLimitKey: typeof (execution?.rate_limit_key ?? annotations?.rate_limit_key ?? annotations?.contract?.rate_limit_key) === "string" ? execution?.rate_limit_key ?? annotations?.rate_limit_key ?? annotations?.contract?.rate_limit_key : void 0,
|
|
4655
|
+
observability: asRecord3(annotations?.observability ?? annotations?.contract?.observability),
|
|
4656
|
+
inputSchema: asObjectSchema(schemas?.input ?? t.inputSchema ?? t.input_schema ?? annotations?.contract?.input_schema),
|
|
4657
|
+
outputSchema: asObjectSchema(schemas?.output ?? t.outputSchema ?? t.output_schema ?? annotations?.contract?.output_schema),
|
|
4658
|
+
annotations
|
|
4659
|
+
};
|
|
4660
|
+
}
|
|
4661
|
+
function asRecord3(value) {
|
|
4662
|
+
return value && typeof value === "object" ? value : void 0;
|
|
4663
|
+
}
|
|
4664
|
+
function asStringArray(value) {
|
|
4665
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : void 0;
|
|
4666
|
+
}
|
|
4667
|
+
function asObjectSchema(value) {
|
|
4668
|
+
return asRecord3(value);
|
|
4669
|
+
}
|
|
4328
4670
|
var Signaliz = class {
|
|
4329
4671
|
constructor(config) {
|
|
4330
4672
|
this.client = new HttpClient(config);
|
|
@@ -4380,25 +4722,18 @@ var Signaliz = class {
|
|
|
4380
4722
|
}
|
|
4381
4723
|
/** List all available MCP tools */
|
|
4382
4724
|
async listTools() {
|
|
4725
|
+
try {
|
|
4726
|
+
const manifest = await this.client.mcp("tools/call", {
|
|
4727
|
+
name: "get_tool_manifest",
|
|
4728
|
+
arguments: { include_schemas: true }
|
|
4729
|
+
});
|
|
4730
|
+
const tools2 = manifest?.tools ?? manifest ?? [];
|
|
4731
|
+
if (Array.isArray(tools2)) return tools2.map(mapMcpToolInfo);
|
|
4732
|
+
} catch (_err) {
|
|
4733
|
+
}
|
|
4383
4734
|
const data = await this.client.mcp("tools/list", {});
|
|
4384
4735
|
const tools = data?.tools ?? data ?? [];
|
|
4385
|
-
return tools.map(
|
|
4386
|
-
name: t.name,
|
|
4387
|
-
description: (t.description ?? "").slice(0, 120),
|
|
4388
|
-
category: t.annotations?.category,
|
|
4389
|
-
costCredits: t.annotations?.cost_credits,
|
|
4390
|
-
contractVersion: t.annotations?.contract_version ?? t.annotations?.contract?.contract_version,
|
|
4391
|
-
permissionLevel: t.annotations?.permission_level ?? t.annotations?.contract?.permission_level,
|
|
4392
|
-
authScopes: t.annotations?.auth_scopes ?? t.annotations?.contract?.auth_scopes,
|
|
4393
|
-
idempotent: t.annotations?.idempotentHint ?? t.annotations?.idempotent ?? t.annotations?.contract?.idempotent,
|
|
4394
|
-
destructive: t.annotations?.destructiveHint ?? t.annotations?.destructive ?? t.annotations?.contract?.destructive,
|
|
4395
|
-
retryable: t.annotations?.retryable ?? t.annotations?.contract?.retryable,
|
|
4396
|
-
rateLimitKey: t.annotations?.rate_limit_key ?? t.annotations?.contract?.rate_limit_key,
|
|
4397
|
-
observability: t.annotations?.observability ?? t.annotations?.contract?.observability,
|
|
4398
|
-
inputSchema: t.inputSchema ?? t.input_schema ?? t.annotations?.contract?.input_schema,
|
|
4399
|
-
outputSchema: t.outputSchema ?? t.output_schema ?? t.annotations?.contract?.output_schema,
|
|
4400
|
-
annotations: t.annotations
|
|
4401
|
-
}));
|
|
4736
|
+
return tools.map(mapMcpToolInfo);
|
|
4402
4737
|
}
|
|
4403
4738
|
/** Discover tools by natural language query */
|
|
4404
4739
|
async discover(query, category) {
|