linkedin-relay-mcp 1.0.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 +205 -0
- package/LICENSE +21 -0
- package/README.md +98 -0
- package/dist/cli.js +2748 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.js +700 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-shim.js +2073 -0
- package/dist/mcp-shim.js.map +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/args.ts","../src/cache/store.ts","../src/commands/local.ts","../src/engine/budget.ts","../src/output.ts","../src/commands/registry.ts","../src/engine/restli.ts"],"sourcesContent":["// Minimal argv parsing. Pure — takes an argv array, returns a plain object.\n\nexport interface ParsedArgs {\n command: string | undefined;\n positionals: string[];\n flags: Record<string, string | boolean>;\n}\n\nexport function parseArgs(argv: string[]): ParsedArgs {\n const [command, ...rest] = argv;\n const positionals: string[] = [];\n const flags: Record<string, string | boolean> = {};\n\n for (let i = 0; i < rest.length; i++) {\n const token = rest[i];\n if (token === undefined) continue;\n\n if (token.startsWith('--')) {\n const key = token.slice(2);\n const next = rest[i + 1];\n // A flag takes a value only when the next token isn't itself a flag.\n if (next !== undefined && !next.startsWith('--')) {\n flags[key] = next;\n i++;\n } else {\n flags[key] = true;\n }\n } else if (token.startsWith('-') && token.length > 1) {\n const key = token.slice(1);\n const next = rest[i + 1];\n if (next !== undefined && !next.startsWith('-')) {\n flags[key] = next;\n i++;\n } else {\n flags[key] = true;\n }\n } else {\n positionals.push(token);\n }\n }\n\n return { command, positionals, flags };\n}\n\nexport function bool(args: ParsedArgs, name: string): boolean {\n return args.flags[name] === true || args.flags[name] === 'true';\n}\n\nexport function str(args: ParsedArgs, name: string): string | undefined {\n const v = args.flags[name];\n return typeof v === 'string' ? v : undefined;\n}\n\nexport function num(args: ParsedArgs, name: string): number | undefined {\n const v = str(args, name);\n if (v === undefined) return undefined;\n const n = Number(v);\n return Number.isFinite(n) ? n : undefined;\n}\n","// ─── Local state store ────────────────────────────────────────────────────────\n//\n// Small, replaceable JSON state (the ledger, the cooldown, credentials\n// metadata) lives here. The research cache proper is SQLite and arrives in\n// Phase 4 — see docs/DESIGN.md §5.\n//\n// The rule that matters, and where we deliberately break with the family:\n//\n// never-throw is NOT never-fail.\n//\n// x-relay's store degrades a corrupt file to an empty object so a read never\n// crashes. That is right on X. Here it composes into a disaster: corrupt file →\n// empty cache → sync sees no prior state → full enumeration against the most\n// hostile platform in the research, triggered by a disk error. So a corrupt\n// file is quarantined and reported loudly. An empty result and a lost result\n// must be distinguishable on disk for exactly the same reason they must be\n// distinguishable in a parse.\n\nimport { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { dirname, join } from 'node:path';\n\nexport function cacheDir(): string {\n return process.env.LNRELAY_CACHE_DIR ?? join(homedir(), '.lnrelay');\n}\n\nexport function cachePath(...parts: string[]): string {\n return join(cacheDir(), ...parts);\n}\n\nexport type LoadResult<T> =\n | { state: 'ok'; value: T }\n | { state: 'missing' }\n | { state: 'corrupt'; quarantinedTo: string; reason: string };\n\n/**\n * Read a JSON file. Never throws. A file that exists but cannot be parsed is\n * MOVED to `quarantine/` and reported as corrupt — never silently treated as\n * absent, because \"we lost your data\" and \"you have no data\" lead to opposite\n * and non-interchangeable actions.\n */\nexport function loadJson<T>(path: string): LoadResult<T> {\n if (!existsSync(path)) return { state: 'missing' };\n\n let raw: string;\n try {\n raw = readFileSync(path, 'utf-8');\n } catch (e) {\n return quarantine(path, `unreadable: ${(e as Error).message}`);\n }\n\n try {\n return { state: 'ok', value: JSON.parse(raw) as T };\n } catch (e) {\n return quarantine(path, `unparseable JSON: ${(e as Error).message}`);\n }\n}\n\nfunction quarantine(path: string, reason: string): LoadResult<never> {\n const stamp = new Date().toISOString().replace(/[:.]/g, '-');\n const target = cachePath('quarantine', stamp, path.split('/').pop() ?? 'file');\n try {\n mkdirSync(dirname(target), { recursive: true });\n renameSync(path, target);\n } catch {\n // If we cannot even move it, still report corrupt — the caller must refuse\n // to proceed either way.\n }\n return { state: 'corrupt', quarantinedTo: target, reason };\n}\n\n/**\n * Write JSON atomically: a temp file in the same directory, then rename. A\n * torn write leaves the previous good file intact rather than a truncated one.\n */\nexport function saveJson(path: string, value: unknown): void {\n mkdirSync(dirname(path), { recursive: true });\n const tmp = `${path}.tmp`;\n writeFileSync(tmp, JSON.stringify(value, null, 2), { encoding: 'utf-8', mode: 0o600 });\n renameSync(tmp, path);\n}\n","// The three commands that work today. All are local: they make no network call\n// and need no LinkedIn session, so they are useful before the Phase 0 gate has\n// even run.\n\nimport { existsSync } from 'node:fs';\nimport { version as nodeVersion } from 'node:process';\nimport { cacheDir, cachePath, loadJson, saveJson } from '../cache/store.ts';\nimport {\n activeCooldown,\n CAPS,\n type Cooldown,\n emptyLedger,\n type Ledger,\n type SpendClass,\n summarise,\n} from '../engine/budget.ts';\nimport { err, ok } from '../output.ts';\nimport type { Envelope } from '../types.ts';\n\nconst LEDGER_FILE = 'budget.json';\nconst COOLDOWN_FILE = 'cooldown.json';\n\ninterface StateLoad<T> {\n value: T | null;\n corrupt: { path: string; quarantinedTo: string; reason: string } | null;\n}\n\nfunction loadState<T>(file: string, fallback: T): StateLoad<T> {\n const path = cachePath(file);\n const result = loadJson<T>(path);\n if (result.state === 'ok') return { value: result.value, corrupt: null };\n if (result.state === 'missing') return { value: fallback, corrupt: null };\n return {\n value: null,\n corrupt: { path, quarantinedTo: result.quarantinedTo, reason: result.reason },\n };\n}\n\nexport function loadLedger(): StateLoad<Ledger> {\n return loadState<Ledger>(LEDGER_FILE, emptyLedger());\n}\n\nexport function loadCooldown(): StateLoad<Cooldown | null> {\n return loadState<Cooldown | null>(COOLDOWN_FILE, null);\n}\n\n// ─── risk ─────────────────────────────────────────────────────────────────────\n\n/**\n * The breaker's current state. Exposed over MCP deliberately, so an agent can\n * check standing BEFORE deciding to spend budget on research rather than\n * discovering the lockout one wasted call at a time.\n */\nexport function runRisk(now: number): Envelope {\n const { value: cooldown, corrupt } = loadCooldown();\n if (corrupt !== null) {\n return err(\n 'risk',\n 'CACHE_CORRUPT',\n `cooldown state was unreadable and has been quarantined: ${corrupt.reason}`,\n `moved to ${corrupt.quarantinedTo}. Inspect it, then re-run — a fresh cooldown file will be created.`,\n );\n }\n\n const blocked = activeCooldown(cooldown ?? null, now);\n return ok('risk', {\n state: blocked ? 'blocked' : 'ok',\n cooldown: cooldown ?? null,\n tosNotice:\n 'Voyager reads breach LinkedIn User Agreement §8.2. This tool is not ToS-compliant and ' +\n 'any account it touches can be restricted or permanently banned.',\n });\n}\n\n// ─── budget ───────────────────────────────────────────────────────────────────\n\nexport function runBudget(now: number, resetCooldown: boolean, confirmed: boolean): Envelope {\n if (resetCooldown && !confirmed) {\n return err(\n 'budget',\n 'CONFIRMATION_REQUIRED',\n 'clearing a cooldown requires --confirm',\n 'A cooldown means LinkedIn signalled a throttle, block or challenge. Log in through a real ' +\n 'browser and confirm you are unblocked before clearing it. Re-run with --confirm.',\n );\n }\n\n if (resetCooldown) {\n saveJson(cachePath(COOLDOWN_FILE), null);\n }\n\n const { value: ledger, corrupt } = loadLedger();\n if (corrupt !== null) {\n return err(\n 'budget',\n 'CACHE_CORRUPT',\n `the spend ledger was unreadable and has been quarantined: ${corrupt.reason}`,\n `moved to ${corrupt.quarantinedTo}. A corrupt ledger is NOT treated as an empty one — that ` +\n 'would silently restore a full budget. Inspect it, then re-run.',\n );\n }\n\n const classes: SpendClass[] = ['profile', 'search', 'page', 'write', 'global'];\n const { value: cooldown } = loadCooldown();\n\n return ok('budget', {\n classes: classes.map((c) => ({\n ...summarise(ledger ?? emptyLedger(), c, now),\n note: CAPS[c].note,\n })),\n cooldown: cooldown ?? null,\n caveat:\n 'Every cap is guessed or transplanted vendor lore — the field research found no corroborated ' +\n 'LinkedIn rate limits. These are starting knobs, not safe thresholds. They also cannot see ' +\n 'your manual browser activity.',\n });\n}\n\n// ─── doctor ───────────────────────────────────────────────────────────────────\n\nexport interface Check {\n name: string;\n ok: boolean;\n detail: string;\n}\n\n/**\n * Diagnose setup. Always returns ok:true at the envelope level — a diagnostic\n * that fails to report because something is broken is useless. Individual checks\n * carry their own pass/fail. Never prints a credential value.\n */\nexport function runDoctor(now: number, offline: boolean): Envelope {\n const checks: Check[] = [];\n\n checks.push({\n name: 'runtime',\n ok: true,\n detail: `node ${nodeVersion}; cache dir ${cacheDir()}${existsSync(cacheDir()) ? '' : ' (not created yet)'}`,\n });\n\n const { value: cooldown, corrupt: cooldownCorrupt } = loadCooldown();\n if (cooldownCorrupt !== null) {\n checks.push({\n name: 'cooldown',\n ok: false,\n detail: `state file was corrupt; quarantined to ${cooldownCorrupt.quarantinedTo}`,\n });\n } else {\n const blocked = activeCooldown(cooldown ?? null, now);\n checks.push({\n name: 'cooldown',\n ok: !blocked,\n detail: blocked\n ? `BLOCKED — ${cooldown?.reason}, clears by ${cooldown?.clearRequires}${\n cooldown?.until === null\n ? ' (indefinite)'\n : ` at ${new Date(cooldown?.until ?? 0).toISOString()}`\n }`\n : 'clear',\n });\n }\n\n const { value: ledger, corrupt: ledgerCorrupt } = loadLedger();\n if (ledgerCorrupt !== null) {\n checks.push({\n name: 'budget',\n ok: false,\n detail: `ledger was corrupt; quarantined to ${ledgerCorrupt.quarantinedTo}`,\n });\n } else {\n const g = summarise(ledger ?? emptyLedger(), 'global', now);\n checks.push({\n name: 'budget',\n ok: g.remaining > 0,\n detail: `${g.spentInWindow}/${g.cap} global calls used in the last 24h (cap provenance: ${g.capProvenance})`,\n });\n }\n\n // Credentials are checked for PRESENCE and LENGTH only — never printed.\n const cookiePath = cachePath('cookies.json');\n checks.push({\n name: 'session',\n ok: false,\n detail: existsSync(cookiePath)\n ? 'a cookie file exists, but the engine is not implemented yet (Phase 2)'\n : 'no session yet — the Phase 0 capture gate has not been run. See docs/PLAN.md.',\n });\n\n checks.push({\n name: 'engine',\n ok: false,\n detail:\n 'not implemented. Phase 0 (three human-paced requests from a residential IP) must pass ' +\n 'before engine code is written — see docs/PLAN.md.',\n });\n\n if (!offline) {\n checks.push({\n name: 'live',\n ok: false,\n detail: 'no live checks available yet; --offline is currently the only meaningful mode',\n });\n }\n\n return ok('doctor', {\n healthy: checks.every((c) => c.ok),\n phase: 'Phase 1 — local scaffolding. No network capability exists yet, by design.',\n checks,\n });\n}\n","// ─── Spend accounting and the circuit breaker ─────────────────────────────────\n//\n// Two structural safety mechanisms live here, both pure (a clock is always\n// injected, never read):\n//\n// 1. Permits. `client` cannot be called without a `Permit`, and `spend()` is\n// the only thing that can make one. \"Issue a network call without\n// accounting for it\" is therefore a compile error rather than a\n// code-review norm. Redirects, pagination continuations and contract\n// discovery all consume permits too — otherwise the traffic easiest to\n// forget is exactly the traffic that escapes accounting.\n//\n// 2. The cooldown. A FILE, not process state. A CLI is a swarm of\n// short-lived processes, so an in-memory breaker protects nothing: the\n// next invocation would start clean and hammer straight back into the\n// throttle that opened it.\n//\n// About the numbers below: the field research swept 364 posts looking for\n// corroborated rate ceilings and found essentially none — one secondhand vendor\n// figure. So every cap is labelled with where it actually came from, and\n// `lnrelay budget` prints that label. None of them is `measured`, because we\n// have measured nothing. They are starting knobs, not LinkedIn facts.\n\nimport type { CapProvenance } from '../types.ts';\n\nconst HOUR = 3_600_000;\nconst DAY = 86_400_000;\n\nexport type SpendClass = 'profile' | 'search' | 'page' | 'write' | 'global';\n\nexport interface Cap {\n perDay: number;\n provenance: CapProvenance;\n note: string;\n}\n\nexport const CAPS: Record<SpendClass, Cap> = {\n profile: {\n perDay: 30,\n provenance: 'vendor-lore',\n note: \"transplanted from jjuanrivvera/linkedin-cli's job-detail cap\",\n },\n search: { perDay: 25, provenance: 'guessed', note: 'no corroborated figure exists' },\n page: { perDay: 60, provenance: 'guessed', note: 'thread/feed pagination' },\n write: {\n perDay: 10,\n provenance: 'guessed',\n note: 'deliberately below the weakly-reported ~20/day connection lore',\n },\n global: { perDay: 250, provenance: 'guessed', note: 'all classes combined' },\n};\n\n/** Minimum gap between any two calls, before jitter. */\nexport const MIN_GAP_MS = 3_000;\n\n// ─── Permits ──────────────────────────────────────────────────────────────────\n\n/**\n * Proof that a call was accounted for. The brand is unexported, so `spend()` is\n * the only thing in the program that can produce one.\n */\nexport interface Permit {\n readonly __brand: unique symbol;\n class: SpendClass;\n issuedAt: number;\n}\n\nexport interface Ledger {\n /** Epoch-ms timestamps of each spend, keyed by class. */\n spends: Record<string, number[]>;\n}\n\nexport function emptyLedger(): Ledger {\n return { spends: {} };\n}\n\nexport interface BudgetError {\n code: 'BUDGET_EXHAUSTED';\n message: string;\n hint: string;\n}\n\nexport type SpendResult = { permit: Permit; ledger: Ledger } | { error: BudgetError };\n\nfunction within(times: number[] | undefined, now: number, window: number): number[] {\n if (times === undefined) return [];\n return times.filter((t) => now - t < window);\n}\n\nfunction allSpends(ledger: Ledger, now: number): number[] {\n return Object.values(ledger.spends).flatMap((times) => within(times, now, DAY));\n}\n\n/**\n * Account for one intended call. Returns a permit and the updated ledger, or a\n * refusal — and a refusal charges nothing, so a denied call never consumes\n * budget.\n */\nexport function spend(ledger: Ledger, cls: SpendClass, now: number): SpendResult {\n const recent = allSpends(ledger, now);\n\n const last = recent.length > 0 ? Math.max(...recent) : undefined;\n if (last !== undefined && now - last < MIN_GAP_MS) {\n return {\n error: {\n code: 'BUDGET_EXHAUSTED',\n message: `minimum gap of ${MIN_GAP_MS}ms between calls not met`,\n hint: 'requests are paced deliberately; wait and retry',\n },\n };\n }\n\n if (recent.length >= CAPS.global.perDay) {\n return {\n error: {\n code: 'BUDGET_EXHAUSTED',\n message: `global daily cap of ${CAPS.global.perDay} calls reached`,\n hint: 'resets on a rolling 24h window; see `lnrelay budget`',\n },\n };\n }\n\n const cap = CAPS[cls];\n const forClass = within(ledger.spends[cls], now, DAY);\n if (forClass.length >= cap.perDay) {\n return {\n error: {\n code: 'BUDGET_EXHAUSTED',\n message: `daily cap of ${cap.perDay} reached for '${cls}'`,\n hint: `cap provenance: ${cap.provenance} (${cap.note}). See \\`lnrelay budget\\`.`,\n },\n };\n }\n\n return {\n permit: { class: cls, issuedAt: now } as Permit,\n ledger: { spends: { ...ledger.spends, [cls]: [...forClass, now] } },\n };\n}\n\nexport interface BudgetSummary {\n class: SpendClass;\n spentInWindow: number;\n cap: number;\n remaining: number;\n capProvenance: CapProvenance;\n warning?: string;\n}\n\nexport function summarise(ledger: Ledger, cls: SpendClass, now: number): BudgetSummary {\n const cap = CAPS[cls];\n const spent =\n cls === 'global' ? allSpends(ledger, now).length : within(ledger.spends[cls], now, DAY).length;\n const remaining = Math.max(0, cap.perDay - spent);\n\n const summary: BudgetSummary = {\n class: cls,\n spentInWindow: spent,\n cap: cap.perDay,\n remaining,\n capProvenance: cap.provenance,\n };\n if (remaining / cap.perDay < 0.25) {\n summary.warning = `only ${remaining} of ${cap.perDay} '${cls}' calls left in this 24h window — consider stopping`;\n }\n return summary;\n}\n\n// ─── The circuit breaker ──────────────────────────────────────────────────────\n\nexport type CooldownReason = 'RATE_LIMITED' | 'REQUEST_DENIED' | 'CHALLENGE_DETECTED';\n\nexport interface Cooldown {\n reason: CooldownReason;\n since: number;\n /** Epoch-ms when it lifts, or null for indefinite. */\n until: number | null;\n clearRequires: 'time' | 'human';\n}\n\n/**\n * Open a cooldown. The durations escalate with how bad the signal is: a 429 is\n * a throttle, a 999 is a network-layer bot block that lifts only as traffic\n * normalises, and a challenge means LinkedIn wants to see a human — so only a\n * human can clear it, via `lnrelay budget --reset-cooldown --confirm`.\n */\nexport function openCooldown(reason: CooldownReason, now: number): Cooldown {\n if (reason === 'CHALLENGE_DETECTED') {\n return { reason, since: now, until: null, clearRequires: 'human' };\n }\n const duration = reason === 'REQUEST_DENIED' ? 6 * HOUR : HOUR;\n return { reason, since: now, until: now + duration, clearRequires: 'time' };\n}\n\nexport function activeCooldown(cooldown: Cooldown | null, now: number): boolean {\n if (cooldown === null) return false;\n if (cooldown.until === null) return true;\n return now < cooldown.until;\n}\n","import type { Envelope, Err, Ok } from './types.ts';\n\nexport function ok<T>(command: string, data: T): Ok<T> {\n return { ok: true, command, data };\n}\n\nexport function err(\n command: string,\n code: string,\n message: string,\n hint?: string,\n status?: number,\n retryAfterMs?: number,\n): Err {\n const error: Err['error'] = { code, message };\n if (hint !== undefined) error.hint = hint;\n if (status !== undefined) error.status = status;\n if (retryAfterMs !== undefined) error.retryAfterMs = retryAfterMs;\n return { ok: false, command, error };\n}\n\nexport function toJson(envelope: unknown): string {\n return JSON.stringify(envelope, null, 2);\n}\n\n// ─── Error taxonomy ───────────────────────────────────────────────────────────\n\nexport const ERROR_CODES = [\n // Raised before any network call is made.\n 'INVALID_INPUT',\n 'UNKNOWN_COMMAND',\n 'CONFIRMATION_REQUIRED',\n 'BUDGET_EXHAUSTED',\n 'COOLDOWN_ACTIVE',\n 'CACHE_CORRUPT',\n 'NOT_IMPLEMENTED',\n // Raised from a response.\n 'AUTH_FAILED',\n 'RATE_LIMITED',\n 'REQUEST_DENIED', // HTTP 999 — LinkedIn's non-standard bot block\n 'CHALLENGE_DETECTED',\n 'SCHEMA_DRIFT',\n 'NOT_FOUND',\n 'FETCH_FAILED',\n 'FETCH_TIMEOUT',\n] as const;\n\nexport type ErrorCode = (typeof ERROR_CODES)[number];\n\n/**\n * Whether a failure may be retried automatically.\n *\n * Almost everything is `false`, and that is the point. On LinkedIn a 429 is the\n * warning shot on a documented escalation ladder — retrying into it is the\n * mechanism by which a throttle becomes a restriction. A `retryAfterMs` is\n * information to print for a human, never permission for the process to try\n * again. The single exception is a timeout where no response was received at\n * all, which carries no signal about our standing with LinkedIn.\n *\n * This is a deliberate break with x-relay, which retries 429 three times. That\n * is correct on a platform where the worst case is a temporary block.\n */\nexport function isRetryable(code: ErrorCode | string): boolean {\n return code === 'FETCH_TIMEOUT';\n}\n\n/** 0 success · 1 command error · 2 unknown command. */\nexport function exitCodeFor(envelope: Envelope): number {\n if (envelope.ok) return 0;\n return envelope.error.code === 'UNKNOWN_COMMAND' ? 2 : 1;\n}\n","// Single source of truth for command definitions. Drives CLI dispatch + help,\n// the MCP tool surface, and the SKILL.md parity test.\n//\n// `audience` is load-bearing, not documentation: the MCP shim registers only\n// commands marked `mcp`, so a write can never reach an agent by accident. The\n// research half of this tool is the product; writes are a thin, human-gated\n// layer that arrives last (docs/PLAN.md Phase 6).\n\nexport type Audience = 'cli' | 'mcp';\nexport type RiskClass = 'read' | 'local' | 'write';\n\nexport interface CommandDef {\n name: string;\n /** Funnel cost hint shown in help + skill. */\n cost: string;\n summary: string;\n usage: string;\n audience: Audience[];\n risk: RiskClass;\n /** false until the command is actually wired up. */\n implemented: boolean;\n}\n\nexport const COMMANDS: CommandDef[] = [\n // ─── local / meta — no network, available today ────────────────────────────\n {\n name: 'doctor',\n cost: 'free with --offline',\n summary: 'Diagnose setup: entry point, cache dir, cookies, cooldown, budget.',\n usage: 'lnrelay doctor [--offline]',\n audience: ['cli', 'mcp'],\n risk: 'local',\n implemented: true,\n },\n {\n name: 'budget',\n cost: 'free',\n summary: \"Spend ledger per class, with each cap's provenance. Reset a cooldown here.\",\n usage: 'lnrelay budget [--reset-cooldown --confirm]',\n audience: ['cli', 'mcp'],\n risk: 'local',\n implemented: true,\n },\n {\n name: 'risk',\n cost: 'free',\n summary: 'Circuit-breaker state. Check this BEFORE spending budget on research.',\n usage: 'lnrelay risk',\n audience: ['cli', 'mcp'],\n risk: 'local',\n implemented: true,\n },\n\n // ─── session ───────────────────────────────────────────────────────────────\n {\n name: 'login',\n cost: 'free — local browser',\n summary: 'Mint a session from a logged-in Chrome via DevTools. Stores cookies owner-only.',\n usage:\n 'lnrelay login\\n' +\n ' Requires a Chrome started with remote debugging on port 9222 (see docs/PLAN.md).',\n audience: ['cli'],\n risk: 'local',\n implemented: true,\n },\n\n // ─── reads — verified live 2026-08-01 ─────────────────────────────────────\n {\n name: 'whoami',\n cost: '1 call',\n summary: 'The authenticated member: name, headline, URN.',\n usage: 'lnrelay whoami',\n audience: ['cli', 'mcp'],\n risk: 'read',\n implemented: true,\n },\n {\n name: 'profile',\n cost: '1 call (+1 per section)',\n summary: 'A member profile. Expensive sections are opt-in.',\n usage:\n 'lnrelay profile <public-id|urn|url> [--raw]\\n' +\n \" Returns headline, location, current title, company and school. LinkedIn's profile\\n\" +\n ' projections do not return a name — use the identifier you passed in.',\n audience: ['cli', 'mcp'],\n risk: 'read',\n implemented: true,\n },\n {\n name: 'search',\n cost: 'cheap — the net',\n summary: 'Search people, companies or jobs. Cast wide, then deep-read the finalists.',\n usage:\n 'lnrelay search people|companies|jobs \"<query>\" [--limit N]\\n' +\n ' [--compact | --fields a,b,c] [--retain] [--raw]',\n audience: ['cli', 'mcp'],\n risk: 'read',\n implemented: true,\n },\n {\n name: 'post',\n cost: 'expensive — full read',\n summary: 'A post plus its comment thread, cursor-followed.',\n usage:\n 'lnrelay post <activity-urn|url> [--limit N] [--compact | --fields a,b] [--retain]\\n' +\n ' Check meta.returnedCount / claimedCount / state. claimedCount > 0 with\\n' +\n ' returnedCount 0 is a FAILED FETCH, not an empty thread.',\n audience: ['cli', 'mcp'],\n risk: 'read',\n implemented: true,\n },\n {\n name: 'reactions',\n cost: 'medium',\n summary: 'Who reacted to a post, and with which reaction.',\n usage: 'lnrelay reactions <activity-urn|url> [--limit N] [--compact | --fields a,b]',\n audience: ['cli', 'mcp'],\n risk: 'read',\n implemented: true,\n },\n {\n name: 'company',\n cost: 'medium',\n summary: 'A company page, optionally with a bounded sample of its updates.',\n usage: 'lnrelay company <universal-name|url> [--updates N]',\n audience: ['cli', 'mcp'],\n risk: 'read',\n implemented: false,\n },\n {\n name: 'job',\n cost: '1 call',\n summary: 'A job posting detail.',\n usage: 'lnrelay job <job-id|url>',\n audience: ['cli', 'mcp'],\n risk: 'read',\n implemented: false,\n },\n {\n name: 'feed',\n cost: 'medium',\n summary: 'Your own chronological feed.',\n usage: 'lnrelay feed [--limit N] [--compact | --fields a,b,c] [--retain] [--raw]',\n audience: ['cli', 'mcp'],\n risk: 'read',\n implemented: true,\n },\n\n // ─── cache-backed — Phase 4 ────────────────────────────────────────────────\n {\n name: 'sync',\n cost: 'medium — 1-2 calls',\n summary: 'Pull your own posts or connections into the local cache for offline search.',\n usage: 'lnrelay sync my-posts|connections [--limit N] [--force]',\n audience: ['cli'],\n risk: 'read',\n implemented: true,\n },\n {\n name: 'connections',\n cost: 'free — local cache',\n summary: 'Your connections, from the local cache. Fill it with `sync connections`.',\n usage:\n 'lnrelay connections [-q \"<query>\"] [--limit N] [--compact | --fields a,b] # free; cache',\n audience: ['cli', 'mcp'],\n risk: 'read',\n implemented: true,\n },\n {\n name: 'my-posts',\n cost: 'free — local cache',\n summary: 'Your own authored posts, from the local cache. Fill it with `sync my-posts`.',\n usage:\n 'lnrelay my-posts [-q \"<query>\"] [--limit N] [--compact | --fields a,b] # free; cache',\n audience: ['cli', 'mcp'],\n risk: 'read',\n implemented: true,\n },\n {\n name: 'local',\n cost: 'free — local cache',\n summary: 'Offline search across everything synced. The default research path after a sync.',\n usage:\n 'lnrelay local \"<query>\" [--source connections,my-posts,third-party] [--since YYYY-MM-DD]\\n' +\n ' [--limit N] [--compact | --fields a,b,c]',\n audience: ['cli', 'mcp'],\n risk: 'read',\n implemented: true,\n },\n {\n name: 'cache-status',\n cost: 'free — local cache',\n summary: 'What is cached, per source, with sync checkpoints and the retention policy.',\n usage: 'lnrelay cache-status',\n audience: ['cli', 'mcp'],\n risk: 'local',\n implemented: true,\n },\n {\n name: 'purge',\n cost: 'free',\n summary: 'Delete cached data. Never contacts LinkedIn.',\n usage: 'lnrelay purge [--all] --confirm # default scope: third-party only',\n audience: ['cli'],\n risk: 'local',\n implemented: true,\n },\n\n // ─── writes — Phase 6, official OAuth only, never MCP ──────────────────────\n {\n name: 'oauth',\n cost: 'free',\n summary: 'OAuth token status for writes. Never prints the token.',\n usage: 'lnrelay oauth',\n audience: ['cli'],\n risk: 'local',\n implemented: true,\n },\n {\n name: 'share',\n cost: '1 call — write',\n summary: \"Post to your own feed via LinkedIn's official OAuth scope.\",\n usage:\n 'lnrelay share \"<text>\" [--visibility public|connections]\\n' +\n ' Stops and asks at an interactive terminal. No TTY = no write, and no network call.',\n audience: ['cli'],\n risk: 'write',\n implemented: true,\n },\n {\n name: 'comment',\n cost: '1 call — write',\n summary: 'Comment on a post via the official OAuth scope.',\n usage: 'lnrelay comment <activity-urn> \"<text>\"',\n audience: ['cli'],\n risk: 'write',\n implemented: true,\n },\n {\n name: 'react',\n cost: '1 call — write',\n summary: 'React to a post via the official OAuth scope. Reversible.',\n usage: 'lnrelay react <activity-urn> [--type LIKE|PRAISE|EMPATHY|INTEREST|APPRECIATION]',\n audience: ['cli'],\n risk: 'write',\n implemented: true,\n },\n];\n\nexport const commandNames = COMMANDS.map((c) => c.name);\n\nexport function findCommand(name: string): CommandDef | undefined {\n return COMMANDS.find((c) => c.name === name);\n}\n\n/** Commands the MCP shim may register. Writes are structurally excluded. */\nexport function mcpCommands(): CommandDef[] {\n return COMMANDS.filter((c) => c.audience.includes('mcp') && c.risk !== 'write');\n}\n\nexport function helpText(): string {\n const lines = ['lnrelay — deep research over LinkedIn from your own account', '', 'Commands:'];\n const width = Math.max(...commandNames.map((n) => n.length));\n for (const c of COMMANDS) {\n const flag = c.implemented ? ' ' : '·'; // · = designed, not yet wired\n lines.push(` ${flag} ${c.name.padEnd(width)} ${c.summary} [${c.cost}]`);\n }\n lines.push('', ' · = specified in docs/DESIGN.md, not yet implemented');\n lines.push('', 'Run `lnrelay <command> --help` for usage.');\n return lines.join('\\n');\n}\n","// ─── Rest.li 2.0 variables grammar ────────────────────────────────────────────\n//\n// LinkedIn's Voyager GraphQL endpoint does NOT take JSON variables. It takes\n// Rest.li 2.0's own tuple grammar:\n//\n// (key:value,key2:value2) object literal\n// List(a,b,c) array\n// a | b OR-group inside a single filter value\n//\n// nested to arbitrary depth. Example (verified, R3 §2):\n//\n// ?queryId=voyagerSearchDashClusters.<hash>&variables=(start:0,query:(keywords:foo,\n// queryParameters:List((key:resultType,value:List(PEOPLE)))))\n//\n// Every client in the 90-repo corpus string-templates this. That is why adding a\n// filter is a guessing game for them: an unescaped comma or paren in a user's\n// search term silently terminates a tuple early and changes what you asked for\n// without erroring. This module is the pure, tested alternative.\n\n/** A value expressible in the Rest.li variables grammar. */\nexport type RestliValue =\n | string\n | number\n | boolean\n | undefined\n | RestliValue[]\n | { [key: string]: RestliValue };\n\n/**\n * Characters that must be percent-encoded inside a scalar value. Two distinct\n * hazards, both silent:\n *\n * Grammar `( ) , : |` change the shape of the tuple. A keyword containing\n * a comma would split one value into two.\n * URL `& # + space %` corrupt the query string the tuple is spliced\n * into. Searching for \"tom & jerry\" would inject a second query\n * parameter, and LinkedIn would answer a question we never asked\n * — returning 200 with plausible results for the wrong query.\n *\n * `%` is listed first and handled first, so an already-percent-looking value is\n * escaped rather than double-decoded into something else.\n */\nconst ENCODED: Record<string, string> = {\n '%': '%25', // MUST be first — see below\n '(': '%28',\n ')': '%29',\n ',': '%2C',\n ':': '%3A',\n '|': '%7C',\n '&': '%26',\n '#': '%23',\n '+': '%2B',\n ' ': '%20',\n};\n\nconst RESERVED = /[%(),:|&#+ ]/g;\n\nfunction encodeScalar(value: string | number | boolean): string {\n if (typeof value !== 'string') return String(value);\n // A single pass over the string, replacing each reserved character with its\n // escape. Because it is one pass, the `%` introduced by an escape is never\n // itself re-escaped — which is what makes the `%` entry above safe.\n return value.replace(RESERVED, (c) => ENCODED[c] ?? c);\n}\n\nfunction encodeValue(value: RestliValue): string | undefined {\n if (value === undefined) return undefined;\n if (Array.isArray(value)) {\n const members = value.map(encodeValue).filter((m): m is string => m !== undefined);\n return `List(${members.join(',')})`;\n }\n if (typeof value === 'object') return encodeObject(value);\n return encodeScalar(value);\n}\n\nfunction encodeObject(obj: { [key: string]: RestliValue }): string {\n const parts: string[] = [];\n for (const [key, value] of Object.entries(obj)) {\n const encoded = encodeValue(value);\n // An undefined value is omitted entirely — never emitted as the string\n // \"undefined\", which LinkedIn would treat as a real filter value.\n if (encoded !== undefined) parts.push(`${key}:${encoded}`);\n }\n return `(${parts.join(',')})`;\n}\n\n/** Encode a variables object into the Rest.li 2.0 grammar. */\nexport function encodeVariables(vars: { [key: string]: RestliValue }): string {\n return encodeObject(vars);\n}\n\n// ─── Composite URNs ───────────────────────────────────────────────────────────\n//\n// Voyager URNs are not always `urn:li:type:id`. Tuple forms appear inline:\n//\n// urn:li:fs_updateV2:(urn:li:activity:999,GROUP_FEED,EMPTY,DEFAULT,false)\n// urn:li:fsd_profilePositionGroup:(urn:li:fsd_profile:ABC,urn:li:fsd_company:(1,2))\n//\n// R3 §4 documents the reference implementation extracting the inner URN with\n// `split(\"(\")[1].split(\",\")[0]`. That is correct only until a member is itself a\n// tuple — and nested tuples do occur. A paren-aware split is barely more code\n// and does not have a silent failure mode.\n\nexport interface TupleUrn {\n /** The URN's own namespace, e.g. `fs_updateV2`. */\n namespace: string;\n /** Top-level members, with nested tuples left intact. */\n members: string[];\n}\n\n/**\n * Parse a composite (tuple-form) URN. Returns null when the URN is not\n * composite, or when its parentheses are unbalanced — an unbalanced URN is\n * malformed data, and guessing at its members would invent structure.\n */\nexport function parseTupleUrn(urn: string): TupleUrn | null {\n const open = urn.indexOf(':(');\n if (open === -1 || !urn.endsWith(')')) return null;\n\n const namespace = urn.slice(0, open).split(':').pop();\n if (namespace === undefined || namespace === '') return null;\n\n const body = urn.slice(open + 2, -1);\n const members: string[] = [];\n let depth = 0;\n let current = '';\n\n for (const char of body) {\n if (char === '(') depth++;\n else if (char === ')') depth--;\n\n if (depth < 0) return null; // closed one we never opened\n\n if (char === ',' && depth === 0) {\n members.push(current);\n current = '';\n } else {\n current += char;\n }\n }\n if (depth !== 0) return null; // opened one we never closed\n\n members.push(current);\n return { namespace, members };\n}\n\n/**\n * The identity a composite URN wraps — its first member. A non-composite URN is\n * returned unchanged, so this is safe to call on any URN.\n */\nexport function innerUrn(urn: string): string {\n const parsed = parseTupleUrn(urn);\n const first = parsed?.members[0];\n return first ?? urn;\n}\n\n// ─── Namespace collapse ───────────────────────────────────────────────────────\n//\n// R3 §4: LinkedIn is mid-migration from `fs_*` (legacy) to `fsd_*` (dash), and\n// three profile URN forms coexist in live responses — the reference client\n// literally string-replaces between them. This is the same legacy/hoisted split\n// that cost x-relay real data, and the fix is the same: collapse to one identity\n// so dedupe and cross-referencing are structural rather than best-effort.\n//\n// Only mappings we have direct evidence for are listed. An unknown namespace\n// passes through untouched — inventing a mapping would silently merge two\n// distinct entities, which is worse than leaving them separate.\nconst NAMESPACE_ALIASES: Record<string, string> = {\n fs_miniProfile: 'fsd_profile',\n fs_profile: 'fsd_profile',\n};\n\n/**\n * Canonicalise a URN: unwrap composite forms to their inner identity, then\n * collapse known legacy namespace aliases onto their dash equivalent.\n * Idempotent.\n */\nexport function canonicalUrn(urn: string): string {\n const inner = innerUrn(urn);\n const parts = inner.split(':');\n // urn:li:<namespace>:<id...>\n const namespace = parts[2];\n if (namespace === undefined) return inner;\n\n const alias = NAMESPACE_ALIASES[namespace];\n if (alias === undefined) return inner;\n\n parts[2] = alias;\n return parts.join(':');\n}\n"],"mappings":";AAQO,SAAS,UAAU,MAA4B;AACpD,QAAM,CAAC,SAAS,GAAG,IAAI,IAAI;AAC3B,QAAM,cAAwB,CAAC;AAC/B,QAAM,QAA0C,CAAC;AAEjD,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,QAAQ,KAAK,CAAC;AACpB,QAAI,UAAU,OAAW;AAEzB,QAAI,MAAM,WAAW,IAAI,GAAG;AAC1B,YAAM,MAAM,MAAM,MAAM,CAAC;AACzB,YAAM,OAAO,KAAK,IAAI,CAAC;AAEvB,UAAI,SAAS,UAAa,CAAC,KAAK,WAAW,IAAI,GAAG;AAChD,cAAM,GAAG,IAAI;AACb;AAAA,MACF,OAAO;AACL,cAAM,GAAG,IAAI;AAAA,MACf;AAAA,IACF,WAAW,MAAM,WAAW,GAAG,KAAK,MAAM,SAAS,GAAG;A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