domain-hound 0.1.5 → 0.1.7

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 (39) hide show
  1. package/.agents/plugins/marketplace.json +1 -0
  2. package/.claude-plugin/marketplace.json +1 -0
  3. package/.claude-plugin/plugin.json +1 -1
  4. package/README.md +84 -13
  5. package/assets/readme-search.png +0 -0
  6. package/clis/domain-check/broker-atom.mjs +78 -0
  7. package/clis/domain-check/com-site.mjs +64 -25
  8. package/clis/domain-check/confirm.mjs +10 -5
  9. package/clis/domain-check/dossier.mjs +603 -0
  10. package/clis/domain-check/google-play.mjs +24 -11
  11. package/clis/domain-check/index.mjs +75 -23
  12. package/clis/domain-check/marketplaces.mjs +107 -0
  13. package/clis/domain-check/meaning-words.LICENSE.txt +408 -0
  14. package/clis/domain-check/meaning-words.json +2397 -0
  15. package/clis/domain-check/meaning.mjs +77 -0
  16. package/clis/domain-check/name-search.mjs +91 -14
  17. package/clis/domain-check/naming-method.mjs +6 -4
  18. package/clis/domain-check/registry.mjs +2 -2
  19. package/clis/domain-check/safe-web.mjs +207 -0
  20. package/clis/domain-check/trademarks.mjs +372 -0
  21. package/clis/domain-check/triage-sources.mjs +39 -12
  22. package/clis/domain-check/triage.mjs +190 -63
  23. package/clis/spaceship/buy.mjs +327 -0
  24. package/clis/spaceship/client.mjs +170 -0
  25. package/clis/spaceship/dns.mjs +292 -0
  26. package/clis/spaceship/quote.mjs +123 -0
  27. package/clis/spaceship/setup.mjs +81 -0
  28. package/clis/spaceship/store.mjs +104 -0
  29. package/clis/spaceship/tools.mjs +258 -0
  30. package/display.mjs +57 -30
  31. package/dossier.mjs +185 -0
  32. package/package.json +20 -2
  33. package/plugin.json +4 -3
  34. package/results-style.mjs +10 -0
  35. package/results.mjs +258 -62
  36. package/server.json +2 -2
  37. package/server.mjs +223 -96
  38. package/share.mjs +43 -0
  39. package/site/r/share-format.mjs +125 -0
@@ -1,4 +1,5 @@
1
1
  import { cacheDir, mapLimit, readCache, writeCache } from './cache.mjs';
2
+ import { setTimeout as delay } from 'node:timers/promises';
2
3
  import { withShopPages } from './confirm.mjs';
3
4
  import { appNameMatches, compactText, day, request } from './triage-sources.mjs';
4
5
 
@@ -146,29 +147,38 @@ async function lookUp(source, name, input, deadline) {
146
147
  });
147
148
  }
148
149
 
