domain-hound 0.1.9 → 0.1.11

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.
@@ -14,18 +14,19 @@ const domainField = { type: 'string', minLength: 3, maxLength: 253, description:
14
14
 
15
15
  export const quoteTool = {
16
16
  name: 'quote_domain',
17
- description: 'Get a live Spaceship quote with the term, upfront and renewal prices, premium status and registry availability. '
18
- + 'Show the exact quote, which expires in 10 minutes. Relay the display as written.',
19
- annotations: { title: 'Quote a domain at Spaceship', readOnlyHint: true, destructiveHint: false, idempotentHint: false, openWorldHint: true },
17
+ description: 'Use this when the person wants a live Spaceship purchase quote for an exact available domain. '
18
+ + 'Shows the term, upfront payment, renewal and premium status, and saves a short-lived quote locally. Use check_domains for list prices and buy_domain for checkout.',
19
+ annotations: { title: 'Quote a domain at Spaceship', readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
20
20
  inputSchema: { type: 'object', properties: {
21
21
  domain: domainField,
22
- years: { type: 'integer', minimum: 1, maximum: 10, description: 'Optional term in years. Omit for the shortest term Spaceship offers.' },
22
+ years: { type: 'integer', minimum: 1, maximum: 10, description: 'Term in years, e.g. 2. Omit for the shortest available term.' },
23
23
  }, required: ['domain'], additionalProperties: false },
24
24
  };
25
25
 
26
26
  export const buyTool = {
27
27
  name: 'buy_domain',
28
- description: 'COSTS MONEY: needs an unexpired quote_id and agreed max_usd. Stop on price changes or above either limit. '
28
+ description: 'Use this when the person wants to buy a domain after getting a live Spaceship quote. COSTS MONEY. '
29
+ + 'Use quote_domain for pricing alone. Requires an unexpired quote_id and agreed max_usd. Stop on any price change or above either limit. '
29
30
  + 'Preview with Spaceship’s ' + spaceshipMcp.tool + ' by default. Check the quote and limits, stop if price or payment method is missing, '
30
31
  + 'and accept the full confirmation only after showing it and getting approval. Direct orders need opt-in, a standard-price minimum term '
31
32
  + 'and approved confirm: true. Spaceship sets the charge. Checkout requires a valid quote and no submitted order. '
@@ -33,40 +34,46 @@ export const buyTool = {
33
34
  annotations: { title: 'Buy a domain (costs money)', readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
34
35
  inputSchema: { type: 'object', properties: {
35
36
  domain: domainField,
36
- quote_id: { type: 'string', maxLength: 40, description: 'The quote ID from quote_domain.' },
37
- max_usd: { type: 'number', exclusiveMinimum: 0, maximum: 100000, description: 'The most the person agreed to pay upfront, in USD.' },
38
- confirm: { type: 'boolean', description: 'True only after the person saw the exact quote and said yes. Otherwise omit for a dry run.' },
37
+ quote_id: { type: 'string', maxLength: 40, description: 'Quote ID returned by quote_domain, e.g. "example-quote-id".' },
38
+ max_usd: { type: 'number', exclusiveMinimum: 0, maximum: 100000, description: 'Approved upfront limit in USD, e.g. 25.' },
39
+ confirm: { type: 'boolean', description: 'Set true only after the person approves the exact quote. Omit for a dry run.' },
39
40
  }, required: ['domain', 'quote_id', 'max_usd'], additionalProperties: false },
40
41
  };
41
42
 
42
43
  const hostField = description => ({ type: 'string', maxLength: 253, description });
43
44
  export const setupTool = {
44
45
  name: 'setup_domain',
45
- description: 'Changes DNS at Spaceship. Preview website and mail changes without plan_id. Apply with plan_id and apply: true after approval. '
46
+ description: 'Use this when pointing an owned Spaceship domain to a website or mail provider, or verifying a purchase. CHANGES DNS when applied. '
47
+ + 'Use buy_domain for buying. Preview without plan_id, then apply with plan_id and apply: true after approval. '
46
48
  + 'Record removal also needs replace: true. Use provider-supplied values. '
47
49
  + 'With only verify: true it writes nothing: it looks the domain up at the registry and in the Spaceship account. '
48
50
  + 'Verify after a purchase and before DNS setup. Relay the display as written.',
49
51
  annotations: { title: 'Set up domain DNS (changes DNS)', readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
50
52
  inputSchema: { type: 'object', properties: {
51
53
  domain: domainField,
52
- website: { type: 'object', additionalProperties: false, required: ['provider'], properties: {
53
- provider: { type: 'string', enum: websiteProviders },
54
+ website: { type: 'object', additionalProperties: false, required: ['provider'],
55
+ description: 'Website settings, e.g. {"provider":"cname","target":"www.example.net"}.', properties: {
56
+ provider: { type: 'string', enum: websiteProviders, description: 'Website provider, e.g. "vercel".' },
54
57
  target: hostField('GitHub Pages user.github.io, Netlify site.netlify.app, Cloudflare Pages project.pages.dev, or a CNAME target.'),
55
- ipv4: { type: 'array', maxItems: 8, items: { type: 'string', maxLength: 15 }, description: 'For ip, or the exact apex IP from Vercel.' },
56
- ipv6: { type: 'array', maxItems: 8, items: { type: 'string', maxLength: 45 }, description: 'For ip only.' },
57
- www_target: hostField('Vercel only: the unique www CNAME from the project’s Domains page.'),
58
+ ipv4: { type: 'array', maxItems: 8, items: { type: 'string', maxLength: 15 }, description: 'IPv4 targets for ip or Vercel, e.g. ["192.0.2.10"].' },
59
+ ipv6: { type: 'array', maxItems: 8, items: { type: 'string', maxLength: 45 }, description: 'IPv6 targets for ip only, e.g. ["2001:db8::10"].' },
60
+ www_target: hostField('Vercel www CNAME from the project’s Domains page, e.g. "www.example.net".'),
58
61
  } },
59
- mail: { type: 'object', additionalProperties: false, required: ['provider'], properties: {
60
- provider: { type: 'string', enum: mailProviders },
62
+ mail: { type: 'object', additionalProperties: false, required: ['provider'],
63
+ description: 'Mail settings, e.g. {"provider":"google-workspace"}.', properties: {
64
+ provider: { type: 'string', enum: mailProviders, description: 'Mail provider, e.g. "google-workspace".' },
61
65
  mx: { type: 'array', minItems: 1, maxItems: 5, items: { type: 'object', additionalProperties: false, required: ['exchange', 'preference'],
62
- properties: { exchange: { type: 'string', maxLength: 253 }, preference: { type: 'integer', minimum: 0, maximum: 65535 } } },
63
- description: 'Provider-supplied MX: required for microsoft-365 (tenant MX) and forward-only; optional custom values for icloud.' },
66
+ properties: { exchange: { type: 'string', maxLength: 253, description: 'Mail server, e.g. "mx.example.net".' },
67
+ preference: { type: 'integer', minimum: 0, maximum: 65535, description: 'MX priority, e.g. 10.' } } },
68
+ description: 'Provider MX, e.g. [{"exchange":"mx.example.net","preference":10}]. Required for microsoft-365 and forward-only. Optional for icloud.' },
64
69
  records: { type: 'array', maxItems: 10, items: { type: 'object', additionalProperties: false, required: ['type', 'name', 'value'],
65
- properties: { type: { type: 'string', enum: ['TXT', 'CNAME'] }, name: { type: 'string', maxLength: 190 }, value: { type: 'string', maxLength: 2048 } } },
66
- description: 'Verification and DKIM records exactly as the mail provider lists them. Never make them up.' },
67
- dmarc: { type: 'string', enum: ['none', 'quarantine', 'reject'], description: 'Only when the person picks a DMARC policy. Otherwise a valid existing policy stays.' },
70
+ properties: { type: { type: 'string', enum: ['TXT', 'CNAME'], description: 'Record type, e.g. "TXT".' },
71
+ name: { type: 'string', maxLength: 190, description: 'Record name, e.g. "@".' },
72
+ value: { type: 'string', maxLength: 2048, description: 'Record value, e.g. "verify-example".' } } },
73
+ description: 'Provider-supplied verification and DKIM records, e.g. [{"type":"TXT","name":"@","value":"verify-example"}]. Never guess.' },
74
+ dmarc: { type: 'string', enum: ['none', 'quarantine', 'reject'], description: 'User-selected DMARC policy, e.g. "quarantine". Omit to keep an existing valid policy.' },
68
75
  } },
69
- plan_id: { type: 'string', maxLength: 40, description: 'The plan ID from the preview.' },
76
+ plan_id: { type: 'string', maxLength: 40, description: 'Plan ID from the preview, e.g. "example-plan-id".' },
70
77
  apply: { type: 'boolean', description: 'True only with plan_id, after the person approved the previewed changes.' },
71
78
  replace: { type: 'boolean', description: 'True only when the person agreed to remove the existing records the plan lists.' },
72
79
  verify: { type: 'boolean', description: 'True, alone with domain, to check a purchase at the registry and in the person’s account. Writes nothing.' },
@@ -75,7 +82,8 @@ export const setupTool = {
75
82
 
76
83
  export const moveTool = {
77
84
  name: 'move_domain',
78
- description: 'Plan a transfer for an owned domain. Compare three-year costs, check locks and expiry, and get registrar steps. '
85
+ description: 'Use this when transferring an owned domain to another registrar or checking a transfer’s progress. '
86
+ + 'For a new registration use check_domains. Compare three-year costs, check locks and expiry, and get registrar steps. '
79
87
  + 'A Spaceship key adds a 10-minute quote. COSTS MONEY with quote_id and max_usd: rechecks the quote and opens a path to checkout. '
80
88
  + 'Direct transfer requires server opt-in, approval, confirm: true and the private auth_code. Keep the code private and never retry an unclear transfer. '
81
89
  + 'Use status: true to follow a transfer. Relay the display as written.',
@@ -83,11 +91,11 @@ export const moveTool = {
83
91
  openWorldHint: true },
84
92
  inputSchema: { type: 'object', properties: {
85
93
  domain: domainField,
86
- quote_id: { type: 'string', maxLength: 40, description: 'The transfer quote ID from the plan.' },
87
- max_usd: { type: 'number', exclusiveMinimum: 0, maximum: 100000, description: 'The most the person agreed to pay for the transfer, in USD.' },
88
- confirm: { type: 'boolean', description: 'Direct transfers only: true after the person saw the dry run and said yes.' },
94
+ quote_id: { type: 'string', maxLength: 40, description: 'Transfer quote ID from the plan, e.g. "example-transfer-id".' },
95
+ max_usd: { type: 'number', exclusiveMinimum: 0, maximum: 100000, description: 'Approved transfer limit in USD, e.g. 25.' },
96
+ confirm: { type: 'boolean', description: 'Set true for a direct transfer only after approval of the dry run.' },
89
97
  auth_code: { type: 'string', minLength: 1, maxLength: 50, description: 'Direct transfers only, with confirm: true. Pass the code from '
90
- + 'the person’s private input. Keep it out of chat, logs and results.' },
98
+ + 'the person’s private input (for example, a registrar-issued transfer code). Keep it out of chat, logs and results.' },
91
99
  status: { type: 'boolean', description: 'True, alone with domain, to follow a transfer into the person’s Spaceship account.' },
92
100
  }, required: ['domain'], additionalProperties: false },
93
101
  };
@@ -95,22 +103,8 @@ export const moveTool = {
95
103
  export const purchaseTools = [quoteTool, buyTool, setupTool, moveTool];
96
104
  export const purchaseToolNames = new Set(purchaseTools.map(tool => tool.name));
97
105
 
98
- // Replace stale global claims in the check tools with the handoff, whatever the rest of their wording says.
99
- const handoffSentence = 'To buy through the person’s own Spaceship account, use quote_domain, then buy_domain.';
100
- export function currentDescription(text, handoff = true) {
101
- const updated = String(text)
102
- .replace(/Domain Hound cannot buy or complete checkout/g, 'This check leaves checkout to you')
103
- .replace(/\bNever buys\./g, 'This check leaves checkout to you.')
104
- .replace(/Domain Hound never buys/gi, 'This check leaves checkout to you')
105
- .replace(/\b(?:cannot|can't|never) buys?\b/gi, 'leaves checkout to you');
106
- return !handoff || updated.includes(handoffSentence) ? updated : updated.trimEnd() + ' ' + handoffSentence;
107
- }
108
-
109
- // The legacy alias stays short, so only check_domains carries the handoff sentence.
110
106
  export function registeredTools(tools) {
111
- const updated = tools.map(tool => tool.name === 'check_domains' || tool.name === 'broker_find'
112
- ? { ...tool, description: currentDescription(tool.description, tool.name === 'check_domains') } : tool);
113
- return [...updated, ...purchaseTools.filter(tool => !updated.some(other => other.name === tool.name))];
107
+ return [...tools, ...purchaseTools.filter(tool => !tools.some(other => other.name === tool.name))];
114
108
  }
115
109
 
116
110
  // One line that offers the exact quote when a checked or watched domain is free.
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
  }
package/dossier.mjs CHANGED
@@ -4,16 +4,16 @@ import { dnsNeed } from './clis/domain-check/prices.mjs';
4
4
 
5
5
  export const dossierTool = {
6
6
  name: 'taken_domain_dossier',
7
- description: 'Investigate a taken domain: registry, site and public listing evidence, likely owner type, and a price range when supported, '
8
- + 'plus up to three available alternatives with upfront, renewal and three-year prices and a quick trademark, app and rival screen. '
9
- + 'Relay the display and sources. Keep maxBudget private and send no drafts. Share follow-up drafts and start a watch only on request.',
10
- annotations: { title: 'Taken domain dossier', readOnlyHint: true, destructiveHint: false, openWorldHint: true },
7
+ description: 'Use this when investigating a taken domain’s ownership, sale listing or likely price range. Checks registry and public site evidence, '
8
+ + 'and finds up to three available alternatives with upfront, renewal and three-year prices and a quick trademark, app and rival screen. '
9
+ + 'For release alerts use watch_domain. Keep maxBudget private and never send an offer draft.',
10
+ annotations: { title: 'Taken domain dossier', readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
11
11
  inputSchema: {
12
12
  type: 'object',
13
13
  properties: {
14
14
  domain: { type: 'string', minLength: 3, maxLength: 127, description: 'The exact taken domain, like example.com.' },
15
15
  maxBudget: { type: 'number', minimum: 0,
16
- description: 'Optional private walk-away price in USD. Kept out of every draft and the display.' },
16
+ description: 'Optional private walk-away price in USD, e.g. 250. Kept out of every draft and the display.' },
17
17
  },
18
18
  required: ['domain'],
19
19
  additionalProperties: false,
@@ -27,8 +27,8 @@ function warning(check) {
27
27
  + '. The match applies to the name across all endings.');
28
28
  }
29
29
 
30
- function nameCheckLines(details, pending, name) {
31
- if (!details) return [pending ? 'Name checks are still running.' : 'Name checks could not be completed.'];
30
+ export function nameCheckLines(details, pending, name) {
31
+ if (!details) return [pending ? 'Name checks are still running. Call the same tool with the same input to collect them.' : 'Name checks could not be completed.'];
32
32
  const { appStore: app, googlePlay, trademarks, handles } = details;
33
33
  const appText = app.status === 'taken' ? 'Matching app found' : app.status === 'no_match_found' ? 'No matching app found'
34
34
  : app.reason === 'rate-limited' ? 'Search rate-limited' : 'Could not complete the search';
@@ -55,32 +55,46 @@ function priceLine(offer, cheapest) {
55
55
  return link(offer.shop, offer.buyUrl) + (cheapest ? ' (cheapest over three years)' : '') + ' · '
56
56
  + money(offer.firstYearUsd) + ' first year · ' + money(offer.renewalUsd) + ' yearly renewal · '
57
57
  + money(offer.threeYearUsd) + ' over three years' + term
58
- + (offer.needsCloudflareDns ? ' · requires Cloudflare DNS' : '');
58
+ + (offer.needsCloudflareDns ? ' · requires Cloudflare DNS' : '')
59
+ + (offer.checkedAt && offer.source ? ' · ' + link(offer.checkedAt.slice(0, 10), offer.source) : '');
59
60
  }
60
61
 
61
- function checkLines(check, pending) {
62
+ export function pickLine(pick) {
63
+ return 'The Hound’s pick is ' + md(pick.domain) + ' at ' + md(pick.shop) + ' for ' + money(pick.threeYearUsd) + ' over three years.';
64
+ }
65
+
66
+ export function checkLines(check, pending, { local = false } = {}) {
62
67
  const { domains, choice, nameChecks, score } = check;
63
68
  const pick = choice?.pick;
64
69
  const taken = domains.filter(row => row.status === 'taken').map(row => row.domain);
65
- const unknown = domains.filter(row => row.status === 'unknown');
70
+ const reserved = domains.filter(row => row.reason === 'reserved');
71
+ const unknown = domains.filter(row => row.status === 'unknown' && row.reason !== 'reserved');
66
72
  return [
67
73
  ...(score?.filtered ? [md(check.query.name) + ' · ' + md(score.filtered)]
68
74
  : Number.isInteger(score?.value) ? [md(check.query.name) + ' · Name score ' + score.value + '/100 · ' + md(score.band),
69
75
  ...(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.'] : []),
76
+ ...(pick ? [pickLine(pick)] : []),
71
77
  ...domains.filter(row => row.status === 'available').flatMap(row => [
72
78
  'Available · ' + md(row.domain),
73
- ...(row.prices?.length ? row.prices.map((offer, index) => priceLine(offer, index === 0)) : ['Check the price at the shop.']),
79
+ ...(row.prices?.length ? row.prices.map((offer, index) => priceLine(offer, !local && index === 0)) : ['Check the price at the shop.']),
80
+ ...(local && row.confirmed ? ['Confirmed at the shop.'] : []),
74
81
  ]),
75
- ...nameCheckLines(nameChecks, pending, check.query.name),
82
+ ...(local ? [] : nameCheckLines(nameChecks, pending, check.query.name)),
76
83
  ...(taken.length ? ['Taken · ' + taken.map(md).join(', ') + '. '
77
84
  + link('Watch', 'https://domainhound.dev/watch/?domain=' + encodeURIComponent(taken[0]))
78
85
  + ' · Draft an offer · Try a new name'] : []),
86
+ ...(reserved.length ? ['Reserved by the registry · ' + reserved.map(row => md(row.domain)).join(', ') + '.'] : []),
79
87
  ...(unknown.length ? ['Could not confirm ' + (domains.length === 1 ? md(unknown[0].domain)
80
88
  : unknown.length + (unknown.length === 1 ? ' ending' : ' endings')) + '.'] : []),
81
89
  ];
82
90
  }
83
91
 
92
+ export function pickDomain(options, { endings, eligible, budget } = {}) {
93
+ return choosePick(options.filter(option => option.buyUrl), {
94
+ requested: endings, eligible, budget, allowOverCap: budget != null,
95
+ }) ?? null;
96
+ }
97
+
84
98
  function preferredPick(check, args) {
85
99
  if (!args.endings?.length && args.budget == null && !args.eligible?.length && !args.country) return check.choice.pick;
86
100
  if (check.query.exactDomain) return check.choice.pick;
@@ -89,7 +103,7 @@ function preferredPick(check, args) {
89
103
  row.prices.filter(offer => args.budget == null || offer.firstPaymentUsd <= args.budget).map(offer => ({
90
104
  ...offer, domain: row.domain, now: offer.firstPaymentUsd, total: offer.threeYearUsd,
91
105
  })));
92
- return choosePick(options, { requested: args.endings, eligible: args.eligible, budget: args.budget }) ?? null;
106
+ return pickDomain(options, args);
93
107
  }
94
108
 
95
109
  export function hostedChecks(checks, args, triage = false) {
@@ -126,16 +140,22 @@ export function generatedChecks(generation) {
126
140
  }));
127
141
  }
128
142
 
129
- export function hostedResult(checks, args, generation, { pending = false, failed = false, checkedAt } = {}) {
130
- const shown = !generation && args.shortlist && checks.some(check => check.score)
143
+ export function visibleChecks(checks, args, generation) {
144
+ return !generation && args.shortlist && checks.some(check => check.score)
131
145
  ? checks.filter(check => scoreEligible(check)).sort((a, b) => compareScores(a.score, b.score)).slice(0, 8) : checks;
146
+ }
147
+
148
+ export function hostedResult(checks, args, generation, { pending = false, failed = false, checkedAt } = {}) {
149
+ const shown = visibleChecks(checks, args, generation);
132
150
  const lines = [
133
151
  ...checks.flatMap(warning),
134
152
  ...(shown.length ? shown.flatMap((check, index) => [
135
153
  ...(shown.length > 1 ? [md(check.query.exactDomain ?? check.query.name)] : []),
136
154
  ...checkLines(check, pending),
137
155
  ...(index < shown.length - 1 ? [''] : []),
138
- ]) : [pending ? 'Still checking names and domains.' : 'No names passed the checks.']),
156
+ ]) : [pending && generation?.suggestions?.length
157
+ ? 'Checking domains for ' + generation.suggestions.map(entry => md(entry.name)).join(', ') + '.'
158
+ : pending ? 'Still checking names and domains.' : 'No names passed the checks.']),
139
159
  ...(pending ? ['The results page updates when the remaining checks finish.'] : []),
140
160
  ...(failed ? ['The remaining checks did not finish.'] : []),
141
161
  ...(generation?.question && !pending ? [md(generation.question)] : []),
@@ -146,12 +166,14 @@ export function hostedResult(checks, args, generation, { pending = false, failed
146
166
  const rows = status => check.domains.filter(row => row.status === status);
147
167
  return { name: check.query.exactDomain ?? check.query.name,
148
168
  available: rows('available').map(row => row.ending), free: rows('available').map(row => ({ d: row.ending })),
149
- taken: rows('taken').map(row => row.ending), shop_check: rows('unknown').map(row => row.ending),
169
+ taken: rows('taken').map(row => row.ending),
170
+ reserved: rows('unknown').filter(row => row.reason === 'reserved').map(row => row.ending),
171
+ shop_check: rows('unknown').filter(row => row.reason !== 'reserved').map(row => row.ending),
150
172
  ...(check.score && { score: check.score }) };
151
173
  });
152
174
  const { details, ...generationResult } = generation ?? {};
153
175
  return { hosted: true, checks, names, ...(generation && { generation: generationResult }), ...(pending && { pending: true }),
154
- complete: generation ? !pending && !failed && generation.complete : checks.every(check => check.complete),
176
+ complete: generation ? !pending && !failed && generation.complete : !pending && checks.every(check => check.complete),
155
177
  checkedAt: checkedAt ?? generation?.checkedAt ?? checks[0]?.checkedAt ?? new Date().toISOString(),
156
178
  lines: attributed(lines.join('\n'), Boolean(args.purchase || (checks.length === 1 && checks[0].query.exactDomain))).split('\n') };
157
179
  }
package/hosted.mjs CHANGED
@@ -2,11 +2,25 @@ import { setTimeout as wait } from 'node:timers/promises';
2
2
  import { checkGooglePlayNames, checkSocialHandles, embedChecksEnabled, handleLabel, handleStates, publicProfiles } from './clis/domain-check/handles.mjs';
3
3
  import { googlePlayLabel, googlePlayLinkLabel, playSearchLink } from './clis/domain-check/google-play.mjs';
4
4
  import { normalizeName } from './clis/domain-check/name-search.mjs';
5
+ import { rdapSignal } from './clis/domain-check/registry.mjs';
5
6
  import { searchApps } from './clis/domain-check/triage-sources.mjs';
6
7
 
7
8
  export const hostedBase = 'https://domainhound-mcp.domainhound.workers.dev';
9
+ // Page-only evidence. Symbols survive the internal object spreads and stay out of MCP JSON.
10
+ export const alternativeEndings = Symbol('alternative endings');
8
11
  export class HostedRateLimit extends Error {}
9
12
 
13
+ export function hostedDebug(message, env = process.env) {
14
+ if (env.DOMAIN_HOUND_DEBUG === '1') process.stderr.write('Domain Hound: ' + message + '\n');
15
+ }
16
+
17
+ class HostedRequestError extends Error {
18
+ constructor(message, transient = false) {
19
+ super(message);
20
+ this.transient = transient;
21
+ }
22
+ }
23
+
10
24
  const validCheck = body => body?.version === 1 && typeof body.query?.ascii === 'string' &&
11
25
  Array.isArray(body.domains) && body.domains.every(row => typeof row.domain === 'string' &&
12
26
  ['available', 'taken', 'unknown'].includes(row.status) && Array.isArray(row.prices)) && body.choice;
@@ -14,39 +28,109 @@ const validDetails = body => body?.version === 1 && body.appStore && body.google
14
28
  Array.isArray(body.trademarks?.us?.marks) && Array.isArray(body.handles);
15
29
  const validGeneration = body => body?.version === 2 && ['initial', 'final'].includes(body.stage) && Array.isArray(body.names);
16
30
 
31
+ // Only the IANA-listed Google Registry route for the returned .app or .dev domain is eligible.
32
+ async function observeRdap(row, ascii, fetchFn, signal) {
33
+ if (row.status !== 'unknown' || !['dev', 'app'].includes(row.ending) ||
34
+ !/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(ascii) ||
35
+ row.domain !== ascii + '.' + row.ending ||
36
+ row.rdapUrl !== 'https://pubapi.registry.google/rdap/domain/' + row.domain) return null;
37
+ try {
38
+ const timeout = AbortSignal.timeout(1600);
39
+ const response = await fetchFn(row.rdapUrl, { redirect: 'error', credentials: 'omit', cache: 'no-store',
40
+ headers: { Accept: 'application/rdap+json, application/json' },
41
+ signal: signal ? AbortSignal.any([signal, timeout]) : timeout });
42
+ const age = Number(response.headers.get('age') ?? 0);
43
+ const type = response.headers.get('content-type')?.split(';', 1)[0].trim().toLowerCase();
44
+ if (![200, 404].includes(response.status) || !Number.isFinite(age) || age > 0 ||
45
+ !['application/rdap+json', 'application/json'].includes(type)) {
46
+ await response.body?.cancel().catch(() => {});
47
+ return null;
48
+ }
49
+ const json = await response.text();
50
+ const body = JSON.parse(json);
51
+ if (response.status === 200) {
52
+ return body?.objectClassName === 'domain' && typeof body.ldhName === 'string' &&
53
+ body.ldhName.toLowerCase().replace(/\.$/, '') === row.domain &&
54
+ !body.status?.some?.(value => /^(reserved|not available)$/i.test(value)) ? row.ending + ':taken' : null;
55
+ }
56
+ const hint = rdapSignal(json);
57
+ return body?.errorCode === 404 && hint !== 'reserved'
58
+ ? row.ending + ':' + (hint ?? 'available') : null;
59
+ } catch {
60
+ return null;
61
+ }
62
+ }
63
+
17
64
  export function hostedClient(version, { env = process.env, fetchFn = fetch, apple = searchApps } = {}) {
18
65
  if (env.DOMAIN_HOUND_LOCAL === '1') return null;
19
66
  let base;
20
67
  try {
21
68
  base = new URL(env.DOMAIN_HOUND_API_URL || hostedBase);
22
69
  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;
70
+ if (base.username || base.password || (base.protocol !== 'https:' && !(loopback && base.protocol === 'http:'))) {
71
+ throw new Error('Invalid hosted API origin');
72
+ }
24
73
  } catch {
74
+ hostedDebug('Hosted API origin is invalid; using the local check.', env);
25
75
  return null;
26
76
  }
27
77
 
28
- async function read(path, { body, params, timeout, signal } = {}) {
78
+ async function request(path, { body, params, timeout, signal, valid } = {}) {
29
79
  const url = new URL(path, base);
30
80
  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
- });
81
+ const deadline = AbortSignal.timeout(timeout);
82
+ let res;
83
+ try {
84
+ res = await fetchFn(url, {
85
+ redirect: 'error',
86
+ headers: { 'X-Domain-Hound-Client': 'mcp/' + version, ...(body && { 'Content-Type': 'application/json' }) },
87
+ ...(body && { method: 'POST', body: JSON.stringify(body) }),
88
+ signal: signal ? AbortSignal.any([signal, deadline]) : deadline,
89
+ });
90
+ } catch (error) {
91
+ const code = error?.cause?.code;
92
+ const reason = signal?.aborted ? 'lookup stopped' : deadline.aborted ? 'request timed out'
93
+ : 'connection failed' + (/^(?:E[A-Z_0-9]+|UND_ERR_[A-Z_0-9]+)$/.test(code ?? '') ? ' (' + code + ')' : '');
94
+ throw new HostedRequestError(reason, true);
95
+ }
37
96
  if (!res.ok) {
38
97
  await res.body?.cancel().catch(() => {});
39
- if (res.status === 429) throw new HostedRateLimit();
40
- throw new Error('Hosted check unavailable');
98
+ if (res.status === 429) throw new HostedRateLimit('HTTP 429');
99
+ throw new HostedRequestError('HTTP ' + res.status, res.status === 408 || res.status >= 500);
41
100
  }
42
- return res.json();
101
+ const answer = await res.json().catch(() => {
102
+ throw new HostedRequestError(signal?.aborted ? 'lookup stopped' : deadline.aborted
103
+ ? 'response timed out' : 'invalid or incomplete JSON response', true);
104
+ });
105
+ if (valid && !valid(answer)) throw new HostedRequestError('response did not match the API format', true);
106
+ return answer;
43
107
  }
44
108
 
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
- };
109
+ async function read(path, options, retry = false) {
110
+ for (let attempt = 1; ; attempt++) {
111
+ const started = performance.now();
112
+ try {
113
+ return await request(path, options);
114
+ } catch (error) {
115
+ const retrying = retry && attempt === 1 && error.transient && !options.signal?.aborted;
116
+ hostedDebug(path + ' attempt ' + attempt + ' failed after ' + Math.round(performance.now() - started)
117
+ + ' ms (' + (error instanceof HostedRequestError || error instanceof HostedRateLimit ? error.message : 'unexpected error')
118
+ + ')' + (retrying ? '; retrying' : ''), env);
119
+ if (!retrying) throw error;
120
+ await wait(200, undefined, { signal: options.signal });
121
+ }
122
+ }
123
+ }
124
+
125
+ async function get(name, signal) {
126
+ const params = new URLSearchParams({ name });
127
+ const options = { params, timeout: 4200, signal, valid: validCheck };
128
+ const initial = await read('/v1/check', options, true);
129
+ const seen = (await Promise.all(initial.domains.map(row => observeRdap(row, initial.query.ascii, fetchFn, signal)))).filter(Boolean);
130
+ if (!seen.length) return initial;
131
+ seen.forEach(observation => params.append('seen', observation));
132
+ return read('/v1/check', options).catch(() => initial);
133
+ }
50
134
 
51
135
  async function recoverApple(app, name, signal) {
52
136
  if (app?.status !== 'unknown' || app.reason !== 'rate-limited') return app;
@@ -109,24 +193,39 @@ export function hostedClient(version, { env = process.env, fetchFn = fetch, appl
109
193
  }
110
194
 
111
195
  return {
112
- async check(name, extraEndings, signal) {
196
+ async check(name, extraEndings, signal, onDomains) {
113
197
  const [main, ...extras] = await Promise.all([get(name, signal),
114
198
  ...extraEndings.map(ending => get(normalizeName(name) + '.' + ending, signal))]);
199
+ const { details, ...answer } = main;
200
+ answer.domains = [...main.domains, ...extras.flatMap(extra => extra.domains)];
201
+ answer.complete = main.complete && extras.every(extra => extra.complete);
202
+ const exact = main.query.exactDomain;
203
+ const needsAlternatives = exact && main.domains.length === 1 && main.domains[0].domain === exact && main.domains[0].status === 'taken';
204
+ // Run alongside the name checks. An unavailable comparison must not discard the exact answer.
205
+ const alternatives = needsAlternatives ? get(main.query.ascii, signal).then(comparison =>
206
+ comparison.query.ascii === main.query.ascii ? {
207
+ domains: comparison.domains, choice: comparison.choice, priceSnapshot: comparison.priceSnapshot,
208
+ share: comparison.share, complete: comparison.complete,
209
+ } : null).catch(() => null) : null;
115
210
  let nameChecks = null;
116
- if (typeof main.details?.id === 'string') {
211
+ if (typeof details?.id === 'string') {
212
+ onDomains?.(answer);
117
213
  nameChecks = await read('/v1/check/details', {
118
- params: { id: main.details.id }, timeout: 6600, signal,
119
- }).then(body => validDetails(body) ? body : null, () => null);
214
+ params: { id: details.id }, timeout: 5300, signal: AbortSignal.any([signal, AbortSignal.timeout(5700)]), valid: validDetails,
215
+ }, true).catch(() => null);
216
+ } else {
217
+ hostedDebug('/v1/check did not provide a name-check token', env);
120
218
  }
121
219
  if (nameChecks) {
122
- await Promise.all([
220
+ const recovered = await Promise.allSettled([
123
221
  recoverApple(nameChecks.appStore, main.query.name, signal).then(app => { nameChecks.appStore = app; }),
124
222
  recoverNameChecks([{ name: main.query.name, nameChecks }], signal),
125
223
  ]);
224
+ for (const [index, result] of recovered.entries()) {
225
+ if (result.status === 'rejected') hostedDebug('Optional ' + (index ? 'handle' : 'App Store') + ' recovery failed', env);
226
+ }
126
227
  }
127
- const { details, ...answer } = main;
128
- return { ...answer, domains: [...main.domains, ...extras.flatMap(extra => extra.domains)], nameChecks,
129
- complete: main.complete && extras.every(extra => extra.complete) };
228
+ return { ...answer, ...(needsAlternatives && { [alternativeEndings]: await alternatives }), nameChecks };
130
229
  },
131
230
 
132
231
  async generate(args, signal) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "domain-hound",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
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",
@@ -45,6 +45,7 @@
45
45
  "display.mjs",
46
46
  "results.mjs",
47
47
  "results-style.mjs",
48
+ "results-cards.mjs",
48
49
  "share.mjs",
49
50
  "site/r/share-format.mjs",
50
51
  "watch.mjs",
@@ -98,6 +99,7 @@
98
99
  "clis/portfolio/transfer-prices.mjs",
99
100
  "assets/",
100
101
  "skills/naming/SKILL.md",
102
+ "skills/domains/SKILL.md",
101
103
  ".claude-plugin/plugin.json",
102
104
  ".claude-plugin/marketplace.json",
103
105
  ".agents/plugins/marketplace.json",
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.11",
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"
@@ -24,6 +24,7 @@
24
24
  ],
25
25
  "websiteURL": "https://domainhound.dev",
26
26
  "privacyPolicyURL": "https://domainhound.dev/privacy/",
27
+ "termsOfServiceURL": "https://domainhound.dev/privacy/#terms",
27
28
  "supportURL": "https://github.com/lars-hv/domain-hound/issues",
28
29
  "logo": "./assets/icon-1024.png",
29
30
  "composerIcon": "./assets/icon-512.png"