openrich 0.0.0-stage → 0.1.1

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.
Files changed (65) hide show
  1. package/.env.example +23 -0
  2. package/LICENSE +21 -0
  3. package/README.md +410 -2
  4. package/assets/logo.svg +41 -0
  5. package/dist/cli.d.ts +2 -0
  6. package/dist/cli.js +144 -0
  7. package/dist/env.d.ts +5 -0
  8. package/dist/env.js +24 -0
  9. package/dist/eval.d.ts +30 -0
  10. package/dist/eval.js +78 -0
  11. package/dist/mcp/client.d.ts +31 -0
  12. package/dist/mcp/client.js +94 -0
  13. package/dist/mcp/oauth.d.ts +13 -0
  14. package/dist/mcp/oauth.js +93 -0
  15. package/dist/mcp/server.d.ts +87 -0
  16. package/dist/mcp/server.js +125 -0
  17. package/dist/merge.d.ts +7 -0
  18. package/dist/merge.js +39 -0
  19. package/dist/providers/devplatforms.d.ts +34 -0
  20. package/dist/providers/devplatforms.js +612 -0
  21. package/dist/providers/finders.d.ts +38 -0
  22. package/dist/providers/finders.js +708 -0
  23. package/dist/providers/freetier.d.ts +9 -0
  24. package/dist/providers/freetier.js +254 -0
  25. package/dist/providers/github.d.ts +8 -0
  26. package/dist/providers/github.js +109 -0
  27. package/dist/providers/identity.d.ts +5 -0
  28. package/dist/providers/identity.js +62 -0
  29. package/dist/providers/index.d.ts +10 -0
  30. package/dist/providers/index.js +68 -0
  31. package/dist/providers/knowledge.d.ts +52 -0
  32. package/dist/providers/knowledge.js +302 -0
  33. package/dist/providers/pattern.d.ts +6 -0
  34. package/dist/providers/pattern.js +99 -0
  35. package/dist/providers/registries.d.ts +36 -0
  36. package/dist/providers/registries.js +396 -0
  37. package/dist/providers/research.d.ts +30 -0
  38. package/dist/providers/research.js +471 -0
  39. package/dist/providers/signals.d.ts +15 -0
  40. package/dist/providers/signals.js +116 -0
  41. package/dist/providers/smtp.d.ts +25 -0
  42. package/dist/providers/smtp.js +97 -0
  43. package/dist/providers/social.d.ts +37 -0
  44. package/dist/providers/social.js +657 -0
  45. package/dist/providers/verifiers.d.ts +47 -0
  46. package/dist/providers/verifiers.js +455 -0
  47. package/dist/providers/websearch.d.ts +32 -0
  48. package/dist/providers/websearch.js +346 -0
  49. package/dist/router.d.ts +31 -0
  50. package/dist/router.js +214 -0
  51. package/dist/server.d.ts +2 -0
  52. package/dist/server.js +52 -0
  53. package/dist/store.d.ts +32 -0
  54. package/dist/store.js +95 -0
  55. package/dist/types.d.ts +82 -0
  56. package/dist/types.js +1 -0
  57. package/dist/util/http.d.ts +19 -0
  58. package/dist/util/http.js +34 -0
  59. package/dist/util/match.d.ts +23 -0
  60. package/dist/util/match.js +72 -0
  61. package/dist/util/names.d.ts +11 -0
  62. package/dist/util/names.js +56 -0
  63. package/dist/util/patterns.d.ts +14 -0
  64. package/dist/util/patterns.js +61 -0
  65. package/package.json +55 -4
