@signaliz/sdk 1.0.47 → 1.0.49
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 +15 -33
- package/dist/{chunk-KTWDTUCI.mjs → chunk-KA66GBVZ.mjs} +87 -224
- package/dist/index.d.mts +34 -4
- package/dist/index.d.ts +34 -4
- package/dist/index.js +87 -224
- package/dist/index.mjs +1 -1
- package/dist/mcp-config.js +87 -224
- package/dist/mcp-config.mjs +1 -1
- package/package.json +1 -1
package/dist/mcp-config.js
CHANGED
|
@@ -488,39 +488,16 @@ var Signaliz = class {
|
|
|
488
488
|
);
|
|
489
489
|
}
|
|
490
490
|
async enrichCompanySignals(params) {
|
|
491
|
+
validateCoreProductMaxWaitMs(params.maxWaitMs);
|
|
491
492
|
const request = companySignalRequestBody(params);
|
|
492
|
-
|
|
493
|
+
const data = await this.client.post("api/v1/company-signals", request);
|
|
493
494
|
if (isCoreProductDryRun(data)) return normalizeCoreProductDryRunResult(data);
|
|
494
|
-
|
|
495
|
-
const maxWaitMs = Math.max(1e3, params.maxWaitMs ?? 20 * 6e4);
|
|
496
|
-
const startedAt = Date.now();
|
|
497
|
-
while (Date.now() - startedAt < maxWaitMs) {
|
|
498
|
-
if (!await waitForNextSignalPoll(data, params.pollIntervalMs, startedAt, maxWaitMs)) break;
|
|
499
|
-
const status = await this.client.post("api/v1/company-signals", {
|
|
500
|
-
...request,
|
|
501
|
-
signal_run_id: data.run_id
|
|
502
|
-
});
|
|
503
|
-
if (isCompletedSignalRun(status)) {
|
|
504
|
-
data = status.output ?? status.result ?? status.data ?? status;
|
|
505
|
-
break;
|
|
506
|
-
}
|
|
507
|
-
if (isFailedSignalRun(status)) {
|
|
508
|
-
throw new Error(`Company signal enrichment ${data.run_id} failed with status ${status.status || "unknown"}`);
|
|
509
|
-
}
|
|
510
|
-
if (!isPendingSignalResponse(status)) {
|
|
511
|
-
data = status.output ?? status.result ?? status.data ?? status;
|
|
512
|
-
break;
|
|
513
|
-
}
|
|
514
|
-
data = status;
|
|
515
|
-
}
|
|
516
|
-
if (isPendingSignalResponse(data)) {
|
|
517
|
-
throw new Error(`Company signal enrichment ${data.run_id} did not complete within ${maxWaitMs}ms`);
|
|
518
|
-
}
|
|
519
|
-
}
|
|
495
|
+
assertTerminalSignalResponse(data, "Company Signals");
|
|
520
496
|
return normalizeCompanySignalResult(params, data);
|
|
521
497
|
}
|
|
522
498
|
async enrichCompanies(companies, options) {
|
|
523
499
|
validateBatchSize(companies);
|
|
500
|
+
companies.forEach((params) => validateCoreProductMaxWaitMs(params.maxWaitMs));
|
|
524
501
|
if (options?.dryRun === true) {
|
|
525
502
|
return this.runCoreProductDryRun(
|
|
526
503
|
"api/v1/company-signals",
|
|
@@ -529,68 +506,22 @@ var Signaliz = class {
|
|
|
529
506
|
);
|
|
530
507
|
}
|
|
531
508
|
const startedAt = Date.now();
|
|
532
|
-
const results = new Array(companies.length);
|
|
533
509
|
const initialTasks = companies.map((params, index) => ({
|
|
534
510
|
index,
|
|
535
511
|
request: companySignalRequestBody(params)
|
|
536
512
|
}));
|
|
537
|
-
const
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
const round = await this.runCoreBatchRound(
|
|
542
|
-
"api/v1/company-signals",
|
|
543
|
-
pending,
|
|
544
|
-
options,
|
|
545
|
-
firstRound ? recoverableBatch : void 0
|
|
546
|
-
);
|
|
547
|
-
firstRound = false;
|
|
548
|
-
const taskByIndex = new Map(pending.map((task) => [task.index, task]));
|
|
549
|
-
const nextPending = [];
|
|
550
|
-
let nextDelayMs = 6e4;
|
|
551
|
-
for (const item of round) {
|
|
552
|
-
const params = companies[item.index];
|
|
553
|
-
const task = taskByIndex.get(item.index);
|
|
554
|
-
if (!item.success || !item.raw) {
|
|
555
|
-
results[item.index] = batchItemFailure(
|
|
556
|
-
item.index,
|
|
557
|
-
item.error || "Company Signal batch request failed",
|
|
558
|
-
item.raw ?? item
|
|
559
|
-
);
|
|
560
|
-
continue;
|
|
561
|
-
}
|
|
562
|
-
if (!isPendingSignalResponse(item.raw) || params.waitForResult === false) {
|
|
563
|
-
results[item.index] = { index: item.index, success: true, data: normalizeCompanySignalResult(params, item.raw) };
|
|
564
|
-
continue;
|
|
565
|
-
}
|
|
566
|
-
const maxWaitMs = Math.max(1e3, params.maxWaitMs ?? 20 * 6e4);
|
|
567
|
-
if (Date.now() - startedAt >= maxWaitMs) {
|
|
568
|
-
results[item.index] = {
|
|
569
|
-
index: item.index,
|
|
570
|
-
success: false,
|
|
571
|
-
error: `Company signal enrichment ${item.raw.signal_run_id || item.raw.run_id || ""} did not complete within ${maxWaitMs}ms`
|
|
572
|
-
};
|
|
573
|
-
continue;
|
|
574
|
-
}
|
|
575
|
-
const signalRunId = item.raw.signal_run_id || item.raw.run_id;
|
|
576
|
-
if (!signalRunId) {
|
|
577
|
-
results[item.index] = { index: item.index, success: false, error: "Company signal enrichment is processing without a signal_run_id" };
|
|
578
|
-
continue;
|
|
579
|
-
}
|
|
580
|
-
nextDelayMs = Math.min(
|
|
581
|
-
nextDelayMs,
|
|
582
|
-
signalPollDelayMs(item.raw, params.pollIntervalMs),
|
|
583
|
-
maxWaitMs - (Date.now() - startedAt)
|
|
584
|
-
);
|
|
585
|
-
nextPending.push({
|
|
586
|
-
...task,
|
|
587
|
-
request: { ...task.request, signal_run_id: signalRunId }
|
|
588
|
-
});
|
|
513
|
+
const round = await this.runCoreBatchRound("api/v1/company-signals", initialTasks, options);
|
|
514
|
+
const results = round.map((item) => {
|
|
515
|
+
if (!item.success || !item.raw) {
|
|
516
|
+
return batchItemFailure(item.index, item.error || "Company Signal batch request failed", item.raw ?? item);
|
|
589
517
|
}
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
518
|
+
try {
|
|
519
|
+
assertTerminalSignalResponse(item.raw, "Company Signals");
|
|
520
|
+
return { index: item.index, success: true, data: normalizeCompanySignalResult(companies[item.index], item.raw) };
|
|
521
|
+
} catch (error) {
|
|
522
|
+
return batchItemFailure(item.index, error instanceof Error ? error.message : String(error), item.raw);
|
|
523
|
+
}
|
|
524
|
+
});
|
|
594
525
|
const compactedResults = compactExactDuplicateResults(results, options?.compactDuplicates === true);
|
|
595
526
|
const succeeded = compactedResults.filter((item) => item.success).length;
|
|
596
527
|
return {
|
|
@@ -604,21 +535,9 @@ var Signaliz = class {
|
|
|
604
535
|
async signalToCopy(params) {
|
|
605
536
|
validateSignalToCopyParams(params);
|
|
606
537
|
const request = signalToCopyRequestBody(params);
|
|
607
|
-
|
|
538
|
+
const data = await this.client.post("api/v1/signal-to-copy", request);
|
|
608
539
|
if (isCoreProductDryRun(data)) return normalizeCoreProductDryRunResult(data);
|
|
609
|
-
|
|
610
|
-
const maxWaitMs = Math.max(1e3, params.maxWaitMs ?? 20 * 6e4);
|
|
611
|
-
const startedAt = Date.now();
|
|
612
|
-
while (Date.now() - startedAt < maxWaitMs) {
|
|
613
|
-
if (!await waitForNextSignalPoll(data, params.pollIntervalMs, startedAt, maxWaitMs)) break;
|
|
614
|
-
const signalRunId = data.signal_run_id || data.run_id;
|
|
615
|
-
data = await this.client.post("api/v1/signal-to-copy", data.resume_context_persisted === true ? { signal_run_id: signalRunId } : { ...request, signal_run_id: signalRunId });
|
|
616
|
-
if (!isPendingSignalResponse(data)) break;
|
|
617
|
-
}
|
|
618
|
-
if (isPendingSignalResponse(data)) {
|
|
619
|
-
throw new Error(`Signal Copy ${data.run_id} did not complete within ${maxWaitMs}ms`);
|
|
620
|
-
}
|
|
621
|
-
}
|
|
540
|
+
assertTerminalSignalResponse(data, "Signal to Copy");
|
|
622
541
|
return normalizeSignalToCopyResult(data);
|
|
623
542
|
}
|
|
624
543
|
async createSignalCopyBatch(requests, options) {
|
|
@@ -633,16 +552,10 @@ var Signaliz = class {
|
|
|
633
552
|
}
|
|
634
553
|
const startedAt = Date.now();
|
|
635
554
|
const deduplicated = dedupeExactBatchItems(requests, (params) => JSON.stringify({
|
|
636
|
-
request: signalToCopyRequestBody(params)
|
|
637
|
-
wait_for_result: params.waitForResult,
|
|
638
|
-
max_wait_ms: params.maxWaitMs,
|
|
639
|
-
poll_interval_ms: params.pollIntervalMs
|
|
555
|
+
request: signalToCopyRequestBody(params)
|
|
640
556
|
}));
|
|
641
557
|
const uniqueRequests = deduplicated.uniqueItems;
|
|
642
|
-
const
|
|
643
|
-
(params) => (!params.signalRunId || !params.signalRunId.startsWith("copy_") && [params.companyDomain, params.personName, params.title, params.campaignOffer].every((value) => typeof value === "string" && Boolean(value.trim()))) && params.waitForResult !== false && params.skipCache !== true && params.enableDeepSearch !== true && params.maxWaitMs === void 0 && params.pollIntervalMs === void 0
|
|
644
|
-
);
|
|
645
|
-
const uniqueResults = canUseRecoverableAvailableDataJob ? await this.runAvailableSignalCopyBatchJob(uniqueRequests, options) : await this.runSignalCopyBatchChunks(uniqueRequests, options);
|
|
558
|
+
const uniqueResults = await this.runSignalCopyBatchChunks(uniqueRequests, options);
|
|
646
559
|
const results = requests.map((_, index) => ({
|
|
647
560
|
...uniqueResults[deduplicated.sourceIndexByInput[index]],
|
|
648
561
|
index
|
|
@@ -698,22 +611,6 @@ var Signaliz = class {
|
|
|
698
611
|
}
|
|
699
612
|
return uniqueResults;
|
|
700
613
|
}
|
|
701
|
-
async runAvailableSignalCopyBatchJob(requests, options) {
|
|
702
|
-
const rows = await this.runRecoverableCoreBatchJob(
|
|
703
|
-
"api/v1/signal-to-copy",
|
|
704
|
-
requests.map(signalToCopyRequestBody),
|
|
705
|
-
"Signal to Copy",
|
|
706
|
-
500,
|
|
707
|
-
20 * 6e4,
|
|
708
|
-
options?.idempotencyKey
|
|
709
|
-
);
|
|
710
|
-
const results = new Array(requests.length);
|
|
711
|
-
for (const row of rows) {
|
|
712
|
-
const index = Number(row.index);
|
|
713
|
-
results[index] = recoverableJobRowFailed(row) ? batchItemFailure(index, row.error || row.message || "Signal to Copy failed", row) : { index, success: true, data: normalizeSignalToCopyResult(row) };
|
|
714
|
-
}
|
|
715
|
-
return results;
|
|
716
|
-
}
|
|
717
614
|
async runRecoverableCoreBatchJob(path2, requests, label, pageSize = 500, maxWaitMs = 20 * 6e4, idempotencyKey) {
|
|
718
615
|
const startedAt = Date.now();
|
|
719
616
|
const submissionIdempotencyKey = idempotencyKey?.trim() || newBatchIdempotencyKey(label);
|
|
@@ -785,77 +682,35 @@ var Signaliz = class {
|
|
|
785
682
|
return rows;
|
|
786
683
|
}
|
|
787
684
|
async runSignalCopyBatchChunk(requests, concurrency, rowRateLimitAttempt = 0) {
|
|
788
|
-
const startedAt = Date.now();
|
|
789
685
|
const results = new Array(requests.length);
|
|
790
686
|
const rateLimited = [];
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
const task = pending[index];
|
|
808
|
-
const item = data.results[index];
|
|
809
|
-
if (item.success === false) {
|
|
810
|
-
if (rowRateLimitAttempt < MAX_ROW_RATE_LIMIT_RETRIES && isRetryableRowRateLimit({
|
|
811
|
-
index: task.index,
|
|
812
|
-
success: false,
|
|
813
|
-
raw: item
|
|
814
|
-
})) {
|
|
815
|
-
rateLimited.push({ index: task.index, params: task.params, raw: item });
|
|
816
|
-
continue;
|
|
817
|
-
}
|
|
818
|
-
results[task.index] = batchItemFailure(
|
|
819
|
-
task.index,
|
|
820
|
-
item.error || item.message || "Signal to Copy failed",
|
|
821
|
-
item
|
|
822
|
-
);
|
|
823
|
-
continue;
|
|
824
|
-
}
|
|
825
|
-
if (!isPendingSignalResponse(item)) {
|
|
826
|
-
results[task.index] = { index: task.index, success: true, data: normalizeSignalToCopyResult(item) };
|
|
827
|
-
continue;
|
|
828
|
-
}
|
|
829
|
-
if (task.params.waitForResult === false) {
|
|
830
|
-
results[task.index] = { index: task.index, success: true, data: normalizeSignalToCopyResult(item) };
|
|
831
|
-
continue;
|
|
832
|
-
}
|
|
833
|
-
const maxWaitMs = Math.max(1e3, task.params.maxWaitMs ?? 20 * 6e4);
|
|
834
|
-
if (Date.now() - startedAt >= maxWaitMs) {
|
|
835
|
-
results[task.index] = {
|
|
836
|
-
index: task.index,
|
|
837
|
-
success: false,
|
|
838
|
-
error: `Signal Copy ${item.signal_run_id || item.run_id || ""} did not complete within ${maxWaitMs}ms`
|
|
839
|
-
};
|
|
840
|
-
continue;
|
|
841
|
-
}
|
|
842
|
-
const signalRunId = item.signal_run_id || item.run_id;
|
|
843
|
-
if (!signalRunId) {
|
|
844
|
-
results[task.index] = { index: task.index, success: false, error: "Signal Copy is processing without a signal_run_id" };
|
|
687
|
+
const data = await this.client.post("api/v1/signal-to-copy", {
|
|
688
|
+
requests: requests.map(signalToCopyRequestBody),
|
|
689
|
+
concurrency
|
|
690
|
+
});
|
|
691
|
+
if (!Array.isArray(data.results) || data.results.length !== requests.length) {
|
|
692
|
+
throw new Error("Signal to Copy batch returned an invalid result count");
|
|
693
|
+
}
|
|
694
|
+
for (let index = 0; index < requests.length; index += 1) {
|
|
695
|
+
const item = data.results[index];
|
|
696
|
+
if (item.success === false) {
|
|
697
|
+
if (rowRateLimitAttempt < MAX_ROW_RATE_LIMIT_RETRIES && isRetryableRowRateLimit({
|
|
698
|
+
index,
|
|
699
|
+
success: false,
|
|
700
|
+
raw: item
|
|
701
|
+
})) {
|
|
702
|
+
rateLimited.push({ index, params: requests[index], raw: item });
|
|
845
703
|
continue;
|
|
846
704
|
}
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
);
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
});
|
|
705
|
+
results[index] = batchItemFailure(index, item.error || item.message || "Signal to Copy failed", item);
|
|
706
|
+
continue;
|
|
707
|
+
}
|
|
708
|
+
try {
|
|
709
|
+
assertTerminalSignalResponse(item, "Signal to Copy");
|
|
710
|
+
results[index] = { index, success: true, data: normalizeSignalToCopyResult(item) };
|
|
711
|
+
} catch (error) {
|
|
712
|
+
results[index] = batchItemFailure(index, error instanceof Error ? error.message : String(error), item);
|
|
856
713
|
}
|
|
857
|
-
pending = nextPending;
|
|
858
|
-
if (pending.length > 0) await sleep2(nextDelayMs);
|
|
859
714
|
}
|
|
860
715
|
if (rateLimited.length > 0) {
|
|
861
716
|
await sleep2(rowRateLimitDelayMs(rateLimited.map((item) => ({
|
|
@@ -874,12 +729,12 @@ var Signaliz = class {
|
|
|
874
729
|
}
|
|
875
730
|
return results;
|
|
876
731
|
}
|
|
877
|
-
async runCoreBatchRound(path2, tasks, options,
|
|
732
|
+
async runCoreBatchRound(path2, tasks, options, rowRateLimitAttempt = 0) {
|
|
878
733
|
const { serverConcurrency, chunkConcurrency } = batchConcurrencyPlan(options);
|
|
879
734
|
const deduplicated = dedupeExactBatchItems(tasks, (task) => JSON.stringify(task.request));
|
|
880
735
|
const uniqueTasks = deduplicated.uniqueItems;
|
|
881
|
-
const recoverableBatch = path2 === "api/v1/find-email" ? { label: "Find Email", pageSize: 500, maxWaitMs: 20 * 6e4 } : path2 === "api/v1/verify-email" ? { label: "Verify Email", pageSize: 500, maxWaitMs: 20 * 6e4 } :
|
|
882
|
-
if (recoverableBatch && uniqueTasks.length > 25) {
|
|
736
|
+
const recoverableBatch = path2 === "api/v1/find-email" ? { label: "Find Email", pageSize: 500, maxWaitMs: 20 * 6e4 } : path2 === "api/v1/verify-email" ? { label: "Verify Email", pageSize: 500, maxWaitMs: 20 * 6e4 } : void 0;
|
|
737
|
+
if (path2 !== "api/v1/company-signals" && recoverableBatch && uniqueTasks.length > 25) {
|
|
883
738
|
const rows = await this.runRecoverableCoreBatchJob(
|
|
884
739
|
path2,
|
|
885
740
|
uniqueTasks.map((task) => task.request),
|
|
@@ -951,7 +806,6 @@ var Signaliz = class {
|
|
|
951
806
|
path2,
|
|
952
807
|
retryTasks,
|
|
953
808
|
options,
|
|
954
|
-
void 0,
|
|
955
809
|
rowRateLimitAttempt + 1
|
|
956
810
|
);
|
|
957
811
|
const retriedByIndex = new Map(retried.map((item) => [item.index, item]));
|
|
@@ -1080,6 +934,15 @@ function normalizeFindEmailResult(data) {
|
|
|
1080
934
|
verifiedAt: typeof data.verified_at === "string" ? data.verified_at : null,
|
|
1081
935
|
needsReverification,
|
|
1082
936
|
providerUsed: data.provider_used ?? data.provider ?? data.email_source ?? data.source ?? "unknown",
|
|
937
|
+
creditsUsed: data.credits_used,
|
|
938
|
+
estimatedExternalCostUsd: data.estimated_external_cost_usd,
|
|
939
|
+
billingMetadata: data.billing_metadata,
|
|
940
|
+
resultReturnedFrom: data.result_returned_from,
|
|
941
|
+
cacheHit: data.cache_hit,
|
|
942
|
+
freshEnrichmentUsed: data.fresh_enrichment_used,
|
|
943
|
+
liveProviderCalled: data.live_provider_called,
|
|
944
|
+
openrouterCalled: data.openrouter_called,
|
|
945
|
+
byoOpenrouterUsed: data.byo_openrouter_used,
|
|
1083
946
|
error: found ? void 0 : data.error ?? "No verified email found",
|
|
1084
947
|
errorCode: found ? void 0 : data.error_code ?? "EMAIL_NOT_FOUND",
|
|
1085
948
|
raw: data
|
|
@@ -1089,6 +952,7 @@ function normalizeVerifyEmailResult(email, data) {
|
|
|
1089
952
|
const verificationStatus = String(data.verification_status ?? "").toLowerCase();
|
|
1090
953
|
const verified = data.email_verified === true || ["valid", "deliverable"].includes(verificationStatus);
|
|
1091
954
|
return {
|
|
955
|
+
success: data.success !== false,
|
|
1092
956
|
email: data.email ?? email,
|
|
1093
957
|
status: String(data.status || "").toLowerCase() === "processing" ? "processing" : "completed",
|
|
1094
958
|
verificationRunId: data.verification_run_id ?? data.run_id,
|
|
@@ -1097,9 +961,20 @@ function normalizeVerifyEmailResult(email, data) {
|
|
|
1097
961
|
isValid: data.is_valid ?? data.valid ?? verified,
|
|
1098
962
|
isDeliverable: data.is_deliverable ?? data.deliverable ?? verified,
|
|
1099
963
|
isCatchAll: data.email_is_catch_all ?? data.is_catch_all ?? data.catch_all ?? data.diagnostics?.is_catch_all ?? false,
|
|
964
|
+
verifiedForSending: data.verified_for_sending === true,
|
|
965
|
+
verificationVerdict: data.verification_verdict ?? data.verification_status ?? "unknown",
|
|
1100
966
|
confidenceScore: data.confidence_score ?? data.confidence ?? data.diagnostics?.confidence_score ?? (verified ? 1 : 0),
|
|
1101
967
|
provider: data.provider,
|
|
1102
968
|
verificationSource: data.verification_source,
|
|
969
|
+
billingReplayed: data.billing_replayed,
|
|
970
|
+
creditsUsed: data.credits_used,
|
|
971
|
+
billingMetadata: data.billing_metadata,
|
|
972
|
+
resultReturnedFrom: data.result_returned_from,
|
|
973
|
+
cacheHit: data.cache_hit,
|
|
974
|
+
freshEnrichmentUsed: data.fresh_enrichment_used,
|
|
975
|
+
liveProviderCalled: data.live_provider_called,
|
|
976
|
+
openrouterCalled: data.openrouter_called,
|
|
977
|
+
byoOpenrouterUsed: data.byo_openrouter_used,
|
|
1103
978
|
raw: data
|
|
1104
979
|
};
|
|
1105
980
|
}
|
|
@@ -1115,41 +990,17 @@ function companySignalRequestBody(params) {
|
|
|
1115
990
|
lookback_days: params.lookbackDays,
|
|
1116
991
|
online,
|
|
1117
992
|
enable_deep_search: params.enableDeepSearch ?? online,
|
|
993
|
+
search_mode: params.searchMode ?? "balanced",
|
|
1118
994
|
include_summary: params.includeSummary,
|
|
1119
995
|
enable_outreach_intelligence: params.enableOutreachIntelligence,
|
|
1120
996
|
enable_predictive_intelligence: params.enablePredictiveIntelligence,
|
|
1121
997
|
skip_cache: params.skipCache,
|
|
1122
|
-
|
|
1123
|
-
// waitForResult controls the SDK polling loop.
|
|
1124
|
-
wait_for_result: false,
|
|
998
|
+
wait_for_result: true,
|
|
1125
999
|
max_wait_ms: params.maxWaitMs,
|
|
1126
1000
|
dry_run: params.dryRun,
|
|
1127
1001
|
idempotency_key: params.idempotencyKey
|
|
1128
1002
|
});
|
|
1129
1003
|
}
|
|
1130
|
-
function companySignalRecoverableBatchOptions(companies, tasks) {
|
|
1131
|
-
if (companies.length <= 25 || companies.some((params) => params.waitForResult === false || Boolean(params.signalRunId))) {
|
|
1132
|
-
return void 0;
|
|
1133
|
-
}
|
|
1134
|
-
const maxWaitMs = Math.max(1e3, companies[0].maxWaitMs ?? 20 * 6e4);
|
|
1135
|
-
if (companies.some((params) => Math.max(1e3, params.maxWaitMs ?? 20 * 6e4) !== maxWaitMs)) {
|
|
1136
|
-
return void 0;
|
|
1137
|
-
}
|
|
1138
|
-
const configKey = (request) => {
|
|
1139
|
-
const {
|
|
1140
|
-
company_domain: _companyDomain,
|
|
1141
|
-
company_name: _companyName,
|
|
1142
|
-
signal_run_id: _signalRunId,
|
|
1143
|
-
wait_for_result: _waitForResult,
|
|
1144
|
-
max_wait_ms: _maxWaitMs,
|
|
1145
|
-
...config
|
|
1146
|
-
} = request;
|
|
1147
|
-
return JSON.stringify(config);
|
|
1148
|
-
};
|
|
1149
|
-
const sharedConfig = configKey(tasks[0].request);
|
|
1150
|
-
if (tasks.some((task) => configKey(task.request) !== sharedConfig)) return void 0;
|
|
1151
|
-
return { label: "Company Signals", pageSize: 25, maxWaitMs };
|
|
1152
|
-
}
|
|
1153
1004
|
function normalizeCompanySignalResult(params, data) {
|
|
1154
1005
|
const rawSignals = data.signals ?? data.signal_feed ?? [];
|
|
1155
1006
|
return {
|
|
@@ -1167,8 +1018,10 @@ function normalizeCompanySignalResult(params, data) {
|
|
|
1167
1018
|
title: signal.title ?? "",
|
|
1168
1019
|
type: signal.type ?? signal.signal_type ?? "unknown",
|
|
1169
1020
|
content: signal.content ?? signal.description ?? "",
|
|
1170
|
-
date: signal.date ??
|
|
1021
|
+
date: signal.date ?? null,
|
|
1022
|
+
detectedAt: signal.detected_at ?? null,
|
|
1171
1023
|
datePrecision: signal.date_precision,
|
|
1024
|
+
hasSpecificDate: signal.has_specific_date ?? metadata?.has_specific_date,
|
|
1172
1025
|
sourceUrl: signal.source_url ?? signal.url ?? null,
|
|
1173
1026
|
sourceType: signal.source_type,
|
|
1174
1027
|
sourceProvenance: signal.source_provenance,
|
|
@@ -1197,7 +1050,10 @@ function normalizeCompanySignalResult(params, data) {
|
|
|
1197
1050
|
billingMetadata: data.billing_metadata,
|
|
1198
1051
|
resultReturnedFrom: data.result_returned_from,
|
|
1199
1052
|
cacheHit: data.cache_hit,
|
|
1053
|
+
freshEnrichmentUsed: data.fresh_enrichment_used,
|
|
1200
1054
|
liveProviderCalled: data.live_provider_called,
|
|
1055
|
+
aiProviderCalled: data.ai_provider_called,
|
|
1056
|
+
byoAiUsed: data.byo_ai_used,
|
|
1201
1057
|
metadata: data.metadata,
|
|
1202
1058
|
raw: data
|
|
1203
1059
|
};
|
|
@@ -1297,11 +1153,13 @@ function signalToCopyRequestBody(params) {
|
|
|
1297
1153
|
signal_run_id: params.signalRunId,
|
|
1298
1154
|
skip_cache: params.skipCache,
|
|
1299
1155
|
enable_deep_search: params.enableDeepSearch,
|
|
1156
|
+
max_wait_ms: params.maxWaitMs,
|
|
1300
1157
|
dry_run: params.dryRun,
|
|
1301
1158
|
idempotency_key: params.idempotencyKey
|
|
1302
1159
|
});
|
|
1303
1160
|
}
|
|
1304
1161
|
function validateSignalToCopyParams(params) {
|
|
1162
|
+
validateCoreProductMaxWaitMs(params.maxWaitMs);
|
|
1305
1163
|
if (typeof params.signalRunId === "string" && params.signalRunId.trim()) return;
|
|
1306
1164
|
const missing = [
|
|
1307
1165
|
["companyDomain", params.companyDomain],
|
|
@@ -1313,6 +1171,12 @@ function validateSignalToCopyParams(params) {
|
|
|
1313
1171
|
throw new TypeError(`Signal to Copy requires signalRunId or: ${missing.join(", ")}`);
|
|
1314
1172
|
}
|
|
1315
1173
|
}
|
|
1174
|
+
function validateCoreProductMaxWaitMs(value) {
|
|
1175
|
+
if (value === void 0) return;
|
|
1176
|
+
if (!Number.isInteger(value) || value < 1e4 || value > 12e4) {
|
|
1177
|
+
throw new RangeError("maxWaitMs must be an integer between 10000 and 120000");
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1316
1180
|
function normalizeSignalToCopyResult(data) {
|
|
1317
1181
|
return {
|
|
1318
1182
|
success: data.success ?? true,
|
|
@@ -1343,11 +1207,10 @@ function normalizeSignalToCopyResult(data) {
|
|
|
1343
1207
|
function isPendingSignalResponse(data) {
|
|
1344
1208
|
return ["triggered", "queued", "processing", "pending", "pending_version", "waiting_for_deploy"].includes(String(data.status || "").toLowerCase());
|
|
1345
1209
|
}
|
|
1346
|
-
function
|
|
1347
|
-
|
|
1348
|
-
}
|
|
1349
|
-
|
|
1350
|
-
return ["failed", "error", "cancelled", "canceled", "crashed", "timed_out"].includes(String(data.status || "").toLowerCase());
|
|
1210
|
+
function assertTerminalSignalResponse(data, capability) {
|
|
1211
|
+
if (isPendingSignalResponse(data) || data.job_id) {
|
|
1212
|
+
throw new Error(`${capability} violated the synchronous response contract.`);
|
|
1213
|
+
}
|
|
1351
1214
|
}
|
|
1352
1215
|
function signalPollDelayMs(data, override) {
|
|
1353
1216
|
if (override !== void 0) return Math.max(250, override);
|
package/dist/mcp-config.mjs
CHANGED
package/package.json
CHANGED