linkedin-relay-mcp 3.8.0 → 3.9.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.
@@ -143,6 +143,12 @@ experience
143
143
  Each role on their profile with its `positionId` and title. The id is what `lnrelay role edit` and
144
144
  `lnrelay role remove` take.
145
145
 
146
+ ### `skills` — live, ~3 calls. The user's skills.
147
+ ```
148
+ skills
149
+ ```
150
+ Each skill on their profile with its `skillId` and name. The id is what `lnrelay skill remove` takes.
151
+
146
152
  ### `sync` — CLI-only. Fills the cache.
147
153
  ```
148
154
  lnrelay sync my-posts | lnrelay sync connections [--limit N] [--force]
@@ -212,6 +218,7 @@ Writes are **not on the MCP surface**. They exist only as CLI commands:
212
218
  | `lnrelay edit headline\|about ("<text>" \| --file <path>)` | change their profile headline (max 220 characters) or About section |
213
219
  | `lnrelay role add --title "…" --company "…" --start YYYY-MM [--end YYYY-MM \| --current] [--location "…"] [--description "…" \| --description-file <path>] [--notify]` | add a role to their Experience |
214
220
  | `lnrelay role edit <position-id> [the same flags]` / `lnrelay role remove <position-id>` | change or remove one of their roles (ids from `experience`) |
221
+ | `lnrelay skill add "<name>"` / `lnrelay skill remove <skill-id>` | add a skill (free text, linked to nothing) or remove one (ids from `skills`); removing drops its endorsements |
215
222
  | `lnrelay react <urn> [--type X] [--remove]` | react to a post or comment |
216
223
  | `lnrelay delete <activity-urn \| comment-urn>` | delete their post or comment |
217
224
 
package/dist/cli.js CHANGED
@@ -3618,6 +3618,15 @@ var COMMANDS = [
3618
3618
  risk: "read",
3619
3619
  implemented: true
3620
3620
  },
3621
+ {
3622
+ name: "skills",
3623
+ cost: "3 calls",
3624
+ summary: "The skills on your own profile, with the skill id `skill remove` takes.",
3625
+ usage: "lnrelay skills",
3626
+ audience: ["cli", "mcp"],
3627
+ risk: "read",
3628
+ implemented: true
3629
+ },
3621
3630
  {
3622
3631
  name: "local",
3623
3632
  cost: "free \u2014 local cache",
@@ -3718,6 +3727,15 @@ var COMMANDS = [
3718
3727
  risk: "write",
3719
3728
  implemented: true
3720
3729
  },
3730
+ {
3731
+ name: "skill",
3732
+ cost: "4-5 reads + 1 write",
3733
+ summary: "Add a skill to your profile, or remove one.",
3734
+ usage: 'lnrelay skill add "<name>"\n lnrelay skill remove <skill-id>\n Skill ids come from `lnrelay skills`. A skill is added as free text, linked to no role,\n school or project. Removing a skill removes its endorsements with it.',
3735
+ audience: ["cli"],
3736
+ risk: "write",
3737
+ implemented: true
3738
+ },
3721
3739
  {
3722
3740
  name: "react",
3723
3741
  cost: "1 call \u2014 write",
@@ -5459,16 +5477,16 @@ async function runRole(sub, target, req, now = Date.now(), deps = terminalDeps()
5459
5477
  const roles = surface ?? liveRoles(ctx.transport.session);
5460
5478
  const me = await roles.vanity();
5461
5479
  if (!me.ok) return err("role", me.code, me.message, me.hint);
5462
- const listed = await roles.list(me.vanity);
5463
- if (!listed.ok) return err("role", listed.code, listed.message, listed.hint);
5464
- if (sub === "add") return addRole(changes, me.vanity, listed.positions, roles, ctx, deps);
5465
- const position = listed.positions.find((p) => p.positionId === target);
5480
+ const listed2 = await roles.list(me.vanity);
5481
+ if (!listed2.ok) return err("role", listed2.code, listed2.message, listed2.hint);
5482
+ if (sub === "add") return addRole(changes, me.vanity, listed2.positions, roles, ctx, deps);
5483
+ const position = listed2.positions.find((p) => p.positionId === target);
5466
5484
  if (position === void 0) {
5467
5485
  return err(
5468
5486
  "role",
5469
5487
  "NOT_FOUND",
5470
5488
  `no role ${target} on your profile`,
5471
- `your roles: ${listed.positions.map((p) => `${p.positionId} (${p.title})`).join(", ") || "none"}`
5489
+ `your roles: ${listed2.positions.map((p) => `${p.positionId} (${p.title})`).join(", ") || "none"}`
5472
5490
  );
5473
5491
  }
5474
5492
  const form = await roles.open({ ...position.payload, vanityName: me.vanity }, true);
@@ -5569,11 +5587,289 @@ async function runExperience(quiet = false) {
5569
5587
  const roles = liveRoles(session.session, quiet);
5570
5588
  const me = await roles.vanity();
5571
5589
  if (!me.ok) return err("experience", me.code, me.message, me.hint);
5572
- const listed = await roles.list(me.vanity);
5573
- if (!listed.ok) return err("experience", listed.code, listed.message, listed.hint);
5590
+ const listed2 = await roles.list(me.vanity);
5591
+ if (!listed2.ok) return err("experience", listed2.code, listed2.message, listed2.hint);
5574
5592
  return ok("experience", {
5575
- items: listed.positions.map((p) => ({ positionId: p.positionId, title: p.title })),
5576
- meta: { state: "complete", returnedCount: listed.positions.length }
5593
+ items: listed2.positions.map((p) => ({ positionId: p.positionId, title: p.title })),
5594
+ meta: { state: "complete", returnedCount: listed2.positions.length }
5595
+ });
5596
+ }
5597
+
5598
+ // src/engine/sdui-skill.ts
5599
+ var SKILL = {
5600
+ addScreen: "com.linkedin.sdui.flagshipnav.profile.ProfileSkillAddForm",
5601
+ editScreen: "com.linkedin.sdui.flagshipnav.profile.ProfileSkillDetailsEditForm",
5602
+ listScreen: "com.linkedin.sdui.flagshipnav.profile.ProfileSkillDetails",
5603
+ pager: "com.linkedin.sdui.pagers.profile.details.skills",
5604
+ save: "com.linkedin.sdui.requests.profile.saveProfileSkillForm",
5605
+ delete: "com.linkedin.sdui.requests.profile.deleteProfileSkillForm"
5606
+ };
5607
+ var EDIT_NAV2 = `{"$type":"proto.sdui.actions.core.NavigateToScreen","screenId":"${SKILL.editScreen}"`;
5608
+ var TEXT2 = /"children":\["((?:[^"\\]|\\.)*)"\]/g;
5609
+ function skillsFromPage(stream) {
5610
+ if (!stream.includes(SKILL.pager) && !stream.includes(EDIT_NAV2) && !stream.includes("isPartialPage")) {
5611
+ return drift2("the skills page could not be read");
5612
+ }
5613
+ const skills = [];
5614
+ let from = 0;
5615
+ let i = 0;
5616
+ for (; ; ) {
5617
+ i = stream.indexOf(EDIT_NAV2, i);
5618
+ if (i === -1) break;
5619
+ const text2 = balanced(stream, i);
5620
+ const end = i;
5621
+ i += EDIT_NAV2.length;
5622
+ if (text2 === null) continue;
5623
+ const payload = JSON.parse(text2).requestedArguments?.payload;
5624
+ const id = payload?.skillId;
5625
+ if (typeof id !== "string" || payload === void 0 || skills.some((s) => s.skillId === id))
5626
+ continue;
5627
+ const names = [...stream.slice(from, end).matchAll(TEXT2)].map(
5628
+ (m) => JSON.parse(`"${m[1]}"`)
5629
+ );
5630
+ skills.push({ skillId: id, name: names.length === 1 ? names[0] ?? null : null, payload });
5631
+ from = end + text2.length;
5632
+ }
5633
+ return { ok: true, skills };
5634
+ }
5635
+ function pagerFrom(payload, start) {
5636
+ const args = {
5637
+ $type: "proto.sdui.actions.requests.RequestedArguments",
5638
+ requestedStateKeys: [],
5639
+ payload: { ...payload, start },
5640
+ requestMetadata: { $type: "proto.sdui.common.RequestMetadata" }
5641
+ };
5642
+ return {
5643
+ pagerId: SKILL.pager,
5644
+ clientArguments: { ...args, states: [], screenId: SKILL.listScreen, knownTemplateIds: [] },
5645
+ paginationRequest: {
5646
+ $type: "proto.sdui.actions.requests.PaginationRequest",
5647
+ pagerId: SKILL.pager,
5648
+ retryCount: 0,
5649
+ requestedArguments: args
5650
+ }
5651
+ };
5652
+ }
5653
+ function readSkillForm(stream) {
5654
+ const model = readModel(stream);
5655
+ if (model === null) return drift2("the skill form carried no initial values");
5656
+ const save = findRequest(stream, SKILL.save);
5657
+ const del = findRequest(stream, SKILL.delete);
5658
+ if (save === null && del === null)
5659
+ return drift2("the skill form carried neither a save nor a delete");
5660
+ return { ok: true, model, save, del, screen: del === null ? SKILL.addScreen : SKILL.editScreen };
5661
+ }
5662
+ var nameKey = (model) => [...model.keys()].find((k) => k.startsWith("addSkillsTypeaheadSkillName"));
5663
+ function skillNameOf(form) {
5664
+ const key = nameKey(form.model);
5665
+ const v = key === void 0 ? void 0 : form.model.get(key)?.value;
5666
+ return typeof v === "string" ? v : null;
5667
+ }
5668
+ function addSkillBody(form, name) {
5669
+ if (name.trim() === "")
5670
+ return { ok: false, code: "INVALID_INPUT", message: "a skill needs a name" };
5671
+ if (form.save === null) return drift2("this form has no save action (it is not the add form)");
5672
+ const key = nameKey(form.model);
5673
+ const current = key === void 0 ? void 0 : form.model.get(key);
5674
+ if (key === void 0 || current === void 0) return drift2("the skill form has no name field");
5675
+ const model = new Map(form.model);
5676
+ model.set(key, { ...current, value: name.trim() });
5677
+ const states2 = wireStates(keysOf(form.save), model, () => void 0);
5678
+ if (!Array.isArray(states2)) return states2;
5679
+ return { ok: true, body: requestBody(SKILL.save, form.save, states2, form.screen) };
5680
+ }
5681
+ function removeSkillBody(form) {
5682
+ if (form.del === null)
5683
+ return drift2("this form has no delete action (it is not an existing skill)");
5684
+ const states2 = wireStates(keysOf(form.del), form.model, () => void 0);
5685
+ if (!Array.isArray(states2)) return states2;
5686
+ return { ok: true, body: requestBody(SKILL.delete, form.del, states2, form.screen) };
5687
+ }
5688
+ var PAGER_URL2 = `https://www.linkedin.com/flagship-web/rsc-action/actions/pagination?sduiid=${SKILL.pager}`;
5689
+ var MAX_PAGES2 = 10;
5690
+ async function fetchSkills(vanityName, client) {
5691
+ const screen = await openForm(
5692
+ SKILL.listScreen,
5693
+ { vanityName, isVanityNameResolved: true },
5694
+ client,
5695
+ "skills-screen"
5696
+ );
5697
+ if (typeof screen !== "string") return screen;
5698
+ const at = screen.indexOf('"filter":"ProfileSkillCategory_ALL"');
5699
+ const open = at === -1 ? -1 : screen.lastIndexOf('"payload":{', at);
5700
+ const text2 = open === -1 ? null : balanced(screen, open + '"payload":'.length);
5701
+ if (text2 === null) return drift2("the Skills screen carried no list request");
5702
+ const payload = JSON.parse(text2);
5703
+ const count2 = typeof payload.count === "number" ? payload.count : 10;
5704
+ const skills = [];
5705
+ for (let page = 0; page < MAX_PAGES2; page++) {
5706
+ const result = await client.request({
5707
+ url: PAGER_URL2,
5708
+ method: "POST",
5709
+ body: pagerFrom(payload, skills.length),
5710
+ spendClass: "page",
5711
+ operation: "skills"
5712
+ });
5713
+ if (!result.ok) return { ok: false, code: result.code, message: result.message };
5714
+ const parsed = skillsFromPage(result.classification.raw ?? "");
5715
+ if (!parsed.ok) return parsed;
5716
+ const fresh = parsed.skills.filter((s) => !skills.some((k) => k.skillId === s.skillId));
5717
+ skills.push(...fresh);
5718
+ if (parsed.skills.length < count2 || fresh.length === 0) break;
5719
+ }
5720
+ return { ok: true, skills };
5721
+ }
5722
+ async function openSkillForm(payload, client, edit2) {
5723
+ const stream = await openForm(
5724
+ edit2 ? SKILL.editScreen : SKILL.addScreen,
5725
+ { ...payload, isVanityNameResolved: true },
5726
+ client,
5727
+ edit2 ? "skill-edit-form" : "skill-add-form"
5728
+ );
5729
+ return typeof stream === "string" ? readSkillForm(stream) : stream;
5730
+ }
5731
+ async function sendSkill(body, requestId, client) {
5732
+ const sent = await sendAction(
5733
+ requestId,
5734
+ body,
5735
+ client,
5736
+ requestId === SKILL.save ? "skill-add" : "skill-remove"
5737
+ );
5738
+ return typeof sent === "string" ? { ok: true } : sent;
5739
+ }
5740
+
5741
+ // src/commands/skill.ts
5742
+ function liveSkills(session, quiet = false) {
5743
+ const client = createLiveClient(session, void 0, quiet);
5744
+ return {
5745
+ vanity: async () => {
5746
+ const me = await createEngine(session, void 0, quiet).whoami();
5747
+ if (!me.ok) return me;
5748
+ const id = me.value?.publicIdentifier;
5749
+ return typeof id === "string" && id !== "" ? { ok: true, vanity: id } : { ok: false, code: "SCHEMA_DRIFT", message: "whoami returned no public profile id" };
5750
+ },
5751
+ list: (vanity) => fetchSkills(vanity, client),
5752
+ open: (payload, edit2) => openSkillForm(payload, client, edit2),
5753
+ send: (body, requestId) => sendSkill(body, requestId, client)
5754
+ };
5755
+ }
5756
+ var listed = (skills) => skills.map((s) => `${s.skillId} (${s.name ?? "?"})`).join(", ") || "none";
5757
+ async function runSkill(sub, arg, now = Date.now(), deps = terminalDeps(), surface) {
5758
+ if (sub !== "add" && sub !== "remove") {
5759
+ return err(
5760
+ "skill",
5761
+ "INVALID_INPUT",
5762
+ `unknown skill subcommand '${sub ?? ""}'`,
5763
+ 'lnrelay skill add "<name>" | lnrelay skill remove <skill-id>'
5764
+ );
5765
+ }
5766
+ if (arg === void 0 || arg.trim() === "") {
5767
+ return err(
5768
+ "skill",
5769
+ "INVALID_INPUT",
5770
+ sub === "add" ? "the skill name is required" : "the skill id is required",
5771
+ "ids come from `lnrelay skills`"
5772
+ );
5773
+ }
5774
+ const unapprovable = refuseUnapprovable("skill", "changing your skills", deps);
5775
+ if (unapprovable !== null) return unapprovable;
5776
+ const ctx = prepare("skill", now, "voyager");
5777
+ if ("ok" in ctx) return ctx;
5778
+ if (ctx.transport.kind !== "voyager")
5779
+ return err("skill", "NOT_IMPLEMENTED", "skill changes go over the browser session only");
5780
+ const skills = surface ?? liveSkills(ctx.transport.session);
5781
+ const me = await skills.vanity();
5782
+ if (!me.ok) return err("skill", me.code, me.message, me.hint);
5783
+ const before = await skills.list(me.vanity);
5784
+ if (!before.ok) return err("skill", before.code, before.message, before.hint);
5785
+ return sub === "add" ? addSkill(arg.trim(), before.skills, me.vanity, skills, ctx, deps) : removeSkill(arg, before.skills, me.vanity, skills, ctx, deps);
5786
+ }
5787
+ async function addSkill(name, current, vanity, skills, ctx, deps) {
5788
+ const dup = current.find((s) => s.name?.toLowerCase() === name.toLowerCase());
5789
+ if (dup !== void 0)
5790
+ return err(
5791
+ "skill",
5792
+ "INVALID_INPUT",
5793
+ `"${dup.name}" is already on your profile (${dup.skillId})`
5794
+ );
5795
+ const form = await skills.open({ vanityName: vanity }, false);
5796
+ if (!form.ok) return err("skill", form.code, form.message, form.hint);
5797
+ const body = addSkillBody(form, name);
5798
+ if (!body.ok) return err("skill", body.code, body.message, body.hint);
5799
+ const plan = {
5800
+ action: "add a skill to your profile",
5801
+ payload: { name },
5802
+ summary: [
5803
+ authorLine(ctx.transport),
5804
+ `skill "${name}"`,
5805
+ "linked to nothing (no roles, schools or projects)"
5806
+ ],
5807
+ reversibility: "removable with `lnrelay skill remove <skill-id>`",
5808
+ transport: "voyager"
5809
+ };
5810
+ const gated = await gate("skill", plan, ctx, deps);
5811
+ if ("ok" in gated) return gated;
5812
+ const sent = await skills.send(body.body, SKILL.save);
5813
+ if (!sent.ok) return err("skill", sent.code, sent.message, sent.hint);
5814
+ const after = await skills.list(vanity);
5815
+ const known = new Set(current.map((s) => s.skillId));
5816
+ const added = after.ok ? after.skills.find((s) => !known.has(s.skillId)) : void 0;
5817
+ if (added === void 0)
5818
+ return err(
5819
+ "skill",
5820
+ "SCHEMA_DRIFT",
5821
+ "LinkedIn accepted the skill, but it does not appear on your profile"
5822
+ );
5823
+ return ok("skill", { added: added.skillId, name: added.name, verified: true });
5824
+ }
5825
+ async function removeSkill(arg, current, vanity, skills, ctx, deps) {
5826
+ const target = current.find((s) => s.skillId === arg);
5827
+ if (target === void 0)
5828
+ return err(
5829
+ "skill",
5830
+ "NOT_FOUND",
5831
+ `no skill ${arg} on your profile`,
5832
+ `your skills: ${listed(current)}`
5833
+ );
5834
+ const form = await skills.open({ ...target.payload, vanityName: vanity }, true);
5835
+ if (!form.ok) return err("skill", form.code, form.message, form.hint);
5836
+ const body = removeSkillBody(form);
5837
+ if (!body.ok) return err("skill", body.code, body.message, body.hint);
5838
+ const name = skillNameOf(form) ?? target.name ?? "?";
5839
+ const plan = {
5840
+ action: "remove a skill from your profile",
5841
+ payload: { skillId: target.skillId, name },
5842
+ summary: [authorLine(ctx.transport), `skill "${name}" (${target.skillId})`],
5843
+ reversibility: "NONE for its endorsements, which go with it; the skill itself can be added again",
5844
+ transport: "voyager"
5845
+ };
5846
+ const gated = await gate("skill", plan, ctx, deps);
5847
+ if ("ok" in gated) return gated;
5848
+ const sent = await skills.send(body.body, SKILL.delete);
5849
+ if (!sent.ok) return err("skill", sent.code, sent.message, sent.hint);
5850
+ const after = await skills.list(vanity);
5851
+ if (!after.ok || after.skills.some((s) => s.skillId === target.skillId)) {
5852
+ return err(
5853
+ "skill",
5854
+ "SCHEMA_DRIFT",
5855
+ "LinkedIn accepted the removal, but the skill is still listed"
5856
+ );
5857
+ }
5858
+ return ok("skill", { removed: target.skillId, verified: true });
5859
+ }
5860
+ async function runSkills(quiet = false) {
5861
+ const session = loadSession();
5862
+ if (session.state !== "ok")
5863
+ return err("skills", "AUTH_FAILED", "no LinkedIn session \u2014 run `lnrelay login`");
5864
+ const skills = liveSkills(session.session, quiet);
5865
+ const me = await skills.vanity();
5866
+ if (!me.ok) return err("skills", me.code, me.message, me.hint);
5867
+ const listedSkills = await skills.list(me.vanity);
5868
+ if (!listedSkills.ok)
5869
+ return err("skills", listedSkills.code, listedSkills.message, listedSkills.hint);
5870
+ return ok("skills", {
5871
+ items: listedSkills.skills.map((s) => ({ skillId: s.skillId, name: s.name })),
5872
+ meta: { state: "complete", returnedCount: listedSkills.skills.length }
5577
5873
  });
5578
5874
  }
5579
5875
 
@@ -5826,6 +6122,8 @@ async function dispatch(argv, now) {
5826
6122
  );
5827
6123
  case "experience":
5828
6124
  return runExperience(bool(args, "quiet"));
6125
+ case "skills":
6126
+ return runSkills(bool(args, "quiet"));
5829
6127
  case "scheduled":
5830
6128
  return runScheduled(bool(args, "quiet"));
5831
6129
  case "sync":
@@ -5960,6 +6258,8 @@ function runWrite(command, args, now, deps) {
5960
6258
  return runDelete(first, now, deps, bool(args, "quiet"));
5961
6259
  case "role":
5962
6260
  return role(args, now, deps);
6261
+ case "skill":
6262
+ return runSkill(first, second, now, deps);
5963
6263
  default:
5964
6264
  return err(command, "NOT_IMPLEMENTED", `'${command}' has no write runner`);
5965
6265
  }