linkedin-relay-mcp 3.7.0 → 3.8.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.
- package/.claude/skills/linkedin-relay/SKILL.md +12 -0
- package/dist/cli.js +933 -351
- package/dist/cli.js.map +1 -1
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp-shim.js +485 -2
- package/dist/mcp-shim.js.map +1 -1
- package/package.json +1 -1
package/dist/mcp-shim.js
CHANGED
|
@@ -2055,6 +2055,15 @@ var COMMANDS = [
|
|
|
2055
2055
|
risk: "read",
|
|
2056
2056
|
implemented: true
|
|
2057
2057
|
},
|
|
2058
|
+
{
|
|
2059
|
+
name: "experience",
|
|
2060
|
+
cost: "2 calls",
|
|
2061
|
+
summary: "The roles on your own profile, with the position id `role edit|remove` takes.",
|
|
2062
|
+
usage: "lnrelay experience",
|
|
2063
|
+
audience: ["cli", "mcp"],
|
|
2064
|
+
risk: "read",
|
|
2065
|
+
implemented: true
|
|
2066
|
+
},
|
|
2058
2067
|
{
|
|
2059
2068
|
name: "local",
|
|
2060
2069
|
cost: "free \u2014 local cache",
|
|
@@ -2146,6 +2155,15 @@ var COMMANDS = [
|
|
|
2146
2155
|
risk: "write",
|
|
2147
2156
|
implemented: true
|
|
2148
2157
|
},
|
|
2158
|
+
{
|
|
2159
|
+
name: "role",
|
|
2160
|
+
cost: "3-4 reads + 1 write",
|
|
2161
|
+
summary: "Add, edit or remove a role in your Experience. Never rewrites your headline; notify network is off unless --notify.",
|
|
2162
|
+
usage: 'lnrelay role add --title "<t>" --company "<c>" --start YYYY-MM [--end YYYY-MM | --current]\n [--location "<l>"] [--description "<d>" | --description-file <path>] [--notify]\n lnrelay role edit <position-id> [any of the flags above]\n lnrelay role remove <position-id>\n Position ids come from `lnrelay experience`. The preview shows the role as it is and\n as it will be; the result is read back from the profile. A role with media attached\n is refused. The company is free text (not linked to a company page).',
|
|
2163
|
+
audience: ["cli"],
|
|
2164
|
+
risk: "write",
|
|
2165
|
+
implemented: true
|
|
2166
|
+
},
|
|
2149
2167
|
{
|
|
2150
2168
|
name: "react",
|
|
2151
2169
|
cost: "1 call \u2014 write",
|
|
@@ -2161,9 +2179,468 @@ function mcpCommands() {
|
|
|
2161
2179
|
return COMMANDS.filter((c) => c.audience.includes("mcp") && c.risk !== "write");
|
|
2162
2180
|
}
|
|
2163
2181
|
|
|
2182
|
+
// src/engine/sdui-form.ts
|
|
2183
|
+
function balanced(s, start) {
|
|
2184
|
+
const open = s[start];
|
|
2185
|
+
const close = open === "[" ? "]" : "}";
|
|
2186
|
+
let depth = 0;
|
|
2187
|
+
let inString = false;
|
|
2188
|
+
let escaped = false;
|
|
2189
|
+
for (let i = start; i < s.length; i++) {
|
|
2190
|
+
const ch = s[i];
|
|
2191
|
+
if (escaped) escaped = false;
|
|
2192
|
+
else if (ch === "\\") escaped = true;
|
|
2193
|
+
else if (ch === '"') inString = !inString;
|
|
2194
|
+
else if (!inString && ch === open) depth++;
|
|
2195
|
+
else if (!inString && ch === close) {
|
|
2196
|
+
depth--;
|
|
2197
|
+
if (depth === 0) return s.slice(start, i + 1);
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
return null;
|
|
2201
|
+
}
|
|
2202
|
+
function parseAt(s, start) {
|
|
2203
|
+
const text2 = start < 0 ? null : balanced(s, start);
|
|
2204
|
+
if (text2 === null) return null;
|
|
2205
|
+
try {
|
|
2206
|
+
return JSON.parse(text2);
|
|
2207
|
+
} catch {
|
|
2208
|
+
return null;
|
|
2209
|
+
}
|
|
2210
|
+
}
|
|
2211
|
+
function plain(v) {
|
|
2212
|
+
const protoCase = String(v.$case);
|
|
2213
|
+
const raw = v[protoCase];
|
|
2214
|
+
if (protoCase === "stringListValue") {
|
|
2215
|
+
return { protoCase, value: raw?.stringValues ?? [] };
|
|
2216
|
+
}
|
|
2217
|
+
if (protoCase === "signedLongValue" && typeof raw === "string" && raw.startsWith("$n")) {
|
|
2218
|
+
return { protoCase, value: { type: "bigint", value: raw.slice(2) } };
|
|
2219
|
+
}
|
|
2220
|
+
return { protoCase, value: raw };
|
|
2221
|
+
}
|
|
2222
|
+
function readModel(stream) {
|
|
2223
|
+
const at = stream.indexOf('"modelStates":[');
|
|
2224
|
+
const entries = parseAt(stream, at === -1 ? -1 : stream.indexOf("[", at));
|
|
2225
|
+
if (entries === null) return null;
|
|
2226
|
+
const model = /* @__PURE__ */ new Map();
|
|
2227
|
+
for (const entry2 of entries) {
|
|
2228
|
+
const id = entry2.key?.key?.value?.id;
|
|
2229
|
+
if (id !== void 0 && entry2.value !== void 0 && !model.has(id)) {
|
|
2230
|
+
model.set(id, plain(entry2.value));
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
return model;
|
|
2234
|
+
}
|
|
2235
|
+
function findRequest(stream, requestId) {
|
|
2236
|
+
const at = stream.indexOf(`"requestId":"${requestId}","requestedArguments":`);
|
|
2237
|
+
if (at === -1) return null;
|
|
2238
|
+
const args = parseAt(
|
|
2239
|
+
stream,
|
|
2240
|
+
stream.indexOf("{", stream.indexOf('"requestedArguments":', at))
|
|
2241
|
+
);
|
|
2242
|
+
return args !== null && Array.isArray(args.requestedStateKeys) && args.payload !== void 0 ? args : null;
|
|
2243
|
+
}
|
|
2244
|
+
var unknownExpression = (what) => ({
|
|
2245
|
+
ok: false,
|
|
2246
|
+
code: "SCHEMA_DRIFT",
|
|
2247
|
+
message: `the form computes a value with an expression this tool does not evaluate (${what})`,
|
|
2248
|
+
hint: "Nothing was sent. Re-capture the form to see what it has become."
|
|
2249
|
+
});
|
|
2250
|
+
function boundId(body) {
|
|
2251
|
+
return body?.key?.key?.value?.id;
|
|
2252
|
+
}
|
|
2253
|
+
function str(node, model) {
|
|
2254
|
+
const e = node.expression;
|
|
2255
|
+
if (e?.$case === "stringValue") return String(e.stringValue);
|
|
2256
|
+
if (e?.$case === "bindableString") {
|
|
2257
|
+
const v = model.get(boundId(e.bindableString) ?? "")?.value;
|
|
2258
|
+
return typeof v === "string" ? v : "";
|
|
2259
|
+
}
|
|
2260
|
+
return null;
|
|
2261
|
+
}
|
|
2262
|
+
function bool(node, model) {
|
|
2263
|
+
const e = node.expression;
|
|
2264
|
+
const body = e?.[e?.$case ?? ""];
|
|
2265
|
+
switch (e?.$case) {
|
|
2266
|
+
case "booleanExpression":
|
|
2267
|
+
return bool(body, model);
|
|
2268
|
+
case "booleanValue":
|
|
2269
|
+
return e.booleanValue === true;
|
|
2270
|
+
case "bindableBoolean":
|
|
2271
|
+
return model.get(boundId(e.bindableBoolean) ?? "")?.value === true;
|
|
2272
|
+
case "notExpression": {
|
|
2273
|
+
const a = bool(body?.a ?? {}, model);
|
|
2274
|
+
return a === null ? null : !a;
|
|
2275
|
+
}
|
|
2276
|
+
case "orExpression":
|
|
2277
|
+
case "andExpression": {
|
|
2278
|
+
const a = bool(body?.a ?? {}, model);
|
|
2279
|
+
const b = bool(body?.b ?? {}, model);
|
|
2280
|
+
if (a === null || b === null) return null;
|
|
2281
|
+
return e.$case === "orExpression" ? a || b : a && b;
|
|
2282
|
+
}
|
|
2283
|
+
case "stringEqualsExpression": {
|
|
2284
|
+
const a = str(body?.a ?? {}, model);
|
|
2285
|
+
const b = str(body?.b ?? {}, model);
|
|
2286
|
+
if (a === null || b === null) return null;
|
|
2287
|
+
return body.ignoreCase === true ? a.toLowerCase() === b.toLowerCase() : a === b;
|
|
2288
|
+
}
|
|
2289
|
+
default:
|
|
2290
|
+
return null;
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2293
|
+
function evaluate(expression, model) {
|
|
2294
|
+
const value = bool(expression, model);
|
|
2295
|
+
return value === null ? unknownExpression(JSON.stringify(expression).slice(0, 80)) : { ok: true, value };
|
|
2296
|
+
}
|
|
2297
|
+
function wireStates(keys, model, resolve) {
|
|
2298
|
+
const out = [];
|
|
2299
|
+
for (const id of keys) {
|
|
2300
|
+
const state = model.get(id);
|
|
2301
|
+
if (state === void 0) continue;
|
|
2302
|
+
let value = state.value;
|
|
2303
|
+
if (state.protoCase === "expression") {
|
|
2304
|
+
const r = resolve(id, state) ?? evaluate(state.value, model);
|
|
2305
|
+
if (!r.ok) return r;
|
|
2306
|
+
value = r.value;
|
|
2307
|
+
}
|
|
2308
|
+
out.push({
|
|
2309
|
+
key: id,
|
|
2310
|
+
namespace: "MemoryNamespace",
|
|
2311
|
+
value,
|
|
2312
|
+
originalProtoCase: state.protoCase,
|
|
2313
|
+
protoKey: { $type: "proto.sdui.Key", value: { $case: "id", id } }
|
|
2314
|
+
});
|
|
2315
|
+
}
|
|
2316
|
+
return out;
|
|
2317
|
+
}
|
|
2318
|
+
var keysOf = (args) => args.requestedStateKeys.map((k) => k.key.value.id);
|
|
2319
|
+
function requestBody(requestId, args, states, screen) {
|
|
2320
|
+
const requestedArguments = {
|
|
2321
|
+
$type: "proto.sdui.actions.requests.RequestedArguments",
|
|
2322
|
+
requestedStateKeys: args.requestedStateKeys,
|
|
2323
|
+
payload: args.payload,
|
|
2324
|
+
requestMetadata: { $type: "proto.sdui.common.RequestMetadata" }
|
|
2325
|
+
};
|
|
2326
|
+
return {
|
|
2327
|
+
requestId,
|
|
2328
|
+
serverRequest: {
|
|
2329
|
+
requestId,
|
|
2330
|
+
requestedArguments,
|
|
2331
|
+
isApfcEnabled: false,
|
|
2332
|
+
isStreaming: false,
|
|
2333
|
+
rumPageKey: ""
|
|
2334
|
+
},
|
|
2335
|
+
states,
|
|
2336
|
+
requestedArguments: { ...requestedArguments, states, screenId: screen, knownTemplateIds: [] }
|
|
2337
|
+
};
|
|
2338
|
+
}
|
|
2339
|
+
function navBody(screen, payload) {
|
|
2340
|
+
return {
|
|
2341
|
+
clientArguments: {
|
|
2342
|
+
$type: "proto.sdui.actions.requests.RequestedArguments",
|
|
2343
|
+
requestedStateKeys: [],
|
|
2344
|
+
payload,
|
|
2345
|
+
requestMetadata: { $type: "proto.sdui.common.RequestMetadata" },
|
|
2346
|
+
states: [],
|
|
2347
|
+
screenId: screen,
|
|
2348
|
+
knownTemplateIds: []
|
|
2349
|
+
},
|
|
2350
|
+
isModal: true
|
|
2351
|
+
};
|
|
2352
|
+
}
|
|
2353
|
+
function responseErrors(raw) {
|
|
2354
|
+
return raw.match(/"errors":\[([^\]]+)\]/)?.[1]?.slice(0, 300) ?? null;
|
|
2355
|
+
}
|
|
2356
|
+
|
|
2357
|
+
// src/engine/sdui-profile.ts
|
|
2358
|
+
var NAV_URL = "https://www.linkedin.com/flagship-web/rsc-action/actions/navigation";
|
|
2359
|
+
var ACTION_URL = "https://www.linkedin.com/flagship-web/rsc-action/actions/server-request";
|
|
2360
|
+
var PROFILE_FIELDS = {
|
|
2361
|
+
headline: {
|
|
2362
|
+
name: "headline",
|
|
2363
|
+
screen: "com.linkedin.sdui.flagshipnav.profile.ProfileEditIntroForm",
|
|
2364
|
+
save: "com.linkedin.sdui.requests.profile.saveProfileIntroForm",
|
|
2365
|
+
binding: "headline",
|
|
2366
|
+
// The web form refuses more ("Exceeded maximum length of 220 characters").
|
|
2367
|
+
maxLength: 220
|
|
2368
|
+
},
|
|
2369
|
+
about: {
|
|
2370
|
+
name: "about",
|
|
2371
|
+
screen: "com.linkedin.sdui.flagshipnav.profile.ProfileAboutForm",
|
|
2372
|
+
save: "com.linkedin.sdui.requests.profile.saveProfileAboutForm",
|
|
2373
|
+
binding: "about",
|
|
2374
|
+
maxLength: 2600
|
|
2375
|
+
}
|
|
2376
|
+
};
|
|
2377
|
+
var drift2 = (message) => ({
|
|
2378
|
+
ok: false,
|
|
2379
|
+
code: "SCHEMA_DRIFT",
|
|
2380
|
+
message,
|
|
2381
|
+
hint: "Re-capture the profile form with scripts/observe-write.ts (edit one character, then revert)."
|
|
2382
|
+
});
|
|
2383
|
+
async function openForm(screen, payload, client, operation) {
|
|
2384
|
+
const result = await client.request({
|
|
2385
|
+
url: `${NAV_URL}?screenId=${screen}&sduiid=${screen}`,
|
|
2386
|
+
method: "POST",
|
|
2387
|
+
body: navBody(screen, payload),
|
|
2388
|
+
spendClass: "page",
|
|
2389
|
+
operation
|
|
2390
|
+
});
|
|
2391
|
+
if (!result.ok) {
|
|
2392
|
+
const out = { ok: false, code: result.code, message: result.message };
|
|
2393
|
+
if (result.hint !== void 0) out.hint = result.hint;
|
|
2394
|
+
return out;
|
|
2395
|
+
}
|
|
2396
|
+
return result.classification.raw ?? "";
|
|
2397
|
+
}
|
|
2398
|
+
async function sendAction(requestId, body, client, operation, spendClass = "write") {
|
|
2399
|
+
const result = await client.request({
|
|
2400
|
+
url: `${ACTION_URL}?sduiid=${requestId}`,
|
|
2401
|
+
method: "POST",
|
|
2402
|
+
body,
|
|
2403
|
+
spendClass,
|
|
2404
|
+
operation
|
|
2405
|
+
});
|
|
2406
|
+
if (!result.ok) {
|
|
2407
|
+
const out = { ok: false, code: result.code, message: result.message };
|
|
2408
|
+
if (result.hint !== void 0) out.hint = result.hint;
|
|
2409
|
+
return out;
|
|
2410
|
+
}
|
|
2411
|
+
const raw = result.classification.raw ?? "";
|
|
2412
|
+
const errors = responseErrors(raw);
|
|
2413
|
+
if (errors !== null) {
|
|
2414
|
+
return { ok: false, code: "INVALID_INPUT", message: `LinkedIn refused it: ${errors}` };
|
|
2415
|
+
}
|
|
2416
|
+
return raw;
|
|
2417
|
+
}
|
|
2418
|
+
|
|
2419
|
+
// src/engine/sdui-position.ts
|
|
2420
|
+
var POSITION = {
|
|
2421
|
+
addScreen: "com.linkedin.sdui.flagshipnav.profile.ProfilePositionAddForm",
|
|
2422
|
+
editScreen: "com.linkedin.sdui.flagshipnav.profile.ProfilePositionDetailsEditForm",
|
|
2423
|
+
listScreen: "com.linkedin.sdui.flagshipnav.profile.ProfileExperienceDetails",
|
|
2424
|
+
media: "com.linkedin.sdui.impl.profile.components.forms.uploadPositionMedia",
|
|
2425
|
+
save: "com.linkedin.sdui.requests.profile.saveProfilePositionForm",
|
|
2426
|
+
delete: "com.linkedin.sdui.requests.profile.deleteProfilePositionForm"
|
|
2427
|
+
};
|
|
2428
|
+
var EDIT_NAV = `{"$type":"proto.sdui.actions.core.NavigateToScreen","screenId":"${POSITION.editScreen}"`;
|
|
2429
|
+
function listPositions(stream) {
|
|
2430
|
+
if (readModel(stream) === null && !stream.includes(EDIT_NAV) && !stream.includes('"rows"')) {
|
|
2431
|
+
return drift2("the Experience screen could not be read");
|
|
2432
|
+
}
|
|
2433
|
+
const positions = [];
|
|
2434
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2435
|
+
let i = 0;
|
|
2436
|
+
for (; ; ) {
|
|
2437
|
+
i = stream.indexOf(EDIT_NAV, i);
|
|
2438
|
+
if (i === -1) break;
|
|
2439
|
+
const text2 = balanced(stream, i);
|
|
2440
|
+
i += EDIT_NAV.length;
|
|
2441
|
+
if (text2 === null) continue;
|
|
2442
|
+
const payload = JSON.parse(text2).requestedArguments?.payload;
|
|
2443
|
+
const id = payload?.positionId;
|
|
2444
|
+
if (typeof id !== "string" || seen.has(id) || payload === void 0) continue;
|
|
2445
|
+
seen.add(id);
|
|
2446
|
+
positions.push({ positionId: id, title: String(payload.title ?? ""), payload });
|
|
2447
|
+
}
|
|
2448
|
+
if (positions.length === 0 && !stream.includes('"rows"') && !stream.includes("Experience")) {
|
|
2449
|
+
return drift2("the Experience screen listed no roles and did not look like one");
|
|
2450
|
+
}
|
|
2451
|
+
return { ok: true, positions };
|
|
2452
|
+
}
|
|
2453
|
+
function readPositionForm(stream) {
|
|
2454
|
+
const model = readModel(stream);
|
|
2455
|
+
if (model === null) return drift2("the position form carried no initial values");
|
|
2456
|
+
const media = findRequest(stream, POSITION.media);
|
|
2457
|
+
const prefix = media?.payload.formIdPrefix;
|
|
2458
|
+
if (media === null || typeof prefix !== "string") {
|
|
2459
|
+
return drift2("the position form carried no save step (uploadPositionMedia)");
|
|
2460
|
+
}
|
|
2461
|
+
const del = findRequest(stream, POSITION.delete);
|
|
2462
|
+
return {
|
|
2463
|
+
ok: true,
|
|
2464
|
+
model,
|
|
2465
|
+
prefix,
|
|
2466
|
+
media,
|
|
2467
|
+
del,
|
|
2468
|
+
screen: del === null ? POSITION.addScreen : POSITION.editScreen
|
|
2469
|
+
};
|
|
2470
|
+
}
|
|
2471
|
+
function noMedia(model) {
|
|
2472
|
+
const count2 = [...model.entries()].find(
|
|
2473
|
+
([k]) => k.endsWith("position-mediaUiCollection-mediaCount")
|
|
2474
|
+
)?.[1].value;
|
|
2475
|
+
return typeof count2 === "number" && count2 > 0 ? {
|
|
2476
|
+
ok: false,
|
|
2477
|
+
code: "NOT_IMPLEMENTED",
|
|
2478
|
+
message: "this role has media attached, and saving one with media has not been verified",
|
|
2479
|
+
hint: "Edit it in the browser for now; nothing was changed."
|
|
2480
|
+
} : null;
|
|
2481
|
+
}
|
|
2482
|
+
var resolver = (key) => key.endsWith("position-mediaIds") ? { ok: true, value: [] } : void 0;
|
|
2483
|
+
function mediaBody(form, model) {
|
|
2484
|
+
const refused = noMedia(model);
|
|
2485
|
+
if (refused !== null) return refused;
|
|
2486
|
+
const states = wireStates(keysOf(form.media), model, resolver);
|
|
2487
|
+
if (!Array.isArray(states)) return states;
|
|
2488
|
+
return { ok: true, body: requestBody(POSITION.media, form.media, states, form.screen) };
|
|
2489
|
+
}
|
|
2490
|
+
function saveFromReply(reply2) {
|
|
2491
|
+
const args = findRequest(reply2, POSITION.save);
|
|
2492
|
+
return args === null ? drift2("the media step did not hand back the save action") : { ok: true, args };
|
|
2493
|
+
}
|
|
2494
|
+
function positionSaveBody(save, model, screen) {
|
|
2495
|
+
const sending = new Map(model);
|
|
2496
|
+
for (const [k, v] of sending)
|
|
2497
|
+
if (k.endsWith("isActiveProfileFormLoading")) sending.set(k, { ...v, value: true });
|
|
2498
|
+
const states = wireStates(keysOf(save), sending, resolver);
|
|
2499
|
+
if (!Array.isArray(states)) return states;
|
|
2500
|
+
return { ok: true, body: requestBody(POSITION.save, save, states, screen) };
|
|
2501
|
+
}
|
|
2502
|
+
function deleteBody(form) {
|
|
2503
|
+
if (form.del === null)
|
|
2504
|
+
return drift2("this form has no delete action (it is not an existing role)");
|
|
2505
|
+
const states = wireStates(keysOf(form.del), form.model, resolver);
|
|
2506
|
+
if (!Array.isArray(states)) return states;
|
|
2507
|
+
return { ok: true, body: requestBody(POSITION.delete, form.del, states, form.screen) };
|
|
2508
|
+
}
|
|
2509
|
+
async function fetchPositions(vanityName, client) {
|
|
2510
|
+
const stream = await openForm(
|
|
2511
|
+
POSITION.listScreen,
|
|
2512
|
+
{ vanityName, isVanityNameResolved: true },
|
|
2513
|
+
client,
|
|
2514
|
+
"experience-list"
|
|
2515
|
+
);
|
|
2516
|
+
return typeof stream === "string" ? listPositions(stream) : stream;
|
|
2517
|
+
}
|
|
2518
|
+
async function openPositionForm(payload, client, edit) {
|
|
2519
|
+
const stream = await openForm(
|
|
2520
|
+
edit ? POSITION.editScreen : POSITION.addScreen,
|
|
2521
|
+
{ ...payload, isVanityNameResolved: true },
|
|
2522
|
+
client,
|
|
2523
|
+
edit ? "position-edit-form" : "position-add-form"
|
|
2524
|
+
);
|
|
2525
|
+
return typeof stream === "string" ? readPositionForm(stream) : stream;
|
|
2526
|
+
}
|
|
2527
|
+
async function sendPositionSave(form, model, client) {
|
|
2528
|
+
const media = mediaBody(form, model);
|
|
2529
|
+
if (!media.ok) return media;
|
|
2530
|
+
const reply2 = await sendAction(POSITION.media, media.body, client, "position-media-step", "page");
|
|
2531
|
+
if (typeof reply2 !== "string") return reply2;
|
|
2532
|
+
const save = saveFromReply(reply2);
|
|
2533
|
+
if (!save.ok) return save;
|
|
2534
|
+
const body = positionSaveBody(save.args, model, form.screen);
|
|
2535
|
+
if (!body.ok) return body;
|
|
2536
|
+
const sent = await sendAction(POSITION.save, body.body, client, "position-save");
|
|
2537
|
+
return typeof sent === "string" ? { ok: true } : sent;
|
|
2538
|
+
}
|
|
2539
|
+
async function sendPositionDelete(form, client) {
|
|
2540
|
+
const body = deleteBody(form);
|
|
2541
|
+
if (!body.ok) return body;
|
|
2542
|
+
const sent = await sendAction(POSITION.delete, body.body, client, "position-delete");
|
|
2543
|
+
return typeof sent === "string" ? { ok: true } : sent;
|
|
2544
|
+
}
|
|
2545
|
+
|
|
2546
|
+
// src/commands/gate.ts
|
|
2547
|
+
import { createInterface } from "readline/promises";
|
|
2548
|
+
|
|
2549
|
+
// src/commands/approval.ts
|
|
2550
|
+
import { appendFileSync, mkdirSync as mkdirSync3 } from "fs";
|
|
2551
|
+
import { dirname as dirname2 } from "path";
|
|
2552
|
+
|
|
2553
|
+
// src/commands/confirm.ts
|
|
2554
|
+
import { createHash } from "crypto";
|
|
2555
|
+
|
|
2556
|
+
// src/commands/write.ts
|
|
2557
|
+
import { readFileSync as readFileSync2, statSync } from "fs";
|
|
2558
|
+
import { basename } from "path";
|
|
2559
|
+
|
|
2560
|
+
// src/engine/sdui-comment.ts
|
|
2561
|
+
var SDUI_ACTION = "https://www.linkedin.com/flagship-web/rsc-action/actions/server-request";
|
|
2562
|
+
var COMMENT_URL = `${SDUI_ACTION}?sduiid=com.linkedin.sdui.comments.createComment`;
|
|
2563
|
+
|
|
2564
|
+
// src/engine/voyager-reply.ts
|
|
2565
|
+
var REPLY_DECORATION = "com.linkedin.voyager.dash.deco.social.NormComment-43";
|
|
2566
|
+
var REPLY_URL = `https://www.linkedin.com/voyager/api/voyagerSocialDashNormComments?decorationId=${REPLY_DECORATION}`;
|
|
2567
|
+
|
|
2568
|
+
// src/engine/voyager-write.ts
|
|
2569
|
+
import { createHash as createHash2 } from "crypto";
|
|
2570
|
+
var VOYAGER2 = "https://www.linkedin.com/voyager/api";
|
|
2571
|
+
var SHARE_URL = `${VOYAGER2}/contentcreation/normShares`;
|
|
2572
|
+
|
|
2573
|
+
// src/commands/token.ts
|
|
2574
|
+
import { existsSync as existsSync3, rmSync } from "fs";
|
|
2575
|
+
|
|
2576
|
+
// src/engine/oauth.ts
|
|
2577
|
+
var CALLBACK_PORT = 53682;
|
|
2578
|
+
var REDIRECT_URI = `http://localhost:${CALLBACK_PORT}/callback`;
|
|
2579
|
+
|
|
2580
|
+
// src/commands/token.ts
|
|
2581
|
+
var OAUTH_SETUP = [
|
|
2582
|
+
"Writes go over LinkedIn's OWN self-serve scope rather than the private API, which is the one",
|
|
2583
|
+
"legitimacy wedge an individual actually has \u2014 but the app has to be registered by you; it",
|
|
2584
|
+
"cannot be created on your behalf.",
|
|
2585
|
+
"",
|
|
2586
|
+
" 1. https://www.linkedin.com/developers/apps/new \u2014 create an app (any LinkedIn Page works).",
|
|
2587
|
+
' 2. Products tab \u2192 add "Sign In with LinkedIn using OpenID Connect" AND "Share on LinkedIn".',
|
|
2588
|
+
" Both are self-serve: no partner review, no verification, no screencast.",
|
|
2589
|
+
` 3. Auth tab \u2192 add redirect URL ${REDIRECT_URI}`,
|
|
2590
|
+
" 4. Run: lnrelay oauth login --client-id <id>",
|
|
2591
|
+
" (the secret is prompted for; or set LINKEDIN_CLIENT_ID / LINKEDIN_CLIENT_SECRET)"
|
|
2592
|
+
].join("\n");
|
|
2593
|
+
|
|
2594
|
+
// src/commands/transport.ts
|
|
2595
|
+
var NO_CREDENTIAL_HINT = [
|
|
2596
|
+
"Two ways to write, and you need one of them:",
|
|
2597
|
+
"",
|
|
2598
|
+
" Sanctioned lnrelay oauth login --client-id <id>",
|
|
2599
|
+
" Needs a developer app, which needs a LinkedIn Page.",
|
|
2600
|
+
"",
|
|
2601
|
+
" Unsanctioned lnrelay login",
|
|
2602
|
+
" Uses the same cookies as reads. No Page needed. Breaches \xA78.2",
|
|
2603
|
+
" and puts the account at risk \u2014 every write still asks first."
|
|
2604
|
+
].join("\n");
|
|
2605
|
+
|
|
2606
|
+
// src/commands/write.ts
|
|
2607
|
+
var MIN_LEAD_MS = 10 * 6e4;
|
|
2608
|
+
var PROFILE_HINT = `profile fields: ${Object.keys(PROFILE_FIELDS).join(", ")}`;
|
|
2609
|
+
|
|
2610
|
+
// src/commands/role.ts
|
|
2611
|
+
function liveRoles(session, quiet = false) {
|
|
2612
|
+
const client = createLiveClient(session, void 0, quiet);
|
|
2613
|
+
return {
|
|
2614
|
+
vanity: async () => {
|
|
2615
|
+
const me = await createEngine(session, void 0, quiet).whoami();
|
|
2616
|
+
if (!me.ok) return me;
|
|
2617
|
+
const id = me.value?.publicIdentifier;
|
|
2618
|
+
return typeof id === "string" && id !== "" ? { ok: true, vanity: id } : { ok: false, code: "SCHEMA_DRIFT", message: "whoami returned no public profile id" };
|
|
2619
|
+
},
|
|
2620
|
+
list: (vanity) => fetchPositions(vanity, client),
|
|
2621
|
+
open: (payload, edit) => openPositionForm(payload, client, edit),
|
|
2622
|
+
save: (form, model) => sendPositionSave(form, model, client),
|
|
2623
|
+
remove: (form) => sendPositionDelete(form, client)
|
|
2624
|
+
};
|
|
2625
|
+
}
|
|
2626
|
+
async function runExperience(quiet = false) {
|
|
2627
|
+
const session = loadSession();
|
|
2628
|
+
if (session.state !== "ok")
|
|
2629
|
+
return err("experience", "AUTH_FAILED", "no LinkedIn session \u2014 run `lnrelay login`");
|
|
2630
|
+
const roles = liveRoles(session.session, quiet);
|
|
2631
|
+
const me = await roles.vanity();
|
|
2632
|
+
if (!me.ok) return err("experience", me.code, me.message, me.hint);
|
|
2633
|
+
const listed = await roles.list(me.vanity);
|
|
2634
|
+
if (!listed.ok) return err("experience", listed.code, listed.message, listed.hint);
|
|
2635
|
+
return ok("experience", {
|
|
2636
|
+
items: listed.positions.map((p) => ({ positionId: p.positionId, title: p.title })),
|
|
2637
|
+
meta: { state: "complete", returnedCount: listed.positions.length }
|
|
2638
|
+
});
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2164
2641
|
// src/entry.ts
|
|
2165
2642
|
import { realpathSync } from "fs";
|
|
2166
|
-
import { basename } from "path";
|
|
2643
|
+
import { basename as basename2 } from "path";
|
|
2167
2644
|
import { fileURLToPath } from "url";
|
|
2168
2645
|
function isMainModule(argv1, moduleUrl, importMetaMain) {
|
|
2169
2646
|
if (importMetaMain === true) return true;
|
|
@@ -2178,7 +2655,7 @@ function isMainModule(argv1, moduleUrl, importMetaMain) {
|
|
|
2178
2655
|
}
|
|
2179
2656
|
function shouldForceEntry(argv1, binNames) {
|
|
2180
2657
|
if (argv1 === void 0) return false;
|
|
2181
|
-
return binNames.includes(
|
|
2658
|
+
return binNames.includes(basename2(argv1));
|
|
2182
2659
|
}
|
|
2183
2660
|
function shouldRunAsEntry(argv1, moduleUrl, importMetaMain, binNames) {
|
|
2184
2661
|
if (isMainModule(argv1, moduleUrl, importMetaMain)) {
|
|
@@ -2284,6 +2761,12 @@ function buildServer() {
|
|
|
2284
2761
|
},
|
|
2285
2762
|
async ({ query, source, since, limit }) => reply(runLocal(query, source, since, limit ?? 25))
|
|
2286
2763
|
);
|
|
2764
|
+
server.tool(
|
|
2765
|
+
"experience",
|
|
2766
|
+
`The roles on the user's own LinkedIn profile: positionId and title. LIVE \u2014 2 calls. The positionId is what \`lnrelay role edit|remove\` takes (CLI-only; changing a role is a write the user approves). ${NO_RETRY}`,
|
|
2767
|
+
{},
|
|
2768
|
+
async () => reply(await runExperience())
|
|
2769
|
+
);
|
|
2287
2770
|
server.tool(
|
|
2288
2771
|
"scheduled",
|
|
2289
2772
|
`The user's own posts waiting to publish, soonest first: urn, scheduledAt (ISO), text. LIVE \u2014 about 1 call per 10 posts. These are NOT in \`my_posts\` until they go out. Links in \`text\` show as lnkd.in short links, as LinkedIn lists them. \`text\` is null when it could not be matched to its post for certain. \`meta.claimedCount\` is LinkedIn's own count; if \`meta.state\` is not "complete", say the list may be short. ${NO_RETRY}`,
|