@signaliz/sdk 1.0.3 → 1.0.4

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/dist/cli.js CHANGED
@@ -174,13 +174,14 @@ var HttpClient = class {
174
174
  details: { responseText: text.slice(0, 500) }
175
175
  });
176
176
  }
177
- if (data.error) {
177
+ const responseError = isRecord(data) && isRecord(data.error) ? data.error : null;
178
+ if (responseError) {
178
179
  const err = new SignalizError({
179
- code: data.error.code?.toString() || data.error.data?.error_code || "MCP_ERROR",
180
- message: data.error.message || "MCP request failed",
181
- errorType: mapMcpErrorType(data.error),
182
- retryAfter: data.error.data?.retry_after,
183
- details: data.error.data
180
+ code: firstString(responseError.code, isRecord(responseError.data) ? responseError.data.error_code : void 0) || "MCP_ERROR",
181
+ message: firstString(responseError.message) || "MCP request failed",
182
+ errorType: mapMcpErrorType(responseError),
183
+ retryAfter: isRecord(responseError.data) && typeof responseError.data.retry_after === "number" ? responseError.data.retry_after : void 0,
184
+ details: isRecord(responseError.data) ? responseError.data : void 0
184
185
  });
185
186
  if (err.isRetryable && attempt < this.maxRetries) {
186
187
  lastError = err;
@@ -257,35 +258,63 @@ function normalizeMcpParams(method, params) {
257
258
  }
258
259
  };
259
260
  }
261
+ function isRecord(value) {
262
+ return typeof value === "object" && value !== null;
263
+ }
264
+ function firstString(...values) {
265
+ const value = values.find((item) => typeof item === "string" && item.length > 0);
266
+ return typeof value === "string" ? value : void 0;
267
+ }
268
+ function firstPayloadError(payload) {
269
+ const errors = payload.errors;
270
+ const first = Array.isArray(errors) ? errors[0] : void 0;
271
+ return isRecord(first) ? first : {};
272
+ }
260
273
  function unwrapMcpResponse(data) {
261
- if (data?.result?.structuredContent !== void 0) {
262
- return unwrapMcpPayload(data.result.structuredContent);
274
+ const result = isRecord(data) ? data.result : void 0;
275
+ if (isRecord(result) && result.structuredContent !== void 0) {
276
+ return unwrapMcpPayload(result.structuredContent);
263
277
  }
264
- const text = data?.result?.content?.[0]?.text;
278
+ const content = isRecord(result) ? result.content : void 0;
279
+ const firstContent = Array.isArray(content) ? content[0] : void 0;
280
+ const text = isRecord(firstContent) ? firstContent.text : void 0;
265
281
  if (typeof text === "string") {
266
282
  const parsed = safeJson(text);
267
283
  return unwrapMcpPayload(parsed ?? text);
268
284
  }
269
- return unwrapMcpPayload(data?.result);
285
+ return unwrapMcpPayload(result);
270
286
  }
271
287
  function unwrapMcpPayload(payload) {
272
- if (payload && typeof payload === "object") {
288
+ if (isRecord(payload)) {
273
289
  if (payload.ok === true && Object.prototype.hasOwnProperty.call(payload, "result")) {
274
290
  return payload.result;
275
291
  }
292
+ if (payload.ok === false) {
293
+ const first = firstPayloadError(payload);
294
+ const code = firstString(first.code, payload.error_code, payload.code) || (payload.approval_required ? "APPROVAL_REQUIRED" : "MCP_ERROR");
295
+ throw new SignalizError({
296
+ code,
297
+ message: firstString(first.message, payload.message, payload.summary, payload.error) || "MCP request failed",
298
+ errorType: mapErrorTypeFromCode(code),
299
+ details: {
300
+ ...payload,
301
+ ...isRecord(first.details) ? first.details : {}
302
+ }
303
+ });
304
+ }
276
305
  if (payload.success === true && Object.prototype.hasOwnProperty.call(payload, "data")) {
277
306
  return payload.data;
278
307
  }
279
308
  if (payload.success === false) {
280
- const first = Array.isArray(payload.errors) ? payload.errors[0] ?? {} : {};
281
- const code = first.code || payload.error_code || (payload.approval_required ? "APPROVAL_REQUIRED" : "MCP_ERROR");
309
+ const first = firstPayloadError(payload);
310
+ const code = firstString(first.code, payload.error_code) || (payload.approval_required ? "APPROVAL_REQUIRED" : "MCP_ERROR");
282
311
  throw new SignalizError({
283
312
  code,
284
- message: first.message || payload.message || payload.summary || "MCP request failed",
313
+ message: firstString(first.message, payload.message, payload.summary) || "MCP request failed",
285
314
  errorType: mapErrorTypeFromCode(code),
286
315
  details: {
287
316
  ...payload,
288
- ...first.details && typeof first.details === "object" ? first.details : {}
317
+ ...isRecord(first.details) ? first.details : {}
289
318
  }
290
319
  });
291
320
  }
@@ -293,8 +322,10 @@ function unwrapMcpPayload(payload) {
293
322
  return payload;
294
323
  }
295
324
  function mapMcpErrorType(error) {
296
- const code = String(error?.data?.error_code || error?.code || "");
297
- const message = String(error?.message || "").toLowerCase();
325
+ const errorRecord = isRecord(error) ? error : {};
326
+ const data = isRecord(errorRecord.data) ? errorRecord.data : {};
327
+ const code = String(data.error_code || errorRecord.code || "");
328
+ const message = String(errorRecord.message || "").toLowerCase();
298
329
  if (code === "429" || message.includes("rate limit")) return "rate_limited";
299
330
  if (code === "401" || code === "AUTH_001" || message.includes("auth")) return "auth_expired";
300
331
  if (code === "400" || code === "-32602" || message.includes("invalid")) return "validation";
@@ -2918,6 +2949,10 @@ function normalizeOpsProofResult(data) {
2918
2949
  failed30d: numberValue(summary.failed_30d ?? summary.failed30d),
2919
2950
  external_delivered_30d: numberValue(summary.external_delivered_30d ?? summary.externalDelivered30d),
2920
2951
  externalDelivered30d: numberValue(summary.external_delivered_30d ?? summary.externalDelivered30d),
2952
+ nango_proofs_30d: numberValue(summary.nango_proofs_30d ?? summary.nangoProofs30d),
2953
+ nangoProofs30d: numberValue(summary.nango_proofs_30d ?? summary.nangoProofs30d),
2954
+ nango_failures_30d: numberValue(summary.nango_failures_30d ?? summary.nangoFailures30d),
2955
+ nangoFailures30d: numberValue(summary.nango_failures_30d ?? summary.nangoFailures30d),
2921
2956
  airbyte_configured: numberValue(summary.airbyte_configured ?? summary.airbyteConfigured),
2922
2957
  airbyteConfigured: numberValue(summary.airbyte_configured ?? summary.airbyteConfigured),
2923
2958
  airbyte_proofs_30d: numberValue(summary.airbyte_proofs_30d ?? summary.airbyteProofs30d),
@@ -3332,9 +3367,10 @@ function buildOpsDebugOptions(params) {
3332
3367
  }
3333
3368
  function buildCreateRoutineBody(params) {
3334
3369
  const { outputSinks, wakeOnEvents, ...rest } = params;
3370
+ const sinks = rest.output_sinks ?? outputSinks;
3335
3371
  return {
3336
3372
  ...rest,
3337
- output_sinks: rest.output_sinks ?? outputSinks,
3373
+ output_sinks: Array.isArray(sinks) ? sinks.map(normalizeOpsSinkRequest) : sinks,
3338
3374
  wake_on_events: rest.wake_on_events ?? wakeOnEvents
3339
3375
  };
3340
3376
  }
@@ -3368,6 +3404,97 @@ function buildCreateOutputSinkBody(params) {
3368
3404
  webhook_url: rest.webhook_url ?? webhookUrl
3369
3405
  };
3370
3406
  }
3407
+ function normalizeOpsSinkRequest(sink) {
3408
+ const {
3409
+ sinkId,
3410
+ connectionId,
3411
+ connectorId,
3412
+ connectorName,
3413
+ deliveryMode,
3414
+ providerConfigKey,
3415
+ integrationId,
3416
+ nangoConnectionId,
3417
+ actionName,
3418
+ nangoAction,
3419
+ proxyPath,
3420
+ nangoProxyPath,
3421
+ fieldMap,
3422
+ requiredFields,
3423
+ writeConfirmed,
3424
+ agentWriteConfirmed,
3425
+ config,
3426
+ ...rest
3427
+ } = sink;
3428
+ const normalizedConfig = normalizeOpsSinkConfigRequest(config);
3429
+ const connection_id = rest.connection_id ?? connectionId;
3430
+ const connector_id = rest.connector_id ?? connectorId;
3431
+ const delivery_mode = rest.delivery_mode ?? deliveryMode;
3432
+ const provider_config_key = rest.provider_config_key ?? providerConfigKey;
3433
+ const integration_id = rest.integration_id ?? integrationId;
3434
+ const nango_connection_id = rest.nango_connection_id ?? nangoConnectionId;
3435
+ const action_name = rest.action_name ?? actionName;
3436
+ const nango_action = rest.nango_action ?? nangoAction;
3437
+ const proxy_path = rest.proxy_path ?? proxyPath;
3438
+ const nango_proxy_path = rest.nango_proxy_path ?? nangoProxyPath;
3439
+ const field_map = rest.field_map ?? fieldMap;
3440
+ const required_fields = rest.required_fields ?? requiredFields;
3441
+ const write_confirmed = rest.write_confirmed ?? writeConfirmed;
3442
+ const agent_write_confirmed = rest.agent_write_confirmed ?? agentWriteConfirmed;
3443
+ if (connection_id !== void 0 && normalizedConfig.connection_id === void 0) normalizedConfig.connection_id = connection_id;
3444
+ if (connector_id !== void 0 && normalizedConfig.connector_id === void 0) normalizedConfig.connector_id = connector_id;
3445
+ if (delivery_mode !== void 0 && normalizedConfig.delivery_mode === void 0) normalizedConfig.delivery_mode = delivery_mode;
3446
+ if (provider_config_key !== void 0 && normalizedConfig.provider_config_key === void 0) normalizedConfig.provider_config_key = provider_config_key;
3447
+ if (integration_id !== void 0 && normalizedConfig.integration_id === void 0) normalizedConfig.integration_id = integration_id;
3448
+ if (nango_connection_id !== void 0 && normalizedConfig.nango_connection_id === void 0) normalizedConfig.nango_connection_id = nango_connection_id;
3449
+ if (action_name !== void 0 && normalizedConfig.action_name === void 0) normalizedConfig.action_name = action_name;
3450
+ if (nango_action !== void 0 && normalizedConfig.nango_action === void 0) normalizedConfig.nango_action = nango_action;
3451
+ if (proxy_path !== void 0 && normalizedConfig.proxy_path === void 0) normalizedConfig.proxy_path = proxy_path;
3452
+ if (nango_proxy_path !== void 0 && normalizedConfig.nango_proxy_path === void 0) normalizedConfig.nango_proxy_path = nango_proxy_path;
3453
+ if (field_map !== void 0 && normalizedConfig.field_map === void 0) normalizedConfig.field_map = field_map;
3454
+ if (required_fields !== void 0 && normalizedConfig.required_fields === void 0) normalizedConfig.required_fields = required_fields;
3455
+ if (write_confirmed !== void 0 && normalizedConfig.write_confirmed === void 0) normalizedConfig.write_confirmed = write_confirmed;
3456
+ if (agent_write_confirmed !== void 0 && normalizedConfig.agent_write_confirmed === void 0) normalizedConfig.agent_write_confirmed = agent_write_confirmed;
3457
+ if (sink.type === "nango" && normalizedConfig.integration_platform === void 0) normalizedConfig.integration_platform = "nango";
3458
+ return {
3459
+ ...rest,
3460
+ sink_id: rest.sink_id ?? sinkId,
3461
+ connection_id,
3462
+ connector_id,
3463
+ connector_name: rest.connector_name ?? connectorName,
3464
+ delivery_mode,
3465
+ provider_config_key,
3466
+ integration_id,
3467
+ nango_connection_id,
3468
+ action_name,
3469
+ nango_action,
3470
+ proxy_path,
3471
+ nango_proxy_path,
3472
+ field_map,
3473
+ required_fields,
3474
+ write_confirmed,
3475
+ agent_write_confirmed,
3476
+ config: normalizedConfig
3477
+ };
3478
+ }
3479
+ function normalizeOpsSinkConfigRequest(config) {
3480
+ const out = { ...config ?? {} };
3481
+ if (out.connection_id === void 0 && out.connectionId !== void 0) out.connection_id = out.connectionId;
3482
+ if (out.connector_id === void 0 && out.connectorId !== void 0) out.connector_id = out.connectorId;
3483
+ if (out.connector_name === void 0 && out.connectorName !== void 0) out.connector_name = out.connectorName;
3484
+ if (out.delivery_mode === void 0 && out.deliveryMode !== void 0) out.delivery_mode = out.deliveryMode;
3485
+ if (out.provider_config_key === void 0 && out.providerConfigKey !== void 0) out.provider_config_key = out.providerConfigKey;
3486
+ if (out.integration_id === void 0 && out.integrationId !== void 0) out.integration_id = out.integrationId;
3487
+ if (out.nango_connection_id === void 0 && out.nangoConnectionId !== void 0) out.nango_connection_id = out.nangoConnectionId;
3488
+ if (out.action_name === void 0 && out.actionName !== void 0) out.action_name = out.actionName;
3489
+ if (out.nango_action === void 0 && out.nangoAction !== void 0) out.nango_action = out.nangoAction;
3490
+ if (out.proxy_path === void 0 && out.proxyPath !== void 0) out.proxy_path = out.proxyPath;
3491
+ if (out.nango_proxy_path === void 0 && out.nangoProxyPath !== void 0) out.nango_proxy_path = out.nangoProxyPath;
3492
+ if (out.field_map === void 0 && out.fieldMap !== void 0) out.field_map = out.fieldMap;
3493
+ if (out.required_fields === void 0 && out.requiredFields !== void 0) out.required_fields = out.requiredFields;
3494
+ if (out.write_confirmed === void 0 && out.writeConfirmed !== void 0) out.write_confirmed = out.writeConfirmed;
3495
+ if (out.agent_write_confirmed === void 0 && out.agentWriteConfirmed !== void 0) out.agent_write_confirmed = out.agentWriteConfirmed;
3496
+ return out;
3497
+ }
3371
3498
  function buildApproveBody(params) {
3372
3499
  const { tokenId, tokenIds, reviewerNotes, ...rest } = params;
3373
3500
  return {
@@ -3516,6 +3643,57 @@ var GtmKernel = class {
3516
3643
  limit: options.limit
3517
3644
  });
3518
3645
  }
3646
+ /** Discover existing provider campaigns, starting with live/Kernel-linked Instantly campaigns, before audit or import preview. */
3647
+ async discoverExistingCampaigns(options = {}) {
3648
+ return this.callMcp("gtm_existing_campaign_discover", {
3649
+ provider: options.provider,
3650
+ integration_id: options.integrationId,
3651
+ search: options.search,
3652
+ limit: options.limit,
3653
+ include_kernel_linked: options.includeKernelLinked,
3654
+ include_provider_live: options.includeProviderLive
3655
+ });
3656
+ }
3657
+ /** Run a read-only existing campaign audit with completeness, recommendations, safe next MCP JSON, and approval boundaries. */
3658
+ async auditExistingCampaign(options) {
3659
+ return this.callMcp("gtm_existing_campaign_audit", {
3660
+ campaign_id: options.campaignId,
3661
+ provider: options.provider,
3662
+ provider_campaign_id: options.providerCampaignId,
3663
+ campaign_name: options.campaignName,
3664
+ days: options.days,
3665
+ include_route_preview: options.includeRoutePreview,
3666
+ include_memory: options.includeMemory,
3667
+ include_brain: options.includeBrain
3668
+ });
3669
+ }
3670
+ /** Discover the first matching existing provider campaign, then run the same read-only audit against that match. */
3671
+ async auditExistingCampaignBySearch(options) {
3672
+ const discovery = await this.discoverExistingCampaigns({
3673
+ provider: options.provider,
3674
+ integrationId: options.integrationId,
3675
+ search: options.search,
3676
+ limit: 1,
3677
+ includeKernelLinked: options.includeKernelLinked,
3678
+ includeProviderLive: options.includeProviderLive
3679
+ });
3680
+ const match = discovery.campaigns?.[0];
3681
+ const campaignId = match?.linked_kernel_campaign_id || void 0;
3682
+ const providerCampaignId = match?.provider_campaign_id || void 0;
3683
+ if (!campaignId && !providerCampaignId) {
3684
+ throw new Error(`No existing ${options.provider || discovery.provider || "provider"} campaign matched "${options.search}"`);
3685
+ }
3686
+ return this.auditExistingCampaign({
3687
+ provider: options.provider || discovery.provider || match?.provider,
3688
+ campaignId,
3689
+ providerCampaignId,
3690
+ campaignName: match?.name || match?.linked_kernel_campaign_name || void 0,
3691
+ days: options.days,
3692
+ includeRoutePreview: options.includeRoutePreview,
3693
+ includeMemory: options.includeMemory,
3694
+ includeBrain: options.includeBrain
3695
+ });
3696
+ }
3519
3697
  /** Create a first-class GTM campaign object in the current workspace. */
3520
3698
  async createCampaign(input) {
3521
3699
  return this.callMcp("gtm_campaign_create", campaignCreateArgs(input));
@@ -3721,6 +3899,47 @@ var GtmKernel = class {
3721
3899
  brain_cycle_min_interval_minutes: input.brainCycleMinIntervalMinutes
3722
3900
  });
3723
3901
  }
3902
+ /** Preview anonymized Instantly workspace sources registered for Kernel import. */
3903
+ async previewKernelImport(input = {}) {
3904
+ return this.callMcp("gtm_kernel_import_preview", {
3905
+ source_ids: input.sourceIds,
3906
+ include_leads: input.includeLeads,
3907
+ include_replies: input.includeReplies,
3908
+ include_private_copy: input.includePrivateCopy,
3909
+ max_pages: input.maxPages,
3910
+ limit: input.limit
3911
+ });
3912
+ }
3913
+ /** Queue the read-only Instantly-to-GTM Kernel import. Live writes require writeApproved. */
3914
+ async runKernelImport(input = {}) {
3915
+ return this.callMcp("gtm_kernel_import_run", {
3916
+ source_ids: input.sourceIds,
3917
+ dry_run: input.dryRun,
3918
+ write_approved: input.writeApproved,
3919
+ include_leads: input.includeLeads,
3920
+ include_replies: input.includeReplies,
3921
+ include_private_copy: input.includePrivateCopy,
3922
+ private_copy_approved: input.privateCopyApproved,
3923
+ promote_global_patterns: input.promoteGlobalPatterns,
3924
+ min_global_privacy_k: input.minGlobalPrivacyK,
3925
+ max_pages: input.maxPages,
3926
+ limit: input.limit
3927
+ });
3928
+ }
3929
+ /** Queue Brain distillation over imported Instantly memory with abstracted-only outputs. */
3930
+ async runBrainDistillation(input = {}) {
3931
+ return this.callMcp("gtm_brain_distill_run", {
3932
+ source_ids: input.sourceIds,
3933
+ write_mode: input.writeMode,
3934
+ write_approved: input.writeApproved,
3935
+ brain_cycle_phases: input.brainCyclePhases,
3936
+ days: input.days,
3937
+ network_days: input.networkDays,
3938
+ min_sample_size: input.minSampleSize,
3939
+ min_workspace_count: input.minWorkspaceCount,
3940
+ min_privacy_k: input.minPrivacyK
3941
+ });
3942
+ }
3724
3943
  /** Prepare a provider-agnostic feedback webhook URL for Smartlead, HeyReach, Airbyte, or custom sender events. */
3725
3944
  async prepareFeedbackWebhook(input) {
3726
3945
  return this.callMcp("gtm_feedback_webhook_prepare", {
@@ -4148,6 +4367,43 @@ var GtmKernel = class {
4148
4367
  context: input.context
4149
4368
  });
4150
4369
  }
4370
+ /** List Nango-backed action tools for a workspace connection without executing them. */
4371
+ async listNangoTools(options = {}) {
4372
+ return this.callMcp("nango_mcp_tools_list", {
4373
+ workspace_connection_id: options.workspaceConnectionId,
4374
+ connection_id: options.connectionId,
4375
+ provider_config_key: options.providerConfigKey,
4376
+ integration_id: options.integrationId,
4377
+ nango_connection_id: options.nangoConnectionId,
4378
+ format: options.format,
4379
+ include_raw: options.includeRaw
4380
+ });
4381
+ }
4382
+ /** Dry-run or execute a Nango-backed action tool through the approval-aware MCP bridge. */
4383
+ async callNangoTool(input) {
4384
+ return this.callMcp("nango_mcp_tool_call", {
4385
+ workspace_connection_id: input.workspaceConnectionId,
4386
+ connection_id: input.connectionId,
4387
+ provider_config_key: input.providerConfigKey,
4388
+ integration_id: input.integrationId,
4389
+ nango_connection_id: input.nangoConnectionId,
4390
+ action_name: input.actionName,
4391
+ tool_name: input.toolName,
4392
+ input: input.input,
4393
+ async: input.async,
4394
+ max_retries: input.maxRetries,
4395
+ dry_run: input.dryRun,
4396
+ confirm: input.confirm,
4397
+ confirm_write: input.confirmWrite
4398
+ });
4399
+ }
4400
+ /** Poll an async Nango action result by action id or status URL. */
4401
+ async getNangoActionResult(input) {
4402
+ return this.callMcp("nango_mcp_action_result_get", {
4403
+ action_id: input.actionId,
4404
+ status_url: input.statusUrl
4405
+ });
4406
+ }
4151
4407
  /** Deliver approved campaign-layer records to a webhook recipe, starting with Clay-style webhooks. */
4152
4408
  async deliverWebhook(input) {
4153
4409
  return this.callMcp("gtm_webhook_deliver", {
@@ -4282,6 +4538,59 @@ function compact2(value) {
4282
4538
  }
4283
4539
 
4284
4540
  // src/index.ts
4541
+ function inferMcpToolCategory(toolName) {
4542
+ if (typeof toolName !== "string" || !toolName) return void 0;
4543
+ if (toolName.startsWith("ops_") || toolName === "get_ops_readiness" || toolName === "get_gtm_ops_readiness" || toolName.startsWith("gtm_") || [
4544
+ "list_routines",
4545
+ "create_routine",
4546
+ "update_routine",
4547
+ "run_routine_now",
4548
+ "get_routine",
4549
+ "get_routine_ticks",
4550
+ "get_tick_items",
4551
+ "get_last_tick_items",
4552
+ "chain_routines",
4553
+ "get_chain_status",
4554
+ "launch_campaign",
4555
+ "quickstart_gtm_book",
4556
+ "list_campaigns",
4557
+ "campaign_performance",
4558
+ "tune_campaign",
4559
+ "emit_event",
4560
+ "approvals_list",
4561
+ "list_output_sinks",
4562
+ "create_output_sink",
4563
+ "update_output_sink",
4564
+ "delete_output_sink",
4565
+ "attach_sink_to_routine"
4566
+ ].includes(toolName)) {
4567
+ return "ops";
4568
+ }
4569
+ if ([
4570
+ "find_emails_with_verification",
4571
+ "verify_email",
4572
+ "enrich_company_signals",
4573
+ "company_intelligence",
4574
+ "find_contacts_with_email",
4575
+ "execute_primitive"
4576
+ ].includes(toolName)) {
4577
+ return "enrichment";
4578
+ }
4579
+ if (toolName.includes("icp")) return "icp";
4580
+ if (toolName.startsWith("ai_clean_")) return "data_cleaning";
4581
+ if (toolName.includes("system") || toolName.includes("workflow")) return "automation";
4582
+ if (toolName.includes("agent") || toolName.includes("platform_health") || toolName === "discover_capabilities") return "observability";
4583
+ return void 0;
4584
+ }
4585
+ function asRecord3(value) {
4586
+ return value && typeof value === "object" ? value : void 0;
4587
+ }
4588
+ function asStringArray(value) {
4589
+ return Array.isArray(value) ? value.filter((item) => typeof item === "string") : void 0;
4590
+ }
4591
+ function asObjectSchema(value) {
4592
+ return asRecord3(value);
4593
+ }
4285
4594
  var Signaliz = class {
4286
4595
  constructor(config) {
4287
4596
  this.client = new HttpClient(config);
@@ -4340,21 +4649,21 @@ var Signaliz = class {
4340
4649
  const data = await this.client.mcp("tools/list", {});
4341
4650
  const tools = data?.tools ?? data ?? [];
4342
4651
  return tools.map((t) => ({
4343
- name: t.name,
4344
- description: (t.description ?? "").slice(0, 120),
4345
- category: t.annotations?.category,
4346
- costCredits: t.annotations?.cost_credits,
4347
- contractVersion: t.annotations?.contract_version ?? t.annotations?.contract?.contract_version,
4348
- permissionLevel: t.annotations?.permission_level ?? t.annotations?.contract?.permission_level,
4349
- authScopes: t.annotations?.auth_scopes ?? t.annotations?.contract?.auth_scopes,
4350
- idempotent: t.annotations?.idempotentHint ?? t.annotations?.idempotent ?? t.annotations?.contract?.idempotent,
4351
- destructive: t.annotations?.destructiveHint ?? t.annotations?.destructive ?? t.annotations?.contract?.destructive,
4352
- retryable: t.annotations?.retryable ?? t.annotations?.contract?.retryable,
4353
- rateLimitKey: t.annotations?.rate_limit_key ?? t.annotations?.contract?.rate_limit_key,
4354
- observability: t.annotations?.observability ?? t.annotations?.contract?.observability,
4355
- inputSchema: t.inputSchema ?? t.input_schema ?? t.annotations?.contract?.input_schema,
4356
- outputSchema: t.outputSchema ?? t.output_schema ?? t.annotations?.contract?.output_schema,
4357
- annotations: t.annotations
4652
+ name: typeof t.name === "string" ? t.name : "",
4653
+ description: String(t.description ?? "").slice(0, 120),
4654
+ category: typeof t.annotations?.category === "string" ? t.annotations.category : inferMcpToolCategory(t.name),
4655
+ costCredits: typeof t.annotations?.cost_credits === "number" ? t.annotations.cost_credits : void 0,
4656
+ contractVersion: typeof (t.annotations?.contract_version ?? t.annotations?.contract?.contract_version) === "string" ? t.annotations?.contract_version ?? t.annotations?.contract?.contract_version : void 0,
4657
+ permissionLevel: typeof (t.annotations?.permission_level ?? t.annotations?.contract?.permission_level) === "string" ? t.annotations?.permission_level ?? t.annotations?.contract?.permission_level : void 0,
4658
+ authScopes: asStringArray(t.annotations?.auth_scopes ?? t.annotations?.contract?.auth_scopes),
4659
+ idempotent: typeof (t.annotations?.idempotentHint ?? t.annotations?.idempotent ?? t.annotations?.contract?.idempotent) === "boolean" ? t.annotations?.idempotentHint ?? t.annotations?.idempotent ?? t.annotations?.contract?.idempotent : void 0,
4660
+ destructive: typeof (t.annotations?.destructiveHint ?? t.annotations?.destructive ?? t.annotations?.contract?.destructive) === "boolean" ? t.annotations?.destructiveHint ?? t.annotations?.destructive ?? t.annotations?.contract?.destructive : void 0,
4661
+ retryable: typeof (t.annotations?.retryable ?? t.annotations?.contract?.retryable) === "boolean" ? t.annotations?.retryable ?? t.annotations?.contract?.retryable : void 0,
4662
+ rateLimitKey: typeof (t.annotations?.rate_limit_key ?? t.annotations?.contract?.rate_limit_key) === "string" ? t.annotations?.rate_limit_key ?? t.annotations?.contract?.rate_limit_key : void 0,
4663
+ observability: asRecord3(t.annotations?.observability ?? t.annotations?.contract?.observability),
4664
+ inputSchema: asObjectSchema(t.inputSchema ?? t.input_schema ?? t.annotations?.contract?.input_schema),
4665
+ outputSchema: asObjectSchema(t.outputSchema ?? t.output_schema ?? t.annotations?.contract?.output_schema),
4666
+ annotations: asRecord3(t.annotations)
4358
4667
  }));
4359
4668
  }
4360
4669
  /** Discover tools by natural language query */
package/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  Signaliz
4
- } from "./chunk-L6XUFJJO.mjs";
4
+ } from "./chunk-EVZZQTWE.mjs";
5
5
 
6
6
  // src/cli.ts
7
7
  var apiKey = process.env.SIGNALIZ_API_KEY;