domain-hound 0.1.9 → 0.1.10

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.
@@ -4,7 +4,7 @@
4
4
  "plugins": [
5
5
  {
6
6
  "name": "domain-hound",
7
- "version": "0.1.9",
7
+ "version": "0.1.10",
8
8
  "source": { "source": "local", "path": "./" },
9
9
  "policy": { "installation": "AVAILABLE", "authentication": "ON_INSTALL" },
10
10
  "category": "Productivity"
@@ -5,7 +5,7 @@
5
5
  "plugins": [
6
6
  {
7
7
  "name": "domain-hound",
8
- "version": "0.1.9",
8
+ "version": "0.1.10",
9
9
  "source": "./",
10
10
  "description": "Domains for agents. One MCP for everything domains: find, check, buy, set up, watch, move, renew, keep track."
11
11
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "domain-hound",
3
3
  "displayName": "Domain Hound",
4
- "version": "0.1.9",
4
+ "version": "0.1.10",
5
5
  "description": "Domains for agents. One MCP for everything domains: find, check, buy, set up, watch, move, renew, keep track.",
6
6
  "author": {
7
7
  "name": "Lars Hvinden"
package/README.md CHANGED
@@ -66,7 +66,9 @@ Pass `names` to screen names you already have. For a second generation round, pa
66
66
  and `avoid` names and the next `round` number.
67
67
 
68
68
  Set `DOMAIN_HOUND_API_URL` to use a different HTTPS API origin or a loopback HTTP origin for development. The package
69
- uses local registry and price checks if the API is unavailable. Set `DOMAIN_HOUND_LOCAL=1` to choose local checks.
69
+ retries a transient check failure once. If the hosted check is still running when the tool returns, repeat the same call
70
+ to collect it. The answer starts with a notice when it uses local checks. Set `DOMAIN_HOUND_LOCAL=1` to choose local
71
+ checks or `DOMAIN_HOUND_DEBUG=1` to log hosted failures to stderr.
70
72
  Local naming uses the naming method to come up with candidates, then checks the supplied names. The local name screen
71
73
  can also use EUIPO and Patentstyret credentials and check rival websites.
72
74
 
@@ -485,7 +485,7 @@ export async function agentResult(input, options = {}) {
485
485
  if (names.includes(null)) return { error: 'Enter a valid name or exact domain.' };
486
486
  const exact = new Set(domain ? [domain] : names.filter((name, index) => batch && exactDomain(input[index])));
487
487
  const groups = [...new Set(names)].map(name => ({ name, candidates: exact.has(name)
488
- ? [{ domain: name, tld: domainEnding(name), exact: true }] : nameCandidates(name, { ...options, variants: !batch }) }));
488
+ ? [{ domain: name, tld: domainEnding(name), exact: true }] : nameCandidates(name, { ...options, variants: !batch && !options.receipt }) }));
489
489
  const keyed = apiShops(options.env ?? process.env).length > 0;
490
490
  const reserve = keyed ? 1800 : 0;
491
491
  const searchOptions = { ...options, budgetMs: Math.max(0, Math.min(remaining() - reserve, batch ? 10_700 : 2700)),
@@ -76,7 +76,7 @@ function fitsCap(option, { budget } = {}) {
76
76
  // The one pick rule. options are free, eligible, in-scope rows shaped { domain, now, total } (total = payments due in
77
77
  // 3 years). The pick is the highest-quality option within the cap; when none fits, the least paid over 3 years.
78
78
  // .ai is never the default: only when the person asked for it or its 3-year total fits the budget they gave.
79
- export function choosePick(options, { requested = [], eligible = [], budget } = {}) {
79
+ export function choosePick(options, { requested = [], eligible = [], budget, allowOverCap = true } = {}) {
80
80
  const allowed = options.filter(option => domainEnding(option.domain) !== 'ai' || asked(option.domain, requested) >= 0
81
81
  || (budget != null && known(option.total) && cents(option.total) <= cents(budget)));
82
82
  const rank = option => qualityRank(option.domain, requested, eligible);
@@ -85,7 +85,7 @@ export function choosePick(options, { requested = [], eligible = [], budget } =
85
85
  || (a.total ?? Infinity) - (b.total ?? Infinity)
86
86
  || (a.now ?? Infinity) - (b.now ?? Infinity) || a.domain.localeCompare(b.domain);
87
87
  return allowed.filter(option => fitsCap(option, { budget })).sort(byQuality)[0]
88
- ?? lowestTotal(allowed, rank);
88
+ ?? (allowOverCap ? lowestTotal(allowed, rank) : undefined);
89
89
  }
90
90
 
91
91
  // The least paid over 3 years; the cheaper first payment, then quality, breaks a tie.
package/display.mjs CHANGED
@@ -8,6 +8,7 @@ export { purchaseLine, showAsIs } from './clis/domain-check/naming-method.mjs';
8
8
  import { compareScores } from './clis/domain-check/name-score.mjs';
9
9
  export const neverBuys = 'This check leaves checkout to you; open the link to buy.';
10
10
  export const attribution = 'via domainhound.dev';
11
+ export const localCheckNotice = 'Checked on your machine; the shared price list was unreachable.';
11
12
 
12
13
  // Every MCP display carries one attribution line. The blank line keeps it out of a preceding table or list.
13
14
  // When the display can show a checkout link, an exact lookup or purchase request can add the purchase line after it.
@@ -82,7 +83,7 @@ function preferredFirst(values, preferred, endingOf = value => value) {
82
83
 
83
84
  // A data-only shop has no search URL (null), so a missing URL must never match it.
84
85
  export function safeLink(url, domain) {
85
- if (typeof url !== 'string' || !url || !/^[a-z0-9-]+\.[a-z0-9-]+$/i.test(domain) ||
86
+ if (typeof url !== 'string' || !url || !/^[a-z0-9-]+\.(?:co\.uk|[a-z0-9-]+)$/i.test(domain) ||
86
87
  !registrarIds.some(id => shopSearchUrl(id, domain) === url)) return null;
87
88
  return '[' + domain + '](' + url + ')';
88
89
  }
@@ -58,7 +58,11 @@ function priceLine(offer, cheapest) {
58
58
  + (offer.needsCloudflareDns ? ' · requires Cloudflare DNS' : '');
59
59
  }
60
60
 
61
- function checkLines(check, pending) {
61
+ export function pickLine(pick) {
62
+ return 'The Hound’s pick is ' + md(pick.domain) + ' at ' + md(pick.shop) + ' for ' + money(pick.threeYearUsd) + ' over three years.';
63
+ }
64
+
65
+ export function checkLines(check, pending, { local = false } = {}) {
62
66
  const { domains, choice, nameChecks, score } = check;
63
67
  const pick = choice?.pick;
64
68
  const taken = domains.filter(row => row.status === 'taken').map(row => row.domain);
@@ -67,12 +71,13 @@ function checkLines(check, pending) {
67
71
  ...(score?.filtered ? [md(check.query.name) + ' · ' + md(score.filtered)]
68
72
  : Number.isInteger(score?.value) ? [md(check.query.name) + ' · Name score ' + score.value + '/100 · ' + md(score.band),
69
73
  ...(score.reasons ?? []).map(md)] : []),
70
- ...(pick ? ['The Hound’s pick is ' + md(pick.domain) + ' at ' + md(pick.shop) + ' for ' + money(pick.threeYearUsd) + ' over three years.'] : []),
74
+ ...(pick ? [pickLine(pick)] : []),
71
75
  ...domains.filter(row => row.status === 'available').flatMap(row => [
72
76
  'Available · ' + md(row.domain),
73
- ...(row.prices?.length ? row.prices.map((offer, index) => priceLine(offer, index === 0)) : ['Check the price at the shop.']),
77
+ ...(row.prices?.length ? row.prices.map((offer, index) => priceLine(offer, !local && index === 0)) : ['Check the price at the shop.']),
78
+ ...(local && row.confirmed ? ['Confirmed at the shop.'] : []),
74
79
  ]),
75
- ...nameCheckLines(nameChecks, pending, check.query.name),
80
+ ...(local ? [] : nameCheckLines(nameChecks, pending, check.query.name)),
76
81
  ...(taken.length ? ['Taken · ' + taken.map(md).join(', ') + '. '
77
82
  + link('Watch', 'https://domainhound.dev/watch/?domain=' + encodeURIComponent(taken[0]))
78
83
  + ' · Draft an offer · Try a new name'] : []),
@@ -81,6 +86,12 @@ function checkLines(check, pending) {
81
86
  ];
82
87
  }
83
88
 
89
+ export function pickDomain(options, { endings, eligible, budget } = {}) {
90
+ return choosePick(options.filter(option => option.buyUrl), {
91
+ requested: endings, eligible, budget, allowOverCap: budget != null,
92
+ }) ?? null;
93
+ }
94
+
84
95
  function preferredPick(check, args) {
85
96
  if (!args.endings?.length && args.budget == null && !args.eligible?.length && !args.country) return check.choice.pick;
86
97
  if (check.query.exactDomain) return check.choice.pick;
@@ -89,7 +100,7 @@ function preferredPick(check, args) {
89
100
  row.prices.filter(offer => args.budget == null || offer.firstPaymentUsd <= args.budget).map(offer => ({
90
101
  ...offer, domain: row.domain, now: offer.firstPaymentUsd, total: offer.threeYearUsd,
91
102
  })));
92
- return choosePick(options, { requested: args.endings, eligible: args.eligible, budget: args.budget }) ?? null;
103
+ return pickDomain(options, args);
93
104
  }
94
105
 
95
106
  export function hostedChecks(checks, args, triage = false) {
package/hosted.mjs CHANGED
@@ -7,6 +7,17 @@ import { searchApps } from './clis/domain-check/triage-sources.mjs';
7
7
  export const hostedBase = 'https://domainhound-mcp.domainhound.workers.dev';
8
8
  export class HostedRateLimit extends Error {}
9
9
 
10
+ export function hostedDebug(message, env = process.env) {
11
+ if (env.DOMAIN_HOUND_DEBUG === '1') process.stderr.write('Domain Hound: ' + message + '\n');
12
+ }
13
+
14
+ class HostedRequestError extends Error {
15
+ constructor(message, transient = false) {
16
+ super(message);
17
+ this.transient = transient;
18
+ }
19
+ }
20
+
10
21
  const validCheck = body => body?.version === 1 && typeof body.query?.ascii === 'string' &&
11
22
  Array.isArray(body.domains) && body.domains.every(row => typeof row.domain === 'string' &&
12
23
  ['available', 'taken', 'unknown'].includes(row.status) && Array.isArray(row.prices)) && body.choice;
@@ -20,33 +31,62 @@ export function hostedClient(version, { env = process.env, fetchFn = fetch, appl
20
31
  try {
21
32
  base = new URL(env.DOMAIN_HOUND_API_URL || hostedBase);
22
33
  const loopback = ['localhost', '127.0.0.1', '[::1]'].includes(base.hostname);
23
- if (base.username || base.password || (base.protocol !== 'https:' && !(loopback && base.protocol === 'http:'))) return null;
34
+ if (base.username || base.password || (base.protocol !== 'https:' && !(loopback && base.protocol === 'http:'))) {
35
+ throw new Error('Invalid hosted API origin');
36
+ }
24
37
  } catch {
38
+ hostedDebug('Hosted API origin is invalid; using the local check.', env);
25
39
  return null;
26
40
  }
27
41
 
28
- async function read(path, { body, params, timeout, signal } = {}) {
42
+ async function request(path, { body, params, timeout, signal, valid } = {}) {
29
43
  const url = new URL(path, base);
30
44
  if (params) url.search = new URLSearchParams(params).toString();
31
- const res = await fetchFn(url, {
32
- redirect: 'error',
33
- headers: { 'X-Domain-Hound-Client': 'mcp/' + version, ...(body && { 'Content-Type': 'application/json' }) },
34
- ...(body && { method: 'POST', body: JSON.stringify(body) }),
35
- signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(timeout)]) : AbortSignal.timeout(timeout),
36
- });
45
+ const deadline = AbortSignal.timeout(timeout);
46
+ let res;
47
+ try {
48
+ res = await fetchFn(url, {
49
+ redirect: 'error',
50
+ headers: { 'X-Domain-Hound-Client': 'mcp/' + version, ...(body && { 'Content-Type': 'application/json' }) },
51
+ ...(body && { method: 'POST', body: JSON.stringify(body) }),
52
+ signal: signal ? AbortSignal.any([signal, deadline]) : deadline,
53
+ });
54
+ } catch (error) {
55
+ const code = error?.cause?.code;
56
+ const reason = signal?.aborted ? 'lookup stopped' : deadline.aborted ? 'request timed out'
57
+ : 'connection failed' + (/^(?:E[A-Z_0-9]+|UND_ERR_[A-Z_0-9]+)$/.test(code ?? '') ? ' (' + code + ')' : '');
58
+ throw new HostedRequestError(reason, true);
59
+ }
37
60
  if (!res.ok) {
38
61
  await res.body?.cancel().catch(() => {});
39
- if (res.status === 429) throw new HostedRateLimit();
40
- throw new Error('Hosted check unavailable');
62
+ if (res.status === 429) throw new HostedRateLimit('HTTP 429');
63
+ throw new HostedRequestError('HTTP ' + res.status, res.status === 408 || res.status >= 500);
41
64
  }
42
- return res.json();
65
+ const answer = await res.json().catch(() => {
66
+ throw new HostedRequestError(signal?.aborted ? 'lookup stopped' : deadline.aborted
67
+ ? 'response timed out' : 'invalid or incomplete JSON response', true);
68
+ });
69
+ if (valid && !valid(answer)) throw new HostedRequestError('response did not match the API format', true);
70
+ return answer;
43
71
  }
44
72
 
45
- const get = async (name, signal) => {
46
- const body = await read('/v1/check', { params: { name }, timeout: 5600, signal });
47
- if (!validCheck(body)) throw new Error('Invalid hosted check');
48
- return body;
49
- };
73
+ async function read(path, options, retry = false) {
74
+ for (let attempt = 1; ; attempt++) {
75
+ const started = performance.now();
76
+ try {
77
+ return await request(path, options);
78
+ } catch (error) {
79
+ const retrying = retry && attempt === 1 && error.transient && !options.signal?.aborted;
80
+ hostedDebug(path + ' attempt ' + attempt + ' failed after ' + Math.round(performance.now() - started)
81
+ + ' ms (' + (error instanceof HostedRequestError || error instanceof HostedRateLimit ? error.message : 'unexpected error')
82
+ + ')' + (retrying ? '; retrying' : ''), env);
83
+ if (!retrying) throw error;
84
+ await wait(200, undefined, { signal: options.signal });
85
+ }
86
+ }
87
+ }
88
+
89
+ const get = (name, signal) => read('/v1/check', { params: { name }, timeout: 5600, signal, valid: validCheck }, true);
50
90
 
51
91
  async function recoverApple(app, name, signal) {
52
92
  if (app?.status !== 'unknown' || app.reason !== 'rate-limited') return app;
@@ -115,14 +155,19 @@ export function hostedClient(version, { env = process.env, fetchFn = fetch, appl
115
155
  let nameChecks = null;
116
156
  if (typeof main.details?.id === 'string') {
117
157
  nameChecks = await read('/v1/check/details', {
118
- params: { id: main.details.id }, timeout: 6600, signal,
119
- }).then(body => validDetails(body) ? body : null, () => null);
158
+ params: { id: main.details.id }, timeout: 6600, signal, valid: validDetails,
159
+ }, true).catch(() => null);
160
+ } else {
161
+ hostedDebug('/v1/check did not provide a name-check token', env);
120
162
  }
121
163
  if (nameChecks) {
122
- await Promise.all([
164
+ const recovered = await Promise.allSettled([
123
165
  recoverApple(nameChecks.appStore, main.query.name, signal).then(app => { nameChecks.appStore = app; }),
124
166
  recoverNameChecks([{ name: main.query.name, nameChecks }], signal),
125
167
  ]);
168
+ for (const [index, result] of recovered.entries()) {
169
+ if (result.status === 'rejected') hostedDebug('Optional ' + (index ? 'handle' : 'App Store') + ' recovery failed', env);
170
+ }
126
171
  }
127
172
  const { details, ...answer } = main;
128
173
  return { ...answer, domains: [...main.domains, ...extras.flatMap(extra => extra.domains)], nameChecks,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "domain-hound",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "Domains for agents. One MCP for everything domains: find, check, buy, set up, watch, move, renew, keep track.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "domain-hound",
4
- "version": "0.1.9",
4
+ "version": "0.1.10",
5
5
  "description": "Domains for agents. One MCP for everything domains: find, check, buy, set up, watch, move, renew, keep track.",
6
6
  "author": {
7
7
  "name": "Lars Hvinden"
package/results.mjs CHANGED
@@ -10,12 +10,14 @@ import { handleLabel, handlePriorities, handleSummary, linkedInSearchHint } from
10
10
  import { googlePlayLabel, googlePlayLinkLabel, playSearchLink } from './clis/domain-check/google-play.mjs';
11
11
  import { dnsNeed, shopSearchUrl, shops } from './clis/domain-check/prices.mjs';
12
12
  import { trademarkSearches } from './clis/domain-check/triage-sources.mjs';
13
- import { safeLink } from './display.mjs';
13
+ import { attributed, localCheckNotice, safeLink } from './display.mjs';
14
+ import { checkLines, pickDomain, pickLine } from './hosted-results.mjs';
14
15
  import { receiptStyle } from './results-style.mjs';
15
16
  import { shareUrl } from './share.mjs';
16
17
  import { compareScores, scoreEligible, scoreHeadline, scoreName } from './clis/domain-check/name-score.mjs';
17
18
 
18
19
  const cash = value => Number.isFinite(value) ? '$' + value.toFixed(2) : null;
20
+ const cloudflareDns = 'Requires Cloudflare DNS';
19
21
  const escape = value => String(value ?? '').replace(/[&<>"']/g, char =>
20
22
  ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[char]);
21
23
  const plain = value => String(value ?? '').replace(/[\r\n\p{Cc}\p{Cf}]+/gu, ' ').replace(/\s*[—–]\s*/g, '. ').trim();
@@ -115,7 +117,7 @@ function resultGroups(data, eligibleEndings, preferred = []) {
115
117
  const checkout = taken || reserved || !eligible ? null : [raw?.checkout, shopUrl].find(url => safeLink(url, domain)) ?? null;
116
118
  return { domain, ending, rank: qualityRank(domain, requested, eligibleList), state, status, ...usd, total,
117
119
  shop, checkout, eligible, source, ...(raw?.savings && { savings: raw.savings }),
118
- ...(includePrice && dnsNeed(usd.shop) && { dns: dnsNeed(usd.shop) }),
120
+ ...(includePrice && dnsNeed(usd.shop) && { dns: cloudflareDns }),
119
121
  priceLabel: usd.now != null || usd.renew != null ? (confirmed ? 'Shop quote' : taken ? 'Standard list price benchmark' : 'List price') : '',
120
122
  checkedAt: raw?.checkedAt ?? data.checkedAt, priceAt: confirmed ? raw?.checkedAt ?? data.checkedAt : raw?.priceAt ?? data.priceListDate,
121
123
  site: raw?.site ?? detail.details?.sites?.[ending] ?? row.details?.sites?.[ending] };
@@ -149,7 +151,7 @@ function offerText(offer, linked = false) {
149
151
  : renew != null ? cash(renew) + ' renewal' : 'price at shop';
150
152
  return (linked && checkout ? '[' + domain + '](' + checkout + ')' : domain) + ' ' + price
151
153
  + (term > 1 ? ' every ' + term + ' years' : '') + (jump ? ' (renewal jumps)' : '')
152
- + (priceLabel ? ' ' + priceLabel.toLowerCase() + priceDate(offer) : '') + (offer.dns ? ' (' + offer.dns.toLowerCase() + ')' : '');
154
+ + (priceLabel ? ' ' + priceLabel.toLowerCase() + priceDate(offer) : '') + (offer.dns ? ' (' + offer.dns + ')' : '');
153
155
  }
154
156
 
155
157
  function appFinding(value, row, source) {
@@ -177,12 +179,11 @@ function signals(group, triage = true) {
177
179
 
178
180
  // One selection feeds the receipt lines and the share link: preferred endings, budget, eligibility, verdict and
179
181
  // confirmed quotes decide the candidates. Each name's pick follows the shared rule (choosePick): the highest-quality
180
- // ending within $60 over 3 years (or the person's budget), else the least paid over 3 years; .ai only when asked for
181
- // or within the budget. Cheapest is the lowest upfront payment and best value the least paid over 3 years, across
182
- // every candidate in scope.
182
+ // ending within $60 over 3 years or the person's budget. Local MCP checks use the hosted rule for offers outside
183
+ // the default cap. Cheapest is the lowest upfront payment and best value the least paid over 3 years.
183
184
  // names[i] is the same choice made inside groups[i] alone: its pick, its best value and its taken rows,
184
185
  // preferred endings first in the user's order (.com first by default).
185
- function receiptSelection(groups, args, triage, eligible = []) {
186
+ function receiptSelection(groups, args, triage, eligible = [], local = false) {
186
187
  const preferred = args.endings ?? [];
187
188
  const budget = args.budget;
188
189
  const exact = !triage && groups.length === 1 && groups[0].row.name.includes('.');
@@ -192,14 +193,18 @@ function receiptSelection(groups, args, triage, eligible = []) {
192
193
  // Triage recommendations require a name that passed its filters. Availability-only checks still show domain offers.
193
194
  const candidates = exact ? [] : groups.flatMap(group => triage && !scoreEligible(group.row) ? [] : group.records
194
195
  .filter(record => inScope(record) && (record.state === 'free' || record.priceLabel === 'Shop quote'))
195
- .map(record => ({ group, record, domain: record.domain, now: record.now ?? null, total: record.total ?? null })));
196
+ .map(record => ({ group, record, domain: record.domain, now: record.now ?? null, total: record.total ?? null, buyUrl: record.checkout })));
196
197
  const context = group => ({ requested: group.row.name.includes('.') ? [...preferred, group.row.name] : preferred,
197
198
  eligible, budget });
198
199
  // Across names, every exact domain the person typed counts as asked for.
199
200
  const across = { requested: [...preferred, ...groups.map(group => group.row.name).filter(name => name.includes('.'))], eligible, budget };
200
201
  // Ties on price go to the better verdict, then the quality order.
201
202
  const rank = item => (verdictOrder[item.group.row.verdict] ?? 0) * 1000 + item.record.rank;
202
- const pickOf = group => choosePick(candidates.filter(item => item.group === group), context(group));
203
+ const pickOf = group => {
204
+ const options = candidates.filter(item => item.group === group);
205
+ const rules = context(group);
206
+ return local ? pickDomain(options, { endings: rules.requested, eligible, budget }) : choosePick(options, rules);
207
+ };
203
208
  const valueOf = items => lowestTotal(items, rank);
204
209
  const picks = groups.flatMap(group => {
205
210
  const pick = pickOf(group);
@@ -227,7 +232,33 @@ function receiptSelection(groups, args, triage, eligible = []) {
227
232
  };
228
233
  }
229
234
 
230
- function summary(groups, args, triage, selection) {
235
+ function checkedOption(record) {
236
+ const term = record.term ?? 1;
237
+ return { domain: record.domain, shop: record.shop, firstYearUsd: record.now == null ? null : record.now / term,
238
+ renewalUsd: record.renew == null ? null : record.renew / term, firstPaymentUsd: record.now, threeYearUsd: record.total,
239
+ minimumYears: term, buyUrl: record.checkout, needsCloudflareDns: Boolean(record.dns) };
240
+ }
241
+
242
+ function localCheckSummary(group, args, selection, priceListDate) {
243
+ const { row, records } = group;
244
+ const exactDomain = row.name.includes('.') ? row.name : null;
245
+ const domains = records.map(record => ({
246
+ domain: record.domain, status: record.state === 'free' ? 'available' : record.state === 'taken' ? 'taken' : 'unknown',
247
+ prices: record.state === 'free' && record.now != null ? [checkedOption(record)] : [],
248
+ confirmed: record.priceLabel === 'Shop quote',
249
+ }));
250
+ const pick = exactDomain
251
+ ? pickDomain(records.filter(record => record.state === 'free').map(record => ({
252
+ ...checkedOption(record), now: record.now, total: record.total,
253
+ })), { ...args, endings: [exactDomain] })
254
+ : selection.best?.record && checkedOption(selection.best.record);
255
+ const lines = checkLines({ domains, choice: { pick }, query: { name: row.name, exactDomain }, score: row.score }, false, { local: true });
256
+ if (priceListDate) lines.push('Dated list prices in USD before tax · ' + priceListDate);
257
+ const savings = selection.best ? [savingsLine(selection.best.record)].filter(Boolean) : [];
258
+ return { lines: attributed(lines.join('\n'), Boolean(args.purchase || exactDomain)).split('\n'), savings };
259
+ }
260
+
261
+ function summary(groups, args, triage, selection, local = false) {
231
262
  const [wanted] = groups;
232
263
  const { exact: isExact, preferred, budget, best, picks, cheapest, value } = selection;
233
264
  const constraints = [...(!isExact && preferred.length ? [preferred.map(ending => '.' + ending).join(', ') + ' first'] : []),
@@ -259,7 +290,8 @@ function summary(groups, args, triage, selection) {
259
290
  const caution = item => item.group.row.verdict === 'Check first' ? ' (Check first)' : '';
260
291
  const label = item => offerText(item.record, true) + caution(item);
261
292
  const offerLines = picks.map(({ group, record }, index) =>
262
- (budget != null && index === 0 ? 'Pick: ' : (index + 1) + '. ') + offerText(record) + ' (' + plain(record.status.toLowerCase()) + ') | '
293
+ (local ? pickLine(checkedOption(record)) + ' ' : (budget != null && index === 0 ? 'Pick: ' : (index + 1) + '. '))
294
+ + offerText(record) + ' (' + plain(record.status.toLowerCase()) + ') | '
263
295
  + (triage ? plain(group.row.verdict) + ' |' + (shortScore(group.row) ? shortScore(group.row).slice(0, -1) + ' |' : '')
264
296
  + (scoreReasons(group.row).length ? ' ' + scoreReasons(group.row).join('; ') + ' |' : '') + ' ' + marksText(group.row) + ' | ' : '')
265
297
  + signals(group, triage));
@@ -293,7 +325,7 @@ function summary(groups, args, triage, selection) {
293
325
  const savings = picks.map(({ record }) => savingsLine(record)).filter(Boolean);
294
326
  const shortLines = args.shortlist && triage ? [
295
327
  constraints.length ? constraints.join(' | ') + '.' : null,
296
- ...picks.map(({ group, record }) => offerText(record) + '. ' + plain(group.row.verdict) + '.' + shortScore(group.row)
328
+ ...picks.map(({ group, record }) => (local ? pickLine(checkedOption(record)) : offerText(record) + '.') + ' ' + plain(group.row.verdict) + '.' + shortScore(group.row)
297
329
  + (scoreReasons(group.row).length ? ' ' + scoreReasons(group.row).join('. ') + '.' : '')),
298
330
  picks.length ? null : 'No available pick in scope.',
299
331
  running.length ? 'Still checking ' + running.join(', ') + '. The results page updates.' : null,
@@ -625,12 +657,15 @@ export function resultPages({ env = process.env,
625
657
  groups = groups.filter(({ row }) => Number.isInteger(row.score?.value) && scoreEligible(row))
626
658
  .sort((a, b) => compareScores(a.row.score, b.row.score)).slice(0, 8);
627
659
  }
628
- const selection = receiptSelection(groups, args, triage, args.eligible ?? data.eligible ?? []);
660
+ const local = !watch && data.source === 'local';
661
+ const selection = receiptSelection(groups, args, triage, args.eligible ?? data.eligible ?? [], local);
629
662
  const { lines, savings, shortLines } = data.hosted ? { lines: data.lines, savings: [] } : watch ? { lines: data.say.split('\n'), savings: [] } : data.pending ? { lines: [
630
663
  ...(data.failed ? ['Some checks did not finish. Registry answers received are on the page.']
631
664
  : ['Still checking trademark, app and web sources. Registry answers so far are on the page.', 'The results page updates by itself.']),
632
665
  ...(args.purchase ? ['This check leaves checkout to you.'] : []),
633
- ], savings: [] } : groups.length ? summary(groups, args, triage, selection)
666
+ ], savings: [] } : local && !triage && groups.length === 1 && !args.confirm && !args.endings && args.budget == null
667
+ ? localCheckSummary(groups[0], args, selection, data.priceListDate)
668
+ : groups.length ? summary(groups, args, triage, selection, local)
634
669
  : { lines: ['No names passed the checks.'], savings: [] };
635
670
  // Before the verdicts arrive the receipt recommends nothing, so the link carries only taken rows and jumps.
636
671
  const shareFacts = selection.names.map(name => data.pending ? { taken: name.taken } : name);
@@ -642,7 +677,7 @@ export function resultPages({ env = process.env,
642
677
  const kept = reusedBase(reuse, directory);
643
678
  const base = kept ?? new Date().toISOString().replaceAll(/[:.]/g, '-') + '-' + slug + '-' + randomUUID().slice(0, 8);
644
679
  const filename = resolve(directory, base + '.html');
645
- const page = render(groups, lines, at, data.sources, watch ? data : null, args.companyType,
680
+ const page = render(groups, local ? [localCheckNotice, ...lines] : lines, at, data.sources, watch ? data : null, args.companyType,
646
681
  { savings, note: watch ? '' : data.hosted ? 'Domain Hound’s hosted service checks registries, prices and public name sources.' : disclosure(data, triage),
647
682
  refresh: Boolean(refresh), shareFacts,
648
683
  hostedShare: data.checks?.length === 1 ? httpsLink(data.checks[0].share?.url) : null });
@@ -676,12 +711,12 @@ export function resultPages({ env = process.env,
676
711
  const handles = data.hosted ? data.checks.flatMap(check => check.nameChecks?.handles ?? [])
677
712
  : groups.flatMap(group => group.row.handles ?? []);
678
713
  const hints = [...new Set(handles.map(linkedInSearchHint).filter(Boolean))];
679
- const say = [resultsLine(url), ...(shortLines ?? lines), ...hints].join('\n');
714
+ const say = [...(local ? [localCheckNotice] : []), resultsLine(url), ...(shortLines ?? lines), ...hints].join('\n');
680
715
  if (data.hosted) {
681
716
  const { hosted, lines, ...structured } = data;
682
717
  return { display: say, say, ...structured, resultPage: url };
683
718
  }
684
- if (triage && args.shortlist) return { display: say, say, checkedAt: at, resultPage: url };
719
+ if (triage && args.shortlist) return { display: say, say, ...(local && { source: 'local' }), checkedAt: at, resultPage: url };
685
720
  const { receiptDetails, say: priorSay, display: priorDisplay, ...structured } = data;
686
721
  if (triage && receiptDetails) structured.names = structured.names.map((row, index) => ({
687
722
  ...row, ...(receiptDetails[index]?.score && { score: receiptDetails[index].score }),
package/server.json CHANGED
@@ -4,12 +4,12 @@
4
4
  "title": "Domain Hound: Domains for agents",
5
5
  "description": "One MCP for everything domains: find, check, buy, set up, watch, move, renew, keep track",
6
6
  "websiteUrl": "https://domainhound.dev",
7
- "version": "0.1.9",
7
+ "version": "0.1.10",
8
8
  "packages": [
9
9
  {
10
10
  "registryType": "npm",
11
11
  "identifier": "domain-hound",
12
- "version": "0.1.9",
12
+ "version": "0.1.10",
13
13
  "transport": {
14
14
  "type": "stdio"
15
15
  }
package/server.mjs CHANGED
@@ -6,7 +6,7 @@ import { createInterface } from 'node:readline';
6
6
  import { fileURLToPath, pathToFileURL } from 'node:url';
7
7
  import { checkSocialHandles, handlePriorities, pendingHandleRows, requestPlatforms } from './clis/domain-check/handles.mjs';
8
8
  import { progressPrefix } from './clis/domain-check/progress.mjs';
9
- import { attributed, errorText, progressText } from './display.mjs';
9
+ import { attributed, errorText, localCheckNotice, progressText } from './display.mjs';
10
10
  import { resultPages, resultsLine } from './results.mjs';
11
11
  import { watchDomain, watchTool } from './watch.mjs';
12
12
  import { domainDossier, dossierTool } from './dossier.mjs';
@@ -14,7 +14,7 @@ import { myDomains, portfolioTool } from './clis/portfolio/portfolio.mjs';
14
14
  import { callPurchaseTool, purchaseToolNames, registeredTools, withCheckQuoteOffer, withWatchQuoteOffer } from './clis/spaceship/tools.mjs';
15
15
  import { candidateFields, compactScore, compareScores, scoreEligible, scoreHandles, scoreName, validCandidate } from './clis/domain-check/name-score.mjs';
16
16
  import { scoreLogger } from './clis/domain-check/score-log.mjs';
17
- import { HostedRateLimit, hostedClient } from './hosted.mjs';
17
+ import { HostedRateLimit, hostedClient, hostedDebug } from './hosted.mjs';
18
18
  import { generatedChecks, hostedChecks, hostedResult } from './hosted-results.mjs';
19
19
 
20
20
  // The capability ships inside the package; tests inject another directory through serve({ cwd }).
@@ -26,6 +26,7 @@ const serverVersion = JSON.parse(readFileSync(new URL('./package.json', import.m
26
26
  const timeoutMs = 14_000;
27
27
  // A lookup still running after this long is stopped.
28
28
  const maxLookupMs = 120_000;
29
+ const hostedLookupMs = 34_000;
29
30
  // Keep completed evidence stable for repeated calls during a short naming session.
30
31
  const keepFinishedMs = 120_000;
31
32
  const versions = ['2025-11-25', '2025-06-18', '2025-03-26', '2024-11-05'];
@@ -56,11 +57,11 @@ const lookupProperties = {
56
57
  ai: { type: 'boolean', description: 'Legacy option. .ai is now included by default.' },
57
58
  endings: endingsSchema,
58
59
  budget: { type: 'number', minimum: 0, maximum: 1000000,
59
- description: 'The person\'s budget in USD, only when they gave one. Endings that cost more upfront are left out, and it replaces the $60 three-year cap of the default pick (highest-quality ending within the cap, else the least paid over 3 years; .ai only when asked for or within this budget). Carry it from the registry screen into triage.' },
60
+ description: 'The person\'s budget in USD, only when they gave one. Endings that cost more upfront are left out. A budget replaces the default $60 three-year cap. The pick is the highest-quality ending within the cap or, with a budget, the cheapest over three years if none fit it. Include .ai in the pick only when asked for or within the budget. Carry the budget from the registry screen into triage.' },
60
61
  eligible: { type: 'array', uniqueItems: true, items: { type: 'string', enum: restrictedEndings },
61
62
  description: 'Restricted endings the buyer qualifies to register. Pass no or eu only when the buyer qualifies for that ending.' },
62
63
  };
63
- const relay = 'The answer starts with the clickable Markdown link on the first line of say. Then give the relevant facts from say.';
64
+ const relay = 'Include the clickable Results page link from say. Keep the notice at the top when a check ran on this machine, then give the relevant facts.';
64
65
  const checkTool = {
65
66
  name: 'check_domains',
66
67
  description: 'Check availability and dated prices for up to 20 names or domains. Use triage_names for product names. '
@@ -147,6 +148,11 @@ function toolResult(json, isError = false) {
147
148
  }
148
149
  const errorResult = message => toolResult(errorText(message), true);
149
150
 
151
+ function localProgress(json) {
152
+ const progress = JSON.parse(json);
153
+ return JSON.stringify({ ...progress, source: 'local', display: localCheckNotice + '\n' + progress.display });
154
+ }
155
+
150
156
  const showValue = value => JSON.stringify(String(value).slice(0, 40));
151
157
 
152
158
  // The DNS form of a valid entry: a bare name as one label, an exact domain as itself, both in punycode when needed.
@@ -485,6 +491,8 @@ export async function serve({
485
491
  const error = (id, code, message) => send({ id, error: { code, message } });
486
492
  const pending = new Set();
487
493
  const lookups = new Map();
494
+ const hostedLookups = new Map();
495
+ const hostedShutdown = new AbortController();
488
496
  const generations = new Map();
489
497
  const background = new Set();
490
498
 
@@ -541,20 +549,44 @@ export async function serve({
541
549
  return tracked;
542
550
  };
543
551
 
544
- async function hostedLookup(args, triage) {
552
+ async function hostedLookup(args, triage, started) {
545
553
  if (!hosted || args?.confirm === true || (triage && args?.additionalHandles?.length)) return null;
546
- let checks;
554
+ let rows;
547
555
  try {
548
556
  (triage ? triageArguments : cliArguments)(args);
549
- const rows = (triage ? triageRows : checkRows)(args);
557
+ rows = (triage ? triageRows : checkRows)(args);
550
558
  if (!rows.length || (triage && args.names.some(name => !normalizeName(name)))) return null;
551
- const extra = selectedEndings(args).filter(ending => !defaultEndings.includes(ending));
552
- const signal = AbortSignal.timeout(Math.max(1, Math.min(13_000, Math.floor(timeout - 750))));
553
- checks = await Promise.all(rows.map(({ name }) => hosted.check(name, name.includes('.') ? [] : extra, signal)));
554
559
  } catch (problem) {
555
- if (problem instanceof HostedRateLimit) return errorResult('The Hound needs a breather. Try again in a few minutes.');
556
- return null;
560
+ return errorResult(problem.message);
561
+ }
562
+ const key = JSON.stringify([triage, Object.entries(args).sort(([a], [b]) => a.localeCompare(b))]);
563
+ let lookup = hostedLookups.get(key);
564
+ if (!lookup) {
565
+ const extra = selectedEndings(args).filter(ending => !defaultEndings.includes(ending));
566
+ const controller = new AbortController();
567
+ const signal = AbortSignal.any([controller.signal, hostedShutdown.signal, AbortSignal.timeout(hostedLookupMs)]);
568
+ const job = { result: null };
569
+ job.done = Promise.all(rows.map(async ({ name }) => hosted.check(name, name.includes('.') ? [] : extra, signal)))
570
+ .then(answers => renderHostedLookup(answers, args, triage), problem => {
571
+ if (problem instanceof HostedRateLimit) return errorResult('The Hound needs a breather. Try again in a few minutes.');
572
+ hostedDebug('Hosted domain lookup could not finish; using the local check.');
573
+ return null;
574
+ }).then(result => {
575
+ job.result = result;
576
+ setTimeout(() => { if (hostedLookups.get(key) === job) hostedLookups.delete(key); }, keepFinishedMs).unref();
577
+ }).finally(() => controller.abort());
578
+ lookup = job;
579
+ hostedLookups.set(key, job);
580
+ }
581
+ if (!await within(lookup, timeout - (performance.now() - started))) {
582
+ hostedDebug('Hosted check exceeded the tool response budget; it is still running.');
583
+ return toolResult(JSON.stringify({ display: attributed('The hosted check is still running. Call the same tool again with the same input to collect it.'),
584
+ complete: false, pending: true }));
557
585
  }
586
+ return lookup.result;
587
+ }
588
+
589
+ async function renderHostedLookup(checks, args, triage) {
558
590
  try {
559
591
  const evidence = hostedChecks(checks, args, triage);
560
592
  const page = await pages(hostedResult(evidence, args), args, { triage });
@@ -621,7 +653,7 @@ export async function serve({
621
653
 
622
654
  function writeTriagePage(lookup, data, args, refresh) {
623
655
  const work = (lookup.pageWork ?? Promise.resolve()).then(async () => {
624
- const page = await pages(data, args, { triage: true, reuse: lookup.page, refresh });
656
+ const page = await pages({ ...data, source: 'local' }, args, { triage: true, reuse: lookup.page, refresh });
625
657
  lookup.page = page.resultPage;
626
658
  return page;
627
659
  });
@@ -781,7 +813,7 @@ export async function serve({
781
813
  protocolVersion: versions.includes(version) ? version : versions[0],
782
814
  capabilities: { tools: {} },
783
815
  serverInfo: { name: 'domain-hound', title: 'Domain Hound', version: serverVersion },
784
- instructions: 'When you use Domain Hound, include its clickable Results page link in your final answer, including for a single exact domain. Copy the first line of say for the link, then give your short answer. For a new product name, call triage_names with idea. To check names you already have, pass names.',
816
+ instructions: 'When you use Domain Hound, include its clickable Results page link from say, including for a single exact domain. Keep the notice at the top when a check ran on this machine. For a new product name, call triage_names with idea. To check names you already have, pass names.',
785
817
  });
786
818
  }
787
819
  if (method !== 'tools/list' && method !== 'tools/call') return error(id, -32601, 'Method not found');
@@ -826,7 +858,7 @@ export async function serve({
826
858
  const started = performance.now();
827
859
  if (name === triageTool.name) {
828
860
  if (isObject(args) && Object.hasOwn(args, 'idea')) return reply(await generateNames(args));
829
- const fromHost = await hostedLookup(args, true);
861
+ const fromHost = await hostedLookup(args, true, started);
830
862
  if (fromHost) return reply(fromHost);
831
863
  let current;
832
864
  const result = await runLookup(args, triageArguments, triageRows, (data, lookup) => triageReceipt(lookup, args, data),
@@ -835,14 +867,14 @@ export async function serve({
835
867
  // Without a repeat call, the finished result still reaches the same page when the lookup ends.
836
868
  if (!progress.answers.size) {
837
869
  finishInBackground(lookup, args);
838
- return summary;
870
+ return localProgress(summary);
839
871
  }
840
872
  const progressPage = pendingTriage(progress, timing.rows);
841
873
  const { resultPage } = await writeTriagePage(lookup, progressPage, args, true);
842
874
  finishInBackground(lookup, args, progressPage);
843
875
  const shown = JSON.parse(summary);
844
876
  shown.display = resultsLine(resultPage) + '\n' + shown.display;
845
- return JSON.stringify({ ...shown, resultPage });
877
+ return localProgress(JSON.stringify({ ...shown, resultPage }));
846
878
  }, lookup => { current = lookup; }, started);
847
879
  reply(result);
848
880
  if (!result.isError && current?.finished && current.outcome?.data) followUp(current);
@@ -851,9 +883,9 @@ export async function serve({
851
883
  if (name !== checkTool.name && name !== legacyTool.name) return error(id, -32602, 'Unknown tool');
852
884
  // An exact lookup includes the purchase line while its registration status is unsettled.
853
885
  const exact = isObject(args) && typeof args.query === 'string' && args.query.includes('.');
854
- const result = await hostedLookup(args, false) ?? await runLookup(
855
- args, cliArguments, checkRows, data => pages(data, args).then(page => withCheckQuoteOffer(page, args)),
856
- (progress, timing) => progressText(progress, { ...timing, purchase: purchase || exact }), undefined, started,
886
+ const result = await hostedLookup(args, false, started) ?? await runLookup(
887
+ args, cliArguments, checkRows, data => pages({ ...data, source: 'local' }, args).then(page => withCheckQuoteOffer(page, args)),
888
+ (progress, timing) => localProgress(progressText(progress, { ...timing, purchase: purchase || exact })), undefined, started,
857
889
  );
858
890
  if (exact && args.picked === true && !result.isError && result.structuredContent?.resultPage) {
859
891
  track(scoreLog?.picked(args.query, 'check_domains'));
@@ -867,6 +899,7 @@ export async function serve({
867
899
  pending.add(response);
868
900
  }
869
901
  await Promise.all(pending);
902
+ hostedShutdown.abort();
870
903
  while (background.size) await Promise.all(background);
871
904
  // The client has gone, so nobody can collect a lookup that is still running.
872
905
  for (const lookup of lookups.values()) if (!lookup.exited) lookup.child.kill('SIGKILL');