@signaliz/sdk 1.0.28 → 1.0.30
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 +3 -0
- package/dist/{chunk-YQXKJ6FB.mjs → chunk-INM326KO.mjs} +440 -151
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +440 -151
- package/dist/index.mjs +1 -1
- package/dist/mcp-config.js +440 -151
- package/dist/mcp-config.mjs +1 -1
- package/package.json +13 -3
package/dist/mcp-config.js
CHANGED
|
@@ -384,89 +384,51 @@ var Signaliz = class {
|
|
|
384
384
|
this.client = new HttpClient(config);
|
|
385
385
|
}
|
|
386
386
|
async findEmail(params) {
|
|
387
|
-
const data = await this.client.post("api/v1/find-email",
|
|
388
|
-
|
|
389
|
-
full_name: params.fullName,
|
|
390
|
-
first_name: params.firstName,
|
|
391
|
-
last_name: params.lastName,
|
|
392
|
-
linkedin_url: params.linkedinUrl,
|
|
393
|
-
company_name: params.companyName,
|
|
394
|
-
skip_cache: params.skipCache
|
|
395
|
-
}));
|
|
396
|
-
const email = typeof data.email === "string" && data.email.trim() ? data.email.trim() : null;
|
|
397
|
-
const found = Boolean(email) && data.found !== false;
|
|
398
|
-
const verificationStatus = data.verification_status ?? data.status ?? "unknown";
|
|
399
|
-
const rawFreshness = String(data.verification_freshness ?? "").toLowerCase();
|
|
400
|
-
const verificationFreshness = rawFreshness === "fresh" || rawFreshness === "stale" ? rawFreshness : "unknown";
|
|
401
|
-
const needsReverification = data.needs_reverification === true || verificationFreshness === "stale";
|
|
402
|
-
const explicitlyNotSendSafe = data.verified_for_sending === false || needsReverification;
|
|
403
|
-
const verified = !explicitlyNotSendSafe && (data.email_verified === true || data.verified_for_sending === true || ["valid", "deliverable"].includes(String(verificationStatus).toLowerCase()));
|
|
404
|
-
const verificationAgeDays = typeof data.verification_age_days === "number" && Number.isFinite(data.verification_age_days) ? data.verification_age_days : null;
|
|
405
|
-
return {
|
|
406
|
-
success: data.success !== false && found,
|
|
407
|
-
found,
|
|
408
|
-
email,
|
|
409
|
-
firstName: data.first_name,
|
|
410
|
-
lastName: data.last_name,
|
|
411
|
-
confidence: data.confidence ?? data.confidence_score ?? (verified ? 1 : 0),
|
|
412
|
-
verificationStatus,
|
|
413
|
-
isVerified: verified,
|
|
414
|
-
isVerifiedForSending: !needsReverification && data.verified_for_sending === true,
|
|
415
|
-
isCatchAll: data.email_is_catch_all === true || data.is_catch_all === true,
|
|
416
|
-
verificationFreshness,
|
|
417
|
-
verificationAgeDays,
|
|
418
|
-
verifiedAt: typeof data.verified_at === "string" ? data.verified_at : null,
|
|
419
|
-
needsReverification,
|
|
420
|
-
providerUsed: data.provider_used ?? data.provider ?? data.email_source ?? data.source ?? "unknown",
|
|
421
|
-
error: found ? void 0 : data.error ?? "No verified email found",
|
|
422
|
-
errorCode: found ? void 0 : data.error_code ?? "EMAIL_NOT_FOUND",
|
|
423
|
-
raw: data
|
|
424
|
-
};
|
|
387
|
+
const data = await this.client.post("api/v1/find-email", findEmailRequestBody(params));
|
|
388
|
+
return normalizeFindEmailResult(data);
|
|
425
389
|
}
|
|
426
390
|
async findEmails(params, options) {
|
|
427
|
-
|
|
391
|
+
validateBatchSize(params);
|
|
392
|
+
const startedAt = Date.now();
|
|
393
|
+
const round = await this.runCoreBatchRound(
|
|
394
|
+
"api/v1/find-email",
|
|
395
|
+
params.map((item, index) => ({ index, request: findEmailRequestBody(item) })),
|
|
396
|
+
options
|
|
397
|
+
);
|
|
398
|
+
return finalizeCoreBatch(
|
|
399
|
+
params.length,
|
|
400
|
+
startedAt,
|
|
401
|
+
round,
|
|
402
|
+
(item) => normalizeFindEmailResult(item.raw)
|
|
403
|
+
);
|
|
428
404
|
}
|
|
429
405
|
async verifyEmail(email, options) {
|
|
430
406
|
const data = await this.client.post("api/v1/verify-email", {
|
|
431
407
|
email,
|
|
432
408
|
skip_cache: options?.skipCache
|
|
433
409
|
});
|
|
434
|
-
|
|
435
|
-
const verified = data.email_verified === true || ["valid", "deliverable"].includes(verificationStatus);
|
|
436
|
-
return {
|
|
437
|
-
email: data.email ?? email,
|
|
438
|
-
isValid: data.is_valid ?? data.valid ?? verified,
|
|
439
|
-
isDeliverable: data.is_deliverable ?? data.deliverable ?? verified,
|
|
440
|
-
isCatchAll: data.is_catch_all ?? data.catch_all ?? data.diagnostics?.is_catch_all ?? false,
|
|
441
|
-
confidenceScore: data.confidence_score ?? data.confidence ?? data.diagnostics?.confidence_score ?? (verified ? 1 : 0),
|
|
442
|
-
provider: data.provider,
|
|
443
|
-
verificationSource: data.verification_source,
|
|
444
|
-
raw: data
|
|
445
|
-
};
|
|
410
|
+
return normalizeVerifyEmailResult(email, data);
|
|
446
411
|
}
|
|
447
412
|
async verifyEmails(emails, options) {
|
|
448
|
-
|
|
413
|
+
validateBatchSize(emails);
|
|
414
|
+
const startedAt = Date.now();
|
|
415
|
+
const round = await this.runCoreBatchRound(
|
|
416
|
+
"api/v1/verify-email",
|
|
417
|
+
emails.map((email, index) => ({
|
|
418
|
+
index,
|
|
419
|
+
request: { email, skip_cache: options?.skipCache }
|
|
420
|
+
})),
|
|
421
|
+
options
|
|
422
|
+
);
|
|
423
|
+
return finalizeCoreBatch(
|
|
424
|
+
emails.length,
|
|
425
|
+
startedAt,
|
|
426
|
+
round,
|
|
427
|
+
(item) => normalizeVerifyEmailResult(emails[item.index], item.raw)
|
|
428
|
+
);
|
|
449
429
|
}
|
|
450
430
|
async enrichCompanySignals(params) {
|
|
451
|
-
const
|
|
452
|
-
const request = compact({
|
|
453
|
-
signal_run_id: params.signalRunId,
|
|
454
|
-
company_domain: params.companyDomain,
|
|
455
|
-
company_name: params.companyName,
|
|
456
|
-
research_prompt: params.researchPrompt,
|
|
457
|
-
signal_types: params.signalTypes,
|
|
458
|
-
target_signal_count: params.targetSignalCount,
|
|
459
|
-
lookback_days: params.lookbackDays,
|
|
460
|
-
online,
|
|
461
|
-
enable_deep_search: params.enableDeepSearch ?? online,
|
|
462
|
-
enable_outreach_intelligence: params.enableOutreachIntelligence,
|
|
463
|
-
enable_predictive_intelligence: params.enablePredictiveIntelligence,
|
|
464
|
-
skip_cache: params.skipCache,
|
|
465
|
-
// REST always returns a resumable run instead of holding the connection;
|
|
466
|
-
// waitForResult controls this SDK's polling loop below.
|
|
467
|
-
wait_for_result: false,
|
|
468
|
-
max_wait_ms: params.maxWaitMs
|
|
469
|
-
});
|
|
431
|
+
const request = companySignalRequestBody(params);
|
|
470
432
|
let data = await this.client.post("api/v1/company-signals", request);
|
|
471
433
|
if (params.waitForResult !== false && data.run_id && isPendingSignalResponse(data)) {
|
|
472
434
|
const maxWaitMs = Math.max(1e3, params.maxWaitMs ?? 20 * 6e4);
|
|
@@ -494,59 +456,71 @@ var Signaliz = class {
|
|
|
494
456
|
throw new Error(`Company signal enrichment ${data.run_id} did not complete within ${maxWaitMs}ms`);
|
|
495
457
|
}
|
|
496
458
|
}
|
|
497
|
-
return
|
|
498
|
-
success: data.success ?? true,
|
|
499
|
-
status: data.status,
|
|
500
|
-
signalRunId: data.signal_run_id ?? data.run_id,
|
|
501
|
-
company: {
|
|
502
|
-
name: data.company?.name ?? params.companyName ?? null,
|
|
503
|
-
domain: data.company?.domain ?? params.companyDomain ?? null
|
|
504
|
-
},
|
|
505
|
-
signals: (data.signals ?? []).map((signal) => {
|
|
506
|
-
const metadata = signal.metadata && typeof signal.metadata === "object" && !Array.isArray(signal.metadata) ? signal.metadata : void 0;
|
|
507
|
-
return {
|
|
508
|
-
id: signal.id,
|
|
509
|
-
title: signal.title ?? "",
|
|
510
|
-
type: signal.type ?? signal.signal_type ?? "unknown",
|
|
511
|
-
content: signal.content ?? signal.description ?? "",
|
|
512
|
-
date: signal.date ?? signal.detected_at ?? null,
|
|
513
|
-
datePrecision: signal.date_precision,
|
|
514
|
-
sourceUrl: signal.source_url ?? signal.url ?? null,
|
|
515
|
-
sourceType: signal.source_type,
|
|
516
|
-
sourceProvenance: signal.source_provenance,
|
|
517
|
-
confidence: signal.confidence ?? signal.confidence_score ?? null,
|
|
518
|
-
entityConfidence: signal.entity_confidence ?? metadata?.entity_confidence ?? null,
|
|
519
|
-
signalFamily: signal.signal_family,
|
|
520
|
-
eventType: signal.signal_event_type,
|
|
521
|
-
eventLabel: signal.signal_event_label,
|
|
522
|
-
classification: signal.signal_classification ?? null,
|
|
523
|
-
derived: signal.derived === true,
|
|
524
|
-
evidencePublishedDate: signal.evidence_published_date ?? metadata?.evidence_published_date ?? null,
|
|
525
|
-
signalFeedSource: signal.signal_feed_source ?? metadata?.signal_feed_source,
|
|
526
|
-
metadata
|
|
527
|
-
};
|
|
528
|
-
}),
|
|
529
|
-
signalCount: data.signal_count ?? data.total_signals ?? data.signals?.length ?? 0,
|
|
530
|
-
intelligence: data.intelligence ?? null,
|
|
531
|
-
credits: data.credits,
|
|
532
|
-
metadata: data.metadata,
|
|
533
|
-
raw: data
|
|
534
|
-
};
|
|
459
|
+
return normalizeCompanySignalResult(params, data);
|
|
535
460
|
}
|
|
536
461
|
async enrichCompanies(companies, options) {
|
|
537
|
-
|
|
462
|
+
validateBatchSize(companies);
|
|
463
|
+
const startedAt = Date.now();
|
|
464
|
+
const results = new Array(companies.length);
|
|
465
|
+
let pending = companies.map((params, index) => ({
|
|
466
|
+
index,
|
|
467
|
+
request: companySignalRequestBody(params)
|
|
468
|
+
}));
|
|
469
|
+
while (pending.length > 0) {
|
|
470
|
+
const round = await this.runCoreBatchRound("api/v1/company-signals", pending, options);
|
|
471
|
+
const taskByIndex = new Map(pending.map((task) => [task.index, task]));
|
|
472
|
+
const nextPending = [];
|
|
473
|
+
let nextDelayMs = 6e4;
|
|
474
|
+
for (const item of round) {
|
|
475
|
+
const params = companies[item.index];
|
|
476
|
+
const task = taskByIndex.get(item.index);
|
|
477
|
+
if (!item.success || !item.raw) {
|
|
478
|
+
results[item.index] = { index: item.index, success: false, error: item.error || "Company Signal batch request failed" };
|
|
479
|
+
continue;
|
|
480
|
+
}
|
|
481
|
+
if (!isPendingSignalResponse(item.raw) || params.waitForResult === false) {
|
|
482
|
+
results[item.index] = { index: item.index, success: true, data: normalizeCompanySignalResult(params, item.raw) };
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
const maxWaitMs = Math.max(1e3, params.maxWaitMs ?? 20 * 6e4);
|
|
486
|
+
if (Date.now() - startedAt >= maxWaitMs) {
|
|
487
|
+
results[item.index] = {
|
|
488
|
+
index: item.index,
|
|
489
|
+
success: false,
|
|
490
|
+
error: `Company signal enrichment ${item.raw.signal_run_id || item.raw.run_id || ""} did not complete within ${maxWaitMs}ms`
|
|
491
|
+
};
|
|
492
|
+
continue;
|
|
493
|
+
}
|
|
494
|
+
const signalRunId = item.raw.signal_run_id || item.raw.run_id;
|
|
495
|
+
if (!signalRunId) {
|
|
496
|
+
results[item.index] = { index: item.index, success: false, error: "Company signal enrichment is processing without a signal_run_id" };
|
|
497
|
+
continue;
|
|
498
|
+
}
|
|
499
|
+
nextDelayMs = Math.min(
|
|
500
|
+
nextDelayMs,
|
|
501
|
+
signalPollDelayMs(item.raw, params.pollIntervalMs),
|
|
502
|
+
maxWaitMs - (Date.now() - startedAt)
|
|
503
|
+
);
|
|
504
|
+
nextPending.push({
|
|
505
|
+
...task,
|
|
506
|
+
request: { ...task.request, signal_run_id: signalRunId }
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
if (nextPending.length === 0) break;
|
|
510
|
+
await sleep2(Math.max(1, nextDelayMs));
|
|
511
|
+
pending = nextPending;
|
|
512
|
+
}
|
|
513
|
+
const succeeded = results.filter((item) => item.success).length;
|
|
514
|
+
return {
|
|
515
|
+
total: companies.length,
|
|
516
|
+
succeeded,
|
|
517
|
+
failed: companies.length - succeeded,
|
|
518
|
+
durationMs: Date.now() - startedAt,
|
|
519
|
+
results
|
|
520
|
+
};
|
|
538
521
|
}
|
|
539
522
|
async signalToCopy(params) {
|
|
540
|
-
const request =
|
|
541
|
-
company_domain: params.companyDomain,
|
|
542
|
-
person_name: params.personName,
|
|
543
|
-
title: params.title,
|
|
544
|
-
campaign_offer: params.campaignOffer,
|
|
545
|
-
research_prompt: params.researchPrompt,
|
|
546
|
-
signal_run_id: params.signalRunId,
|
|
547
|
-
skip_cache: params.skipCache,
|
|
548
|
-
enable_deep_search: params.enableDeepSearch
|
|
549
|
-
});
|
|
523
|
+
const request = signalToCopyRequestBody(params);
|
|
550
524
|
let data = await this.client.post("api/v1/signal-to-copy", request);
|
|
551
525
|
if (params.waitForResult !== false && data.run_id && isPendingSignalResponse(data)) {
|
|
552
526
|
const maxWaitMs = Math.max(1e3, params.maxWaitMs ?? 20 * 6e4);
|
|
@@ -563,30 +537,152 @@ var Signaliz = class {
|
|
|
563
537
|
throw new Error(`Signal Copy ${data.run_id} did not complete within ${maxWaitMs}ms`);
|
|
564
538
|
}
|
|
565
539
|
}
|
|
540
|
+
return normalizeSignalToCopyResult(data);
|
|
541
|
+
}
|
|
542
|
+
async createSignalCopyBatch(requests, options) {
|
|
543
|
+
validateBatchSize(requests);
|
|
544
|
+
const startedAt = Date.now();
|
|
545
|
+
const chunks = [];
|
|
546
|
+
for (let offset = 0; offset < requests.length; offset += 25) {
|
|
547
|
+
chunks.push({ offset, requests: requests.slice(offset, offset + 25) });
|
|
548
|
+
}
|
|
549
|
+
const { serverConcurrency, chunkConcurrency } = batchConcurrencyPlan(options);
|
|
550
|
+
const chunkBatch = await runBatch(
|
|
551
|
+
chunks,
|
|
552
|
+
(chunk) => this.runSignalCopyBatchChunk(chunk.requests, serverConcurrency),
|
|
553
|
+
{ concurrency: chunkConcurrency }
|
|
554
|
+
);
|
|
555
|
+
const results = new Array(requests.length);
|
|
556
|
+
for (const chunkResult of chunkBatch.results) {
|
|
557
|
+
const chunk = chunks[chunkResult.index];
|
|
558
|
+
if (!chunkResult.success || !chunkResult.data) {
|
|
559
|
+
for (let index = 0; index < chunk.requests.length; index += 1) {
|
|
560
|
+
results[chunk.offset + index] = {
|
|
561
|
+
index: chunk.offset + index,
|
|
562
|
+
success: false,
|
|
563
|
+
error: chunkResult.error || "Signal to Copy batch request failed"
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
continue;
|
|
567
|
+
}
|
|
568
|
+
for (const item of chunkResult.data) {
|
|
569
|
+
results[chunk.offset + item.index] = { ...item, index: chunk.offset + item.index };
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
const succeeded = results.filter((item) => item.success).length;
|
|
566
573
|
return {
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
subjectLine: data.subject_line ?? "",
|
|
573
|
-
openingLine: data.opening_line ?? "",
|
|
574
|
-
confidence: data.confidence ?? 0,
|
|
575
|
-
evidenceUrl: data.evidence_url ?? "",
|
|
576
|
-
researchPrompt: data.research_prompt,
|
|
577
|
-
variations: (data.variations ?? []).map((variation) => ({
|
|
578
|
-
style: variation.style,
|
|
579
|
-
subjectLine: variation.subject_line ?? "",
|
|
580
|
-
openingLine: variation.opening_line ?? "",
|
|
581
|
-
cta: variation.cta ?? "",
|
|
582
|
-
prediction: variation.prediction,
|
|
583
|
-
email: variation.email
|
|
584
|
-
})),
|
|
585
|
-
raw: data
|
|
574
|
+
total: requests.length,
|
|
575
|
+
succeeded,
|
|
576
|
+
failed: requests.length - succeeded,
|
|
577
|
+
durationMs: Date.now() - startedAt,
|
|
578
|
+
results
|
|
586
579
|
};
|
|
587
580
|
}
|
|
588
|
-
async
|
|
589
|
-
|
|
581
|
+
async runSignalCopyBatchChunk(requests, concurrency) {
|
|
582
|
+
const startedAt = Date.now();
|
|
583
|
+
const results = new Array(requests.length);
|
|
584
|
+
let pending = requests.map((params, index) => ({
|
|
585
|
+
index,
|
|
586
|
+
params,
|
|
587
|
+
request: signalToCopyRequestBody(params)
|
|
588
|
+
}));
|
|
589
|
+
while (pending.length > 0) {
|
|
590
|
+
const data = await this.client.post("api/v1/signal-to-copy", {
|
|
591
|
+
requests: pending.map((item) => item.request),
|
|
592
|
+
concurrency
|
|
593
|
+
});
|
|
594
|
+
if (!Array.isArray(data.results) || data.results.length !== pending.length) {
|
|
595
|
+
throw new Error("Signal to Copy batch returned an invalid result count");
|
|
596
|
+
}
|
|
597
|
+
const nextPending = [];
|
|
598
|
+
let nextDelayMs = 6e4;
|
|
599
|
+
for (let index = 0; index < pending.length; index += 1) {
|
|
600
|
+
const task = pending[index];
|
|
601
|
+
const item = data.results[index];
|
|
602
|
+
if (item.success === false) {
|
|
603
|
+
results[task.index] = { index: task.index, success: false, error: item.error || item.message || "Signal to Copy failed" };
|
|
604
|
+
continue;
|
|
605
|
+
}
|
|
606
|
+
if (!isPendingSignalResponse(item)) {
|
|
607
|
+
results[task.index] = { index: task.index, success: true, data: normalizeSignalToCopyResult(item) };
|
|
608
|
+
continue;
|
|
609
|
+
}
|
|
610
|
+
if (task.params.waitForResult === false) {
|
|
611
|
+
results[task.index] = { index: task.index, success: true, data: normalizeSignalToCopyResult(item) };
|
|
612
|
+
continue;
|
|
613
|
+
}
|
|
614
|
+
const maxWaitMs = Math.max(1e3, task.params.maxWaitMs ?? 20 * 6e4);
|
|
615
|
+
if (Date.now() - startedAt >= maxWaitMs) {
|
|
616
|
+
results[task.index] = {
|
|
617
|
+
index: task.index,
|
|
618
|
+
success: false,
|
|
619
|
+
error: `Signal Copy ${item.signal_run_id || item.run_id || ""} did not complete within ${maxWaitMs}ms`
|
|
620
|
+
};
|
|
621
|
+
continue;
|
|
622
|
+
}
|
|
623
|
+
const signalRunId = item.signal_run_id || item.run_id;
|
|
624
|
+
if (!signalRunId) {
|
|
625
|
+
results[task.index] = { index: task.index, success: false, error: "Signal Copy is processing without a signal_run_id" };
|
|
626
|
+
continue;
|
|
627
|
+
}
|
|
628
|
+
nextDelayMs = Math.min(
|
|
629
|
+
nextDelayMs,
|
|
630
|
+
signalPollDelayMs(item, task.params.pollIntervalMs),
|
|
631
|
+
maxWaitMs - (Date.now() - startedAt)
|
|
632
|
+
);
|
|
633
|
+
nextPending.push({
|
|
634
|
+
...task,
|
|
635
|
+
request: { ...task.request, signal_run_id: signalRunId }
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
pending = nextPending;
|
|
639
|
+
if (pending.length > 0) await sleep2(nextDelayMs);
|
|
640
|
+
}
|
|
641
|
+
return results;
|
|
642
|
+
}
|
|
643
|
+
async runCoreBatchRound(path2, tasks, options) {
|
|
644
|
+
const { serverConcurrency, chunkConcurrency } = batchConcurrencyPlan(options);
|
|
645
|
+
const chunks = [];
|
|
646
|
+
for (let offset = 0; offset < tasks.length; offset += 25) {
|
|
647
|
+
chunks.push({ offset, tasks: tasks.slice(offset, offset + 25) });
|
|
648
|
+
}
|
|
649
|
+
const chunkBatch = await runBatch(chunks, async (chunk) => {
|
|
650
|
+
const data = await this.client.post(path2, {
|
|
651
|
+
requests: chunk.tasks.map((task) => task.request),
|
|
652
|
+
concurrency: serverConcurrency
|
|
653
|
+
});
|
|
654
|
+
if (!Array.isArray(data.results) || data.results.length !== chunk.tasks.length) {
|
|
655
|
+
throw new Error(`${path2} batch returned an invalid result count`);
|
|
656
|
+
}
|
|
657
|
+
if (data.results.some((row, index) => row.index !== index)) {
|
|
658
|
+
throw new Error(`${path2} batch returned results out of order`);
|
|
659
|
+
}
|
|
660
|
+
return data.results;
|
|
661
|
+
}, { concurrency: chunkConcurrency });
|
|
662
|
+
const results = new Array(tasks.length);
|
|
663
|
+
for (const chunkResult of chunkBatch.results) {
|
|
664
|
+
const chunk = chunks[chunkResult.index];
|
|
665
|
+
if (!chunkResult.success || !chunkResult.data) {
|
|
666
|
+
for (let index = 0; index < chunk.tasks.length; index += 1) {
|
|
667
|
+
results[chunk.offset + index] = {
|
|
668
|
+
index: chunk.tasks[index].index,
|
|
669
|
+
success: false,
|
|
670
|
+
error: chunkResult.error || `${path2} batch request failed`
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
continue;
|
|
674
|
+
}
|
|
675
|
+
for (let index = 0; index < chunkResult.data.length; index += 1) {
|
|
676
|
+
const raw = chunkResult.data[index];
|
|
677
|
+
results[chunk.offset + index] = {
|
|
678
|
+
index: chunk.tasks[index].index,
|
|
679
|
+
success: raw.success !== false,
|
|
680
|
+
raw,
|
|
681
|
+
error: raw.success === false ? raw.error || raw.message || raw.error_code || `${path2} item failed` : void 0
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
return results;
|
|
590
686
|
}
|
|
591
687
|
async listTools() {
|
|
592
688
|
const result = await this.client.mcp("tools/list");
|
|
@@ -603,6 +699,207 @@ var Signaliz = class {
|
|
|
603
699
|
function compact(input) {
|
|
604
700
|
return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== void 0));
|
|
605
701
|
}
|
|
702
|
+
function findEmailRequestBody(params) {
|
|
703
|
+
return compact({
|
|
704
|
+
company_domain: params.companyDomain,
|
|
705
|
+
full_name: params.fullName,
|
|
706
|
+
first_name: params.firstName,
|
|
707
|
+
last_name: params.lastName,
|
|
708
|
+
linkedin_url: params.linkedinUrl,
|
|
709
|
+
company_name: params.companyName,
|
|
710
|
+
skip_cache: params.skipCache
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
function normalizeFindEmailResult(data) {
|
|
714
|
+
const email = typeof data.email === "string" && data.email.trim() ? data.email.trim() : null;
|
|
715
|
+
const found = Boolean(email) && data.found !== false;
|
|
716
|
+
const verificationStatus = data.verification_status ?? data.status ?? "unknown";
|
|
717
|
+
const rawFreshness = String(data.verification_freshness ?? "").toLowerCase();
|
|
718
|
+
const verificationFreshness = rawFreshness === "fresh" || rawFreshness === "stale" ? rawFreshness : "unknown";
|
|
719
|
+
const needsReverification = data.needs_reverification === true || verificationFreshness === "stale";
|
|
720
|
+
const explicitlyNotSendSafe = data.verified_for_sending === false || needsReverification;
|
|
721
|
+
const verified = !explicitlyNotSendSafe && (data.email_verified === true || data.verified_for_sending === true || ["valid", "deliverable"].includes(String(verificationStatus).toLowerCase()));
|
|
722
|
+
const verificationAgeDays = typeof data.verification_age_days === "number" && Number.isFinite(data.verification_age_days) ? data.verification_age_days : null;
|
|
723
|
+
return {
|
|
724
|
+
success: data.success !== false && found,
|
|
725
|
+
found,
|
|
726
|
+
email,
|
|
727
|
+
firstName: data.first_name,
|
|
728
|
+
lastName: data.last_name,
|
|
729
|
+
confidence: data.confidence ?? data.confidence_score ?? (verified ? 1 : 0),
|
|
730
|
+
verificationStatus,
|
|
731
|
+
isVerified: verified,
|
|
732
|
+
isVerifiedForSending: !needsReverification && data.verified_for_sending === true,
|
|
733
|
+
isCatchAll: data.email_is_catch_all === true || data.is_catch_all === true,
|
|
734
|
+
verificationFreshness,
|
|
735
|
+
verificationAgeDays,
|
|
736
|
+
verifiedAt: typeof data.verified_at === "string" ? data.verified_at : null,
|
|
737
|
+
needsReverification,
|
|
738
|
+
providerUsed: data.provider_used ?? data.provider ?? data.email_source ?? data.source ?? "unknown",
|
|
739
|
+
error: found ? void 0 : data.error ?? "No verified email found",
|
|
740
|
+
errorCode: found ? void 0 : data.error_code ?? "EMAIL_NOT_FOUND",
|
|
741
|
+
raw: data
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
function normalizeVerifyEmailResult(email, data) {
|
|
745
|
+
const verificationStatus = String(data.verification_status ?? "").toLowerCase();
|
|
746
|
+
const verified = data.email_verified === true || ["valid", "deliverable"].includes(verificationStatus);
|
|
747
|
+
return {
|
|
748
|
+
email: data.email ?? email,
|
|
749
|
+
isValid: data.is_valid ?? data.valid ?? verified,
|
|
750
|
+
isDeliverable: data.is_deliverable ?? data.deliverable ?? verified,
|
|
751
|
+
isCatchAll: data.email_is_catch_all ?? data.is_catch_all ?? data.catch_all ?? data.diagnostics?.is_catch_all ?? false,
|
|
752
|
+
confidenceScore: data.confidence_score ?? data.confidence ?? data.diagnostics?.confidence_score ?? (verified ? 1 : 0),
|
|
753
|
+
provider: data.provider,
|
|
754
|
+
verificationSource: data.verification_source,
|
|
755
|
+
raw: data
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
function companySignalRequestBody(params) {
|
|
759
|
+
const online = params.online ?? true;
|
|
760
|
+
return compact({
|
|
761
|
+
signal_run_id: params.signalRunId,
|
|
762
|
+
company_domain: params.companyDomain,
|
|
763
|
+
company_name: params.companyName,
|
|
764
|
+
research_prompt: params.researchPrompt,
|
|
765
|
+
signal_types: params.signalTypes,
|
|
766
|
+
target_signal_count: params.targetSignalCount,
|
|
767
|
+
lookback_days: params.lookbackDays,
|
|
768
|
+
online,
|
|
769
|
+
enable_deep_search: params.enableDeepSearch ?? online,
|
|
770
|
+
enable_outreach_intelligence: params.enableOutreachIntelligence,
|
|
771
|
+
enable_predictive_intelligence: params.enablePredictiveIntelligence,
|
|
772
|
+
skip_cache: params.skipCache,
|
|
773
|
+
// REST always returns a resumable run instead of holding the connection;
|
|
774
|
+
// waitForResult controls the SDK polling loop.
|
|
775
|
+
wait_for_result: false,
|
|
776
|
+
max_wait_ms: params.maxWaitMs
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
function normalizeCompanySignalResult(params, data) {
|
|
780
|
+
return {
|
|
781
|
+
success: data.success ?? true,
|
|
782
|
+
status: data.status,
|
|
783
|
+
signalRunId: data.signal_run_id ?? data.run_id,
|
|
784
|
+
company: {
|
|
785
|
+
name: data.company?.name ?? params.companyName ?? null,
|
|
786
|
+
domain: data.company?.domain ?? params.companyDomain ?? null
|
|
787
|
+
},
|
|
788
|
+
signals: (data.signals ?? []).map((signal) => {
|
|
789
|
+
const metadata = signal.metadata && typeof signal.metadata === "object" && !Array.isArray(signal.metadata) ? signal.metadata : void 0;
|
|
790
|
+
return {
|
|
791
|
+
id: signal.id,
|
|
792
|
+
title: signal.title ?? "",
|
|
793
|
+
type: signal.type ?? signal.signal_type ?? "unknown",
|
|
794
|
+
content: signal.content ?? signal.description ?? "",
|
|
795
|
+
date: signal.date ?? signal.detected_at ?? null,
|
|
796
|
+
datePrecision: signal.date_precision,
|
|
797
|
+
sourceUrl: signal.source_url ?? signal.url ?? null,
|
|
798
|
+
sourceType: signal.source_type,
|
|
799
|
+
sourceProvenance: signal.source_provenance,
|
|
800
|
+
confidence: signal.confidence ?? signal.confidence_score ?? null,
|
|
801
|
+
entityConfidence: signal.entity_confidence ?? metadata?.entity_confidence ?? null,
|
|
802
|
+
signalFamily: signal.signal_family,
|
|
803
|
+
eventType: signal.signal_event_type,
|
|
804
|
+
eventLabel: signal.signal_event_label,
|
|
805
|
+
classification: signal.signal_classification ?? null,
|
|
806
|
+
derived: signal.derived === true,
|
|
807
|
+
evidencePublishedDate: signal.evidence_published_date ?? metadata?.evidence_published_date ?? null,
|
|
808
|
+
signalFeedSource: signal.signal_feed_source ?? metadata?.signal_feed_source,
|
|
809
|
+
metadata
|
|
810
|
+
};
|
|
811
|
+
}),
|
|
812
|
+
signalCount: data.signal_count ?? data.total_signals ?? data.signals?.length ?? 0,
|
|
813
|
+
intelligence: data.intelligence ?? null,
|
|
814
|
+
credits: data.credits,
|
|
815
|
+
metadata: data.metadata,
|
|
816
|
+
raw: data
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
function validateBatchSize(items) {
|
|
820
|
+
if (!Array.isArray(items) || items.length === 0) {
|
|
821
|
+
throw new Error("Signaliz batch requests require at least one item");
|
|
822
|
+
}
|
|
823
|
+
if (items.length > 5e3) {
|
|
824
|
+
throw new Error(`Signaliz batch requests support at most 5,000 items; received ${items.length}`);
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
function validatedBatchConcurrency(options) {
|
|
828
|
+
const concurrency = options?.concurrency ?? 10;
|
|
829
|
+
if (!Number.isInteger(concurrency) || concurrency < 1 || concurrency > 50) {
|
|
830
|
+
throw new Error("Signaliz batch concurrency must be an integer between 1 and 50");
|
|
831
|
+
}
|
|
832
|
+
return concurrency;
|
|
833
|
+
}
|
|
834
|
+
function batchConcurrencyPlan(options) {
|
|
835
|
+
const concurrency = validatedBatchConcurrency(options);
|
|
836
|
+
const serverConcurrency = Math.min(10, concurrency);
|
|
837
|
+
return {
|
|
838
|
+
serverConcurrency,
|
|
839
|
+
chunkConcurrency: Math.max(1, Math.floor(concurrency / serverConcurrency))
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
function finalizeCoreBatch(total, startedAt, round, normalize) {
|
|
843
|
+
const results = new Array(total);
|
|
844
|
+
for (const item of round) {
|
|
845
|
+
if (!item.success || !item.raw) {
|
|
846
|
+
results[item.index] = { index: item.index, success: false, error: item.error || "Signaliz batch item failed" };
|
|
847
|
+
continue;
|
|
848
|
+
}
|
|
849
|
+
try {
|
|
850
|
+
results[item.index] = { index: item.index, success: true, data: normalize(item) };
|
|
851
|
+
} catch (error) {
|
|
852
|
+
results[item.index] = {
|
|
853
|
+
index: item.index,
|
|
854
|
+
success: false,
|
|
855
|
+
error: error instanceof Error ? error.message : String(error)
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
const succeeded = results.filter((item) => item.success).length;
|
|
860
|
+
return {
|
|
861
|
+
total,
|
|
862
|
+
succeeded,
|
|
863
|
+
failed: total - succeeded,
|
|
864
|
+
durationMs: Date.now() - startedAt,
|
|
865
|
+
results
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
function signalToCopyRequestBody(params) {
|
|
869
|
+
return compact({
|
|
870
|
+
company_domain: params.companyDomain,
|
|
871
|
+
person_name: params.personName,
|
|
872
|
+
title: params.title,
|
|
873
|
+
campaign_offer: params.campaignOffer,
|
|
874
|
+
research_prompt: params.researchPrompt,
|
|
875
|
+
signal_run_id: params.signalRunId,
|
|
876
|
+
skip_cache: params.skipCache,
|
|
877
|
+
enable_deep_search: params.enableDeepSearch
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
function normalizeSignalToCopyResult(data) {
|
|
881
|
+
return {
|
|
882
|
+
success: data.success ?? true,
|
|
883
|
+
status: data.status,
|
|
884
|
+
runId: data.signal_run_id ?? data.run_id,
|
|
885
|
+
strongestSignal: data.strongest_signal ?? "",
|
|
886
|
+
whyNow: data.why_now ?? "",
|
|
887
|
+
subjectLine: data.subject_line ?? "",
|
|
888
|
+
openingLine: data.opening_line ?? "",
|
|
889
|
+
confidence: data.confidence ?? 0,
|
|
890
|
+
evidenceUrl: data.evidence_url ?? "",
|
|
891
|
+
researchPrompt: data.research_prompt,
|
|
892
|
+
variations: (data.variations ?? []).map((variation) => ({
|
|
893
|
+
style: variation.style,
|
|
894
|
+
subjectLine: variation.subject_line ?? "",
|
|
895
|
+
openingLine: variation.opening_line ?? "",
|
|
896
|
+
cta: variation.cta ?? "",
|
|
897
|
+
prediction: variation.prediction,
|
|
898
|
+
email: variation.email
|
|
899
|
+
})),
|
|
900
|
+
raw: data
|
|
901
|
+
};
|
|
902
|
+
}
|
|
606
903
|
function isPendingSignalResponse(data) {
|
|
607
904
|
return ["triggered", "queued", "processing", "pending", "pending_version", "waiting_for_deploy"].includes(String(data.status || "").toLowerCase());
|
|
608
905
|
}
|
|
@@ -629,16 +926,8 @@ function sleep2(ms) {
|
|
|
629
926
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
630
927
|
}
|
|
631
928
|
async function runBatch(items, execute, options) {
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
}
|
|
635
|
-
if (items.length > 5e3) {
|
|
636
|
-
throw new Error(`Signaliz batch requests support at most 5,000 items; received ${items.length}`);
|
|
637
|
-
}
|
|
638
|
-
const concurrency = options?.concurrency ?? 10;
|
|
639
|
-
if (!Number.isInteger(concurrency) || concurrency < 1 || concurrency > 50) {
|
|
640
|
-
throw new Error("Signaliz batch concurrency must be an integer between 1 and 50");
|
|
641
|
-
}
|
|
929
|
+
validateBatchSize(items);
|
|
930
|
+
const concurrency = validatedBatchConcurrency(options);
|
|
642
931
|
const startedAt = Date.now();
|
|
643
932
|
const results = new Array(items.length);
|
|
644
933
|
let nextIndex = 0;
|
package/dist/mcp-config.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signaliz/sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.30",
|
|
4
4
|
"description": "Signaliz SDK for Find Email, Verify Email, Company Signal Enrichment, and Signal to Copy AI.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -8,14 +8,24 @@
|
|
|
8
8
|
"bin": {
|
|
9
9
|
"signaliz-mcp": "dist/mcp-config.js"
|
|
10
10
|
},
|
|
11
|
-
"files": [
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
12
15
|
"scripts": {
|
|
13
16
|
"generate-types": "tsx scripts/generate-types.ts",
|
|
14
17
|
"build": "npm run generate-types && tsup src/index.ts src/mcp-config.ts --format cjs,esm --dts --clean",
|
|
15
18
|
"test": "tsx tests/core-products.test.ts",
|
|
16
19
|
"prepublishOnly": "npm run build"
|
|
17
20
|
},
|
|
18
|
-
"keywords": [
|
|
21
|
+
"keywords": [
|
|
22
|
+
"signaliz",
|
|
23
|
+
"mcp",
|
|
24
|
+
"email-finder",
|
|
25
|
+
"email-verification",
|
|
26
|
+
"company-signals",
|
|
27
|
+
"signal-to-copy"
|
|
28
|
+
],
|
|
19
29
|
"license": "MIT",
|
|
20
30
|
"repository": {
|
|
21
31
|
"type": "git",
|