linkedin-relay-mcp 3.10.1 → 3.11.0

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.
@@ -59,7 +59,7 @@ Out-of-network people come back as `name: "LinkedIn Member"` with a `/headless`
59
59
  LinkedIn behaviour, not a bug — LinkedIn will not name them to this account. Say so rather than
60
60
  presenting it as a data problem.
61
61
 
62
- ### `jobs` — 1 job-search call per 25 results. Job search with every filter.
62
+ ### `jobs` — 1 job-search call per 100 results. Job search with every filter.
63
63
  ```
64
64
  jobs keywords:"<terms>" [location:"<place>" | geoId:"<id>"] [distance:<miles>]
65
65
  [posted:"24h|week|month|<N>h|<N>d"] [experience:[internship|entry|associate|mid-senior|director|executive]]
@@ -71,8 +71,8 @@ jobs keywords:"<terms>" [location:"<place>" | geoId:"<id>"] [distance:<miles>]
71
71
  Each item: `id`, `title`, `company`, `location`, `workplace`, `listed` (YYYY-MM-DD), `easyApply`,
72
72
  `promoted`, `salary` (when the card shows one), `insights`, `url`. `compact` gives one line per job.
73
73
 
74
- - **Rank on the rows, then read the finalists with `job`.** `details` reads *every* row (1 profile
75
- job read each, 60 a day) to add the apply link, applicants and employment type.
74
+ - **Rank on the rows, then read the finalists with `job`.** `details` reads every row in full, 100
75
+ per job read, to add the apply link, applicants and employment type.
76
76
  - **Check `data.location`.** A typed location is resolved by LinkedIn, and the place it chose is
77
77
  reported there. "Vienna, Austria" resolved to one district of Vienna. Pass `geoId` for an exact
78
78
  place; ids are in `job_filters` under `populatedPlace`.
@@ -80,13 +80,16 @@ Each item: `id`, `title`, `company`, `location`, `workplace`, `listed` (YYYY-MM-
80
80
  batch, and `meta.state` is `complete` only when the results ran out. LinkedIn serves at most 1000
81
81
  per search; narrow the query rather than paging deep.
82
82
  - Job hunting has its own budget: 150 job-search calls and 60 job reads a day, apart from the
83
- people and company `search`. That is about ten keyword searches read in full. The same job turns
83
+ people and company `search`. A search call returns 100 jobs, so ten keyword searches of a few
84
+ hundred results each take about 30 calls. The same job turns
84
85
  up under several keywords; merge the lists by `id` before reading any in full.
85
86
 
86
- ### `job` — 1 job read. One job, in full.
87
+ ### `job` — 1 job read per 100 jobs. Jobs, in full.
87
88
  ```