@@ -0,0 +1,9 @@
1
+ import type { Finding, Provider } from '../types.ts';
2
+ export declare const hunterProvider: Provider;
3
+ export declare const pdlProvider: Provider;
4
+ export declare const ENROW_MCP_URL = "https://mcp.enrow.io/mcp";
5
+ /** Turns an Enrow result (same shape from the API and from the MCP tool) into findings. */
6
+ export declare function enrowFindings(d: any, via: string): Finding[];
7
+ export declare const enrowProvider: Provider;
8
+ export declare const getprospectProvider: Provider;
9
+ export declare const prospeoProvider: Provider;
@@ -0,0 +1,254 @@
1
+ import { getJson, HttpError, QuotaExceeded } from "../util/http.js";
2
+ import { McpClient, McpError } from "../mcp/client.js";
3
+ /**
4
+ * Free-tier APIs. Each uses the user's OWN key on the provider's free plan.
5
+ * One account per user; never rotate keys across accounts (that breaks every provider's terms).
6
+ * Quotas below are the free-plan numbers from research/people-sources.md (Dec 2026); the router
7
+ * also stops a provider for the period as soon as it answers 402/429.
8
+ */
9
+ const s = (v) => (typeof v === 'string' && v.trim() ? v.trim() : null);
10
+ export const hunterProvider = {
11
+ id: 'hunter',
12
+ kind: 'free-tier',
13
+ description: 'Hunter.io Email Finder (free plan: 50 credits/month)',
14
+ provides: ['email', 'title', 'linkedin', 'twitter', 'phone', 'company'],
15
+ keyEnv: 'HUNTER_API_KEY',
16
+ quota: { limit: 50, period: 'month' },
17
+ needs: (q) => Boolean(q.firstName && q.lastName && (q.domain || q.company) && !q.email),
18
+ async run(q, ctx) {
19
+ const p = new URLSearchParams({ first_name: q.firstName, last_name: q.lastName, api_key: ctx.env.HUNTER_API_KEY });
20
+ if (q.domain)
21
+ p.set('domain', q.domain);
22
+ else
23
+ p.set('company', q.company);
24
+ const r = await getJson(ctx.fetch, `https://api.hunter.io/v2/email-finder?${p}`);
25
+ const d = r.data?.data;
26
+ if (!d?.email)
27
+ return [];
28
+ const conf = Math.min(0.95, (d.score ?? 50) / 100) * (d.accept_all ? 0.7 : 1);
29
+ const out = [{ field: 'email', value: d.email.toLowerCase(), source: 'hunter', confidence: conf, evidence: `score ${d.score}${d.accept_all ? ', accept-all domain' : ''}` }];
30
+ const add = (field, v) => { const x = s(v); if (x)
31
+ out.push({ field, value: x, source: 'hunter', confidence: 0.7 }); };
32
+ add('title', d.position);
33
+ add('linkedin', d.linkedin_url);
34
+ add('twitter', d.twitter ? `https://x.com/${d.twitter}` : null);
35
+ add('phone', d.phone_number);
36
+ add('company', d.company);
37
+ return out;
38
+ },
39
+ };
40
+ export const pdlProvider = {
41
+ id: 'pdl',
42
+ kind: 'free-tier',
43
+ description: 'People Data Labs Person Enrichment (free plan: 100/month; contact fields may be withheld on free)',
44
+ provides: ['title', 'company', 'location', 'linkedin', 'github', 'twitter', 'email', 'phone', 'name'],
45
+ keyEnv: 'PDL_API_KEY',
46
+ quota: { limit: 100, period: 'month' },
47
+ needs: (q) => Boolean(q.email || (q.name && (q.domain || q.company))),
48
+ async run(q, ctx) {
49
+ const p = new URLSearchParams({ min_likelihood: '6' });
50
+ if (q.email)
51
+ p.set('email', q.email);
52
+ if (q.name)
53
+ p.set('name', q.name);
54
+ if (q.domain)
55
+ p.set('company', q.domain);
56
+ else if (q.company)
57
+ p.set('company', q.company);
58
+ const r = await getJson(ctx.fetch, `https://api.peopledatalabs.com/v5/person/enrich?${p}`, {
59
+ headers: { 'X-Api-Key': ctx.env.PDL_API_KEY },
60
+ });
61
+ const d = r.data?.data;
62
+ if (!d)
63
+ return [];
64
+ const conf = Math.min(0.95, (r.data.likelihood ?? 6) / 10);
65
+ const out = [];
66
+ const add = (field, v, c = conf) => { const x = s(v); if (x)
67
+ out.push({ field, value: x, source: 'pdl', confidence: c }); };
68
+ add('name', d.full_name);
69
+ add('title', d.job_title);
70
+ add('company', d.job_company_name);
71
+ add('location', d.location_name);
72
+ add('linkedin', d.linkedin_url ? `https://${String(d.linkedin_url).replace(/^https?:\/\//, '')}` : null);
73
+ add('github', d.github_url ? `https://${String(d.github_url).replace(/^https?:\/\//, '')}` : null);
74
+ add('twitter', d.twitter_url ? `https://${String(d.twitter_url).replace(/^https?:\/\//, '')}` : null);
75
+ add('email', typeof d.work_email === 'string' ? d.work_email.toLowerCase() : null);
76
+ add('phone', d.mobile_phone);
77
+ return out;
78
+ },
79
+ };
80
+ export const ENROW_MCP_URL = 'https://mcp.enrow.io/mcp';
81
+ /** Turns an Enrow result (same shape from the API and from the MCP tool) into findings. */
82
+ export function enrowFindings(d, via) {
83
+ if ((d?.qualification === 'valid' || d?.qualification === 'found') && d.email) {
84
+ return [{ field: 'email', value: String(d.email).toLowerCase(), source: 'enrow', confidence: 0.88, evidence: `qualification ${d.qualification} (${via})` }];
85
+ }
86
+ return [];
87
+ }
88
+ const ongoing = (d) => !d || d.qualification === 'ongoing' || (!d.qualification && /operating|ongoing|pending/i.test(String(d.message ?? '')));
89
+ export const enrowProvider = {
90
+ id: 'enrow',
91
+ kind: 'free-tier',
92
+ description: 'Enrow Email Finder (free plan: 50 credits/month through its MCP server; API key on paid plans)',
93
+ provides: ['email'],
94
+ keyEnv: 'ENROW_API_KEY',
95
+ enabled: (env) => Boolean(env.ENROW_API_KEY || env.ENROW_MCP_TOKEN),
96
+ quota: { limit: 50, period: 'month' },
97
+ needs: (q) => Boolean(q.name && (q.domain || q.company) && !q.email),
98
+ async run(q, ctx) {
99
+ const body = { fullname: q.name };
100
+ if (q.domain)
101
+ body.company_domain = q.domain;
102
+ else
103
+ body.company_name = q.company;
104
+ const wait = (i) => new Promise((r) => setTimeout(r, i < 5 ? 1000 : 3000));
105
+ // Free plan: call Enrow's own MCP server like an API, signed in with `openrich login enrow`.
106
+ if (!ctx.env.ENROW_API_KEY) {
107
+ const mcp = new McpClient(ENROW_MCP_URL, ctx.env.ENROW_MCP_TOKEN, ctx.fetch);
108
+ try {
109
+ const start = await mcp.callTool('find_email', body);
110
+ if (start.isError) {
111
+ if (/credit|quota|limit/i.test(start.text))
112
+ throw new QuotaExceeded(`enrow: ${start.text}`);
113
+ throw new Error(`enrow find_email: ${start.text.slice(0, 200)}`);
114
+ }
115
+ const id = start.data?.id;
116
+ if (!id)
117
+ return enrowFindings(start.data, 'mcp');
118
+ for (let i = 0; i < 30; i++) {
119
+ await wait(i);
120
+ const r = await mcp.callTool('get_email_result', { id });
121
+ if (r.isError)
122
+ throw new Error(`enrow get_email_result: ${r.text.slice(0, 200)}`);
123
+ if (ongoing(r.data))
124
+ continue;
125
+ return enrowFindings(r.data, 'mcp');
126
+ }
127
+ }
128
+ catch (e) {
129
+ if (e instanceof McpError && e.status === 401)
130
+ throw new Error('enrow: MCP sign-in expired, run `openrich login enrow`');
131
+ if (e instanceof McpError && (e.status === 402 || e.status === 429))
132
+ throw new QuotaExceeded(`enrow MCP HTTP ${e.status}`);
133
+ throw e;
134
+ }
135
+ ctx.log('enrow: gave up waiting for result');
136
+ return [];
137
+ }
138
+ // Paid plan: REST API.
139
+ const headers = { 'x-api-key': ctx.env.ENROW_API_KEY, 'content-type': 'application/json' };
140
+ const start = await getJson(ctx.fetch, 'https://api.enrow.io/email/find/single', { method: 'POST', headers, body: JSON.stringify(body) });
141
+ const id = start.data?.id;
142
+ if (!id)
143
+ return [];
144
+ for (let i = 0; i < 30; i++) {
145
+ await wait(i);
146
+ const res = await ctx.fetch(`https://api.enrow.io/email/find/single?id=${encodeURIComponent(id)}`, {
147
+ headers,
148
+ signal: AbortSignal.timeout(15000),
149
+ });
150
+ if (res.status === 202)
151
+ continue;
152
+ if (res.status === 402)
153
+ throw new QuotaExceeded('enrow: insufficient credits');
154
+ if (!res.ok)
155
+ throw new HttpError(res.status, await res.text(), res.url);
156
+ const d = await res.json();
157
+ if (ongoing(d))
158
+ continue;
159
+ return enrowFindings(d, 'api');
160
+ }
161
+ ctx.log('enrow: gave up waiting for result');
162
+ return [];
163
+ },
164
+ };
165
+ export const getprospectProvider = {
166
+ id: 'getprospect',
167
+ kind: 'free-tier',
168
+ description: 'GetProspect Email Finder (free plan: 50 valid emails/month, API included)',
169
+ provides: ['email'],
170
+ keyEnv: 'GETPROSPECT_API_KEY',
171
+ quota: { limit: 50, period: 'month' },
172
+ needs: (q) => Boolean(q.firstName && q.lastName && (q.domain || q.company) && !q.email),
173
+ async run(q, ctx) {
174
+ const data = { first_name: q.firstName, last_name: q.lastName };
175
+ if (q.domain)
176
+ data.domain = q.domain;
177
+ else
178
+ data.company = q.company;
179
+ const res = await ctx.fetch('https://api.getprospect.com/v2/email/find', {
180
+ method: 'POST',
181
+ headers: { 'x-api-key': ctx.env.GETPROSPECT_API_KEY, 'content-type': 'application/json' },
182
+ body: JSON.stringify({ data }),
183
+ signal: AbortSignal.timeout(100000), // docs: searches can take > 1 minute
184
+ });
185
+ if (res.status === 402 || res.status === 429)
186
+ throw new QuotaExceeded(`getprospect HTTP ${res.status}`);
187
+ if (res.status === 408) {
188
+ ctx.log('getprospect: search still running (408), not charged');
189
+ return [];
190
+ }
191
+ const j = await res.json().catch(() => null);
192
+ if (!res.ok && j?.data?.status !== 'not_found')
193
+ throw new HttpError(res.status, JSON.stringify(j), res.url);
194
+ if (j?.success && j.data?.email && j.data.status === 'valid') {
195
+ return [{ field: 'email', value: String(j.data.email).toLowerCase(), source: 'getprospect', confidence: 0.88, evidence: `status ${j.data.status}` }];
196
+ }
197
+ return [];
198
+ },
199
+ };
200
+ export const prospeoProvider = {
201
+ id: 'prospeo',
202
+ kind: 'free-tier',
203
+ description: 'Prospeo Enrich Person (free plan; 1 credit per email found, misses free, API on free plan)',
204
+ provides: ['email', 'title', 'linkedin', 'location', 'company', 'name'],
205
+ keyEnv: 'PROSPEO_API_KEY',
206
+ // Free plan: 100 credits/month (account-information endpoint, Dec 2026), API capped at 50 requests/day. Router also stops on 429.
207
+ quota: { limit: 100, period: 'month' },
208
+ needs: (q) => Boolean(q.email || (q.name && (q.domain || q.company))),
209
+ async run(q, ctx) {
210
+ const data = {};
211
+ if (q.firstName && q.lastName) {
212
+ data.first_name = q.firstName;
213
+ data.last_name = q.lastName;
214
+ }
215
+ else if (q.name)
216
+ data.full_name = q.name;
217
+ if (q.domain)
218
+ data.company_website = q.domain;
219
+ if (q.company)
220
+ data.company_name = q.company;
221
+ if (q.email)
222
+ data.email = q.email;
223
+ const res = await ctx.fetch('https://api.prospeo.io/enrich-person', {
224
+ method: 'POST',
225
+ headers: { 'X-KEY': ctx.env.PROSPEO_API_KEY, 'content-type': 'application/json' },
226
+ body: JSON.stringify({ data }),
227
+ signal: AbortSignal.timeout(30000),
228
+ });
229
+ const j = await res.json().catch(() => null);
230
+ const code = String(j?.error_code ?? '');
231
+ if (res.status === 429 || /RATE_LIMIT|INSUFFICIENT_CREDITS/i.test(code))
232
+ throw new QuotaExceeded(`prospeo ${code || res.status}`);
233
+ if (j?.error) {
234
+ if (/NO_MATCH|NOT_FOUND/i.test(code))
235
+ return [];
236
+ throw new HttpError(res.status, JSON.stringify(j), res.url);
237
+ }
238
+ const p = j?.person;
239
+ if (!p)
240
+ return [];
241
+ const out = [];
242
+ const add = (field, v, c = 0.8) => { const x = s(v); if (x)
243
+ out.push({ field, value: x, source: 'prospeo', confidence: c }); };
244
+ const em = p.email?.email;
245
+ if (typeof em === 'string' && !em.includes('*'))
246
+ add('email', em.toLowerCase(), p.email.status === 'VERIFIED' ? 0.9 : 0.6);
247
+ add('name', p.full_name);
248
+ add('title', p.current_job_title);
249
+ add('linkedin', p.linkedin_url);
250
+ add('location', [p.location?.city, p.location?.state, p.location?.country].filter(Boolean).join(', '));
251
+ add('company', j.company?.name);
252
+ return out;
253
+ },
254
+ };
@@ -0,0 +1,8 @@
1
+ import type { Provider } from '../types.ts';
2
+ /**
3
+ * GitHub (free; GITHUB_TOKEN optional, raises search limit 10 -> 30/min).
4
+ * - email given: find the account that authored commits with it
5
+ * - name + domain: find commit author emails at that domain
6
+ * - then read the public profile (name, company, location, blog, twitter, bio)
7
+ */
8
+ export declare const githubProvider: Provider;
@@ -0,0 +1,109 @@
1
+ import { getJson, UA } from "../util/http.js";
2
+ import { CLAIMED, LINKED, linksBack, sameName as samePerson } from "../util/match.js";
3
+ const API = 'https://api.github.com';
4
+ const NOREPLY = /noreply|users\.noreply\.github\.com|localhost|\.local$/i;
5
+ function headers(ctx) {
6
+ const h = { 'User-Agent': UA, Accept: 'application/vnd.github+json', 'X-GitHub-Api-Version': '2022-11-28' };
7
+ if (ctx.env.GITHUB_TOKEN)
8
+ h.Authorization = `Bearer ${ctx.env.GITHUB_TOKEN}`;
9
+ return h;
10
+ }
11
+ /** Same first and last name as the query, compared word by word ("YannLeCun25" is not "Yann LeCun"). */
12
+ function sameName(a, q) {
13
+ return Boolean(q.firstName && q.lastName) && samePerson(a ?? undefined, `${q.firstName} ${q.lastName}`);
14
+ }
15
+ function mentions(text, q) {
16
+ if (!text)
17
+ return false;
18
+ const t = text.toLowerCase();
19
+ if (q.domain && t.includes(q.domain.split('.')[0]))
20
+ return true;
21
+ if (q.company && t.includes(q.company.toLowerCase()))
22
+ return true;
23
+ return false;
24
+ }
25
+ /**
26
+ * GitHub (free; GITHUB_TOKEN optional, raises search limit 10 -> 30/min).
27
+ * - email given: find the account that authored commits with it
28
+ * - name + domain: find commit author emails at that domain
29
+ * - then read the public profile (name, company, location, blog, twitter, bio)
30
+ */
31
+ export const githubProvider = {
32
+ id: 'github',
33
+ kind: 'free',
34
+ description: 'GitHub public profiles and commit author emails',
35
+ provides: ['email', 'personal_email', 'github', 'name', 'company', 'location', 'website', 'twitter', 'bio', 'photo'],
36
+ needs: (q) => Boolean(q.github || q.email || (q.firstName && q.lastName && (q.domain || q.company))),
37
+ async run(q, ctx) {
38
+ const h = headers(ctx);
39
+ const out = [];
40
+ let login = q.github ?? null;
41
+ let matchConf = login ? 0.95 : 0;
42
+ if (!login && q.email) {
43
+ const r = await getJson(ctx.fetch, `${API}/search/commits?q=${encodeURIComponent(`author-email:${q.email}`)}&per_page=5`, { headers: h });
44
+ const a = r.data?.items?.find((i) => i.author?.login)?.author?.login;
45
+ if (a) {
46
+ login = a;
47
+ matchConf = 0.9;
48
+ }
49
+ }
50
+ if (!login && q.firstName && q.lastName && q.domain) {
51
+ const r = await getJson(ctx.fetch, `${API}/search/commits?q=${encodeURIComponent(`author-name:"${q.firstName} ${q.lastName}"`)}&per_page=50`, { headers: h });
52
+ const atDomain = new Map();
53
+ for (const it of r.data?.items ?? []) {
54
+ const em = String(it.commit?.author?.email ?? '').toLowerCase();
55
+ if (!em || NOREPLY.test(em))
56
+ continue;
57
+ if (em.endsWith(`@${q.domain}`) && sameName(it.commit?.author?.name, q))
58
+ atDomain.set(em, it.author?.login ?? null);
59
+ }
60
+ for (const [em, l] of atDomain) {
61
+ out.push({ field: 'email', value: em, source: 'github', confidence: 0.85, evidence: 'commit author email' });
62
+ if (l && !login) {
63
+ login = l;
64
+ matchConf = 0.85;
65
+ }
66
+ }
67
+ }
68
+ if (!login && q.firstName && q.lastName && (q.domain || q.company)) {
69
+ const r = await getJson(ctx.fetch, `${API}/search/users?q=${encodeURIComponent(`fullname:"${q.firstName} ${q.lastName}"`)}&per_page=5`, { headers: h });
70
+ for (const u of r.data?.items ?? []) {
71
+ const p = (await getJson(ctx.fetch, `${API}/users/${u.login}`, { headers: h })).data;
72
+ if (p && sameName(p.name, q) && (mentions(p.company, q) || mentions(p.blog, q) || (q.domain && p.email?.endsWith(`@${q.domain}`)))) {
73
+ // Name + company is only claimed: copycat accounts copy both. The person's own site linking
74
+ // back to this account is what a copycat cannot fake.
75
+ login = p.login;
76
+ matchConf = (await linksBack(ctx.fetch, p.blog, `github.com/${p.login}`)) ? LINKED : CLAIMED;
77
+ break;
78
+ }
79
+ }
80
+ }
81
+ if (!login)
82
+ return out;
83
+ const p = (await getJson(ctx.fetch, `${API}/users/${login}`, { headers: h })).data;
84
+ if (!p)
85
+ return out;
86
+ const c = matchConf;
87
+ const add = (field, value, conf = c) => {
88
+ if (typeof value === 'string' && value.trim())
89
+ out.push({ field, value: value.trim(), source: 'github', confidence: conf });
90
+ };
91
+ add('github', p.html_url);
92
+ add('name', p.name);
93
+ add('company', p.company?.replace(/^@/, ''));
94
+ add('location', p.location);
95
+ if (/(twitter|x)\.com\//i.test(p.blog ?? ''))
96
+ add('twitter', p.blog);
97
+ else
98
+ add('website', p.blog);
99
+ add('twitter', p.twitter_username ? `https://x.com/${p.twitter_username}` : null);
100
+ add('bio', p.bio);
101
+ add('photo', p.avatar_url, c * 0.9);
102
+ if (p.email && !NOREPLY.test(p.email)) {
103
+ const em = String(p.email).toLowerCase();
104
+ // A profile email at another domain (e.g. gmail) is not the work email we were asked for.
105
+ add(q.domain && !em.endsWith(`@${q.domain}`) ? 'personal_email' : 'email', em, Math.min(0.95, c));
106
+ }
107
+ return out;
108
+ },
109
+ };
@@ -0,0 +1,5 @@
1
+ import type { Provider } from '../types.ts';
2
+ /** Gravatar public profile by email hash (free, no key needed for public fields). */
3
+ export declare const gravatarProvider: Provider;
4
+ /** keys.openpgp.org: owner-verified email + the name on the key. */
5
+ export declare const openpgpProvider: Provider;
@@ -0,0 +1,62 @@
1
+ import { getJson, UA } from "../util/http.js";
2
+ import { openpgpLookup, sha256 } from "./signals.js";
3
+ /** Gravatar public profile by email hash (free, no key needed for public fields). */
4
+ export const gravatarProvider = {
5
+ id: 'gravatar',
6
+ kind: 'free',
7
+ description: 'Gravatar public profile from an email address',
8
+ provides: ['email', 'name', 'title', 'company', 'location', 'photo', 'bio', 'website', 'linkedin', 'github', 'twitter'],
9
+ needs: (q) => Boolean(q.email),
10
+ async run(q, ctx) {
11
+ const headers = { 'User-Agent': UA };
12
+ if (ctx.env.GRAVATAR_API_KEY)
13
+ headers.Authorization = `Bearer ${ctx.env.GRAVATAR_API_KEY}`;
14
+ const r = await getJson(ctx.fetch, `https://api.gravatar.com/v3/profiles/${sha256(q.email)}`, { headers });
15
+ const p = r.data;
16
+ if (!p)
17
+ return [];
18
+ const out = [{ field: 'email', value: q.email, source: 'gravatar', confidence: 0.75, evidence: 'gravatar profile exists' }];
19
+ const add = (field, v, conf = 0.75) => {
20
+ if (typeof v === 'string' && v.trim())
21
+ out.push({ field, value: v.trim(), source: 'gravatar', confidence: conf });
22
+ };
23
+ add('name', p.display_name);
24
+ add('title', p.job_title);
25
+ add('company', p.company);
26
+ add('location', p.location);
27
+ add('photo', p.avatar_url);
28
+ add('bio', p.description);
29
+ for (const a of p.verified_accounts ?? []) {
30
+ const t = String(a.service_type ?? a.service_label ?? '').toLowerCase();
31
+ if (t.includes('linkedin'))
32
+ add('linkedin', a.url, 0.9);
33
+ else if (t.includes('github'))
34
+ add('github', a.url, 0.9);
35
+ else if (t === 'twitter' || t === 'x')
36
+ add('twitter', a.url, 0.9);
37
+ }
38
+ for (const l of p.links ?? [])
39
+ add('website', l.url, 0.6);
40
+ return out;
41
+ },
42
+ };
43
+ /** keys.openpgp.org: owner-verified email + the name on the key. */
44
+ export const openpgpProvider = {
45
+ id: 'openpgp',
46
+ kind: 'free',
47
+ description: 'OpenPGP keyserver (owner-verified emails and key names)',
48
+ provides: ['email', 'name'],
49
+ needs: (q) => Boolean(q.email),
50
+ async run(q, ctx) {
51
+ const uids = await openpgpLookup(ctx.fetch, q.email);
52
+ if (!uids)
53
+ return [];
54
+ const out = [{ field: 'email', value: q.email, source: 'openpgp', confidence: 0.9, evidence: 'owner-verified key' }];
55
+ for (const u of uids) {
56
+ const m = u.match(/^([^<]+?)\s*</);
57
+ if (m && u.toLowerCase().includes(q.email))
58
+ out.push({ field: 'name', value: m[1], source: 'openpgp', confidence: 0.8 });
59
+ }
60
+ return out;
61
+ },
62
+ };
@@ -0,0 +1,10 @@
1
+ import type { Provider } from '../types.ts';
2
+ /**
3
+ * Default order.
4
+ * Free providers (no key, or a free key with no metered quota) run first, in parallel within a round.
5
+ * Free-tier providers run one at a time, in this order, only while a wanted field is still missing:
6
+ * 1. verifiers with a recurring allowance (confirming a guess costs less than finding)
7
+ * 2. finders with a recurring monthly allowance, richest first
8
+ * 3. one-time grants last, so they are not burned while recurring quota is left
9
+ */
10
+ export declare const DEFAULT_PROVIDERS: Provider[];
@@ -0,0 +1,68 @@
1
+ import { githubProvider } from "./github.js";
2
+ import { gravatarProvider, openpgpProvider } from "./identity.js";
3
+ import { patternProvider } from "./pattern.js";
4
+ import { enrowProvider, getprospectProvider, hunterProvider, pdlProvider, prospeoProvider } from "./freetier.js";
5
+ import { KNOWLEDGE_PROVIDERS } from "./knowledge.js";
6
+ import { RESEARCH_PROVIDERS } from "./research.js";
7
+ import { DEV_PROVIDERS } from "./devplatforms.js";
8
+ import { SOCIAL_PROVIDERS } from "./social.js";
9
+ import { REGISTRY_PROVIDERS } from "./registries.js";
10
+ import { FINDER_PROVIDERS } from "./finders.js";
11
+ import { VERIFIER_PROVIDERS } from "./verifiers.js";
12
+ import { exaPeopleProvider, exaWebsetsProvider, parallelEntityProvider, parallelSearchProvider, parallelTaskProvider } from "./websearch.js";
13
+ const byId = (list, ids) => ids.map((id) => {
14
+ const p = list.find((x) => x.id === id);
15
+ if (!p)
16
+ throw new Error(`provider ${id} missing`);
17
+ return p;
18
+ });
19
+ /** Verifiers spend a credit on every check (also on "invalid"), and confirm a guess instead of finding one. */
20
+ const verifier = (p) => ({ ...p, verifies: true, chargesOnMiss: true });
21
+ /** Finders that bill a request even when they find nothing. */
22
+ const CHARGE_ON_MISS = new Set(['diffbot', 'getemail', 'minelead']);
23
+ const finder = (p) => (CHARGE_ON_MISS.has(p.id) ? { ...p, chargesOnMiss: true } : p);
24
+ /** Sources keyed on handles or emails found during the lookup: worth one more try when new ones appear. */
25
+ const RETRY = new Set(['wkd', 'libravatar', 'mastodon', 'medium', 'nostr-nip05', 'launchpad']);
26
+ const retry = (p) => (RETRY.has(p.id) || DEV_PROVIDERS.includes(p) ? { ...p, retryOnNewInputs: true } : p);
27
+ const V = (ids) => byId(VERIFIER_PROVIDERS, ids).map(verifier);
28
+ const F = (ids) => byId(FINDER_PROVIDERS, ids).map(finder);
29
+ /**
30
+ * Default order.
31
+ * Free providers (no key, or a free key with no metered quota) run first, in parallel within a round.
32
+ * Free-tier providers run one at a time, in this order, only while a wanted field is still missing:
33
+ * 1. verifiers with a recurring allowance (confirming a guess costs less than finding)
34
+ * 2. finders with a recurring monthly allowance, richest first
35
+ * 3. one-time grants last, so they are not burned while recurring quota is left
36
+ */
37
+ export const DEFAULT_PROVIDERS = [
38
+ // free
39
+ githubProvider,
40
+ patternProvider,
41
+ gravatarProvider,
42
+ openpgpProvider,
43
+ ...KNOWLEDGE_PROVIDERS.filter((p) => p.kind === 'free'),
44
+ ...RESEARCH_PROVIDERS,
45
+ ...DEV_PROVIDERS.map(retry),
46
+ ...SOCIAL_PROVIDERS.map(retry),
47
+ ...REGISTRY_PROVIDERS,
48
+ parallelSearchProvider,
49
+ // free-tier: cheap profile finders (LinkedIn, title) at a fraction of a cent
50
+ exaPeopleProvider,
51
+ parallelEntityProvider,
52
+ // free-tier: recurring verifiers
53
+ ...V(['mailboxvalidator', 'verifalia', 'reoon', 'zerobounce', 'quickemailverification', 'abstract-email', 'enrow-verify', 'hunter-verify']),
54
+ // free-tier: recurring finders
55
+ prospeoProvider,
56
+ enrowProvider,
57
+ getprospectProvider,
58
+ hunterProvider,
59
+ ...F(['tomba', 'snov', 'skrapp', 'surfe', 'minelead', 'getemail', 'cufinder', 'datagma', 'diffbot', 'apollo']),
60
+ pdlProvider,
61
+ // free-tier: AI web research for email (slower, ~1 min, cents per run)
62
+ parallelTaskProvider,
63
+ exaWebsetsProvider,
64
+ ...KNOWLEDGE_PROVIDERS.filter((p) => p.kind === 'free-tier'),
65
+ // free-tier: one-time grants
66
+ ...V(['getprospect-verify', 'emailable', 'millionverifier', 'bouncer', 'clearout', 'debounce', 'kickbox', 'neverbounce']),
67
+ ...F(['voilanorbert', 'dropcontact', 'icypeas']),
68
+ ];
@@ -0,0 +1,52 @@
1
+ import type { PersonQuery, Provider, ProviderContext } from '../types.ts';
2
+ type Claim = {
3
+ mainsnak?: {
4
+ datavalue?: {
5
+ value?: any;
6
+ };
7
+ };
8
+ rank?: string;
9
+ qualifiers?: Record<string, {
10
+ datavalue?: {
11
+ value?: any;
12
+ };
13
+ }[]>;
14
+ };
15
+ type Entity = {
16
+ id: string;
17
+ labels?: Record<string, {
18
+ value: string;
19
+ }>;
20
+ aliases?: Record<string, {
21
+ value: string;
22
+ }[]>;
23
+ descriptions?: Record<string, {
24
+ value: string;
25
+ }>;
26
+ claims?: Record<string, Claim[]>;
27
+ sitelinks?: Record<string, {
28
+ title: string;
29
+ }>;
30
+ };
31
+ export interface WikidataCandidate {
32
+ entity: Entity;
33
+ /** Item labels, keyed by QID, for everything this entity points at (plus orgs it leads). */
34
+ labels: Record<string, string>;
35
+ /** Orgs that name this person as founder/CEO/chair. */
36
+ led: string[];
37
+ /** Human-readable reasons this person is linked to the query's company; empty = no link. */
38
+ companyHits: string[];
39
+ }
40
+ export declare function lookupWikidata(q: PersonQuery, ctx: ProviderContext): Promise<WikidataCandidate[]>;
41
+ export declare const wikidataProvider: Provider;
42
+ /** First sentence. A stop only counts when a capital follows and it does not end an initial or abbreviation ("Jane Q. Doe Jr. is"). */
43
+ export declare function firstSentence(s: string): string;
44
+ export declare const wikipediaProvider: Provider;
45
+ /**
46
+ * Google Knowledge Graph Search API. Free: 100,000 read calls/day per project (needs an API key
47
+ * from a Google Cloud project with the API enabled). Returns name + short description + a
48
+ * Wikipedia-derived detailedDescription; no employer field, so the company must appear in the text.
49
+ */
50
+ export declare const googleKgProvider: Provider;
51
+ export declare const KNOWLEDGE_PROVIDERS: Provider[];
52
+ export {};