lumnisai 0.5.43 → 0.5.45

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/dist/index.cjs CHANGED
@@ -1044,6 +1044,12 @@ class CrmResource {
1044
1044
  * details through `accountRef`. Provider degradation and unknown deal stages
1045
1045
  * are returned explicitly and must not be treated as safe negative results.
1046
1046
  *
1047
+ * Capped at 100 candidates per request; chunk longer lists and reassemble by
1048
+ * `inputKey`. Provider selection comes from the resolved owner's active
1049
+ * HubSpot/Attio connections: no active supported connection is
1050
+ * `409 crm_not_connected`, and a connection-verification failure is a
1051
+ * retryable `503 crm_connection_status_unavailable`.
1052
+ *
1047
1053
  * @example
1048
1054
  * ```typescript
1049
1055
  * const context = await client.crm.accountContextBatch({
@@ -3219,6 +3225,31 @@ class PeopleResource {
3219
3225
  }
3220
3226
  }
3221
3227
 
3228
+ const DATE_RANGES = [
3229
+ "past-24h",
3230
+ "past-week",
3231
+ "past-2-weeks",
3232
+ "past-3-weeks",
3233
+ "past-month",
3234
+ "past-quarter",
3235
+ "past-6-months",
3236
+ "past-year",
3237
+ "past-2-years",
3238
+ "past-3-years"
3239
+ ];
3240
+ const SIGNAL_TYPES = [
3241
+ "hiring",
3242
+ "engagement",
3243
+ "recently_joined",
3244
+ "funding",
3245
+ "events"
3246
+ ];
3247
+ const DISABLED_SIGNAL_TYPES = ["competitor_tools", "web_traffic"];
3248
+ const ENGAGEMENT_ACTIVITIES = [
3249
+ "reactions",
3250
+ "comments",
3251
+ "authored_posts"
3252
+ ];
3222
3253
  class ResponsesResource {
3223
3254
  constructor(http) {
3224
3255
  this.http = http;
@@ -3242,7 +3273,13 @@ class ResponsesResource {
3242
3273
  throw new ValidationError("criteria_definitions cannot be empty");
3243
3274
  const criterionIds = /* @__PURE__ */ new Set();
3244
3275
  const columnNames = /* @__PURE__ */ new Set();
3245
- const validTypes = ["universal", "varying", "validation_only"];
3276
+ const validTypes = [
3277
+ "universal",
3278
+ "post_hard",
3279
+ "varying",
3280
+ "post_soft",
3281
+ "validation_only"
3282
+ ];
3246
3283
  criteriaDefinitions.forEach((criterion, index) => {
3247
3284
  if (!this._isPlainObject(criterion))
3248
3285
  throw new ValidationError(`Criterion ${index} must be an object`);
@@ -3276,7 +3313,9 @@ class ResponsesResource {
3276
3313
  if (!this._isPlainObject(criteriaClassification))
3277
3314
  throw new ValidationError("criteria_classification must be an object");
3278
3315
  const universalCriteria = this._getParamValue(criteriaClassification, "universalCriteria", "universal_criteria");
3316
+ const postHardCriteria = this._getParamValue(criteriaClassification, "postHardCriteria", "post_hard_criteria");
3279
3317
  const varyingCriteria = this._getParamValue(criteriaClassification, "varyingCriteria", "varying_criteria");
3318
+ const postSoftCriteria = this._getParamValue(criteriaClassification, "postSoftCriteria", "post_soft_criteria");
3280
3319
  const validationOnlyCriteria = this._getParamValue(criteriaClassification, "validationOnlyCriteria", "validation_only_criteria");
3281
3320
  if (!Array.isArray(universalCriteria))
3282
3321
  throw new ValidationError("criteria_classification missing or invalid universal_criteria");
@@ -3284,6 +3323,10 @@ class ResponsesResource {
3284
3323
  throw new ValidationError("criteria_classification missing or invalid varying_criteria");
3285
3324
  if (!Array.isArray(validationOnlyCriteria))
3286
3325
  throw new ValidationError("criteria_classification missing or invalid validation_only_criteria");
3326
+ if (postHardCriteria !== void 0 && !Array.isArray(postHardCriteria))
3327
+ throw new ValidationError("criteria_classification has invalid post_hard_criteria");
3328
+ if (postSoftCriteria !== void 0 && !Array.isArray(postSoftCriteria))
3329
+ throw new ValidationError("criteria_classification has invalid post_soft_criteria");
3287
3330
  }
3288
3331
  _validateCompetitorPostEngagementParams(params) {
3289
3332
  const company = this._getParamValue(params, "company", "company");
@@ -3354,6 +3397,154 @@ class ResponsesResource {
3354
3397
  throw new ValidationError("maxCommentsPerPost must be between 1 and 100");
3355
3398
  }
3356
3399
  }
3400
+ _validateDateRange(value, field) {
3401
+ if (value === void 0 || value === null)
3402
+ return;
3403
+ if (typeof value !== "string" || !DATE_RANGES.includes(value)) {
3404
+ throw new ValidationError(
3405
+ `Invalid ${field} value: ${String(value)}. Choose from: ${DATE_RANGES.join(", ")}.`
3406
+ );
3407
+ }
3408
+ }
3409
+ /** Company targets are compared the way the backend compares them: trimmed, case-folded, no trailing slash. */
3410
+ _targetCompanyKey(value) {
3411
+ return value.trim().toLowerCase().replace(/\/+$/, "");
3412
+ }
3413
+ _validateEngagementSettings(settings) {
3414
+ const activities = this._getParamValue(settings, "activities", "activities");
3415
+ if (activities !== void 0 && activities !== null) {
3416
+ if (!Array.isArray(activities) || activities.length === 0)
3417
+ throw new ValidationError("engagement settings.activities cannot be empty");
3418
+ for (const activity of activities) {
3419
+ if (typeof activity !== "string" || !ENGAGEMENT_ACTIVITIES.includes(activity)) {
3420
+ throw new ValidationError(
3421
+ `Invalid engagement activity: ${String(activity)}. Choose from: ${ENGAGEMENT_ACTIVITIES.join(", ")}.`
3422
+ );
3423
+ }
3424
+ }
3425
+ if (new Set(activities).size !== activities.length)
3426
+ throw new ValidationError("engagement settings.activities must not contain duplicates");
3427
+ }
3428
+ const targetCompanies = this._getParamValue(
3429
+ settings,
3430
+ "targetCompanies",
3431
+ "target_companies"
3432
+ );
3433
+ if (targetCompanies !== void 0 && targetCompanies !== null) {
3434
+ if (!Array.isArray(targetCompanies) || targetCompanies.length === 0 || targetCompanies.some((company) => typeof company !== "string" || !company.trim())) {
3435
+ throw new ValidationError(
3436
+ "engagement settings.targetCompanies must contain at least one non-empty company name, domain, or LinkedIn company URL"
3437
+ );
3438
+ }
3439
+ const keys = targetCompanies.map((company) => this._targetCompanyKey(company));
3440
+ if (new Set(keys).size !== keys.length)
3441
+ throw new ValidationError("engagement settings.targetCompanies must not contain duplicates");
3442
+ }
3443
+ }
3444
+ _validateSignalSettings(name, settings) {
3445
+ if (settings === void 0 || settings === null)
3446
+ return;
3447
+ if (!this._isPlainObject(settings))
3448
+ throw new ValidationError(`signalDefinitions '${name}' settings must be an object`);
3449
+ const allowed = name === "engagement" ? ["dateRange", "date_range", "activities", "targetCompanies", "target_companies"] : ["dateRange", "date_range"];
3450
+ for (const key of Object.keys(settings)) {
3451
+ if (!allowed.includes(key)) {
3452
+ throw new ValidationError(
3453
+ `Unknown setting '${key}' for the '${name}' signal. Supported settings: ${allowed.filter((setting) => !setting.includes("_")).join(", ")}.`
3454
+ );
3455
+ }
3456
+ }
3457
+ this._validateDateRange(
3458
+ this._getParamValue(settings, "dateRange", "date_range"),
3459
+ `signalDefinitions '${name}' settings.dateRange`
3460
+ );
3461
+ if (name === "engagement")
3462
+ this._validateEngagementSettings(settings);
3463
+ }
3464
+ /**
3465
+ * Validate the one manual signal-enrichment input before anything paid runs.
3466
+ * Mirrors the backend registry: object entries only, known enabled names, no
3467
+ * duplicates, no unknown settings.
3468
+ */
3469
+ _validateSignalDefinitions(value) {
3470
+ if (value === void 0 || value === null)
3471
+ return;
3472
+ if (!Array.isArray(value))
3473
+ throw new ValidationError("signalDefinitions must be an array");
3474
+ const seen = /* @__PURE__ */ new Set();
3475
+ for (const entry of value) {
3476
+ if (!this._isPlainObject(entry)) {
3477
+ throw new ValidationError(
3478
+ `Each signalDefinitions entry must be an object like { name: 'hiring', settings: { dateRange: 'past-month' } }`
3479
+ );
3480
+ }
3481
+ const rawName = this._getParamValue(entry, "name", "name");
3482
+ const name = typeof rawName === "string" ? rawName.trim().toLowerCase() : rawName;
3483
+ if (typeof name !== "string" || !name)
3484
+ throw new ValidationError("Each signalDefinitions entry requires a signal name");
3485
+ if (DISABLED_SIGNAL_TYPES.includes(name)) {
3486
+ throw new ValidationError(
3487
+ `The '${name}' signal is temporarily disabled because of company-record cost. Choose from the enabled signals: ${SIGNAL_TYPES.join(", ")}.`
3488
+ );
3489
+ }
3490
+ if (!SIGNAL_TYPES.includes(name)) {
3491
+ throw new ValidationError(
3492
+ `'${name}' is not a signal we know. Choose from: ${SIGNAL_TYPES.join(", ")}.`
3493
+ );
3494
+ }
3495
+ if (seen.has(name)) {
3496
+ throw new ValidationError(
3497
+ `The '${name}' signal appears more than once in signalDefinitions \u2014 send each signal once.`
3498
+ );
3499
+ }
3500
+ seen.add(name);
3501
+ for (const key of Object.keys(entry)) {
3502
+ if (key !== "name" && key !== "settings") {
3503
+ throw new ValidationError(
3504
+ `Unknown signalDefinitions field '${key}'. Each entry accepts only name and settings.`
3505
+ );
3506
+ }
3507
+ }
3508
+ this._validateSignalSettings(
3509
+ name,
3510
+ this._getParamValue(entry, "settings", "settings")
3511
+ );
3512
+ }
3513
+ }
3514
+ /**
3515
+ * Validate the signal-enrichment, automatic-selection and intent-scoring
3516
+ * params. These apply to every people agent, so they are checked on the
3517
+ * request rather than per agent.
3518
+ */
3519
+ _validateSignalParams(params) {
3520
+ this._validateSignalDefinitions(
3521
+ this._getParamValue(params, "signalDefinitions", "signal_definitions")
3522
+ );
3523
+ for (const [camel, snake] of [
3524
+ ["autoSelectLane", "auto_select_lane"],
3525
+ ["autoSelectSignals", "auto_select_signals"]
3526
+ ]) {
3527
+ const value = this._getParamValue(params, camel, snake);
3528
+ if (value !== void 0 && value !== null && typeof value !== "boolean")
3529
+ throw new ValidationError(`${camel} must be true or false`);
3530
+ }
3531
+ const intentScoringInstructions = this._getParamValue(
3532
+ params,
3533
+ "intentScoringInstructions",
3534
+ "intent_scoring_instructions"
3535
+ );
3536
+ if (intentScoringInstructions !== void 0 && intentScoringInstructions !== null && typeof intentScoringInstructions !== "string") {
3537
+ throw new ValidationError("intentScoringInstructions must be a string");
3538
+ }
3539
+ this._validateDateRange(
3540
+ this._getParamValue(params, "jobSignalDateRange", "job_signal_date_range"),
3541
+ "jobSignalDateRange"
3542
+ );
3543
+ this._validateDateRange(
3544
+ this._getParamValue(params, "postsDateRange", "posts_date_range"),
3545
+ "postsDateRange"
3546
+ );
3547
+ }
3357
3548
  _validateCompetitorRepEngagementParams(params) {
3358
3549
  const company = this._getParamValue(params, "company", "company");
3359
3550
  const competitors = this._getParamValue(params, "competitors", "competitors");
@@ -3487,25 +3678,10 @@ class ResponsesResource {
3487
3678
  }
3488
3679
  }
3489
3680
  }
3490
- const postsDateRange = this._getParamValue(
3491
- params,
3492
- "postsDateRange",
3493
- "posts_date_range"
3494
- );
3495
- if (postsDateRange !== void 0) {
3496
- const validRanges = [
3497
- "past-24h",
3498
- "past-week",
3499
- "past-month",
3500
- "past-quarter",
3501
- "past-6-months",
3502
- "past-year",
3503
- "past-2-years",
3504
- "past-3-years"
3505
- ];
3506
- if (!validRanges.includes(postsDateRange))
3507
- throw new ValidationError(`Invalid postsDateRange value: ${String(postsDateRange)}`);
3508
- }
3681
+ this._validateDateRange(
3682
+ this._getParamValue(params, "postsDateRange", "posts_date_range"),
3683
+ "postsDateRange"
3684
+ );
3509
3685
  for (const [camel, snake, maximum] of [
3510
3686
  ["limit", "limit", 1e3],
3511
3687
  ["maxReactorsPerPost", "max_reactors_per_post", 5e3],
@@ -3578,6 +3754,25 @@ class ResponsesResource {
3578
3754
  );
3579
3755
  }
3580
3756
  }
3757
+ /**
3758
+ * Every place a caller may put specialized-agent params: the dedicated field
3759
+ * and the legacy nested copy inside `options`. Both are validated so a nested
3760
+ * request cannot smuggle an unknown signal past the SDK.
3761
+ */
3762
+ _specializedParamSources(request) {
3763
+ const sources = [];
3764
+ if (this._isPlainObject(request.specializedAgentParams))
3765
+ sources.push(request.specializedAgentParams);
3766
+ const requestOptions = request.options;
3767
+ const nested = requestOptions ? this._getParamValue(
3768
+ requestOptions,
3769
+ "specializedAgentParams",
3770
+ "specialized_agent_params"
3771
+ ) : void 0;
3772
+ if (this._isPlainObject(nested))
3773
+ sources.push(nested);
3774
+ return sources;
3775
+ }
3581
3776
  _validateSalesNavigatorRequest(request) {
3582
3777
  const directParams = request.specializedAgentParams;
3583
3778
  const directUrl = directParams ? this._getParamValue(directParams, "salesNavigatorUrl", "sales_navigator_url") : void 0;
@@ -3629,6 +3824,11 @@ class ResponsesResource {
3629
3824
  "salesNavigatorUrl must be a Sales Navigator people-search or people-list URL"
3630
3825
  );
3631
3826
  }
3827
+ const autoSelectLane = this._specializedParamSources(request).some(
3828
+ (params) => this._getParamValue(params, "autoSelectLane", "auto_select_lane") === true
3829
+ );
3830
+ if (autoSelectLane)
3831
+ return;
3632
3832
  if (typeof request.userId !== "string" || !request.userId.trim())
3633
3833
  throw new ValidationError("userId is required when salesNavigatorUrl is provided");
3634
3834
  }
@@ -3795,6 +3995,8 @@ class ResponsesResource {
3795
3995
  this._validateFileReference(file.uri);
3796
3996
  }
3797
3997
  this._validateSalesNavigatorRequest(request);
3998
+ for (const params of this._specializedParamSources(request))
3999
+ this._validateSignalParams(params);
3798
4000
  if (request.specializedAgentParams)
3799
4001
  this._validateCriteriaParams(request.specializedAgentParams, request.specializedAgent);
3800
4002
  return this.http.post("/responses", request);
@@ -3938,10 +4140,16 @@ class ResponsesResource {
3938
4140
  * @param options.deepValidationBackfillBelowCriteria - Pad with criteria-failed candidates when under count; @default true
3939
4141
  * @param options.enrichEngagementHistory - Add recent LinkedIn engagement evidence before validation; forced off for Sales Navigator V1
3940
4142
  * @param options.deepSearchCriteriaModel - Override criteria decomposition model (e.g. 'openai:gpt-5.4')
4143
+ * @param options.jobSignalDateRange - Posting window for the standalone job-signal lane; omit for the planner's 90-365 days
4144
+ * @param options.signalDefinitions - Signal enrichments to run on fast-filter survivors before validation; omit or `[]` for none
4145
+ * @param options.autoSelectLane - Let the backend choose the discovery lane; ignores the manual lane controls; @default false
4146
+ * @param options.autoSelectSignals - Let the backend choose the signals; ignores `signalDefinitions`; @default false
4147
+ * @param options.intentScoringInstructions - Plain-English direction for every intent-scoring stage (never changes fit or filtering)
3941
4148
  * @returns Response with structured_response containing:
3942
- * - candidates: Validated and scored candidates
4149
+ * - candidates: Validated and scored candidates, each with `signalEvidence` for the selected signals
3943
4150
  * - criteria: Generated/reused criteria definitions and classification
3944
- * - searchStats: Search execution statistics
4151
+ * - searchStats: Search execution statistics, including `enrichment` and `signalFunnel`
4152
+ * - autoSearchSelection: What automatic selection applied, when either auto flag ran
3945
4153
  */
3946
4154
  async deepPeopleSearch(query, options) {
3947
4155
  const request = {
@@ -4023,7 +4231,17 @@ class ResponsesResource {
4023
4231
  params.enrichEngagementHistory = options.enrichEngagementHistory;
4024
4232
  if (options.deepSearchCriteriaModel)
4025
4233
  params.deepSearchCriteriaModel = options.deepSearchCriteriaModel;
4026
- if (options.salesNavigatorUrl !== void 0) {
4234
+ if (options.jobSignalDateRange !== void 0)
4235
+ params.jobSignalDateRange = options.jobSignalDateRange;
4236
+ if (options.signalDefinitions !== void 0)
4237
+ params.signalDefinitions = options.signalDefinitions;
4238
+ if (options.autoSelectLane !== void 0)
4239
+ params.autoSelectLane = options.autoSelectLane;
4240
+ if (options.autoSelectSignals !== void 0)
4241
+ params.autoSelectSignals = options.autoSelectSignals;
4242
+ if (options.intentScoringInstructions !== void 0)
4243
+ params.intentScoringInstructions = options.intentScoringInstructions;
4244
+ if (options.salesNavigatorUrl !== void 0 && options.autoSelectLane !== true) {
4027
4245
  params.searchProfiles = false;
4028
4246
  params.searchPosts = false;
4029
4247
  params.searchConnections = false;
@@ -4086,6 +4304,8 @@ class ResponsesResource {
4086
4304
  request.specializedAgentParams.addAndRunCriterion = options.addAndRunCriterion;
4087
4305
  if (options.deepSearchCriteriaModel)
4088
4306
  request.specializedAgentParams.deepSearchCriteriaModel = options.deepSearchCriteriaModel;
4307
+ if (options.intentScoringInstructions !== void 0)
4308
+ request.specializedAgentParams.intentScoringInstructions = options.intentScoringInstructions;
4089
4309
  }
4090
4310
  return this.create(request);
4091
4311
  }
@@ -4165,6 +4385,10 @@ class ResponsesResource {
4165
4385
  if (options?.deepValidationUseRelevanceReranker !== void 0) {
4166
4386
  params.deepValidationUseRelevanceReranker = options.deepValidationUseRelevanceReranker;
4167
4387
  }
4388
+ if (options.signalDefinitions !== void 0)
4389
+ params.signalDefinitions = options.signalDefinitions;
4390
+ if (options.intentScoringInstructions !== void 0)
4391
+ params.intentScoringInstructions = options.intentScoringInstructions;
4168
4392
  return this.create({
4169
4393
  messages: [{ role: "user", content: query }],
4170
4394
  specializedAgent: "engagement_expansion",
@@ -4211,6 +4435,10 @@ class ResponsesResource {
4211
4435
  params.excludeUrls = options.excludeUrls;
4212
4436
  if (options.limit !== void 0)
4213
4437
  params.limit = options.limit;
4438
+ if (options.signalDefinitions !== void 0)
4439
+ params.signalDefinitions = options.signalDefinitions;
4440
+ if (options.intentScoringInstructions !== void 0)
4441
+ params.intentScoringInstructions = options.intentScoringInstructions;
4214
4442
  return this.create({
4215
4443
  messages: [{ role: "user", content: query }],
4216
4444
  specializedAgent: "influencer_engagement",
@@ -4282,6 +4510,10 @@ class ResponsesResource {
4282
4510
  params.maxReactorsPerPost = options.maxReactorsPerPost;
4283
4511
  if (options.maxCommentsPerPost !== void 0)
4284
4512
  params.maxCommentsPerPost = options.maxCommentsPerPost;
4513
+ if (options.signalDefinitions !== void 0)
4514
+ params.signalDefinitions = options.signalDefinitions;
4515
+ if (options.intentScoringInstructions !== void 0)
4516
+ params.intentScoringInstructions = options.intentScoringInstructions;
4285
4517
  request.specializedAgentParams = params;
4286
4518
  return this.create(request);
4287
4519
  }
@@ -4348,6 +4580,10 @@ class ResponsesResource {
4348
4580
  params.maxCompetitors = options.maxCompetitors;
4349
4581
  if (options.thoroughEnrichment !== void 0)
4350
4582
  params.thoroughEnrichment = options.thoroughEnrichment;
4583
+ if (options.signalDefinitions !== void 0)
4584
+ params.signalDefinitions = options.signalDefinitions;
4585
+ if (options.intentScoringInstructions !== void 0)
4586
+ params.intentScoringInstructions = options.intentScoringInstructions;
4351
4587
  request.specializedAgentParams = params;
4352
4588
  return this.create(request);
4353
4589
  }