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