88
- job job:"<id | /jobs/view/ URL | ?currentJobId= URL>"
89
+ job job:"<id | /jobs/view/ URL | ?currentJobId= URL>" or job job:["<id>", "<id>", …]
89
90
  ```
91
+ One id returns the job; a list returns `{items, meta}`, read 100 per call, so pass all your finalists
92
+ at once rather than one call each. `meta.unread` lists ids LinkedIn did not return.
90
93
  `description`, `apply: {type: "external" | "easy-apply", url}`, `company`, `companyUrl`,
91
94
  `location`, `workplace`, `employmentType`, `experienceLevel`, `industries`, `functions`, `listed`,
92
95
  `expires`, `state` (`LISTED` or `CLOSED`), `applicants`, `ats` (the employer's applicant tracking
package/dist/cli.js CHANGED
@@ -2907,7 +2907,8 @@ function contract(name) {
2907
2907
  if (c?.decorationId === void 0) throw new Error(`job contract '${name}' is missing`);
2908
2908
  return { path: c.path, decorationId: c.decorationId };
2909
2909
  }
2910
- var PAGE_SIZE2 = 25;
2910
+ var PAGE_SIZE2 = 100;
2911
+ var BATCH_SIZE = 100;
2911
2912
  function queryTuple(q2) {
2912
2913
  const locationUnion = q2.geoId !== void 0 ? { geoId: q2.geoId } : q2.location !== void 0 ? { seoLocation: { location: q2.location } } : void 0;
2913
2914
  const selected = Object.entries(q2.filters).filter(([, v]) => v.length > 0);
@@ -2931,6 +2932,10 @@ function jobDetailUrl(id) {
2931
2932
  const c = contract("jobPosting");
2932
2933
  return `${c.path}/${id}?decorationId=${c.decorationId}`;
2933
2934
  }
2935
+ function jobBatchUrl(ids) {
2936
+ const c = contract("jobPosting");
2937
+ return `${c.path}?ids=List(${ids.join(",")})&decorationId=${c.decorationId}`;
2938
+ }
2934
2939
  function jobIdOf(input) {
2935
2940
  const s = input.trim();
2936
2941
  if (/^\d+$/.test(s)) return s;
@@ -3039,7 +3044,7 @@ function parseJobCards(json) {
3039
3044
  return { ok: true, jobs, total, start, ...resolvedGeo(included), unknownTypes };
3040
3045
  }
3041
3046
  var WORKPLACE_URN = { "1": "on-site", "2": "remote", "3": "hybrid" };
3042
- function applyOf(method) {
3047
+ function applyOf(method, id) {
3043
3048
  const m = method;
3044
3049
  if (m === null || m === void 0) return void 0;
3045
3050
  const type = String(m.$type ?? "");
@@ -3048,19 +3053,15 @@ function applyOf(method) {
3048
3053
  return defined2({ type: "external", url });
3049
3054
  }
3050
3055
  if (type.endsWith("OnsiteApply")) {
3051
- const url = typeof m.easyApplyUrl === "string" ? m.easyApplyUrl : void 0;
3052
- return defined2({ type: "easy-apply", url });
3056
+ const url = typeof m.easyApplyUrl === "string" ? m.easyApplyUrl : viewUrl(id);
3057
+ return { type: "easy-apply", url };
3053
3058
  }
3054
3059
  return void 0;
3055
3060
  }
3056
- function parseJobDetail(json) {
3057
- const root = json;
3058
- const d = root?.data;
3059
- const rawId = d?.jobPostingId ?? d?.entityUrn;
3061
+ function postingToJob(d, included) {
3062
+ const rawId = d.jobPostingId ?? d.entityUrn;
3060
3063
  const id = rawId === void 0 ? void 0 : jobIdOf(String(rawId));
3061
- if (d === void 0 || id === void 0 || typeof d.title !== "string")
3062
- return drift2("the job response carried no posting");
3063
- const included = root?.included ?? [];
3064
+ if (id === void 0 || typeof d.title !== "string") return void 0;
3064
3065
  const find = (urn) => typeof urn === "string" ? included.find((n) => n.entityUrn === urn) : void 0;
3065
3066
  const details = d.companyDetails ?? {};
3066
3067
  const company = find(details.company ?? details["*companyResolutionResult"]);
@@ -3070,31 +3071,53 @@ function parseJobDetail(json) {
3070
3071
  const applying = find(d["*applyingInfo"]);
3071
3072
  const saving = find(d["*savingInfo"]);
3072
3073
  const list2 = (v) => Array.isArray(v) && v.length > 0 ? v.filter((x) => typeof x === "string") : void 0;
3073
- return {
3074
- ok: true,
3075
- job: defined2({
3076
- id,
3077
- title: d.title,
3078
- company: companyName,
3079
- companyUrl: typeof company?.url === "string" ? company.url : void 0,
3080
- location: typeof d.formattedLocation === "string" ? d.formattedLocation : void 0,
3081
- workplace: workplace ?? (d.workRemoteAllowed === true ? "remote" : void 0),
3082
- employmentType: typeof d.formattedEmploymentStatus === "string" && d.formattedEmploymentStatus !== "" ? d.formattedEmploymentStatus : void 0,
3083
- experienceLevel: typeof d.formattedExperienceLevel === "string" && d.formattedExperienceLevel !== "" ? d.formattedExperienceLevel : void 0,
3084
- industries: list2(d.formattedIndustries),
3085
- functions: list2(d.formattedJobFunctions),
3086
- listed: day(d.listedAt),
3087
- expires: day(d.expireAt),
3088
- state: typeof d.jobState === "string" ? d.jobState : void 0,
3089
- applicants: typeof d.applies === "number" && d.applies > 0 ? d.applies : void 0,
3090
- apply: applyOf(d.applyMethod),
3091
- ats: typeof d.applicantTrackingSystem === "string" ? d.applicantTrackingSystem : void 0,
3092
- applied: typeof applying?.applied === "boolean" ? applying.applied : void 0,
3093
- saved: typeof saving?.saved === "boolean" ? saving.saved : void 0,
3094
- description: text2(d.description),
3095
- url: viewUrl(id)
3096
- })
3097
- };
3074
+ const nonEmpty = (v) => typeof v === "string" && v !== "" ? v : void 0;
3075
+ return defined2({
3076
+ id,
3077
+ title: d.title,
3078
+ company: companyName,
3079
+ companyUrl: typeof company?.url === "string" ? company.url : void 0,
3080
+ location: nonEmpty(d.formattedLocation),
3081
+ workplace: workplace ?? (d.workRemoteAllowed === true ? "remote" : void 0),
3082
+ employmentType: nonEmpty(d.formattedEmploymentStatus),
3083
+ experienceLevel: nonEmpty(d.formattedExperienceLevel),
3084
+ industries: list2(d.formattedIndustries),
3085
+ functions: list2(d.formattedJobFunctions),
3086
+ listed: day(d.listedAt),
3087
+ expires: day(d.expireAt),
3088
+ state: nonEmpty(d.jobState),
3089
+ applicants: typeof d.applies === "number" && d.applies > 0 ? d.applies : void 0,
3090
+ apply: applyOf(d.applyMethod, id),
3091
+ ats: nonEmpty(d.applicantTrackingSystem),
3092
+ applied: typeof applying?.applied === "boolean" ? applying.applied : void 0,
3093
+ saved: typeof saving?.saved === "boolean" ? saving.saved : void 0,
3094
+ description: text2(d.description),
3095
+ url: viewUrl(id)
3096
+ });
3097
+ }
3098
+ function parseJobDetail(json) {
3099
+ const root = json;
3100
+ const job = root?.data === void 0 ? void 0 : postingToJob(root.data, root.included ?? []);
3101
+ return job === void 0 ? drift2("the job response carried no posting") : { ok: true, job };
3102
+ }
3103
+ function parseJobBatch(json) {
3104
+ const root = json;
3105
+ const results = root?.data?.results;
3106
+ if (results === null || typeof results !== "object")
3107
+ return drift2("the batch job response carried no results");
3108
+ const included = root?.included ?? [];
3109
+ const byUrn = new Map(included.map((n) => [n.entityUrn, n]));
3110
+ const jobs = [];
3111
+ for (const ref of Object.values(results)) {
3112
+ const node = typeof ref === "string" ? byUrn.get(ref) : ref;
3113
+ const job = node === void 0 ? void 0 : postingToJob(node, included);
3114
+ if (job !== void 0) jobs.push(job);
3115
+ }
3116
+ const claimed = Object.keys(results).length;
3117
+ if (claimed > 0 && jobs.length === 0)
3118
+ return drift2(`the batch listed ${claimed} jobs but none could be read`);
3119
+ const errors = root?.data?.errors ?? {};
3120
+ return { ok: true, jobs, missing: Object.keys(errors).map((k) => k.replace(/^\*/, "")) };
3098
3121
  }
3099
3122
  function parseJobFilters(json) {
3100
3123
  const elements = json?.data?.elements;
@@ -3295,15 +3318,29 @@ async function collect(get, query, first, want) {
3295
3318
  }
3296
3319
  return out;
3297
3320
  }
3298
- async function addDetails(get, jobs, withDescription) {
3299
- for (const job of jobs) {
3300
- const res = await get(jobDetailUrl(job.id), "jobRead");
3301
- const detail = res.ok ? parseJobDetail(res.json) : res;
3302
- if (!detail.ok) return detail.code;
3303
- const { description, id: _id, url: _url, ...rest } = detail.job;
3304
- Object.assign(job, rest, withDescription ? { description } : {});
3321
+ async function readJobs(get, ids) {
3322
+ const jobs = /* @__PURE__ */ new Map();
3323
+ for (let at = 0; at < ids.length; at += BATCH_SIZE) {
3324
+ const res = await get(jobBatchUrl(ids.slice(at, at + BATCH_SIZE)), "jobRead");
3325
+ const batch = res.ok ? parseJobBatch(res.json) : res;
3326
+ if (!batch.ok) return { jobs, stoppedBy: batch.code };
3327
+ for (const job of batch.jobs) if (ids.includes(job.id)) jobs.set(job.id, job);
3305
3328
  }
3306
- return void 0;
3329
+ return { jobs };
3330
+ }
3331
+ async function addDetails(get, rows, withDescription) {
3332
+ const read = await readJobs(
3333
+ get,
3334
+ rows.map((r) => r.id)
3335
+ );
3336
+ for (const row of rows) {
3337
+ const detail = read.jobs.get(row.id);
3338
+ if (detail === void 0) continue;
3339
+ const { description, id: _id, url: _url, ...rest } = detail;
3340
+ Object.assign(row, rest, withDescription ? { description } : {});
3341
+ }
3342
+ const unread = rows.filter((r) => !read.jobs.has(r.id)).length;
3343
+ return read.stoppedBy === void 0 ? { unread } : { unread, stoppedBy: read.stoppedBy };
3307
3344
  }
3308
3345
  async function runJobs(req, opts = {}, fetch2) {
3309
3346
  const hasQuery = [req.keywords, req.location, req.geoId].some((v) => v !== void 0 && v !== "");
@@ -3325,9 +3362,11 @@ async function runJobs(req, opts = {}, fetch2) {
3325
3362
  const query = queryOf(req, selection2.filters);
3326
3363
  const found = await collect(get, query, first, want);
3327
3364
  if ("ok" in found) return err("jobs", found.code, found.message, found.hint);
3365
+ let unread = 0;
3328
3366
  if (req.details === true) {
3329
- const stopped = await addDetails(get, found.jobs, req.description === true);
3330
- found.stoppedBy = found.stoppedBy ?? stopped;
3367
+ const added = await addDetails(get, found.jobs, req.description === true);
3368
+ found.stoppedBy = found.stoppedBy ?? added.stoppedBy;
3369
+ unread = added.unread;
3331
3370
  }
3332
3371
  const { jobs, stoppedBy, exhausted, unknownTypes } = found;
3333
3372
  return ok("jobs", {
@@ -3335,29 +3374,59 @@ async function runJobs(req, opts = {}, fetch2) {
3335
3374
  ...found.resolved !== void 0 ? { location: found.resolved } : {},
3336
3375
  items: shape(jobs, opts, compactJob),
3337
3376
  meta: {
3338
- state: stoppedBy === void 0 && exhausted ? "complete" : "partial",
3377
+ state: stoppedBy === void 0 && exhausted && unread === 0 ? "complete" : "partial",
3339
3378
  operation: "jobs",
3340
3379
  claimedCount: found.total,
3341
3380
  returnedCount: jobs.length,
3342
3381
  start: first,
3343
3382
  next: exhausted ? void 0 : first + jobs.length,
3344
3383
  ...stoppedBy !== void 0 ? { stoppedBy } : {},
3384
+ ...unread > 0 ? { unread } : {},
3345
3385
  ...Object.keys(unknownTypes).length > 0 ? { unknownTypes } : {}
3346
3386
  }
3347
3387
  });
3348
3388
  }
3349
3389
  async function runJob(input, opts = {}, fetch2) {
3350
- const id = input === void 0 ? void 0 : jobIdOf(input);
3351
- if (id === void 0) {
3352
- return err("job", "INVALID_INPUT", "a job id or job URL is required", "lnrelay job <id|url>");
3390
+ const given = input === void 0 ? [] : Array.isArray(input) ? input : [input];
3391
+ const ids = [...new Set(given.map(jobIdOf))];
3392
+ if (ids.length === 0 || ids.some((id) => id === void 0)) {
3393
+ const bad = given.filter((g) => jobIdOf(g) === void 0);
3394
+ return err(
3395
+ "job",
3396
+ "INVALID_INPUT",
3397
+ bad.length > 0 ? `not a job id or URL: ${bad.join(", ")}` : "a job id or job URL is required",
3398
+ "lnrelay job <id|url> [<id|url> ...]"
3399
+ );
3353
3400
  }
3354
3401
  const get = fetch2 ?? liveFetch("job", opts.quiet === true);
3355
3402
  if (typeof get !== "function") return get;
3356
- const res = await get(jobDetailUrl(id), "jobRead");
3357
- if (!res.ok) return err("job", res.code, res.message, res.hint);
3358
- const detail = parseJobDetail(res.json);
3359
- if (!detail.ok) return err("job", detail.code, detail.message, detail.hint);
3360
- return ok("job", detail.job);
3403
+ const wanted = ids;
3404
+ if (wanted.length === 1) {
3405
+ const res = await get(jobDetailUrl(wanted[0]), "jobRead");
3406
+ if (!res.ok) return err("job", res.code, res.message, res.hint);
3407
+ const detail = parseJobDetail(res.json);
3408
+ if (!detail.ok) return err("job", detail.code, detail.message, detail.hint);
3409
+ return ok("job", detail.job);
3410
+ }
3411
+ const read = await readJobs(get, wanted);
3412
+ if (read.jobs.size === 0 && read.stoppedBy !== void 0)
3413
+ return err("job", read.stoppedBy, "no job could be read");
3414
+ const unread = wanted.filter((id) => !read.jobs.has(id));
3415
+ const jobs = wanted.flatMap((id) => read.jobs.get(id) ?? []);
3416
+ return ok("job", {
3417
+ items: shape(
3418
+ jobs,
3419
+ opts,
3420
+ (j) => compactJob({ ...j, easyApply: j.apply?.type === "easy-apply", promoted: false })
3421
+ ),
3422
+ meta: {
3423
+ state: unread.length === 0 ? "complete" : "partial",
3424
+ operation: "job",
3425
+ returnedCount: jobs.length,
3426
+ ...unread.length > 0 ? { unread } : {},
3427
+ ...read.stoppedBy !== void 0 ? { stoppedBy: read.stoppedBy } : {}
3428
+ }
3429
+ });
3361
3430
  }
3362
3431
  async function runJobFilters(req, opts = {}, fetch2) {
3363
3432
  const selection2 = jobFilterSelection(req.filter ?? {});
@@ -4049,7 +4118,7 @@ var COMMANDS = [
4049
4118
  },
4050
4119
  {
4051
4120
  name: "jobs",
4052
- cost: "1 job-search call per 25 jobs; --details adds 1 job read per job",
4121
+ cost: "1 job-search call per 100 jobs; --details adds 1 job read per 100 jobs",
4053
4122
  summary: "Job search with every filter the jobs page has. Cards carry id, title, company, place, workplace, listed date, Easy Apply. Read finalists with `job`.",
4054
4123
  usage: 'lnrelay jobs "<keywords>" [--location "<place>" | --geo <id>] [--distance <miles>]\n [--posted 24h|week|month|<N>h|<N>d] [--experience internship,entry,associate,\n mid-senior,director,executive] [--type full-time,part-time,contract,temporary,\n volunteer,internship,other] [--workplace on-site,remote,hybrid] [--easy-apply]\n [--under-10] [--verified] [--in-network] [--fair-chance] [--company <ids>]\n [--industry <ids>] [--function <codes>] [--title <ids>] [--place <geo-ids>]\n [--filter key=v1,v2 ...] [--sort recent|relevant] [--limit N] [--start N]\n [--details [--description]] [--compact | --fields a,b,c]\n Ids for --company/--industry/--title/--place/--filter come from `job-filters`.\n The resolved place is in data.location: check it, "Vienna" may resolve narrow.',
4055
4124
  audience: ["cli", "mcp"],
@@ -4058,9 +4127,9 @@ var COMMANDS = [
4058
4127
  },
4059
4128
  {
4060
4129
  name: "job",
4061
- cost: "1 job read",
4062
- summary: "One job: description, apply link (external or Easy Apply), applicants, state.",
4063
- usage: "lnrelay job <id|job-url>",
4130
+ cost: "1 job read per 100 jobs",
4131
+ summary: "Jobs in full: description, apply link (external or Easy Apply), applicants, state. Several ids are read together, 100 a call.",
4132
+ usage: "lnrelay job <id|job-url> [<id|job-url> ...] [--compact | --fields a,b,c]",
4064
4133
  audience: ["cli", "mcp"],
4065
4134
  risk: "read",
4066
4135
  implemented: true
@@ -6731,7 +6800,7 @@ async function dispatch(argv, now) {
6731
6800
  case "jobs":
6732
6801
  return runJobs(jobsRequest(args), output(args));
6733
6802
  case "job":
6734
- return runJob(args.positionals[0], output(args));
6803
+ return runJob(args.positionals, output(args));
6735
6804
  case "job-filters":
6736
6805
  return runJobFilters(jobsRequest(args), output(args));
6737
6806
  case "search":