@signaliz/sdk 1.0.52 → 1.0.54
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 +30 -6
- package/dist/{chunk-IFHOCPIP.mjs → chunk-W4JH6JJA.mjs} +160 -64
- package/dist/index.d.mts +83 -21
- package/dist/index.d.ts +83 -21
- package/dist/index.js +160 -64
- package/dist/index.mjs +1 -1
- package/dist/mcp-config.js +160 -64
- package/dist/mcp-config.mjs +1 -1
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -169,6 +169,8 @@ interface CompanySignalEnrichmentParams {
|
|
|
169
169
|
enableOutreachIntelligence?: boolean;
|
|
170
170
|
enablePredictiveIntelligence?: boolean;
|
|
171
171
|
skipCache?: boolean;
|
|
172
|
+
/** Include all evaluated evidence candidates, including rejected diagnostics. Defaults to selected-signal evidence only. */
|
|
173
|
+
includeCandidateEvidence?: boolean;
|
|
172
174
|
/** @deprecated Company Signals is always synchronous; this option is ignored. */
|
|
173
175
|
waitForResult?: boolean;
|
|
174
176
|
/** Maximum server-side synchronous execution window. */
|
|
@@ -188,20 +190,13 @@ interface CompanySignal {
|
|
|
188
190
|
date?: string | null;
|
|
189
191
|
detectedAt?: string | null;
|
|
190
192
|
datePrecision?: string;
|
|
191
|
-
hasSpecificDate?: boolean;
|
|
192
193
|
sourceUrl?: string | null;
|
|
193
194
|
sourceType?: string;
|
|
194
|
-
sourceProvenance?: string;
|
|
195
195
|
confidence?: number | null;
|
|
196
|
-
entityConfidence?: number | null;
|
|
197
196
|
signalFamily?: string;
|
|
198
197
|
eventType?: string;
|
|
199
198
|
eventLabel?: string;
|
|
200
199
|
classification?: Record<string, unknown> | string | null;
|
|
201
|
-
derived?: boolean;
|
|
202
|
-
evidencePublishedDate?: string | null;
|
|
203
|
-
signalFeedSource?: string;
|
|
204
|
-
metadata?: Record<string, unknown>;
|
|
205
200
|
}
|
|
206
201
|
interface CompanySignalEnrichmentResult {
|
|
207
202
|
success: boolean;
|
|
@@ -214,22 +209,89 @@ interface CompanySignalEnrichmentResult {
|
|
|
214
209
|
signals: CompanySignal[];
|
|
215
210
|
signalCount: number;
|
|
216
211
|
signalSummary: string | null;
|
|
217
|
-
signalSummarySource?: string;
|
|
218
212
|
intelligence?: Record<string, unknown> | null;
|
|
219
213
|
copyFuel?: Record<string, unknown> | null;
|
|
220
214
|
evidenceValidation?: Record<string, unknown>;
|
|
221
215
|
evidenceSources?: Record<string, unknown>[];
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
216
|
+
evidenceCount?: number;
|
|
217
|
+
evidenceCountTotal?: number;
|
|
218
|
+
evidenceSourcesOmitted?: number;
|
|
219
|
+
evidenceScope?: 'selected_signals' | 'all_candidates';
|
|
220
|
+
raw: Record<string, unknown>;
|
|
221
|
+
}
|
|
222
|
+
type SignalDiscoverySource = 'web' | 'news';
|
|
223
|
+
type SignalDiscoveryStatus = 'planned' | 'queued' | 'processing' | 'completed' | 'completed_with_warnings' | 'failed';
|
|
224
|
+
interface SignalDiscoveryParams {
|
|
225
|
+
/** Natural-language description of the signals to find. Required for a new search. */
|
|
226
|
+
query?: string;
|
|
227
|
+
/** Number of qualified company signals requested. Defaults to 100; allowed range is 1-1,000. */
|
|
228
|
+
limit?: number;
|
|
229
|
+
/** Restrict discovery to selected source families. */
|
|
230
|
+
sources?: SignalDiscoverySource[];
|
|
231
|
+
/** Maximum signal age in days. Allowed range is 1-365. */
|
|
232
|
+
lookbackDays?: number;
|
|
233
|
+
/** Resume an existing asynchronous discovery run without starting another search. */
|
|
234
|
+
signalSearchRunId?: string;
|
|
235
|
+
/** Stable retry key for recovering the same search after an ambiguous response. */
|
|
236
|
+
idempotencyKey?: string;
|
|
237
|
+
/** Return a no-dispatch plan without provider calls or jobs. */
|
|
238
|
+
dryRun?: boolean;
|
|
239
|
+
}
|
|
240
|
+
interface SignalDiscoverySignal {
|
|
241
|
+
id?: string;
|
|
242
|
+
company: {
|
|
243
|
+
/** Every returned discovery signal is attributed to a distinct company. */
|
|
244
|
+
name: string;
|
|
245
|
+
domain: string;
|
|
246
|
+
linkedinUrl?: string | null;
|
|
247
|
+
};
|
|
248
|
+
title: string;
|
|
249
|
+
type: string;
|
|
250
|
+
summary: string;
|
|
251
|
+
eventDate?: string | null;
|
|
252
|
+
evidence: Array<{
|
|
253
|
+
url: string;
|
|
254
|
+
publishedAt: string;
|
|
255
|
+
source: string;
|
|
256
|
+
}>;
|
|
257
|
+
/** Compatibility alias for summary. */
|
|
258
|
+
content: string;
|
|
259
|
+
/** Compatibility alias for eventDate. */
|
|
260
|
+
date?: string | null;
|
|
261
|
+
detectedAt?: string | null;
|
|
262
|
+
sourceUrl?: string | null;
|
|
263
|
+
sourceType?: string | null;
|
|
264
|
+
confidence?: number | null;
|
|
265
|
+
classification?: Record<string, unknown> | string | null;
|
|
266
|
+
raw: Record<string, unknown>;
|
|
267
|
+
}
|
|
268
|
+
interface SignalDiscoveryCostGuardrail {
|
|
269
|
+
/** Strict ceiling: a qualified company signal must cost less than this amount to return. */
|
|
270
|
+
maxCostPerQualifiedSignalUsd: number;
|
|
271
|
+
projectedSourceCostUsd?: number | null;
|
|
272
|
+
maxSourceCostUsd?: number | null;
|
|
273
|
+
projectedCostPerRequestedCompanySignalUsd?: number | null;
|
|
274
|
+
sourceCostUsd?: number | null;
|
|
275
|
+
costSource?: 'observed' | 'catalog_bounded' | 'mixed' | 'unavailable';
|
|
276
|
+
qualifiedCompanySignalCount?: number;
|
|
277
|
+
returnedCompanySignalCount?: number;
|
|
278
|
+
costPerQualifiedSignalUsd?: number | null;
|
|
279
|
+
withinLimit: boolean;
|
|
280
|
+
}
|
|
281
|
+
interface SignalDiscoveryResult {
|
|
282
|
+
success: boolean;
|
|
283
|
+
status: SignalDiscoveryStatus;
|
|
284
|
+
capability: 'signals_everything';
|
|
285
|
+
signalSearchRunId: string;
|
|
286
|
+
query: string;
|
|
287
|
+
requestedCount: number;
|
|
288
|
+
nextPollAfterSeconds?: number;
|
|
289
|
+
signals: SignalDiscoverySignal[];
|
|
290
|
+
signalCount: number;
|
|
291
|
+
sourceLanes?: string[];
|
|
292
|
+
evidenceValidation?: Record<string, unknown>;
|
|
293
|
+
costGuardrail?: SignalDiscoveryCostGuardrail;
|
|
294
|
+
warnings?: string[];
|
|
233
295
|
raw: Record<string, unknown>;
|
|
234
296
|
}
|
|
235
297
|
interface SignalToCopyParams {
|
|
@@ -323,6 +385,7 @@ declare class Signaliz {
|
|
|
323
385
|
dryRun: true;
|
|
324
386
|
}): Promise<CoreProductDryRunResult>;
|
|
325
387
|
enrichCompanySignals(params: CompanySignalEnrichmentParams): Promise<CompanySignalEnrichmentResult>;
|
|
388
|
+
discoverSignals(params: SignalDiscoveryParams): Promise<SignalDiscoveryResult>;
|
|
326
389
|
enrichCompanies(companies: CompanySignalEnrichmentParams[], options: BatchOptions & {
|
|
327
390
|
dryRun: true;
|
|
328
391
|
}): Promise<CoreProductDryRunResult>;
|
|
@@ -338,11 +401,10 @@ declare class Signaliz {
|
|
|
338
401
|
private runCoreProductDryRun;
|
|
339
402
|
private runSignalCopyBatchChunks;
|
|
340
403
|
private runRecoverableCoreBatchJob;
|
|
341
|
-
private runRecoverableSignalCopyBatch;
|
|
342
404
|
private runSignalCopyBatchChunk;
|
|
343
405
|
private runCoreBatchRound;
|
|
344
406
|
listTools(): Promise<MCPToolInfo[]>;
|
|
345
407
|
health(): Promise<PlatformHealth>;
|
|
346
408
|
}
|
|
347
409
|
|
|
348
|
-
export { type BatchItemResult, type BatchOptions, type BatchResult, type CompanySignal, type CompanySignalEnrichmentParams, type CompanySignalEnrichmentResult, type ErrorType, type FindEmailParams, type FindEmailResult, type MCPToolInfo, type PlatformHealth, type SignalToCopyParams, type SignalToCopyResult, type SignalToCopyVariation, Signaliz, type SignalizConfig, SignalizError, type SignalizErrorData, type VerifyEmailBatchOptions, type VerifyEmailOptions, type VerifyEmailResult };
|
|
410
|
+
export { type BatchItemResult, type BatchOptions, type BatchResult, type CompanySignal, type CompanySignalEnrichmentParams, type CompanySignalEnrichmentResult, type ErrorType, type FindEmailParams, type FindEmailResult, type MCPToolInfo, type PlatformHealth, type SignalDiscoveryParams, type SignalDiscoveryResult, type SignalDiscoverySignal, type SignalDiscoverySource, type SignalDiscoveryStatus, type SignalToCopyParams, type SignalToCopyResult, type SignalToCopyVariation, Signaliz, type SignalizConfig, SignalizError, type SignalizErrorData, type VerifyEmailBatchOptions, type VerifyEmailOptions, type VerifyEmailResult };
|
package/dist/index.js
CHANGED
|
@@ -66,7 +66,11 @@ function publicRetryDetails(body) {
|
|
|
66
66
|
const details = {
|
|
67
67
|
...body?.retry_eligible !== void 0 ? { retry_eligible: body.retry_eligible } : {},
|
|
68
68
|
...body?.retry_after !== void 0 ? { retry_after: body.retry_after } : {},
|
|
69
|
-
...body?.retry_after_seconds !== void 0 ? { retry_after_seconds: body.retry_after_seconds } : {}
|
|
69
|
+
...body?.retry_after_seconds !== void 0 ? { retry_after_seconds: body.retry_after_seconds } : {},
|
|
70
|
+
...body?.run_id !== void 0 ? { run_id: body.run_id } : {},
|
|
71
|
+
...body?.signal_run_id !== void 0 ? { signal_run_id: body.signal_run_id } : {},
|
|
72
|
+
...body?.company_signal_run_id !== void 0 ? { company_signal_run_id: body.company_signal_run_id } : {},
|
|
73
|
+
...body?.resume_context_persisted !== void 0 ? { resume_context_persisted: body.resume_context_persisted } : {}
|
|
70
74
|
};
|
|
71
75
|
return Object.keys(details).length > 0 ? details : void 0;
|
|
72
76
|
}
|
|
@@ -491,6 +495,14 @@ var Signaliz = class {
|
|
|
491
495
|
assertTerminalSignalResponse(data, "Company Signals");
|
|
492
496
|
return normalizeCompanySignalResult(params, data);
|
|
493
497
|
}
|
|
498
|
+
async discoverSignals(params) {
|
|
499
|
+
validateSignalDiscoveryParams(params);
|
|
500
|
+
const data = await this.client.post(
|
|
501
|
+
"api/v1/signals",
|
|
502
|
+
signalDiscoveryRequestBody(params)
|
|
503
|
+
);
|
|
504
|
+
return normalizeSignalDiscoveryResult(params, data);
|
|
505
|
+
}
|
|
494
506
|
async enrichCompanies(companies, options) {
|
|
495
507
|
validateBatchSize(companies);
|
|
496
508
|
companies.forEach((params) => validateCoreProductMaxWaitMs(params.maxWaitMs));
|
|
@@ -551,10 +563,7 @@ var Signaliz = class {
|
|
|
551
563
|
request: signalToCopyRequestBody(params)
|
|
552
564
|
}));
|
|
553
565
|
const uniqueRequests = deduplicated.uniqueItems;
|
|
554
|
-
const
|
|
555
|
-
(request) => request.skipCache === true || request.enableDeepSearch === true
|
|
556
|
-
);
|
|
557
|
-
const uniqueResults = uniqueRequests.length > 25 && !requiresFreshResearch ? await this.runRecoverableSignalCopyBatch(uniqueRequests, options) : await this.runSignalCopyBatchChunks(uniqueRequests, options);
|
|
566
|
+
const uniqueResults = await this.runSignalCopyBatchChunks(uniqueRequests, options);
|
|
558
567
|
const results = requests.map((_, index) => ({
|
|
559
568
|
...uniqueResults[deduplicated.sourceIndexByInput[index]],
|
|
560
569
|
index
|
|
@@ -585,7 +594,7 @@ var Signaliz = class {
|
|
|
585
594
|
for (let offset = 0; offset < uniqueRequests.length; offset += 25) {
|
|
586
595
|
chunks.push({ offset, requests: uniqueRequests.slice(offset, offset + 25) });
|
|
587
596
|
}
|
|
588
|
-
const { serverConcurrency, chunkConcurrency } = batchConcurrencyPlan(options);
|
|
597
|
+
const { serverConcurrency, chunkConcurrency } = batchConcurrencyPlan(options, 25, 25);
|
|
589
598
|
const chunkBatch = await runBatch(
|
|
590
599
|
chunks,
|
|
591
600
|
(chunk) => this.runSignalCopyBatchChunk(chunk.requests, serverConcurrency),
|
|
@@ -680,35 +689,6 @@ var Signaliz = class {
|
|
|
680
689
|
if (seen.size !== requests.length) throw new Error(`${label} batch returned incomplete indexed results`);
|
|
681
690
|
return rows;
|
|
682
691
|
}
|
|
683
|
-
async runRecoverableSignalCopyBatch(requests, options) {
|
|
684
|
-
const rows = await this.runRecoverableCoreBatchJob(
|
|
685
|
-
"api/v1/signal-to-copy",
|
|
686
|
-
requests.map(signalToCopyRequestBody),
|
|
687
|
-
"Signal to Copy",
|
|
688
|
-
100,
|
|
689
|
-
20 * 6e4,
|
|
690
|
-
options?.idempotencyKey
|
|
691
|
-
);
|
|
692
|
-
const results = new Array(requests.length);
|
|
693
|
-
for (const row of rows) {
|
|
694
|
-
const index = Number(row.index);
|
|
695
|
-
if (recoverableJobRowFailed(row)) {
|
|
696
|
-
results[index] = batchItemFailure(
|
|
697
|
-
index,
|
|
698
|
-
row.error || row._error || row.message || row.failure_reason || "Signal to Copy item failed",
|
|
699
|
-
row
|
|
700
|
-
);
|
|
701
|
-
continue;
|
|
702
|
-
}
|
|
703
|
-
try {
|
|
704
|
-
assertTerminalSignalResponse(row, "Signal to Copy");
|
|
705
|
-
results[index] = { index, success: true, data: normalizeSignalToCopyResult(row) };
|
|
706
|
-
} catch (error) {
|
|
707
|
-
results[index] = batchItemFailure(index, error instanceof Error ? error.message : String(error), row);
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
return results;
|
|
711
|
-
}
|
|
712
692
|
async runSignalCopyBatchChunk(requests, concurrency, rowRateLimitAttempt = 0) {
|
|
713
693
|
const results = new Array(requests.length);
|
|
714
694
|
const rateLimited = [];
|
|
@@ -758,12 +738,11 @@ var Signaliz = class {
|
|
|
758
738
|
return results;
|
|
759
739
|
}
|
|
760
740
|
async runCoreBatchRound(path, tasks, options, rowRateLimitAttempt = 0) {
|
|
761
|
-
const { serverConcurrency, chunkConcurrency } = batchConcurrencyPlan(options);
|
|
741
|
+
const { serverConcurrency, chunkConcurrency } = path === "api/v1/company-signals" ? batchConcurrencyPlan(options, 25, 25) : batchConcurrencyPlan(options);
|
|
762
742
|
const deduplicated = dedupeExactBatchItems(tasks, (task) => JSON.stringify(task.request));
|
|
763
743
|
const uniqueTasks = deduplicated.uniqueItems;
|
|
764
|
-
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 } :
|
|
765
|
-
|
|
766
|
-
if (recoverableBatch && uniqueTasks.length > 25 && !containsSignalRunRecovery) {
|
|
744
|
+
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;
|
|
745
|
+
if (path !== "api/v1/company-signals" && recoverableBatch && uniqueTasks.length > 25) {
|
|
767
746
|
const rows = await this.runRecoverableCoreBatchJob(
|
|
768
747
|
path,
|
|
769
748
|
uniqueTasks.map((task) => task.request),
|
|
@@ -1028,6 +1007,7 @@ function companySignalRequestBody(params) {
|
|
|
1028
1007
|
enable_outreach_intelligence: params.enableOutreachIntelligence,
|
|
1029
1008
|
enable_predictive_intelligence: params.enablePredictiveIntelligence,
|
|
1030
1009
|
skip_cache: params.skipCache,
|
|
1010
|
+
include_candidate_evidence: params.includeCandidateEvidence,
|
|
1031
1011
|
wait_for_result: true,
|
|
1032
1012
|
max_wait_ms: params.maxWaitMs,
|
|
1033
1013
|
dry_run: params.dryRun,
|
|
@@ -1045,7 +1025,6 @@ function normalizeCompanySignalResult(params, data) {
|
|
|
1045
1025
|
domain: data.company?.domain ?? params.companyDomain ?? null
|
|
1046
1026
|
},
|
|
1047
1027
|
signals: rawSignals.map((signal) => {
|
|
1048
|
-
const metadata = signal.metadata && typeof signal.metadata === "object" && !Array.isArray(signal.metadata) ? signal.metadata : void 0;
|
|
1049
1028
|
return {
|
|
1050
1029
|
id: signal.id,
|
|
1051
1030
|
title: signal.title ?? "",
|
|
@@ -1054,43 +1033,160 @@ function normalizeCompanySignalResult(params, data) {
|
|
|
1054
1033
|
date: signal.date ?? null,
|
|
1055
1034
|
detectedAt: signal.detected_at ?? null,
|
|
1056
1035
|
datePrecision: signal.date_precision,
|
|
1057
|
-
hasSpecificDate: signal.has_specific_date ?? metadata?.has_specific_date,
|
|
1058
1036
|
sourceUrl: signal.source_url ?? signal.url ?? null,
|
|
1059
1037
|
sourceType: signal.source_type,
|
|
1060
|
-
sourceProvenance: signal.source_provenance,
|
|
1061
1038
|
confidence: signal.confidence ?? signal.confidence_score ?? null,
|
|
1062
|
-
entityConfidence: signal.entity_confidence ?? metadata?.entity_confidence ?? null,
|
|
1063
1039
|
signalFamily: signal.signal_family,
|
|
1064
1040
|
eventType: signal.signal_event_type,
|
|
1065
1041
|
eventLabel: signal.signal_event_label,
|
|
1066
|
-
classification: signal.signal_classification ?? null
|
|
1067
|
-
derived: signal.derived === true,
|
|
1068
|
-
evidencePublishedDate: signal.evidence_published_date ?? metadata?.evidence_published_date ?? null,
|
|
1069
|
-
signalFeedSource: signal.signal_feed_source ?? metadata?.signal_feed_source,
|
|
1070
|
-
metadata
|
|
1042
|
+
classification: signal.signal_classification ?? null
|
|
1071
1043
|
};
|
|
1072
1044
|
}),
|
|
1073
1045
|
signalCount: data.signal_count ?? data.total_signals ?? rawSignals.length,
|
|
1074
1046
|
signalSummary: data.signal_summary ?? null,
|
|
1075
|
-
signalSummarySource: data.signal_summary_source,
|
|
1076
1047
|
intelligence: data.intelligence ?? null,
|
|
1077
1048
|
copyFuel: data.copy_fuel ?? null,
|
|
1078
1049
|
evidenceValidation: data.evidence_validation,
|
|
1079
|
-
evidenceSources: data.evidence_sources,
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
resultReturnedFrom: data.result_returned_from,
|
|
1085
|
-
cacheHit: data.cache_hit,
|
|
1086
|
-
freshEnrichmentUsed: data.fresh_enrichment_used,
|
|
1087
|
-
liveProviderCalled: data.live_provider_called,
|
|
1088
|
-
aiProviderCalled: data.ai_provider_called,
|
|
1089
|
-
byoAiUsed: data.byo_ai_used,
|
|
1090
|
-
metadata: data.metadata,
|
|
1050
|
+
evidenceSources: data.metadata?.evidence_sources ?? data.evidence_sources,
|
|
1051
|
+
evidenceCount: data.evidence_count,
|
|
1052
|
+
evidenceCountTotal: data.evidence_count_total,
|
|
1053
|
+
evidenceSourcesOmitted: data.evidence_sources_omitted,
|
|
1054
|
+
evidenceScope: data.evidence_scope,
|
|
1091
1055
|
raw: data
|
|
1092
1056
|
};
|
|
1093
1057
|
}
|
|
1058
|
+
var SIGNAL_DISCOVERY_SOURCES = /* @__PURE__ */ new Set(["web", "news"]);
|
|
1059
|
+
var SIGNAL_DISCOVERY_STATUSES = /* @__PURE__ */ new Set([
|
|
1060
|
+
"planned",
|
|
1061
|
+
"queued",
|
|
1062
|
+
"processing",
|
|
1063
|
+
"completed",
|
|
1064
|
+
"completed_with_warnings",
|
|
1065
|
+
"failed"
|
|
1066
|
+
]);
|
|
1067
|
+
function validateSignalDiscoveryParams(params) {
|
|
1068
|
+
const runId = typeof params.signalSearchRunId === "string" ? params.signalSearchRunId.trim() : "";
|
|
1069
|
+
const query = typeof params.query === "string" ? params.query.trim() : "";
|
|
1070
|
+
if (!runId && !query) {
|
|
1071
|
+
throw new TypeError("Signals Everything requires query or signalSearchRunId");
|
|
1072
|
+
}
|
|
1073
|
+
if (query && (query.length < 2 || query.length > 2e3)) {
|
|
1074
|
+
throw new RangeError("query must contain between 2 and 2000 characters");
|
|
1075
|
+
}
|
|
1076
|
+
if (params.limit !== void 0 && (!Number.isInteger(params.limit) || params.limit < 1 || params.limit > 1e3)) {
|
|
1077
|
+
throw new RangeError("limit must be an integer between 1 and 1000");
|
|
1078
|
+
}
|
|
1079
|
+
if (params.lookbackDays !== void 0 && (!Number.isInteger(params.lookbackDays) || params.lookbackDays < 1 || params.lookbackDays > 365)) {
|
|
1080
|
+
throw new RangeError("lookbackDays must be an integer between 1 and 365");
|
|
1081
|
+
}
|
|
1082
|
+
if (params.sources !== void 0 && (!Array.isArray(params.sources) || params.sources.length < 1 || params.sources.length > 2 || params.sources.some((source) => !SIGNAL_DISCOVERY_SOURCES.has(source)))) {
|
|
1083
|
+
throw new TypeError("sources must contain only web or news");
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
function signalDiscoveryRequestBody(params) {
|
|
1087
|
+
const runId = typeof params.signalSearchRunId === "string" ? params.signalSearchRunId.trim() : "";
|
|
1088
|
+
if (runId) {
|
|
1089
|
+
return compact({
|
|
1090
|
+
signal_search_run_id: runId,
|
|
1091
|
+
dry_run: params.dryRun,
|
|
1092
|
+
idempotency_key: params.idempotencyKey
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
return compact({
|
|
1096
|
+
query: params.query?.trim(),
|
|
1097
|
+
limit: params.limit ?? 100,
|
|
1098
|
+
sources: params.sources,
|
|
1099
|
+
lookback_days: params.lookbackDays,
|
|
1100
|
+
dry_run: params.dryRun,
|
|
1101
|
+
idempotency_key: params.idempotencyKey
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1104
|
+
function normalizeSignalDiscoveryResult(params, data) {
|
|
1105
|
+
const rawSignals = Array.isArray(data.signals) ? data.signals : [];
|
|
1106
|
+
const rawStatus = String(data.status || "").toLowerCase();
|
|
1107
|
+
const status = SIGNAL_DISCOVERY_STATUSES.has(rawStatus) ? rawStatus : rawSignals.length > 0 ? "completed" : "failed";
|
|
1108
|
+
const signals = rawSignals.map(normalizeSignalDiscoverySignal);
|
|
1109
|
+
return {
|
|
1110
|
+
success: data.success !== false,
|
|
1111
|
+
status,
|
|
1112
|
+
capability: "signals_everything",
|
|
1113
|
+
signalSearchRunId: String(data.signal_search_run_id ?? params.signalSearchRunId ?? ""),
|
|
1114
|
+
query: String(data.query ?? params.query ?? ""),
|
|
1115
|
+
requestedCount: Number(data.requested_count ?? params.limit ?? 100),
|
|
1116
|
+
nextPollAfterSeconds: typeof data.next_poll_after_seconds === "number" ? data.next_poll_after_seconds : void 0,
|
|
1117
|
+
signals,
|
|
1118
|
+
signalCount: signals.length,
|
|
1119
|
+
sourceLanes: Array.isArray(data.source_lanes) ? data.source_lanes.filter((lane) => typeof lane === "string") : void 0,
|
|
1120
|
+
evidenceValidation: data.evidence_validation && typeof data.evidence_validation === "object" ? data.evidence_validation : void 0,
|
|
1121
|
+
costGuardrail: normalizeSignalDiscoveryCostGuardrail(data.cost_guardrail),
|
|
1122
|
+
warnings: Array.isArray(data.warnings) ? data.warnings.filter((warning) => typeof warning === "string") : void 0,
|
|
1123
|
+
raw: data
|
|
1124
|
+
};
|
|
1125
|
+
}
|
|
1126
|
+
function normalizeSignalDiscoveryCostGuardrail(value) {
|
|
1127
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
1128
|
+
const guardrail = value;
|
|
1129
|
+
const maxCost = Number(guardrail.max_cost_per_qualified_signal_usd);
|
|
1130
|
+
const withinLimit = guardrail.within_limit === true;
|
|
1131
|
+
if (!Number.isFinite(maxCost)) return void 0;
|
|
1132
|
+
const numberOrNullable = (candidate) => {
|
|
1133
|
+
if (candidate === null) return null;
|
|
1134
|
+
const numeric = Number(candidate);
|
|
1135
|
+
return Number.isFinite(numeric) ? numeric : void 0;
|
|
1136
|
+
};
|
|
1137
|
+
const numberOrUndefined = (candidate) => {
|
|
1138
|
+
const numeric = Number(candidate);
|
|
1139
|
+
return Number.isFinite(numeric) ? numeric : void 0;
|
|
1140
|
+
};
|
|
1141
|
+
return {
|
|
1142
|
+
maxCostPerQualifiedSignalUsd: maxCost,
|
|
1143
|
+
projectedSourceCostUsd: numberOrNullable(guardrail.projected_source_cost_usd),
|
|
1144
|
+
maxSourceCostUsd: numberOrNullable(guardrail.max_source_cost_usd),
|
|
1145
|
+
projectedCostPerRequestedCompanySignalUsd: numberOrNullable(
|
|
1146
|
+
guardrail.projected_cost_per_requested_company_signal_usd
|
|
1147
|
+
),
|
|
1148
|
+
sourceCostUsd: numberOrNullable(guardrail.source_cost_usd),
|
|
1149
|
+
costSource: ["observed", "catalog_bounded", "mixed", "unavailable"].includes(String(guardrail.cost_source)) ? String(guardrail.cost_source) : void 0,
|
|
1150
|
+
qualifiedCompanySignalCount: numberOrUndefined(guardrail.qualified_company_signal_count),
|
|
1151
|
+
returnedCompanySignalCount: numberOrUndefined(guardrail.returned_company_signal_count),
|
|
1152
|
+
costPerQualifiedSignalUsd: numberOrNullable(guardrail.cost_per_qualified_signal_usd),
|
|
1153
|
+
withinLimit
|
|
1154
|
+
};
|
|
1155
|
+
}
|
|
1156
|
+
function normalizeSignalDiscoverySignal(value) {
|
|
1157
|
+
const signal = value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
1158
|
+
const company = signal.company && typeof signal.company === "object" && !Array.isArray(signal.company) ? signal.company : {};
|
|
1159
|
+
const companyName = String(company.name ?? signal.company_name ?? "").trim();
|
|
1160
|
+
const companyDomain = String(company.domain ?? signal.company_domain ?? "").trim();
|
|
1161
|
+
if (!companyName || !companyDomain) {
|
|
1162
|
+
throw new Error("Signals Everything response violated the company attribution contract.");
|
|
1163
|
+
}
|
|
1164
|
+
return {
|
|
1165
|
+
id: signal.id,
|
|
1166
|
+
company: {
|
|
1167
|
+
name: companyName,
|
|
1168
|
+
domain: companyDomain,
|
|
1169
|
+
linkedinUrl: company.linkedin_url ?? signal.company_linkedin_url ?? void 0
|
|
1170
|
+
},
|
|
1171
|
+
title: signal.title ?? "",
|
|
1172
|
+
type: signal.type ?? signal.signal_type ?? "unknown",
|
|
1173
|
+
summary: signal.summary ?? signal.content ?? signal.description ?? "",
|
|
1174
|
+
eventDate: signal.event_date ?? signal.date ?? signal.signal_date ?? null,
|
|
1175
|
+
evidence: Array.isArray(signal.evidence) ? signal.evidence.map((item) => ({
|
|
1176
|
+
url: String(item?.url ?? ""),
|
|
1177
|
+
publishedAt: String(item?.published_at ?? item?.publishedAt ?? ""),
|
|
1178
|
+
source: String(item?.source ?? "")
|
|
1179
|
+
})).filter((item) => Boolean(item.url)) : [],
|
|
1180
|
+
content: signal.summary ?? signal.content ?? signal.description ?? "",
|
|
1181
|
+
date: signal.event_date ?? signal.date ?? signal.signal_date ?? null,
|
|
1182
|
+
detectedAt: signal.event_date ?? signal.detected_at ?? null,
|
|
1183
|
+
sourceUrl: signal.source_url ?? signal.url ?? null,
|
|
1184
|
+
sourceType: signal.source_type ?? null,
|
|
1185
|
+
confidence: signal.confidence ?? signal.confidence_score ?? null,
|
|
1186
|
+
classification: signal.signal_classification ?? signal.classification ?? null,
|
|
1187
|
+
raw: signal
|
|
1188
|
+
};
|
|
1189
|
+
}
|
|
1094
1190
|
function validateBatchSize(items) {
|
|
1095
1191
|
if (!Array.isArray(items) || items.length === 0) {
|
|
1096
1192
|
throw new Error("Signaliz batch requests require at least one item");
|
|
@@ -1106,9 +1202,9 @@ function validatedBatchConcurrency(options) {
|
|
|
1106
1202
|
}
|
|
1107
1203
|
return concurrency;
|
|
1108
1204
|
}
|
|
1109
|
-
function batchConcurrencyPlan(options) {
|
|
1110
|
-
const concurrency = validatedBatchConcurrency(options);
|
|
1111
|
-
const serverConcurrency = Math.min(
|
|
1205
|
+
function batchConcurrencyPlan(options, defaultConcurrency = 10, maximumServerConcurrency = 10) {
|
|
1206
|
+
const concurrency = options?.concurrency === void 0 ? defaultConcurrency : validatedBatchConcurrency(options);
|
|
1207
|
+
const serverConcurrency = Math.min(maximumServerConcurrency, concurrency);
|
|
1112
1208
|
return {
|
|
1113
1209
|
serverConcurrency,
|
|
1114
1210
|
chunkConcurrency: Math.max(1, Math.floor(concurrency / serverConcurrency))
|