@signaliz/sdk 1.0.46 → 1.0.48
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 +24 -33
- package/dist/{chunk-4LXMT3S5.mjs → chunk-NOOQDYOJ.mjs} +129 -228
- package/dist/index.d.mts +67 -4
- package/dist/index.d.ts +67 -4
- package/dist/index.js +129 -228
- package/dist/index.mjs +1 -1
- package/dist/mcp-config.js +129 -228
- package/dist/mcp-config.mjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -405,10 +405,17 @@ var Signaliz = class {
|
|
|
405
405
|
}
|
|
406
406
|
async findEmail(params) {
|
|
407
407
|
const data = await this.client.post("api/v1/find-email", findEmailRequestBody(params));
|
|
408
|
-
return normalizeFindEmailResult(data);
|
|
408
|
+
return isCoreProductDryRun(data) ? normalizeCoreProductDryRunResult(data) : normalizeFindEmailResult(data);
|
|
409
409
|
}
|
|
410
410
|
async findEmails(params, options) {
|
|
411
411
|
validateBatchSize(params);
|
|
412
|
+
if (options?.dryRun === true) {
|
|
413
|
+
return this.runCoreProductDryRun(
|
|
414
|
+
"api/v1/find-email",
|
|
415
|
+
params.map(findEmailRequestBody),
|
|
416
|
+
options.idempotencyKey
|
|
417
|
+
);
|
|
418
|
+
}
|
|
412
419
|
const startedAt = Date.now();
|
|
413
420
|
const round = await this.runCoreBatchRound(
|
|
414
421
|
"api/v1/find-email",
|
|
@@ -427,9 +434,12 @@ var Signaliz = class {
|
|
|
427
434
|
const request = compact({
|
|
428
435
|
email: email || void 0,
|
|
429
436
|
verification_run_id: options?.verificationRunId,
|
|
430
|
-
skip_cache: options?.skipCache
|
|
437
|
+
skip_cache: options?.skipCache,
|
|
438
|
+
dry_run: options?.dryRun,
|
|
439
|
+
idempotency_key: options?.idempotencyKey
|
|
431
440
|
});
|
|
432
441
|
let data = await this.client.post("api/v1/verify-email", request);
|
|
442
|
+
if (isCoreProductDryRun(data)) return normalizeCoreProductDryRunResult(data);
|
|
433
443
|
if (options?.waitForResult !== false && isPendingSignalResponse(data) && data.verification_run_id) {
|
|
434
444
|
const maxWaitMs = Math.max(1e3, options?.maxWaitMs ?? 10 * 6e4);
|
|
435
445
|
const startedAt = Date.now();
|
|
@@ -449,6 +459,13 @@ var Signaliz = class {
|
|
|
449
459
|
}
|
|
450
460
|
async verifyEmails(emails, options) {
|
|
451
461
|
validateBatchSize(emails);
|
|
462
|
+
if (options?.dryRun === true) {
|
|
463
|
+
return this.runCoreProductDryRun(
|
|
464
|
+
"api/v1/verify-email",
|
|
465
|
+
emails.map((email) => ({ email, skip_cache: options.skipCache })),
|
|
466
|
+
options.idempotencyKey
|
|
467
|
+
);
|
|
468
|
+
}
|
|
452
469
|
const startedAt = Date.now();
|
|
453
470
|
const round = await this.runCoreBatchRound(
|
|
454
471
|
"api/v1/verify-email",
|
|
@@ -468,100 +485,37 @@ var Signaliz = class {
|
|
|
468
485
|
}
|
|
469
486
|
async enrichCompanySignals(params) {
|
|
470
487
|
const request = companySignalRequestBody(params);
|
|
471
|
-
|
|
472
|
-
if (
|
|
473
|
-
|
|
474
|
-
const startedAt = Date.now();
|
|
475
|
-
while (Date.now() - startedAt < maxWaitMs) {
|
|
476
|
-
if (!await waitForNextSignalPoll(data, params.pollIntervalMs, startedAt, maxWaitMs)) break;
|
|
477
|
-
const status = await this.client.post("api/v1/company-signals", {
|
|
478
|
-
...request,
|
|
479
|
-
signal_run_id: data.run_id
|
|
480
|
-
});
|
|
481
|
-
if (isCompletedSignalRun(status)) {
|
|
482
|
-
data = status.output ?? status.result ?? status.data ?? status;
|
|
483
|
-
break;
|
|
484
|
-
}
|
|
485
|
-
if (isFailedSignalRun(status)) {
|
|
486
|
-
throw new Error(`Company signal enrichment ${data.run_id} failed with status ${status.status || "unknown"}`);
|
|
487
|
-
}
|
|
488
|
-
if (!isPendingSignalResponse(status)) {
|
|
489
|
-
data = status.output ?? status.result ?? status.data ?? status;
|
|
490
|
-
break;
|
|
491
|
-
}
|
|
492
|
-
data = status;
|
|
493
|
-
}
|
|
494
|
-
if (isPendingSignalResponse(data)) {
|
|
495
|
-
throw new Error(`Company signal enrichment ${data.run_id} did not complete within ${maxWaitMs}ms`);
|
|
496
|
-
}
|
|
497
|
-
}
|
|
488
|
+
const data = await this.client.post("api/v1/company-signals", request);
|
|
489
|
+
if (isCoreProductDryRun(data)) return normalizeCoreProductDryRunResult(data);
|
|
490
|
+
assertTerminalSignalResponse(data, "Company Signals");
|
|
498
491
|
return normalizeCompanySignalResult(params, data);
|
|
499
492
|
}
|
|
500
493
|
async enrichCompanies(companies, options) {
|
|
501
494
|
validateBatchSize(companies);
|
|
495
|
+
if (options?.dryRun === true) {
|
|
496
|
+
return this.runCoreProductDryRun(
|
|
497
|
+
"api/v1/company-signals",
|
|
498
|
+
companies.map(companySignalRequestBody),
|
|
499
|
+
options.idempotencyKey
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
502
|
const startedAt = Date.now();
|
|
503
|
-
const results = new Array(companies.length);
|
|
504
503
|
const initialTasks = companies.map((params, index) => ({
|
|
505
504
|
index,
|
|
506
505
|
request: companySignalRequestBody(params)
|
|
507
506
|
}));
|
|
508
|
-
const
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
const round = await this.runCoreBatchRound(
|
|
513
|
-
"api/v1/company-signals",
|
|
514
|
-
pending,
|
|
515
|
-
options,
|
|
516
|
-
firstRound ? recoverableBatch : void 0
|
|
517
|
-
);
|
|
518
|
-
firstRound = false;
|
|
519
|
-
const taskByIndex = new Map(pending.map((task) => [task.index, task]));
|
|
520
|
-
const nextPending = [];
|
|
521
|
-
let nextDelayMs = 6e4;
|
|
522
|
-
for (const item of round) {
|
|
523
|
-
const params = companies[item.index];
|
|
524
|
-
const task = taskByIndex.get(item.index);
|
|
525
|
-
if (!item.success || !item.raw) {
|
|
526
|
-
results[item.index] = batchItemFailure(
|
|
527
|
-
item.index,
|
|
528
|
-
item.error || "Company Signal batch request failed",
|
|
529
|
-
item.raw ?? item
|
|
530
|
-
);
|
|
531
|
-
continue;
|
|
532
|
-
}
|
|
533
|
-
if (!isPendingSignalResponse(item.raw) || params.waitForResult === false) {
|
|
534
|
-
results[item.index] = { index: item.index, success: true, data: normalizeCompanySignalResult(params, item.raw) };
|
|
535
|
-
continue;
|
|
536
|
-
}
|
|
537
|
-
const maxWaitMs = Math.max(1e3, params.maxWaitMs ?? 20 * 6e4);
|
|
538
|
-
if (Date.now() - startedAt >= maxWaitMs) {
|
|
539
|
-
results[item.index] = {
|
|
540
|
-
index: item.index,
|
|
541
|
-
success: false,
|
|
542
|
-
error: `Company signal enrichment ${item.raw.signal_run_id || item.raw.run_id || ""} did not complete within ${maxWaitMs}ms`
|
|
543
|
-
};
|
|
544
|
-
continue;
|
|
545
|
-
}
|
|
546
|
-
const signalRunId = item.raw.signal_run_id || item.raw.run_id;
|
|
547
|
-
if (!signalRunId) {
|
|
548
|
-
results[item.index] = { index: item.index, success: false, error: "Company signal enrichment is processing without a signal_run_id" };
|
|
549
|
-
continue;
|
|
550
|
-
}
|
|
551
|
-
nextDelayMs = Math.min(
|
|
552
|
-
nextDelayMs,
|
|
553
|
-
signalPollDelayMs(item.raw, params.pollIntervalMs),
|
|
554
|
-
maxWaitMs - (Date.now() - startedAt)
|
|
555
|
-
);
|
|
556
|
-
nextPending.push({
|
|
557
|
-
...task,
|
|
558
|
-
request: { ...task.request, signal_run_id: signalRunId }
|
|
559
|
-
});
|
|
507
|
+
const round = await this.runCoreBatchRound("api/v1/company-signals", initialTasks, options);
|
|
508
|
+
const results = round.map((item) => {
|
|
509
|
+
if (!item.success || !item.raw) {
|
|
510
|
+
return batchItemFailure(item.index, item.error || "Company Signal batch request failed", item.raw ?? item);
|
|
560
511
|
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
512
|
+
try {
|
|
513
|
+
assertTerminalSignalResponse(item.raw, "Company Signals");
|
|
514
|
+
return { index: item.index, success: true, data: normalizeCompanySignalResult(companies[item.index], item.raw) };
|
|
515
|
+
} catch (error) {
|
|
516
|
+
return batchItemFailure(item.index, error instanceof Error ? error.message : String(error), item.raw);
|
|
517
|
+
}
|
|
518
|
+
});
|
|
565
519
|
const compactedResults = compactExactDuplicateResults(results, options?.compactDuplicates === true);
|
|
566
520
|
const succeeded = compactedResults.filter((item) => item.success).length;
|
|
567
521
|
return {
|
|
@@ -575,37 +529,27 @@ var Signaliz = class {
|
|
|
575
529
|
async signalToCopy(params) {
|
|
576
530
|
validateSignalToCopyParams(params);
|
|
577
531
|
const request = signalToCopyRequestBody(params);
|
|
578
|
-
|
|
579
|
-
if (
|
|
580
|
-
|
|
581
|
-
const startedAt = Date.now();
|
|
582
|
-
while (Date.now() - startedAt < maxWaitMs) {
|
|
583
|
-
if (!await waitForNextSignalPoll(data, params.pollIntervalMs, startedAt, maxWaitMs)) break;
|
|
584
|
-
const signalRunId = data.signal_run_id || data.run_id;
|
|
585
|
-
data = await this.client.post("api/v1/signal-to-copy", data.resume_context_persisted === true ? { signal_run_id: signalRunId } : { ...request, signal_run_id: signalRunId });
|
|
586
|
-
if (!isPendingSignalResponse(data)) break;
|
|
587
|
-
}
|
|
588
|
-
if (isPendingSignalResponse(data)) {
|
|
589
|
-
throw new Error(`Signal Copy ${data.run_id} did not complete within ${maxWaitMs}ms`);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
532
|
+
const data = await this.client.post("api/v1/signal-to-copy", request);
|
|
533
|
+
if (isCoreProductDryRun(data)) return normalizeCoreProductDryRunResult(data);
|
|
534
|
+
assertTerminalSignalResponse(data, "Signal to Copy");
|
|
592
535
|
return normalizeSignalToCopyResult(data);
|
|
593
536
|
}
|
|
594
537
|
async createSignalCopyBatch(requests, options) {
|
|
595
538
|
validateBatchSize(requests);
|
|
596
539
|
requests.forEach(validateSignalToCopyParams);
|
|
540
|
+
if (options?.dryRun === true) {
|
|
541
|
+
return this.runCoreProductDryRun(
|
|
542
|
+
"api/v1/signal-to-copy",
|
|
543
|
+
requests.map(signalToCopyRequestBody),
|
|
544
|
+
options.idempotencyKey
|
|
545
|
+
);
|
|
546
|
+
}
|
|
597
547
|
const startedAt = Date.now();
|
|
598
548
|
const deduplicated = dedupeExactBatchItems(requests, (params) => JSON.stringify({
|
|
599
|
-
request: signalToCopyRequestBody(params)
|
|
600
|
-
wait_for_result: params.waitForResult,
|
|
601
|
-
max_wait_ms: params.maxWaitMs,
|
|
602
|
-
poll_interval_ms: params.pollIntervalMs
|
|
549
|
+
request: signalToCopyRequestBody(params)
|
|
603
550
|
}));
|
|
604
551
|
const uniqueRequests = deduplicated.uniqueItems;
|
|
605
|
-
const
|
|
606
|
-
(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
|
|
607
|
-
);
|
|
608
|
-
const uniqueResults = canUseRecoverableAvailableDataJob ? await this.runAvailableSignalCopyBatchJob(uniqueRequests, options) : await this.runSignalCopyBatchChunks(uniqueRequests, options);
|
|
552
|
+
const uniqueResults = await this.runSignalCopyBatchChunks(uniqueRequests, options);
|
|
609
553
|
const results = requests.map((_, index) => ({
|
|
610
554
|
...uniqueResults[deduplicated.sourceIndexByInput[index]],
|
|
611
555
|
index
|
|
@@ -620,6 +564,17 @@ var Signaliz = class {
|
|
|
620
564
|
results: compactedResults
|
|
621
565
|
};
|
|
622
566
|
}
|
|
567
|
+
async runCoreProductDryRun(path, requests, idempotencyKey) {
|
|
568
|
+
const data = await this.client.post(path, compact({
|
|
569
|
+
requests,
|
|
570
|
+
dry_run: true,
|
|
571
|
+
idempotency_key: idempotencyKey
|
|
572
|
+
}));
|
|
573
|
+
if (!isCoreProductDryRun(data)) {
|
|
574
|
+
throw new Error(`${path} dry run returned a live-result contract`);
|
|
575
|
+
}
|
|
576
|
+
return normalizeCoreProductDryRunResult(data);
|
|
577
|
+
}
|
|
623
578
|
async runSignalCopyBatchChunks(uniqueRequests, options) {
|
|
624
579
|
const chunks = [];
|
|
625
580
|
for (let offset = 0; offset < uniqueRequests.length; offset += 25) {
|
|
@@ -650,22 +605,6 @@ var Signaliz = class {
|
|
|
650
605
|
}
|
|
651
606
|
return uniqueResults;
|
|
652
607
|
}
|
|
653
|
-
async runAvailableSignalCopyBatchJob(requests, options) {
|
|
654
|
-
const rows = await this.runRecoverableCoreBatchJob(
|
|
655
|
-
"api/v1/signal-to-copy",
|
|
656
|
-
requests.map(signalToCopyRequestBody),
|
|
657
|
-
"Signal to Copy",
|
|
658
|
-
500,
|
|
659
|
-
20 * 6e4,
|
|
660
|
-
options?.idempotencyKey
|
|
661
|
-
);
|
|
662
|
-
const results = new Array(requests.length);
|
|
663
|
-
for (const row of rows) {
|
|
664
|
-
const index = Number(row.index);
|
|
665
|
-
results[index] = recoverableJobRowFailed(row) ? batchItemFailure(index, row.error || row.message || "Signal to Copy failed", row) : { index, success: true, data: normalizeSignalToCopyResult(row) };
|
|
666
|
-
}
|
|
667
|
-
return results;
|
|
668
|
-
}
|
|
669
608
|
async runRecoverableCoreBatchJob(path, requests, label, pageSize = 500, maxWaitMs = 20 * 6e4, idempotencyKey) {
|
|
670
609
|
const startedAt = Date.now();
|
|
671
610
|
const submissionIdempotencyKey = idempotencyKey?.trim() || newBatchIdempotencyKey(label);
|
|
@@ -737,77 +676,35 @@ var Signaliz = class {
|
|
|
737
676
|
return rows;
|
|
738
677
|
}
|
|
739
678
|
async runSignalCopyBatchChunk(requests, concurrency, rowRateLimitAttempt = 0) {
|
|
740
|
-
const startedAt = Date.now();
|
|
741
679
|
const results = new Array(requests.length);
|
|
742
680
|
const rateLimited = [];
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
const task = pending[index];
|
|
760
|
-
const item = data.results[index];
|
|
761
|
-
if (item.success === false) {
|
|
762
|
-
if (rowRateLimitAttempt < MAX_ROW_RATE_LIMIT_RETRIES && isRetryableRowRateLimit({
|
|
763
|
-
index: task.index,
|
|
764
|
-
success: false,
|
|
765
|
-
raw: item
|
|
766
|
-
})) {
|
|
767
|
-
rateLimited.push({ index: task.index, params: task.params, raw: item });
|
|
768
|
-
continue;
|
|
769
|
-
}
|
|
770
|
-
results[task.index] = batchItemFailure(
|
|
771
|
-
task.index,
|
|
772
|
-
item.error || item.message || "Signal to Copy failed",
|
|
773
|
-
item
|
|
774
|
-
);
|
|
775
|
-
continue;
|
|
776
|
-
}
|
|
777
|
-
if (!isPendingSignalResponse(item)) {
|
|
778
|
-
results[task.index] = { index: task.index, success: true, data: normalizeSignalToCopyResult(item) };
|
|
779
|
-
continue;
|
|
780
|
-
}
|
|
781
|
-
if (task.params.waitForResult === false) {
|
|
782
|
-
results[task.index] = { index: task.index, success: true, data: normalizeSignalToCopyResult(item) };
|
|
783
|
-
continue;
|
|
784
|
-
}
|
|
785
|
-
const maxWaitMs = Math.max(1e3, task.params.maxWaitMs ?? 20 * 6e4);
|
|
786
|
-
if (Date.now() - startedAt >= maxWaitMs) {
|
|
787
|
-
results[task.index] = {
|
|
788
|
-
index: task.index,
|
|
789
|
-
success: false,
|
|
790
|
-
error: `Signal Copy ${item.signal_run_id || item.run_id || ""} did not complete within ${maxWaitMs}ms`
|
|
791
|
-
};
|
|
792
|
-
continue;
|
|
793
|
-
}
|
|
794
|
-
const signalRunId = item.signal_run_id || item.run_id;
|
|
795
|
-
if (!signalRunId) {
|
|
796
|
-
results[task.index] = { index: task.index, success: false, error: "Signal Copy is processing without a signal_run_id" };
|
|
681
|
+
const data = await this.client.post("api/v1/signal-to-copy", {
|
|
682
|
+
requests: requests.map(signalToCopyRequestBody),
|
|
683
|
+
concurrency
|
|
684
|
+
});
|
|
685
|
+
if (!Array.isArray(data.results) || data.results.length !== requests.length) {
|
|
686
|
+
throw new Error("Signal to Copy batch returned an invalid result count");
|
|
687
|
+
}
|
|
688
|
+
for (let index = 0; index < requests.length; index += 1) {
|
|
689
|
+
const item = data.results[index];
|
|
690
|
+
if (item.success === false) {
|
|
691
|
+
if (rowRateLimitAttempt < MAX_ROW_RATE_LIMIT_RETRIES && isRetryableRowRateLimit({
|
|
692
|
+
index,
|
|
693
|
+
success: false,
|
|
694
|
+
raw: item
|
|
695
|
+
})) {
|
|
696
|
+
rateLimited.push({ index, params: requests[index], raw: item });
|
|
797
697
|
continue;
|
|
798
698
|
}
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
);
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
});
|
|
699
|
+
results[index] = batchItemFailure(index, item.error || item.message || "Signal to Copy failed", item);
|
|
700
|
+
continue;
|
|
701
|
+
}
|
|
702
|
+
try {
|
|
703
|
+
assertTerminalSignalResponse(item, "Signal to Copy");
|
|
704
|
+
results[index] = { index, success: true, data: normalizeSignalToCopyResult(item) };
|
|
705
|
+
} catch (error) {
|
|
706
|
+
results[index] = batchItemFailure(index, error instanceof Error ? error.message : String(error), item);
|
|
808
707
|
}
|
|
809
|
-
pending = nextPending;
|
|
810
|
-
if (pending.length > 0) await sleep2(nextDelayMs);
|
|
811
708
|
}
|
|
812
709
|
if (rateLimited.length > 0) {
|
|
813
710
|
await sleep2(rowRateLimitDelayMs(rateLimited.map((item) => ({
|
|
@@ -826,12 +723,12 @@ var Signaliz = class {
|
|
|
826
723
|
}
|
|
827
724
|
return results;
|
|
828
725
|
}
|
|
829
|
-
async runCoreBatchRound(path, tasks, options,
|
|
726
|
+
async runCoreBatchRound(path, tasks, options, rowRateLimitAttempt = 0) {
|
|
830
727
|
const { serverConcurrency, chunkConcurrency } = batchConcurrencyPlan(options);
|
|
831
728
|
const deduplicated = dedupeExactBatchItems(tasks, (task) => JSON.stringify(task.request));
|
|
832
729
|
const uniqueTasks = deduplicated.uniqueItems;
|
|
833
|
-
const recoverableBatch = path === "api/v1/find-email" ? { label: "Find Email", pageSize: 500, maxWaitMs: 20 * 6e4 } : path === "api/v1/verify-email" ? { label: "Verify Email", pageSize: 500, maxWaitMs: 20 * 6e4 } :
|
|
834
|
-
if (recoverableBatch && uniqueTasks.length > 25) {
|
|
730
|
+
const recoverableBatch = path === "api/v1/find-email" ? { label: "Find Email", pageSize: 500, maxWaitMs: 20 * 6e4 } : path === "api/v1/verify-email" ? { label: "Verify Email", pageSize: 500, maxWaitMs: 20 * 6e4 } : void 0;
|
|
731
|
+
if (path !== "api/v1/company-signals" && recoverableBatch && uniqueTasks.length > 25) {
|
|
835
732
|
const rows = await this.runRecoverableCoreBatchJob(
|
|
836
733
|
path,
|
|
837
734
|
uniqueTasks.map((task) => task.request),
|
|
@@ -903,7 +800,6 @@ var Signaliz = class {
|
|
|
903
800
|
path,
|
|
904
801
|
retryTasks,
|
|
905
802
|
options,
|
|
906
|
-
void 0,
|
|
907
803
|
rowRateLimitAttempt + 1
|
|
908
804
|
);
|
|
909
805
|
const retriedByIndex = new Map(retried.map((item) => [item.index, item]));
|
|
@@ -978,9 +874,34 @@ function findEmailRequestBody(params) {
|
|
|
978
874
|
last_name: params.lastName,
|
|
979
875
|
linkedin_url: params.linkedinUrl,
|
|
980
876
|
company_name: params.companyName,
|
|
981
|
-
skip_cache: params.skipCache
|
|
877
|
+
skip_cache: params.skipCache,
|
|
878
|
+
dry_run: params.dryRun,
|
|
879
|
+
idempotency_key: params.idempotencyKey
|
|
982
880
|
});
|
|
983
881
|
}
|
|
882
|
+
function isCoreProductDryRun(data) {
|
|
883
|
+
return data.dry_run === true && data.status === "planned";
|
|
884
|
+
}
|
|
885
|
+
function normalizeCoreProductDryRunResult(data) {
|
|
886
|
+
const estimatedCredits = data.estimated_credits && typeof data.estimated_credits === "object" ? data.estimated_credits : { min: 0, max: 0 };
|
|
887
|
+
return {
|
|
888
|
+
success: true,
|
|
889
|
+
dryRun: true,
|
|
890
|
+
status: "planned",
|
|
891
|
+
capability: String(data.capability || ""),
|
|
892
|
+
inputCount: Number(data.input_count || 0),
|
|
893
|
+
recoveryReadCount: Number(data.recovery_read_count || 0),
|
|
894
|
+
plan: data.plan && typeof data.plan === "object" ? data.plan : {},
|
|
895
|
+
estimate: data.estimate && typeof data.estimate === "object" ? data.estimate : {},
|
|
896
|
+
estimatedCredits: {
|
|
897
|
+
min: Number(estimatedCredits.min || 0),
|
|
898
|
+
max: Number(estimatedCredits.max || 0)
|
|
899
|
+
},
|
|
900
|
+
creditsCharged: 0,
|
|
901
|
+
sideEffects: Array.isArray(data.side_effects) ? data.side_effects : [],
|
|
902
|
+
raw: data
|
|
903
|
+
};
|
|
904
|
+
}
|
|
984
905
|
function normalizeFindEmailResult(data) {
|
|
985
906
|
const email = typeof data.email === "string" && data.email.trim() ? data.email.trim() : null;
|
|
986
907
|
const found = Boolean(email) && data.found !== false;
|
|
@@ -1042,39 +963,17 @@ function companySignalRequestBody(params) {
|
|
|
1042
963
|
lookback_days: params.lookbackDays,
|
|
1043
964
|
online,
|
|
1044
965
|
enable_deep_search: params.enableDeepSearch ?? online,
|
|
966
|
+
search_mode: params.searchMode ?? "balanced",
|
|
1045
967
|
include_summary: params.includeSummary,
|
|
1046
968
|
enable_outreach_intelligence: params.enableOutreachIntelligence,
|
|
1047
969
|
enable_predictive_intelligence: params.enablePredictiveIntelligence,
|
|
1048
970
|
skip_cache: params.skipCache,
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
971
|
+
wait_for_result: true,
|
|
972
|
+
max_wait_ms: params.maxWaitMs,
|
|
973
|
+
dry_run: params.dryRun,
|
|
974
|
+
idempotency_key: params.idempotencyKey
|
|
1053
975
|
});
|
|
1054
976
|
}
|
|
1055
|
-
function companySignalRecoverableBatchOptions(companies, tasks) {
|
|
1056
|
-
if (companies.length <= 25 || companies.some((params) => params.waitForResult === false || Boolean(params.signalRunId))) {
|
|
1057
|
-
return void 0;
|
|
1058
|
-
}
|
|
1059
|
-
const maxWaitMs = Math.max(1e3, companies[0].maxWaitMs ?? 20 * 6e4);
|
|
1060
|
-
if (companies.some((params) => Math.max(1e3, params.maxWaitMs ?? 20 * 6e4) !== maxWaitMs)) {
|
|
1061
|
-
return void 0;
|
|
1062
|
-
}
|
|
1063
|
-
const configKey = (request) => {
|
|
1064
|
-
const {
|
|
1065
|
-
company_domain: _companyDomain,
|
|
1066
|
-
company_name: _companyName,
|
|
1067
|
-
signal_run_id: _signalRunId,
|
|
1068
|
-
wait_for_result: _waitForResult,
|
|
1069
|
-
max_wait_ms: _maxWaitMs,
|
|
1070
|
-
...config
|
|
1071
|
-
} = request;
|
|
1072
|
-
return JSON.stringify(config);
|
|
1073
|
-
};
|
|
1074
|
-
const sharedConfig = configKey(tasks[0].request);
|
|
1075
|
-
if (tasks.some((task) => configKey(task.request) !== sharedConfig)) return void 0;
|
|
1076
|
-
return { label: "Company Signals", pageSize: 25, maxWaitMs };
|
|
1077
|
-
}
|
|
1078
977
|
function normalizeCompanySignalResult(params, data) {
|
|
1079
978
|
const rawSignals = data.signals ?? data.signal_feed ?? [];
|
|
1080
979
|
return {
|
|
@@ -1221,7 +1120,10 @@ function signalToCopyRequestBody(params) {
|
|
|
1221
1120
|
research_prompt: params.researchPrompt,
|
|
1222
1121
|
signal_run_id: params.signalRunId,
|
|
1223
1122
|
skip_cache: params.skipCache,
|
|
1224
|
-
enable_deep_search: params.enableDeepSearch
|
|
1123
|
+
enable_deep_search: params.enableDeepSearch,
|
|
1124
|
+
max_wait_ms: params.maxWaitMs,
|
|
1125
|
+
dry_run: params.dryRun,
|
|
1126
|
+
idempotency_key: params.idempotencyKey
|
|
1225
1127
|
});
|
|
1226
1128
|
}
|
|
1227
1129
|
function validateSignalToCopyParams(params) {
|
|
@@ -1266,11 +1168,10 @@ function normalizeSignalToCopyResult(data) {
|
|
|
1266
1168
|
function isPendingSignalResponse(data) {
|
|
1267
1169
|
return ["triggered", "queued", "processing", "pending", "pending_version", "waiting_for_deploy"].includes(String(data.status || "").toLowerCase());
|
|
1268
1170
|
}
|
|
1269
|
-
function
|
|
1270
|
-
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
return ["failed", "error", "cancelled", "canceled", "crashed", "timed_out"].includes(String(data.status || "").toLowerCase());
|
|
1171
|
+
function assertTerminalSignalResponse(data, capability) {
|
|
1172
|
+
if (isPendingSignalResponse(data) || data.job_id) {
|
|
1173
|
+
throw new Error(`${capability} violated the synchronous response contract.`);
|
|
1174
|
+
}
|
|
1274
1175
|
}
|
|
1275
1176
|
function signalPollDelayMs(data, override) {
|
|
1276
1177
|
if (override !== void 0) return Math.max(250, override);
|