150
+ // Leave room for a retry on slow pages or failed connections within the shared clock.
151
+ const playAttemptMs = 2800;
152
+
149
153
  export async function searchAndroidApps(names, options = {}) {
150
154
  const { directory = cacheDir, now = new Date(), playBudgetMs = 12000, cacheLifetime = day } = options;
151
- const deadline = performance.now() + Math.min(12000, playBudgetMs);
155
+ const budget = Math.min(30000, playBudgetMs);
156
+ const deadline = performance.now() + budget;
157
+ const retryMs = Math.min(playAttemptMs, budget / 2);
158
+ const answered = (name, apps) => { results.set(name, apps); options.onResult?.(name, apps); };
152
159
  const results = new Map();
153
160
  const pending = (await Promise.all([...names].map(async ([name, input]) => {
154
161
  const filename = 'triage-play-' + name + '.json';
155
162
  const prior = await readCache(directory, filename);
156
163
  const age = now.getTime() - prior?.at;
157
164
  if (age >= 0 && age < cacheLifetime && Array.isArray(prior.apps) && prior.apps.every(app => Object.hasOwn(app, 'ratings')) && (!prior.apps.length || prior.version === 2)) {
158
- results.set(name, prior.apps);
165
+ answered(name, prior.apps);
159
166
  return null;
160
167
  }
161
168
  return { name, input, filename };
162
169
  }))).filter(Boolean);
170
+ const waits = budget < 1600 ? [0, 0] : [0, 350, 1200];
163
171
  const search = useSource => mapLimit(pending, 5, async ({ name, input, filename }) => {
164
172
  if (performance.now() >= deadline) return;
165
- for (let attempt = 0; attempt < 2 && performance.now() < deadline; attempt++) {
173
+ for (const pause of waits) {
174
+ if (options.signal?.aborted || deadline - performance.now() < (pause ? retryMs + pause : 1)) break;
175
+ if (pause) await delay(pause);
166
176
  let source;
167
177
  try {
168
178
  source = await useSource();
169
- const apps = await lookUp(source, name, input, Math.min(deadline, performance.now() + 2800));
179
+ const apps = await lookUp(source, name, input, Math.min(deadline, performance.now() + 8000));
170
180
  if (apps === null || performance.now() >= deadline) continue;
171
- results.set(name, apps);
181
+ answered(name, apps);
172
182
  await writeCache(directory, filename, { at: now.getTime(), apps, version: 2 }).catch(() => {});
173
183
  return;
174
184
  } catch { /* An unavailable search gives no evidence about the name. */ }
@@ -176,12 +186,15 @@ export async function searchAndroidApps(names, options = {}) {
176
186
  }
177
187
  });
178
188
  if (pending.length && performance.now() < deadline) {
179
- let browserReady = false;
180
- let browserFailed = false;
181
- await withShopPages(deadline, async (_, openPage) => {
182
- browserReady = true;
183
- await search(async () => browserSource(await openPage()));
184
- }, { ...options, onFailure: () => { browserFailed = !browserReady; return null; } });
189
+ // The public search response includes the cards. A normal lookup needs no browser or page assets.
190
+ let browserFailed = !options.launch;
191
+ if (options.launch) {
192
+ let browserReady = false;
193
+ await withShopPages(deadline, async (_, openPage) => {
194
+ browserReady = true;
195
+ await search(async () => browserSource(await openPage()));
196
+ }, { ...options, onFailure: () => { browserFailed = !browserReady; return null; } });
197
+ }
185
198
  if (browserFailed && performance.now() < deadline) {
186
199
  const parse = await import('parse5').then(module => module.parse, () => null);
187
200
  if (parse) await search(() => fetchSource(parse, options));
@@ -1,11 +1,12 @@
1
1
  import { execFile } from 'node:child_process';
2
+ import { getDefaultAutoSelectFamilyAttemptTimeout, setDefaultAutoSelectFamilyAttemptTimeout } from 'node:net';
2
3
  import { setTimeout as delay } from 'node:timers/promises';
3
4
  import { pathToFileURL } from 'node:url';
4
5
  import { promisify } from 'node:util';
5
6
  import { apiShops, cachedSignals, confirmDomain, confirmingShops, lightConfirm } from './confirm.mjs';
6
7
  import { checkDomainSite } from './com-site.mjs';
7
8
  import { appStoreSearchLink, googleSearchLink, nameCheckLines, playSearchLink } from './google-search.mjs';
8
- import { applyLiveSite, asciiDomain, domainEnding, canRecommend, defaultEndings, eligibilityNotes, listQuote, mergeQuote, nameCandidates, normalizeName, pickName,
9
+ import { applyLiveSite, asciiDomain, domainEnding, canRecommend, defaultEndings, eligibilityNotes, endingTier, listQuote, mergeQuote, nameCandidates, normalizeName, pickName,
9
10
  premiumRisk, rankName, registrationStatus, searchCandidates, searchName, termCosts, unicodeName, validEligibility, validEndings,
10
11
  withPremiumRisk, withoutListPrice } from './name-search.mjs';
11
12
  import { bundledCatalog, catalogOffers, datedListPrices, isListPriceUsable, loadCachedCatalog, refreshPrices } from './price-catalog.mjs';
@@ -327,7 +328,7 @@ function agentPrice({ firstPayment: now, renewalPayment: renew, threeYear: y3, m
327
328
  const quoteClock = value => typeof value === 'string' ? value.match(/T(\d{2}:\d{2})/)?.[1] ?? null : null;
328
329
 
329
330
  function compactAgentResult(groups, names, complete, checkedAt, batch, rateLimited = false, liveCheck = null,
330
- { eligible, otherEndings } = {}) {
331
+ { eligible, otherEndings, requested = [] } = {}) {
331
332
  const buyUrlTemplate = {};
332
333
  const shopCheckWhy = {};
333
334
  const listPrices = {};
@@ -335,6 +336,7 @@ function compactAgentResult(groups, names, complete, checkedAt, batch, rateLimit
335
336
  const byName = new Map();
336
337
  let priceListDate;
337
338
  let best;
339
+ let bestTier;
338
340
  for (const { name, results } of groups) {
339
341
  const taken = [], resale = [], free = [], shop_check = [], reserved = [], likelyFree = [], likelyTaken = [];
340
342
  for (const row of results) {
@@ -390,8 +392,11 @@ function compactAgentResult(groups, names, complete, checkedAt, batch, rateLimit
390
392
  if (confirmed && !premium && canRecommend(row.tld, eligible) && !premiumRisk(row.domain)) {
391
393
  const { now, renew, y3, term, jump } = price;
392
394
  const buyUrl = row.buyUrl ?? shopSearchUrl(shopId, row.domain);
393
- // The cheapest confirmed quote is the pick; rows are already sorted by first payment within a name.
394
- if (best && (best.priceNow ?? Infinity) <= (now ?? Infinity)) continue;
395
+ // The cheapest confirmed quote in the most attractive tier is the pick; rows are already sorted by tier, then
396
+ // first payment within a name.
397
+ const tier = endingTier(row.domain, requested, eligible);
398
+ if (best && (bestTier < tier || bestTier === tier && (best.priceNow ?? Infinity) <= (now ?? Infinity))) continue;
399
+ bestTier = tier;
395
400
  best = { domain: row.domain, status: 'free-confirmed', ...(now != null && { priceNow: now }), ...(at && { at }),
396
401
  ...(renew != null && { renewal: renew }), ...(y3 != null && { threeYear: y3 }),
397
402
  ...(term && { term }),
@@ -439,11 +444,20 @@ function compactAgentResult(groups, names, complete, checkedAt, batch, rateLimit
439
444
  return result;
440
445
  }
441
446
 
442
- // The top pick and up to three runners-up get a light confirm: registry signals first, then a keyed shop API.
443
- export function lightTargets(rows, eligible, count = 4) {
444
- const top = pickName(rows, eligible);
445
- const others = rankName(rows.filter(row => row !== top && ['probably-free', 'premium'].includes(row.status)
446
- && canRecommend(row.tld, eligible)));
447
+ // The light confirm uses registry signals first, then a keyed shop API (only with the person's own key). By default only
448
+ // the pick is sent to a shop, so no shop sees the other names. DOMAIN_HOUND_SHOP_QUOTES=top4 adds up to three runners-up.
449
+ export const shopQuoteCount = (env = process.env) => env?.DOMAIN_HOUND_SHOP_QUOTES === 'top4' ? 4 : 1;
450
+
451
+ // The shop quote goes to the pick: the first preferred ending in order, else the cheapest upfront payment in the most
452
+ // attractive tier. explicit lists exact domains the person typed; like preferred endings, they are never demoted.
453
+ export function lightTargets(rows, eligible, count = 1, preferred = [], cap, explicit = []) {
454
+ const requested = [...preferred, ...explicit];
455
+ const inScope = rows.filter(row => (!preferred.length || preferred.includes(row.tld))
456
+ && (cap == null || (row.firstPayment ?? Infinity) <= cap));
457
+ const top = preferred.length ? preferred.map(tld => pickName(inScope.filter(row => row.tld === tld), eligible)).find(Boolean)
458
+ : pickName(inScope, eligible, requested);
459
+ const others = rankName(inScope.filter(row => row !== top && ['probably-free', 'premium'].includes(row.status)
460
+ && canRecommend(row.tld, eligible)), requested, eligible);
447
461
  return [top, ...others].filter(Boolean).slice(0, count);
448
462
  }
449
463
 
@@ -477,11 +491,15 @@ export async function agentResult(input, options = {}) {
477
491
  const rows = fast.groups.flatMap(group => group.results);
478
492
  const targets = domain ? rows.filter(row => canRecommend(row.tld, options.eligible)
479
493
  && ['probably-free', 'check-at-shop', 'premium'].includes(row.status))
480
- : lightTargets(rows, options.eligible);
494
+ : lightTargets(rows, options.eligible, shopQuoteCount(options.env ?? process.env), options.preferredEndings, options.upfrontCap,
495
+ [...exact]);
481
496
  const [candidate] = targets;
482
497
  // A Google retry can settle every row that the first pass left waiting.
483
498
  let complete = fast.complete || !rows.some(row => row.registryReason === 'Registry lookup timed out');
484
499
  const quotes = new Map();
500
+ // The domains a shop was asked about in this lookup, for the receipt's disclosure.
501
+ const asked = new Set();
502
+ const onShopQuery = (_shop, domain) => asked.add(domain);
485
503
  if (targets.length) {
486
504
  options.onProgress?.({ stage: 'quotes' });
487
505
  const catalog = await loadCachedCatalog(options.directory);
@@ -489,7 +507,7 @@ export async function agentResult(input, options = {}) {
489
507
  options.bundledCatalog === undefined ? bundledCatalog : options.bundledCatalog).find(row => row.id === shop) ?? null;
490
508
  const light = options.lightConfirm ?? lightConfirm;
491
509
  const found = await light(targets.map(row => row.domain), { env: options.env, fetcher: options.fetcher,
492
- directory: options.directory, now: options.now, deadline: performance.now() + Math.max(0, remaining() - 150), listFor })
510
+ directory: options.directory, now: options.now, deadline: performance.now() + Math.max(0, remaining() - 150), listFor, onShopQuery })
493
511
  .catch(() => new Map());
494
512
  for (const [key, value] of found) quotes.set(key, value);
495
513
  }
@@ -505,7 +523,7 @@ export async function agentResult(input, options = {}) {
505
523
  try {
506
524
  quote = await Promise.race([
507
525
  confirm(candidate.confirmShop, candidate.domain, { deadline, directory: options.directory,
508
- unsupported: ['so', 'no'], fresh: true, oneShop: batch }).catch(() => null),
526
+ unsupported: ['so', 'no'], fresh: true, oneShop: batch, onShopQuery }).catch(() => null),
509
527
  new Promise(resolve => { timer = setTimeout(resolve, remaining()); }),
510
528
  ]);
511
529
  if (!remaining() || quote === undefined) complete = false;
@@ -520,16 +538,19 @@ export async function agentResult(input, options = {}) {
520
538
  complete = false;
521
539
  }
522
540
  const apply = row => quotes.has(row.domain) ? mergeQuote(row, quotes.get(row.domain)) : row;
523
- const rankedGroups = fast.groups.map(group => ({ ...group, results: rankName(group.results.map(apply)) }));
541
+ const requested = [...(options.preferredEndings ?? []), ...exact];
542
+ const rankedGroups = fast.groups.map(group => ({ ...group, results: rankName(group.results.map(apply), requested, options.eligible) }));
524
543
  const checkedAt = options.now?.toISOString() ?? new Date().toISOString();
525
544
  // An exact .com gets the standard list prices of the other endings as one benchmark line, with no extra lookups.
526
545
  const exactCom = names.length === 1 && names[0].endsWith('.com') ? names[0] : null;
527
546
  const otherEndings = exactCom ? await endingBenchmarks(exactCom, options) : null;
528
547
  const result = compactAgentResult(rankedGroups, names, complete, checkedAt, batch, rateLimited,
529
- options.browser ? liveCheckFor(candidate, quote) : null, { eligible: options.eligible, otherEndings });
548
+ options.browser ? liveCheckFor(candidate, quote) : null, { eligible: options.eligible, otherEndings, requested });
549
+ if (asked.size) result.shopAsked = [...asked];
530
550
  if (options.receipt) result.receiptDetails = rankedGroups.map(({ results, sites }) => ({ endings: results.map(row => ({
531
551
  domain: row.domain, source: row.source, checkedAt: row.checkedAt, priceAt: row.priceCheckedAt,
532
552
  shop: row.shop, checkout: row.buyUrl, site: sites?.[row.tld], risk: row.premium === 'risk' || row.premiumRisk,
553
+ ...(row.savings && { savings: row.savings }),
533
554
  })) }));
534
555
  return result;
535
556
  }
@@ -612,7 +633,7 @@ async function retryGoogle(fast, remaining, options) {
612
633
  for (const key of ['price', 'renewal', 'shop', 'priceSource', 'priceCheckedAt', 'buyUrl']) delete settled[key];
613
634
  return price == null ? settled : { ...settled, listPrice: { shop, checkedAt: priceCheckedAt,
614
635
  ...termCosts(row.tld, price, renewal), renewalJump: renewal > 2 * price } };
615
- }));
636
+ }), options.preferredEndings, options.eligible);
616
637
  }
617
638
  return limited;
618
639
  }
@@ -656,6 +677,8 @@ function lookupArgs(args) {
656
677
  const arg = args[index];
657
678
  if (arg === '--ai') options.ai = true;
658
679
  else if (arg === '--endings' && !options.endings) options.endings = (args[++index] ?? '').split(',');
680
+ else if (arg === '--prefer-endings' && !options.preferredEndings) options.preferredEndings = (args[++index] ?? '').split(',');
681
+ else if (arg === '--upfront-cap' && options.upfrontCap === undefined) options.upfrontCap = Number(args[++index]);
659
682
  else if (arg === '--eligible' && !options.eligible) options.eligible = (args[++index] ?? '').split(',');
660
683
  else if (arg === '--category' && !options.category) options.category = (args[++index] ?? '').slice(0, 100);
661
684
  else if (arg === '--compact') options.compact = true;
@@ -669,12 +692,44 @@ function lookupArgs(args) {
669
692
  return { options, positional };
670
693
  }
671
694
 
695
+ function triageOutput(result, options) {
696
+ if (options.compact) {
697
+ for (const row of result.names ?? []) {
698
+ row.checks = nameCheckLines(row).map(({ label, text, link }) => label + ': ' + text + ' · ' + link);
699
+ }
700
+ }
701
+ return result;
702
+ }
703
+
704
+ function printResult(result) {
705
+ const packet = process.env.DOMAIN_HOUND_MCP_OUTPUT === '1' && !result.error ? { ...result, _mcpResult: true } : result;
706
+ console.log(JSON.stringify(packet));
707
+ }
708
+
709
+ // The name screen's first answer comes by answerMs with the checks done so far. With followUp, the slow checks keep
710
+ // running in the same process (no lookup is repeated) and a second, re-assessed result follows on the next line.
711
+ export const firstAnswerMs = 8000;
712
+ export const followUpMs = 24000;
713
+ export const lateSiteMs = 8000;
714
+ export async function triageWithFollowUp(names, options, { followUp = false, answerMs = firstAnswerMs, print = () => {} } = {}) {
715
+ if (!followUp) return triageNames(names, options);
716
+ const memo = new Map();
717
+ const run = { ...options, memo, budgetMs: options.budgetMs ?? followUpMs, lateSiteMs };
718
+ const first = await triageNames(names, { ...run, answerAt: performance.now() + answerMs });
719
+ if (first.error || !first.followUp) return first;
720
+ print(first);
721
+ return triageNames(names, run);
722
+ }
723
+
672
724
  function runConfirmation(shop, domain) {
673
725
  return confirmDomain(shop, domain, { unsupported: ['so', 'no'], fresh: true });
674
726
  }
675
727
 
676
728
  if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
677
729
  const args = process.argv.slice(2);
730
+ // The 250 ms default was cutting off the IPv4 leg before several public sources could connect.
731
+ // The individual request deadlines and the first-answer deadline still apply.
732
+ if (args[0] === '--triage') setDefaultAutoSelectFamilyAttemptTimeout(Math.max(900, getDefaultAutoSelectFamilyAttemptTimeout()));
678
733
  const { options, positional } = lookupArgs(args.slice(1));
679
734
  // The MCP server reads these to answer with progress when a lookup outlasts its budget.
680
735
  const onProgress = progressReporter();
@@ -696,15 +751,12 @@ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
696
751
  : args[0] === '--refresh-tranco' && args.length === 1
697
752
  ? await refreshTranco({ directory: process.env.DOMAIN_HOUND_TRANCO_CACHE ? pathToFileURL(process.env.DOMAIN_HOUND_TRANCO_CACHE.replace(/\/?$/, '/')) : undefined })
698
753
  : args[0] === '--presence' && args.length === 2 ? await namePresence(args[1], { refreshTranco: true })
699
- : args[0] === '--triage' ? await triageNames(positional.length === 1 ? positional[0].split(',') : null,
700
- { ...options, refreshTranco: true, deferHandles: process.env.DOMAIN_HOUND_DEFER_HANDLES === '1' })
754
+ : args[0] === '--triage' ? await triageWithFollowUp(positional.length === 1 ? positional[0].split(',') : null,
755
+ { ...options, refreshTranco: true, deferHandles: process.env.DOMAIN_HOUND_DEFER_HANDLES === '1' },
756
+ { followUp: process.env.DOMAIN_HOUND_FOLLOW_UP === '1', answerMs: Number(process.env.DOMAIN_HOUND_ANSWER_MS) || undefined,
757
+ print: first => printResult(triageOutput(first, options)) })
701
758
  : await checkDomain(args.length === 1 ? args[0] : undefined);
702
759
  if (result.error) process.exitCode = 1;
703
- if (args[0] === '--triage' && options.compact) {
704
- for (const row of result.names ?? []) {
705
- row.checks = nameCheckLines(row).map(({ label, text, link }) => label + ': ' + text + ' · ' + link);
706
- }
707
- }
708
- console.log(JSON.stringify(result));
760
+ printResult(args[0] === '--triage' ? triageOutput(result, options) : result);
709
761
  }
710
762
  }
@@ -0,0 +1,107 @@
1
+ // Domain marketplaces for the taken-domain dossier. Fail closed: no marketplace is read automatically until its
2
+ // terms are confirmed to permit it and an authorized public endpoint is independently verified. Until then each
3
+ // one is a manual link and its listing state is "unchecked". An adapter that is enabled must bind its answer to the
4
+ // exact domain; a search page, parking page or failed request never counts as a listing.
5
+ import { shopSearchUrl } from './prices.mjs';
6
+ import { hostMatches, safeUrl, evidenceUrl } from './safe-web.mjs';
7
+ import { atomSearchDocs, exactAtomListingUrl, lookupAtomListing } from './broker-atom.mjs';
8
+
9
+ const godaddyTerms = 'https://www.godaddy.com/en/legal/agreements/universal-terms-of-service-agreement';
10
+ const policy = (note, url) => ({ automated: false, note, url });
11
+ const atomManualUrl = domain => 'https://www.atom.com/name/' + encodeURIComponent(domain.replace(/\.com$/, ''));
12
+
13
+ export const providers = Object.freeze([
14
+ { id: 'afternic', name: 'Afternic / GoDaddy', hosts: ['afternic.com', 'godaddy.com'],
15
+ policy: policy('Public listings require a manual check. The designated portfolio API is for sellers.', godaddyTerms),
16
+ manualUrl: domain => 'https://www.afternic.com/domain/' + encodeURIComponent(domain) },
17
+ { id: 'sedo', name: 'Sedo', hosts: ['sedo.com'],
18
+ policy: policy('Sedo prohibits scraping its marketplace.', 'https://sedo.com/us/about-us/policies/general-terms-and-conditions/'),
19
+ manualUrl: domain => 'https://sedo.com/search/details/?domain=' + encodeURIComponent(domain) },
20
+ // Dan.com forwarded to Afternic when checked on 2026-11-25.
21
+ { id: 'dan', name: 'Dan.com', hosts: ['dan.com', 'undeveloped.com'],
22
+ policy: policy('Dan landers are part of GoDaddy’s aftermarket. Check through Afternic.', 'https://blog.afternic.com/dan-landers-afternic/'),
23
+ manualUrl: domain => 'https://dan.com/buy-domain/' + encodeURIComponent(domain) },
24
+ { id: 'atom', name: 'Atom / Squadhelp', hosts: ['atom.com', 'squadhelp.com'],
25
+ policy: { automated: true, url: atomSearchDocs }, manualUrl: atomManualUrl,
26
+ async check(domain, { signal }) {
27
+ const result = await lookupAtomListing(domain, { signal });
28
+ if (result.status === 'unavailable') throw new Error('Public search unavailable');
29
+ return {
30
+ domain, url: result.listingUrl ?? atomManualUrl(domain), listed: result.status === 'listed',
31
+ price: result.price?.amount, currency: result.price?.currency, sourceUrl: result.url, checkedAt: result.checkedAt,
32
+ };
33
+ } },
34
+ { id: 'spaceship', name: 'Spaceship marketplace', hosts: ['spaceship.com'],
35
+ policy: policy('The documented marketplace search requires signing in.', 'https://www.spaceship.com/knowledgebase/spaceship-connector-mcp/'),
36
+ manualUrl: domain => shopSearchUrl('spaceship', domain) },
37
+ ]);
38
+
39
+ // Hosts where a redirect chain stops without a request: marketplaces (terms not confirmed) and ad-parking services.
40
+ const otherSaleHosts = ['hugedomains.com', 'buydomains.com', 'brandbucket.com', 'sedoparking.com', 'uniregistry.com'];
41
+ const parkingHosts = ['parkingcrew.net', 'bodis.com', 'above.com', 'parklogic.com', 'parked.com', 'parking-page.net',
42
+ 'cashparking.com', 'smartname.com', 'domaincontrol.com'];
43
+
44
+ export function marketplaceFor(host) {
45
+ return providers.find(provider => hostMatches(host, provider.hosts)) ?? null;
46
+ }
47
+
48
+ // Why a redirect target is not fetched, or null when it may be.
49
+ export function stopReason(url) {
50
+ const host = url?.hostname;
51
+ if (marketplaceFor(host) || hostMatches(host, otherSaleHosts)) return 'marketplace';
52
+ if (hostMatches(host, parkingHosts)) return 'parking';
53
+ return null;
54
+ }
55
+
56
+ // True when a URL names the exact domain in its path or query (not a longer or shorter name).
57
+ export function urlBindsDomain(value, domain) {
58
+ const url = safeUrl(value);
59
+ if (!url) return false;
60
+ if (exactAtomListingUrl(url.href, domain)) return true;
61
+ let text;
62
+ try { text = decodeURIComponent(url.pathname + ' ' + url.search).toLowerCase(); } catch { return false; }
63
+ return new RegExp('(?:^|[^a-z0-9.-])' + domain.replace(/[.]/g, '\\.') + '(?![a-z0-9-]|\\.[a-z0-9])').test(text);
64
+ }
65
+
66
+ const currencies = new Set(['USD', 'EUR', 'GBP']);
67
+ const validPrice = value => typeof value === 'number' && Number.isFinite(value) && value >= 1 && value <= 100_000_000;
68
+
69
+ // One adapter answer checked against the exact domain and the provider's own hosts.
70
+ export function acceptAnswer(provider, domain, answer, checkedAt) {
71
+ const url = evidenceUrl(answer?.url);
72
+ const bound = typeof answer?.domain === 'string' && answer.domain.toLowerCase() === domain;
73
+ if (!bound || !url || !hostMatches(new URL(url).hostname, provider.hosts) || typeof answer.listed !== 'boolean') {
74
+ return { state: 'unavailable', reason: 'answer not bound to this exact domain', checkedAt };
75
+ }
76
+ const matchingPage = provider.id === 'atom' ? exactAtomListingUrl(answer.url, domain)
77
+ : urlBindsDomain(answer.url, domain) && !/^\/(?:search|listings)\/?$/i.test(new URL(url).pathname);
78
+ if (answer.listed && !matchingPage) {
79
+ return { state: 'unavailable', reason: 'listing page does not name this exact domain', checkedAt };
80
+ }
81
+ if (!answer.listed) {
82
+ // Only an endpoint that authoritatively covers every listing can confirm absence.
83
+ return provider.policy.authoritative ? { state: 'not-listed', url, checkedAt } : { state: 'unknown', url, checkedAt };
84
+ }
85
+ const price = validPrice(answer.price) && currencies.has(answer.currency) ? { amount: answer.price, currency: answer.currency } : null;
86
+ return { state: 'listed', url, checkedAt, ...(price && { price }) };
87
+ }
88
+
89
+ // Listing state per marketplace. Unpermitted ones are not contacted and come back "unchecked" with a manual link.
90
+ export async function checkListings(domain, { list = providers, signal, clock = () => new Date() } = {}) {
91
+ return Promise.all(list.map(async provider => {
92
+ const row = { id: provider.id, name: provider.name, manualUrl: provider.manualUrl(domain) ?? null,
93
+ ...(provider.policy?.url && { policyUrl: provider.policy.url }) };
94
+ if (provider.policy?.automated !== true || typeof provider.check !== 'function') {
95
+ return { ...row, state: 'unchecked', reason: provider.policy?.note ?? 'No permitted public lookup.',
96
+ checkedAt: clock().toISOString() };
97
+ }
98
+ try {
99
+ const answer = await provider.check(domain, { signal });
100
+ return { ...row, ...acceptAnswer(provider, domain, answer, answer?.checkedAt ?? clock().toISOString()),
101
+ ...(answer?.sourceUrl && { sourceUrl: answer.sourceUrl }),
102
+ ...(provider.id === 'atom' && answer?.listed === false && { reason: 'No exact match in the public search. Coverage is incomplete.' }) };
103
+ } catch {
104
+ return { ...row, state: 'unavailable', reason: signal?.aborted ? 'timed out' : 'no answer', checkedAt: clock().toISOString() };
105
+ }
106
+ }));
107
+ }