@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.
@@ -202,13 +202,14 @@ var HttpClient = class {
202
202
  details: { responseText: text.slice(0, 500) }
203
203
  });
204
204
  }
205
- if (data.error) {
205
+ const responseError = isRecord(data) && isRecord(data.error) ? data.error : null;
206
+ if (responseError) {
206
207
  const err = new SignalizError({
207
- code: data.error.code?.toString() || data.error.data?.error_code || "MCP_ERROR",
208
- message: data.error.message || "MCP request failed",
209
- errorType: mapMcpErrorType(data.error),
210
- retryAfter: data.error.data?.retry_after,
211
- details: data.error.data
208
+ code: firstString(responseError.code, isRecord(responseError.data) ? responseError.data.error_code : void 0) || "MCP_ERROR",
209
+ message: firstString(responseError.message) || "MCP request failed",
210
+ errorType: mapMcpErrorType(responseError),
211
+ retryAfter: isRecord(responseError.data) && typeof responseError.data.retry_after === "number" ? responseError.data.retry_after : void 0,
212
+ details: isRecord(responseError.data) ? responseError.data : void 0
212
213
  });
213
214
  if (err.isRetryable && attempt < this.maxRetries) {
214
215
  lastError = err;
@@ -285,35 +286,63 @@ function normalizeMcpParams(method, params) {
285
286
  }
286
287
  };
287
288
  }
289
+ function isRecord(value) {
290
+ return typeof value === "object" && value !== null;
291
+ }
292
+ function firstString(...values) {
293
+ const value = values.find((item) => typeof item === "string" && item.length > 0);
294
+ return typeof value === "string" ? value : void 0;
295
+ }
296
+ function firstPayloadError(payload) {
297
+ const errors = payload.errors;
298
+ const first = Array.isArray(errors) ? errors[0] : void 0;
299
+ return isRecord(first) ? first : {};
300
+ }
288
301
  function unwrapMcpResponse(data) {
289
- if (data?.result?.structuredContent !== void 0) {
290
- return unwrapMcpPayload(data.result.structuredContent);
302
+ const result = isRecord(data) ? data.result : void 0;
303
+ if (isRecord(result) && result.structuredContent !== void 0) {
304
+ return unwrapMcpPayload(result.structuredContent);
291
305
  }
292
- const text = data?.result?.content?.[0]?.text;
306
+ const content = isRecord(result) ? result.content : void 0;
307
+ const firstContent = Array.isArray(content) ? content[0] : void 0;
308
+ const text = isRecord(firstContent) ? firstContent.text : void 0;
293
309
  if (typeof text === "string") {
294
310
  const parsed = safeJson(text);
295
311
  return unwrapMcpPayload(parsed ?? text);
296
312
  }
297
- return unwrapMcpPayload(data?.result);
313
+ return unwrapMcpPayload(result);
298
314
  }
299
315
  function unwrapMcpPayload(payload) {
300
- if (payload && typeof payload === "object") {
316
+ if (isRecord(payload)) {
301
317
  if (payload.ok === true && Object.prototype.hasOwnProperty.call(payload, "result")) {
302
- return payload.result;
318
+ return unwrapMcpPayload(payload.result);
319
+ }
320
+ if (payload.ok === false) {
321
+ const first = firstPayloadError(payload);
322
+ const code = firstString(first.code, payload.error_code, payload.code) || (payload.approval_required ? "APPROVAL_REQUIRED" : "MCP_ERROR");
323
+ throw new SignalizError({
324
+ code,
325
+ message: firstString(first.message, payload.message, payload.summary, payload.error) || "MCP request failed",
326
+ errorType: mapErrorTypeFromCode(code),
327
+ details: {
328
+ ...payload,
329
+ ...isRecord(first.details) ? first.details : {}
330
+ }
331
+ });
303
332
  }
304
333
  if (payload.success === true && Object.prototype.hasOwnProperty.call(payload, "data")) {
305
334
  return payload.data;
306
335
  }
307
336
  if (payload.success === false) {
308
- const first = Array.isArray(payload.errors) ? payload.errors[0] ?? {} : {};
309
- const code = first.code || payload.error_code || (payload.approval_required ? "APPROVAL_REQUIRED" : "MCP_ERROR");
337
+ const first = firstPayloadError(payload);
338
+ const code = firstString(first.code, payload.error_code) || (payload.approval_required ? "APPROVAL_REQUIRED" : "MCP_ERROR");
310
339
  throw new SignalizError({
311
340
  code,
312
- message: first.message || payload.message || payload.summary || "MCP request failed",
341
+ message: firstString(first.message, payload.message, payload.summary) || "MCP request failed",
313
342
  errorType: mapErrorTypeFromCode(code),
314
343
  details: {
315
344
  ...payload,
316
- ...first.details && typeof first.details === "object" ? first.details : {}
345
+ ...isRecord(first.details) ? first.details : {}
317
346
  }
318
347
  });
319
348
  }
@@ -321,8 +350,10 @@ function unwrapMcpPayload(payload) {
321
350
  return payload;
322
351
  }
323
352
  function mapMcpErrorType(error) {
324
- const code = String(error?.data?.error_code || error?.code || "");
325
- const message = String(error?.message || "").toLowerCase();
353
+ const errorRecord = isRecord(error) ? error : {};
354
+ const data = isRecord(errorRecord.data) ? errorRecord.data : {};
355
+ const code = String(data.error_code || errorRecord.code || "");
356
+ const message = String(errorRecord.message || "").toLowerCase();
326
357
  if (code === "429" || message.includes("rate limit")) return "rate_limited";
327
358
  if (code === "401" || code === "AUTH_001" || message.includes("auth")) return "auth_expired";
328
359
  if (code === "400" || code === "-32602" || message.includes("invalid")) return "validation";
@@ -805,15 +836,17 @@ var Campaigns = class {
805
836
  args.idempotency_key = options.idempotencyKey;
806
837
  }
807
838
  const data = await this.callMcp("build_campaign", args);
839
+ const isDryRun = request.dryRun === true || data.dry_run === true || data.status === "dry_run";
840
+ 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.` : "");
808
841
  return {
809
842
  campaignBuildId: data.campaign_build_id ?? null,
810
843
  campaignId: data.campaign_id ?? null,
811
844
  campaignObject: data.campaign_object ?? null,
812
- status: data.dry_run ? "dry_run" : data.status ?? "queued",
813
- currentPhase: data.dry_run ? "plan" : data.current_phase ?? "acquisition",
845
+ status: isDryRun ? "dry_run" : data.status ?? "queued",
846
+ currentPhase: isDryRun ? "plan" : data.current_phase ?? "acquisition",
814
847
  nextPollAfterSeconds: data.next_poll_after_seconds ?? 10,
815
- message: data.message ?? data.summary ?? "",
816
- dryRun: data.dry_run === true,
848
+ message,
849
+ dryRun: isDryRun,
817
850
  requestedTargetCount: data.requested_target_count,
818
851
  plannedTargetCount: data.planned_target_count,
819
852
  estimatedCredits: data.estimated_credits,
@@ -927,8 +960,8 @@ function mapStatus(data) {
927
960
  recordsProcessed: data.records_processed ?? 0,
928
961
  recordsSucceeded: data.records_succeeded ?? 0,
929
962
  recordsFailed: data.records_failed ?? 0,
930
- warnings: data.warnings ?? [],
931
- errors: data.errors ?? [],
963
+ warnings: diagnosticMessages(data.warnings),
964
+ errors: diagnosticMessages(data.errors),
932
965
  artifactCount: data.artifact_count ?? 0,
933
966
  providerRoute: mapProviderRoute(data),
934
967
  nextAction: data.next_action ?? "",
@@ -963,6 +996,14 @@ function recordOrNull(value) {
963
996
  function stringArray(value) {
964
997
  return Array.isArray(value) ? value.map((item) => String(item || "").trim()).filter(Boolean) : [];
965
998
  }
999
+ function diagnosticMessages(value) {
1000
+ if (!Array.isArray(value)) return [];
1001
+ return value.map((item) => {
1002
+ if (typeof item === "string") return item;
1003
+ const record = recordOrNull(item);
1004
+ return typeof record?.message === "string" ? record.message : null;
1005
+ }).filter((item) => typeof item === "string" && item.length > 0);
1006
+ }
966
1007
  function booleanOrNull(value) {
967
1008
  return typeof value === "boolean" ? value : null;
968
1009
  }
@@ -2283,22 +2324,22 @@ function queryFieldFor(kind) {
2283
2324
  function statusCommandFor(kind, id) {
2284
2325
  switch (kind) {
2285
2326
  case "op":
2286
- return `signaliz status ${id}`;
2327
+ return `signaliz ops status ${id}`;
2287
2328
  case "trigger_run":
2288
2329
  case "dataplane_run":
2289
2330
  case "replay_run":
2290
- return `signaliz watch ${id}`;
2331
+ return `signaliz ops run-status ${id} --watch`;
2291
2332
  case "queue_job":
2292
- return `signaliz queue --job-id ${id}`;
2333
+ return `signaliz ops queue --job-id ${id}`;
2293
2334
  case "routine":
2294
- return `signaliz routine ${id}`;
2335
+ return `signaliz ops routine ${id}`;
2295
2336
  default:
2296
2337
  return void 0;
2297
2338
  }
2298
2339
  }
2299
2340
  function replayCommandFor(kind, id) {
2300
2341
  if (kind !== "execution_event") return void 0;
2301
- return `signaliz replay ${id}`;
2342
+ return `signaliz ops replay ${id}`;
2302
2343
  }
2303
2344
 
2304
2345
  // src/resources/ops.ts
@@ -2946,6 +2987,10 @@ function normalizeOpsProofResult(data) {
2946
2987
  failed30d: numberValue(summary.failed_30d ?? summary.failed30d),
2947
2988
  external_delivered_30d: numberValue(summary.external_delivered_30d ?? summary.externalDelivered30d),
2948
2989
  externalDelivered30d: numberValue(summary.external_delivered_30d ?? summary.externalDelivered30d),
2990
+ nango_proofs_30d: numberValue(summary.nango_proofs_30d ?? summary.nangoProofs30d),
2991
+ nangoProofs30d: numberValue(summary.nango_proofs_30d ?? summary.nangoProofs30d),
2992
+ nango_failures_30d: numberValue(summary.nango_failures_30d ?? summary.nangoFailures30d),
2993
+ nangoFailures30d: numberValue(summary.nango_failures_30d ?? summary.nangoFailures30d),
2949
2994
  airbyte_configured: numberValue(summary.airbyte_configured ?? summary.airbyteConfigured),
2950
2995
  airbyteConfigured: numberValue(summary.airbyte_configured ?? summary.airbyteConfigured),
2951
2996
  airbyte_proofs_30d: numberValue(summary.airbyte_proofs_30d ?? summary.airbyteProofs30d),
@@ -3360,9 +3405,10 @@ function buildOpsDebugOptions(params) {
3360
3405
  }
3361
3406
  function buildCreateRoutineBody(params) {
3362
3407
  const { outputSinks, wakeOnEvents, ...rest } = params;
3408
+ const sinks = rest.output_sinks ?? outputSinks;
3363
3409
  return {
3364
3410
  ...rest,
3365
- output_sinks: rest.output_sinks ?? outputSinks,
3411
+ output_sinks: Array.isArray(sinks) ? sinks.map(normalizeOpsSinkRequest) : sinks,
3366
3412
  wake_on_events: rest.wake_on_events ?? wakeOnEvents
3367
3413
  };
3368
3414
  }
@@ -3396,6 +3442,97 @@ function buildCreateOutputSinkBody(params) {
3396
3442
  webhook_url: rest.webhook_url ?? webhookUrl
3397
3443
  };
3398
3444
  }
3445
+ function normalizeOpsSinkRequest(sink) {
3446
+ const {
3447
+ sinkId,
3448
+ connectionId,
3449
+ connectorId,
3450
+ connectorName,
3451
+ deliveryMode,
3452
+ providerConfigKey,
3453
+ integrationId,
3454
+ nangoConnectionId,
3455
+ actionName,
3456
+ nangoAction,
3457
+ proxyPath,
3458
+ nangoProxyPath,
3459
+ fieldMap,
3460
+ requiredFields,
3461
+ writeConfirmed,
3462
+ agentWriteConfirmed,
3463
+ config,
3464
+ ...rest
3465
+ } = sink;
3466
+ const normalizedConfig = normalizeOpsSinkConfigRequest(config);
3467
+ const connection_id = rest.connection_id ?? connectionId;
3468
+ const connector_id = rest.connector_id ?? connectorId;
3469
+ const delivery_mode = rest.delivery_mode ?? deliveryMode;
3470
+ const provider_config_key = rest.provider_config_key ?? providerConfigKey;
3471
+ const integration_id = rest.integration_id ?? integrationId;
3472
+ const nango_connection_id = rest.nango_connection_id ?? nangoConnectionId;
3473
+ const action_name = rest.action_name ?? actionName;
3474
+ const nango_action = rest.nango_action ?? nangoAction;
3475
+ const proxy_path = rest.proxy_path ?? proxyPath;
3476
+ const nango_proxy_path = rest.nango_proxy_path ?? nangoProxyPath;
3477
+ const field_map = rest.field_map ?? fieldMap;
3478
+ const required_fields = rest.required_fields ?? requiredFields;
3479
+ const write_confirmed = rest.write_confirmed ?? writeConfirmed;
3480
+ const agent_write_confirmed = rest.agent_write_confirmed ?? agentWriteConfirmed;
3481
+ if (connection_id !== void 0 && normalizedConfig.connection_id === void 0) normalizedConfig.connection_id = connection_id;
3482
+ if (connector_id !== void 0 && normalizedConfig.connector_id === void 0) normalizedConfig.connector_id = connector_id;
3483
+ if (delivery_mode !== void 0 && normalizedConfig.delivery_mode === void 0) normalizedConfig.delivery_mode = delivery_mode;
3484
+ if (provider_config_key !== void 0 && normalizedConfig.provider_config_key === void 0) normalizedConfig.provider_config_key = provider_config_key;
3485
+ if (integration_id !== void 0 && normalizedConfig.integration_id === void 0) normalizedConfig.integration_id = integration_id;
3486
+ if (nango_connection_id !== void 0 && normalizedConfig.nango_connection_id === void 0) normalizedConfig.nango_connection_id = nango_connection_id;
3487
+ if (action_name !== void 0 && normalizedConfig.action_name === void 0) normalizedConfig.action_name = action_name;
3488
+ if (nango_action !== void 0 && normalizedConfig.nango_action === void 0) normalizedConfig.nango_action = nango_action;
3489
+ if (proxy_path !== void 0 && normalizedConfig.proxy_path === void 0) normalizedConfig.proxy_path = proxy_path;
3490
+ if (nango_proxy_path !== void 0 && normalizedConfig.nango_proxy_path === void 0) normalizedConfig.nango_proxy_path = nango_proxy_path;
3491
+ if (field_map !== void 0 && normalizedConfig.field_map === void 0) normalizedConfig.field_map = field_map;
3492
+ if (required_fields !== void 0 && normalizedConfig.required_fields === void 0) normalizedConfig.required_fields = required_fields;
3493
+ if (write_confirmed !== void 0 && normalizedConfig.write_confirmed === void 0) normalizedConfig.write_confirmed = write_confirmed;
3494
+ if (agent_write_confirmed !== void 0 && normalizedConfig.agent_write_confirmed === void 0) normalizedConfig.agent_write_confirmed = agent_write_confirmed;
3495
+ if (sink.type === "nango" && normalizedConfig.integration_platform === void 0) normalizedConfig.integration_platform = "nango";
3496
+ return {
3497
+ ...rest,
3498
+ sink_id: rest.sink_id ?? sinkId,
3499
+ connection_id,
3500
+ connector_id,
3501
+ connector_name: rest.connector_name ?? connectorName,
3502
+ delivery_mode,
3503
+ provider_config_key,
3504
+ integration_id,
3505
+ nango_connection_id,
3506
+ action_name,
3507
+ nango_action,
3508
+ proxy_path,
3509
+ nango_proxy_path,
3510
+ field_map,
3511
+ required_fields,
3512
+ write_confirmed,
3513
+ agent_write_confirmed,
3514
+ config: normalizedConfig
3515
+ };
3516
+ }
3517
+ function normalizeOpsSinkConfigRequest(config) {
3518
+ const out = { ...config ?? {} };
3519
+ if (out.connection_id === void 0 && out.connectionId !== void 0) out.connection_id = out.connectionId;
3520
+ if (out.connector_id === void 0 && out.connectorId !== void 0) out.connector_id = out.connectorId;
3521
+ if (out.connector_name === void 0 && out.connectorName !== void 0) out.connector_name = out.connectorName;
3522
+ if (out.delivery_mode === void 0 && out.deliveryMode !== void 0) out.delivery_mode = out.deliveryMode;
3523
+ if (out.provider_config_key === void 0 && out.providerConfigKey !== void 0) out.provider_config_key = out.providerConfigKey;
3524
+ if (out.integration_id === void 0 && out.integrationId !== void 0) out.integration_id = out.integrationId;
3525
+ if (out.nango_connection_id === void 0 && out.nangoConnectionId !== void 0) out.nango_connection_id = out.nangoConnectionId;
3526
+ if (out.action_name === void 0 && out.actionName !== void 0) out.action_name = out.actionName;
3527
+ if (out.nango_action === void 0 && out.nangoAction !== void 0) out.nango_action = out.nangoAction;
3528
+ if (out.proxy_path === void 0 && out.proxyPath !== void 0) out.proxy_path = out.proxyPath;
3529
+ if (out.nango_proxy_path === void 0 && out.nangoProxyPath !== void 0) out.nango_proxy_path = out.nangoProxyPath;
3530
+ if (out.field_map === void 0 && out.fieldMap !== void 0) out.field_map = out.fieldMap;
3531
+ if (out.required_fields === void 0 && out.requiredFields !== void 0) out.required_fields = out.requiredFields;
3532
+ if (out.write_confirmed === void 0 && out.writeConfirmed !== void 0) out.write_confirmed = out.writeConfirmed;
3533
+ if (out.agent_write_confirmed === void 0 && out.agentWriteConfirmed !== void 0) out.agent_write_confirmed = out.agentWriteConfirmed;
3534
+ return out;
3535
+ }
3399
3536
  function buildApproveBody(params) {
3400
3537
  const { tokenId, tokenIds, reviewerNotes, ...rest } = params;
3401
3538
  return {
@@ -3544,6 +3681,57 @@ var GtmKernel = class {
3544
3681
  limit: options.limit
3545
3682
  });
3546
3683
  }
3684
+ /** Discover existing provider campaigns, starting with live/Kernel-linked Instantly campaigns, before audit or import preview. */
3685
+ async discoverExistingCampaigns(options = {}) {
3686
+ return this.callMcp("gtm_existing_campaign_discover", {
3687
+ provider: options.provider,
3688
+ integration_id: options.integrationId,
3689
+ search: options.search,
3690
+ limit: options.limit,
3691
+ include_kernel_linked: options.includeKernelLinked,
3692
+ include_provider_live: options.includeProviderLive
3693
+ });
3694
+ }
3695
+ /** Run a read-only existing campaign audit with completeness, recommendations, safe next MCP JSON, and approval boundaries. */
3696
+ async auditExistingCampaign(options) {
3697
+ return this.callMcp("gtm_existing_campaign_audit", {
3698
+ campaign_id: options.campaignId,
3699
+ provider: options.provider,
3700
+ provider_campaign_id: options.providerCampaignId,
3701
+ campaign_name: options.campaignName,
3702
+ days: options.days,
3703
+ include_route_preview: options.includeRoutePreview,
3704
+ include_memory: options.includeMemory,
3705
+ include_brain: options.includeBrain
3706
+ });
3707
+ }
3708
+ /** Discover the first matching existing provider campaign, then run the same read-only audit against that match. */
3709
+ async auditExistingCampaignBySearch(options) {
3710
+ const discovery = await this.discoverExistingCampaigns({
3711
+ provider: options.provider,
3712
+ integrationId: options.integrationId,
3713
+ search: options.search,
3714
+ limit: 1,
3715
+ includeKernelLinked: options.includeKernelLinked,
3716
+ includeProviderLive: options.includeProviderLive
3717
+ });
3718
+ const match = discovery.campaigns?.[0];
3719
+ const campaignId = match?.linked_kernel_campaign_id || void 0;
3720
+ const providerCampaignId = match?.provider_campaign_id || void 0;
3721
+ if (!campaignId && !providerCampaignId) {
3722
+ throw new Error(`No existing ${options.provider || discovery.provider || "provider"} campaign matched "${options.search}"`);
3723
+ }
3724
+ return this.auditExistingCampaign({
3725
+ provider: options.provider || discovery.provider || match?.provider,
3726
+ campaignId,
3727
+ providerCampaignId,
3728
+ campaignName: match?.name || match?.linked_kernel_campaign_name || void 0,
3729
+ days: options.days,
3730
+ includeRoutePreview: options.includeRoutePreview,
3731
+ includeMemory: options.includeMemory,
3732
+ includeBrain: options.includeBrain
3733
+ });
3734
+ }
3547
3735
  /** Create a first-class GTM campaign object in the current workspace. */
3548
3736
  async createCampaign(input) {
3549
3737
  return this.callMcp("gtm_campaign_create", campaignCreateArgs(input));
@@ -3749,6 +3937,47 @@ var GtmKernel = class {
3749
3937
  brain_cycle_min_interval_minutes: input.brainCycleMinIntervalMinutes
3750
3938
  });
3751
3939
  }
3940
+ /** Preview anonymized Instantly workspace sources registered for Kernel import. */
3941
+ async previewKernelImport(input = {}) {
3942
+ return this.callMcp("gtm_kernel_import_preview", {
3943
+ source_ids: input.sourceIds,
3944
+ include_leads: input.includeLeads,
3945
+ include_replies: input.includeReplies,
3946
+ include_private_copy: input.includePrivateCopy,
3947
+ max_pages: input.maxPages,
3948
+ limit: input.limit
3949
+ });
3950
+ }
3951
+ /** Queue the read-only Instantly-to-GTM Kernel import. Live writes require writeApproved. */
3952
+ async runKernelImport(input = {}) {
3953
+ return this.callMcp("gtm_kernel_import_run", {
3954
+ source_ids: input.sourceIds,
3955
+ dry_run: input.dryRun,
3956
+ write_approved: input.writeApproved,
3957
+ include_leads: input.includeLeads,
3958
+ include_replies: input.includeReplies,
3959
+ include_private_copy: input.includePrivateCopy,
3960
+ private_copy_approved: input.privateCopyApproved,
3961
+ promote_global_patterns: input.promoteGlobalPatterns,
3962
+ min_global_privacy_k: input.minGlobalPrivacyK,
3963
+ max_pages: input.maxPages,
3964
+ limit: input.limit
3965
+ });
3966
+ }
3967
+ /** Queue Brain distillation over imported Instantly memory with abstracted-only outputs. */
3968
+ async runBrainDistillation(input = {}) {
3969
+ return this.callMcp("gtm_brain_distill_run", {
3970
+ source_ids: input.sourceIds,
3971
+ write_mode: input.writeMode,
3972
+ write_approved: input.writeApproved,
3973
+ brain_cycle_phases: input.brainCyclePhases,
3974
+ days: input.days,
3975
+ network_days: input.networkDays,
3976
+ min_sample_size: input.minSampleSize,
3977
+ min_workspace_count: input.minWorkspaceCount,
3978
+ min_privacy_k: input.minPrivacyK
3979
+ });
3980
+ }
3752
3981
  /** Prepare a provider-agnostic feedback webhook URL for Smartlead, HeyReach, Airbyte, or custom sender events. */
3753
3982
  async prepareFeedbackWebhook(input) {
3754
3983
  return this.callMcp("gtm_feedback_webhook_prepare", {
@@ -4176,6 +4405,43 @@ var GtmKernel = class {
4176
4405
  context: input.context
4177
4406
  });
4178
4407
  }
4408
+ /** List Nango-backed action tools for a workspace connection without executing them. */
4409
+ async listNangoTools(options = {}) {
4410
+ return this.callMcp("nango_mcp_tools_list", {
4411
+ workspace_connection_id: options.workspaceConnectionId,
4412
+ connection_id: options.connectionId,
4413
+ provider_config_key: options.providerConfigKey,
4414
+ integration_id: options.integrationId,
4415
+ nango_connection_id: options.nangoConnectionId,
4416
+ format: options.format,
4417
+ include_raw: options.includeRaw
4418
+ });
4419
+ }
4420
+ /** Dry-run or execute a Nango-backed action tool through the approval-aware MCP bridge. */
4421
+ async callNangoTool(input) {
4422
+ return this.callMcp("nango_mcp_tool_call", {
4423
+ workspace_connection_id: input.workspaceConnectionId,
4424
+ connection_id: input.connectionId,
4425
+ provider_config_key: input.providerConfigKey,
4426
+ integration_id: input.integrationId,
4427
+ nango_connection_id: input.nangoConnectionId,
4428
+ action_name: input.actionName,
4429
+ tool_name: input.toolName,
4430
+ input: input.input,
4431
+ async: input.async,
4432
+ max_retries: input.maxRetries,
4433
+ dry_run: input.dryRun,
4434
+ confirm: input.confirm,
4435
+ confirm_write: input.confirmWrite
4436
+ });
4437
+ }
4438
+ /** Poll an async Nango action result by action id or status URL. */
4439
+ async getNangoActionResult(input) {
4440
+ return this.callMcp("nango_mcp_action_result_get", {
4441
+ action_id: input.actionId,
4442
+ status_url: input.statusUrl
4443
+ });
4444
+ }
4179
4445
  /** Deliver approved campaign-layer records to a webhook recipe, starting with Clay-style webhooks. */
4180
4446
  async deliverWebhook(input) {
4181
4447
  return this.callMcp("gtm_webhook_deliver", {
@@ -4310,6 +4576,82 @@ function compact2(value) {
4310
4576
  }
4311
4577
 
4312
4578
  // src/index.ts
4579
+ function inferMcpToolCategory(toolName) {
4580
+ if (typeof toolName !== "string" || !toolName) return void 0;
4581
+ if (toolName.startsWith("ops_") || toolName === "get_ops_readiness" || toolName === "get_gtm_ops_readiness" || toolName.startsWith("gtm_") || [
4582
+ "list_routines",
4583
+ "create_routine",
4584
+ "update_routine",
4585
+ "run_routine_now",
4586
+ "get_routine",
4587
+ "get_routine_ticks",
4588
+ "get_tick_items",
4589
+ "get_last_tick_items",
4590
+ "chain_routines",
4591
+ "get_chain_status",
4592
+ "launch_campaign",
4593
+ "quickstart_gtm_book",
4594
+ "list_campaigns",
4595
+ "campaign_performance",
4596
+ "tune_campaign",
4597
+ "emit_event",
4598
+ "approvals_list",
4599
+ "list_output_sinks",
4600
+ "create_output_sink",
4601
+ "update_output_sink",
4602
+ "delete_output_sink",
4603
+ "attach_sink_to_routine"
4604
+ ].includes(toolName)) {
4605
+ return "ops";
4606
+ }
4607
+ if ([
4608
+ "find_emails_with_verification",
4609
+ "verify_email",
4610
+ "enrich_company_signals",
4611
+ "company_intelligence",
4612
+ "find_contacts_with_email",
4613
+ "execute_primitive"
4614
+ ].includes(toolName)) {
4615
+ return "enrichment";
4616
+ }
4617
+ if (toolName.includes("icp")) return "icp";
4618
+ if (toolName.startsWith("ai_clean_")) return "data_cleaning";
4619
+ if (toolName.includes("system") || toolName.includes("workflow")) return "automation";
4620
+ if (toolName.includes("agent") || toolName.includes("platform_health") || toolName === "discover_capabilities") return "observability";
4621
+ return void 0;
4622
+ }
4623
+ function mapMcpToolInfo(t) {
4624
+ const annotations = asRecord3(t.annotations);
4625
+ const execution = asRecord3(t.execution);
4626
+ const schemas = asRecord3(t.schemas);
4627
+ const name = typeof t.name === "string" ? t.name : typeof t.id === "string" ? t.id : "";
4628
+ return {
4629
+ name,
4630
+ description: String(t.description ?? t.short_description ?? "").slice(0, 120),
4631
+ category: typeof t.category === "string" ? t.category : typeof annotations?.category === "string" ? annotations.category : inferMcpToolCategory(name),
4632
+ costCredits: typeof (execution?.cost_credits ?? annotations?.cost_credits) === "number" ? execution?.cost_credits ?? annotations?.cost_credits : void 0,
4633
+ 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,
4634
+ 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,
4635
+ authScopes: asStringArray(execution?.auth_scopes ?? annotations?.auth_scopes ?? annotations?.contract?.auth_scopes),
4636
+ idempotent: typeof (execution?.idempotent ?? annotations?.idempotentHint ?? annotations?.idempotent ?? annotations?.contract?.idempotent) === "boolean" ? execution?.idempotent ?? annotations?.idempotentHint ?? annotations?.idempotent ?? annotations?.contract?.idempotent : void 0,
4637
+ destructive: typeof (execution?.destructive ?? annotations?.destructiveHint ?? annotations?.destructive ?? annotations?.contract?.destructive) === "boolean" ? execution?.destructive ?? annotations?.destructiveHint ?? annotations?.destructive ?? annotations?.contract?.destructive : void 0,
4638
+ retryable: typeof (execution?.retryable ?? annotations?.retryable ?? annotations?.contract?.retryable) === "boolean" ? execution?.retryable ?? annotations?.retryable ?? annotations?.contract?.retryable : void 0,
4639
+ 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,
4640
+ observability: asRecord3(annotations?.observability ?? annotations?.contract?.observability),
4641
+ inputSchema: asObjectSchema(schemas?.input ?? t.inputSchema ?? t.input_schema ?? annotations?.contract?.input_schema),
4642
+ outputSchema: asObjectSchema(schemas?.output ?? t.outputSchema ?? t.output_schema ?? annotations?.contract?.output_schema),
4643
+ annotations
4644
+ };
4645
+ }
4646
+ function asRecord3(value) {
4647
+ return value && typeof value === "object" ? value : void 0;
4648
+ }
4649
+ function asStringArray(value) {
4650
+ return Array.isArray(value) ? value.filter((item) => typeof item === "string") : void 0;
4651
+ }
4652
+ function asObjectSchema(value) {
4653
+ return asRecord3(value);
4654
+ }
4313
4655
  var Signaliz = class {
4314
4656
  constructor(config) {
4315
4657
  this.client = new HttpClient(config);
@@ -4365,25 +4707,18 @@ var Signaliz = class {
4365
4707
  }
4366
4708
  /** List all available MCP tools */
4367
4709
  async listTools() {
4710
+ try {
4711
+ const manifest = await this.client.mcp("tools/call", {
4712
+ name: "get_tool_manifest",
4713
+ arguments: { include_schemas: true }
4714
+ });
4715
+ const tools2 = manifest?.tools ?? manifest ?? [];
4716
+ if (Array.isArray(tools2)) return tools2.map(mapMcpToolInfo);
4717
+ } catch (_err) {
4718
+ }
4368
4719
  const data = await this.client.mcp("tools/list", {});
4369
4720
  const tools = data?.tools ?? data ?? [];
4370
- return tools.map((t) => ({
4371
- name: t.name,
4372
- description: (t.description ?? "").slice(0, 120),
4373
- category: t.annotations?.category,
4374
- costCredits: t.annotations?.cost_credits,
4375
- contractVersion: t.annotations?.contract_version ?? t.annotations?.contract?.contract_version,
4376
- permissionLevel: t.annotations?.permission_level ?? t.annotations?.contract?.permission_level,
4377
- authScopes: t.annotations?.auth_scopes ?? t.annotations?.contract?.auth_scopes,
4378
- idempotent: t.annotations?.idempotentHint ?? t.annotations?.idempotent ?? t.annotations?.contract?.idempotent,
4379
- destructive: t.annotations?.destructiveHint ?? t.annotations?.destructive ?? t.annotations?.contract?.destructive,
4380
- retryable: t.annotations?.retryable ?? t.annotations?.contract?.retryable,
4381
- rateLimitKey: t.annotations?.rate_limit_key ?? t.annotations?.contract?.rate_limit_key,
4382
- observability: t.annotations?.observability ?? t.annotations?.contract?.observability,
4383
- inputSchema: t.inputSchema ?? t.input_schema ?? t.annotations?.contract?.input_schema,
4384
- outputSchema: t.outputSchema ?? t.output_schema ?? t.annotations?.contract?.output_schema,
4385
- annotations: t.annotations
4386
- }));
4721
+ return tools.map(mapMcpToolInfo);
4387
4722
  }
4388
4723
  /** Discover tools by natural language query */
4389
4724
  async discover(query, category) {
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  Signaliz
4
- } from "./chunk-L6XUFJJO.mjs";
4
+ } from "./chunk-GF2T2X3W.mjs";
5
5
 
6
6
  // src/mcp-config.ts
7
7
  import * as fs from "fs";
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@signaliz/sdk",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Signaliz SDK — GTM Kernel, Nango routes, MCP, and enrichment for AI agents",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
8
8
  "bin": {
9
- "signaliz": "./dist/cli.js",
10
- "signaliz-mcp": "./dist/mcp-config.js"
9
+ "signaliz": "dist/cli.js",
10
+ "signaliz-mcp": "dist/mcp-config.js"
11
11
  },
12
12
  "files": ["dist", "README.md"],
13
13
  "scripts": {
@@ -20,7 +20,7 @@
20
20
  "license": "MIT",
21
21
  "repository": {
22
22
  "type": "git",
23
- "url": "https://github.com/signaliz/sdk"
23
+ "url": "git+https://github.com/signaliz/sdk.git"
24
24
  },
25
25
  "engines": {
26
26
  "node": ">=18"