slab-mcp 0.1.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +190 -107
  2. package/dist/client.d.ts +34 -13
  3. package/dist/client.js +99 -59
  4. package/dist/config.d.ts +7 -2
  5. package/dist/config.js +30 -7
  6. package/dist/context.d.ts +8 -12
  7. package/dist/context.js +7 -29
  8. package/dist/credentials.d.ts +33 -0
  9. package/dist/credentials.js +77 -0
  10. package/dist/errors.js +6 -2
  11. package/dist/format.d.ts +2 -0
  12. package/dist/format.js +7 -1
  13. package/dist/index.js +4 -2
  14. package/dist/prompts/index.js +31 -6
  15. package/dist/resources/index.d.ts +2 -1
  16. package/dist/resources/index.js +4 -3
  17. package/dist/tools/args.d.ts +18 -0
  18. package/dist/tools/args.js +26 -0
  19. package/dist/tools/catalog.d.ts +21 -6
  20. package/dist/tools/catalog.js +88 -47
  21. package/dist/tools/chases.d.ts +28 -0
  22. package/dist/tools/chases.js +72 -0
  23. package/dist/tools/collection.d.ts +26 -18
  24. package/dist/tools/collection.js +113 -82
  25. package/dist/tools/community.d.ts +16 -3
  26. package/dist/tools/community.js +110 -50
  27. package/dist/tools/filters.d.ts +6 -0
  28. package/dist/tools/filters.js +6 -0
  29. package/dist/tools/index.js +2 -0
  30. package/dist/tools/lines.d.ts +20 -0
  31. package/dist/tools/lines.js +31 -0
  32. package/dist/tools/meta.js +5 -4
  33. package/dist/tools/pricing.d.ts +21 -16
  34. package/dist/tools/pricing.js +167 -63
  35. package/dist/tools/writes.d.ts +43 -47
  36. package/dist/tools/writes.js +65 -29
  37. package/dist/types.d.ts +48 -77
  38. package/dist/types.js +6 -6
  39. package/dist/version.d.ts +13 -0
  40. package/dist/version.js +16 -0
  41. package/package.json +14 -5
  42. package/dist/client.js.map +0 -1
  43. package/dist/config.js.map +0 -1
  44. package/dist/context.js.map +0 -1
  45. package/dist/errors.js.map +0 -1
  46. package/dist/format.js.map +0 -1
  47. package/dist/index.js.map +0 -1
  48. package/dist/prompts/index.js.map +0 -1
  49. package/dist/resources/index.js.map +0 -1
  50. package/dist/tools/catalog.js.map +0 -1
  51. package/dist/tools/collection.js.map +0 -1
  52. package/dist/tools/community.js.map +0 -1
  53. package/dist/tools/filters.js.map +0 -1
  54. package/dist/tools/index.js.map +0 -1
  55. package/dist/tools/meta.js.map +0 -1
  56. package/dist/tools/pricing.js.map +0 -1
  57. package/dist/tools/types.js.map +0 -1
  58. package/dist/tools/writes.js.map +0 -1
  59. package/dist/types.js.map +0 -1
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Input pieces every tool shares, defined once.
3
+ *
4
+ * Ids are validated as UUIDs before a handler runs. The client already encodes each one as a single
5
+ * path segment, so a malformed id can't reach another route; refusing it here as well gives the
6
+ * model a clear "that isn't an id" instead of a 404 it might retry.
7
+ */
8
+ import { z } from 'zod';
9
+ /** A slab UUID. The description names the tool that produces it, so the model never invents one. */
10
+ export declare const uuid: (description: string) => z.ZodGUID;
11
+ export declare const optionalUuid: (description: string) => z.ZodOptional<z.ZodGUID>;
12
+ /** An ISO date, YYYY-MM-DD. */
13
+ export declare const isoDate: (description: string) => z.ZodString;
14
+ export declare const optionalIsoDate: (description: string) => z.ZodOptional<z.ZodString>;
15
+ /** The optional collector override on every collection tool. */
16
+ export declare const collectorArg: z.ZodOptional<z.ZodGUID>;
17
+ /** A price key's grade: RAW, or company-grade as the API spells it ("PSA-10", "BGS-9.5"). */
18
+ export declare const gradeKeyArg: z.ZodOptional<z.ZodString>;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Input pieces every tool shares, defined once.
3
+ *
4
+ * Ids are validated as UUIDs before a handler runs. The client already encodes each one as a single
5
+ * path segment, so a malformed id can't reach another route; refusing it here as well gives the
6
+ * model a clear "that isn't an id" instead of a 404 it might retry.
7
+ */
8
+ import { z } from 'zod';
9
+ const guid = () => z.guid({ error: 'Must be a slab UUID — get one from the tool this field names.' });
10
+ const date = () => z.string().regex(/^\d{4}-\d{2}-\d{2}$/, 'Must be an ISO date, YYYY-MM-DD');
11
+ // `.describe()` goes on last: zod keeps a description on the schema it was set on, and
12
+ // `.optional()` makes a new one, so describe-then-optional loses it (the registry test checks).
13
+ /** A slab UUID. The description names the tool that produces it, so the model never invents one. */
14
+ export const uuid = (description) => guid().describe(description);
15
+ export const optionalUuid = (description) => guid().optional().describe(description);
16
+ /** An ISO date, YYYY-MM-DD. */
17
+ export const isoDate = (description) => date().describe(description);
18
+ export const optionalIsoDate = (description) => date().optional().describe(description);
19
+ /** The optional collector override on every collection tool. */
20
+ export const collectorArg = optionalUuid('Collector UUID. Omit it: the server acts for the collector this API key belongs to. Only pass one for an account with several collectors.');
21
+ /** A price key's grade: RAW, or company-grade as the API spells it ("PSA-10", "BGS-9.5"). */
22
+ export const gradeKeyArg = z
23
+ .string()
24
+ .optional()
25
+ .describe('One price key: "RAW", or company-grade as slab spells it, e.g. "PSA-10", "BGS-9.5". Omit for every grade with data. get_vocab lists the grades.');
26
+ //# sourceMappingURL=args.js.map
@@ -1,9 +1,7 @@
1
- /** Catalog tools: finding cards, products, and what's in a product. */
1
+ /** Catalog tools: finding cards and products, and what a product holds and costs. */
2
2
  import { z } from 'zod';
3
- import type { CardOut } from '../types.js';
4
- /** One card on one line. UUID first — it is the only field the model must carry forward. */
5
- export declare function cardLine(card: CardOut): string;
6
3
  export declare const searchCards: import("./types.js").ToolModule<z.ZodObject<{
4
+ collapse_parallels: z.ZodOptional<z.ZodBoolean>;
7
5
  include_market: z.ZodOptional<z.ZodBoolean>;
8
6
  owned: z.ZodOptional<z.ZodBoolean>;
9
7
  facets: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -13,8 +11,10 @@ export declare const searchCards: import("./types.js").ToolModule<z.ZodObject<{
13
11
  q: z.ZodOptional<z.ZodString>;
14
12
  subject: z.ZodOptional<z.ZodString>;
15
13
  subject_exact: z.ZodOptional<z.ZodBoolean>;
14
+ subject_all: z.ZodOptional<z.ZodArray<z.ZodString>>;
16
15
  card_number: z.ZodOptional<z.ZodString>;
17
16
  set_slug: z.ZodOptional<z.ZodArray<z.ZodString>>;
17
+ release: z.ZodOptional<z.ZodArray<z.ZodString>>;
18
18
  brand: z.ZodOptional<z.ZodArray<z.ZodString>>;
19
19
  subset: z.ZodOptional<z.ZodArray<z.ZodString>>;
20
20
  year: z.ZodOptional<z.ZodNumber>;
@@ -22,6 +22,10 @@ export declare const searchCards: import("./types.js").ToolModule<z.ZodObject<{
22
22
  year_max: z.ZodOptional<z.ZodNumber>;
23
23
  team: z.ZodOptional<z.ZodArray<z.ZodString>>;
24
24
  league: z.ZodOptional<z.ZodArray<z.ZodString>>;
25
+ sport: z.ZodOptional<z.ZodArray<z.ZodString>>;
26
+ honor: z.ZodOptional<z.ZodArray<z.ZodString>>;
27
+ honor_year_min: z.ZodOptional<z.ZodNumber>;
28
+ honor_year_max: z.ZodOptional<z.ZodNumber>;
25
29
  attribute: z.ZodOptional<z.ZodArray<z.ZodString>>;
26
30
  attribute_all: z.ZodOptional<z.ZodArray<z.ZodString>>;
27
31
  attribute_not: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -45,10 +49,13 @@ export declare const searchSets: import("./types.js").ToolModule<z.ZodObject<{
45
49
  sport: z.ZodOptional<z.ZodString>;
46
50
  }, z.core.$strip>>;
47
51
  export declare const getSetDetail: import("./types.js").ToolModule<z.ZodObject<{
48
- set_uuid: z.ZodString;
52
+ set_uuid: z.ZodGUID;
49
53
  top_cards: z.ZodOptional<z.ZodNumber>;
54
+ sealed_history: z.ZodOptional<z.ZodString>;
55
+ history_start: z.ZodOptional<z.ZodString>;
50
56
  }, z.core.$strip>>;
51
57
  export declare const catalogTools: (import("./types.js").ToolModule<z.ZodObject<{
58
+ collapse_parallels: z.ZodOptional<z.ZodBoolean>;
52
59
  include_market: z.ZodOptional<z.ZodBoolean>;
53
60
  owned: z.ZodOptional<z.ZodBoolean>;
54
61
  facets: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -58,8 +65,10 @@ export declare const catalogTools: (import("./types.js").ToolModule<z.ZodObject<
58
65
  q: z.ZodOptional<z.ZodString>;
59
66
  subject: z.ZodOptional<z.ZodString>;
60
67
  subject_exact: z.ZodOptional<z.ZodBoolean>;
68
+ subject_all: z.ZodOptional<z.ZodArray<z.ZodString>>;
61
69
  card_number: z.ZodOptional<z.ZodString>;
62
70
  set_slug: z.ZodOptional<z.ZodArray<z.ZodString>>;
71
+ release: z.ZodOptional<z.ZodArray<z.ZodString>>;
63
72
  brand: z.ZodOptional<z.ZodArray<z.ZodString>>;
64
73
  subset: z.ZodOptional<z.ZodArray<z.ZodString>>;
65
74
  year: z.ZodOptional<z.ZodNumber>;
@@ -67,6 +76,10 @@ export declare const catalogTools: (import("./types.js").ToolModule<z.ZodObject<
67
76
  year_max: z.ZodOptional<z.ZodNumber>;
68
77
  team: z.ZodOptional<z.ZodArray<z.ZodString>>;
69
78
  league: z.ZodOptional<z.ZodArray<z.ZodString>>;
79
+ sport: z.ZodOptional<z.ZodArray<z.ZodString>>;
80
+ honor: z.ZodOptional<z.ZodArray<z.ZodString>>;
81
+ honor_year_min: z.ZodOptional<z.ZodNumber>;
82
+ honor_year_max: z.ZodOptional<z.ZodNumber>;
70
83
  attribute: z.ZodOptional<z.ZodArray<z.ZodString>>;
71
84
  attribute_all: z.ZodOptional<z.ZodArray<z.ZodString>>;
72
85
  attribute_not: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -88,6 +101,8 @@ export declare const catalogTools: (import("./types.js").ToolModule<z.ZodObject<
88
101
  year: z.ZodOptional<z.ZodNumber>;
89
102
  sport: z.ZodOptional<z.ZodString>;
90
103
  }, z.core.$strip>> | import("./types.js").ToolModule<z.ZodObject<{
91
- set_uuid: z.ZodString;
104
+ set_uuid: z.ZodGUID;
92
105
  top_cards: z.ZodOptional<z.ZodNumber>;
106
+ sealed_history: z.ZodOptional<z.ZodString>;
107
+ history_start: z.ZodOptional<z.ZodString>;
93
108
  }, z.core.$strip>>)[];
@@ -1,46 +1,44 @@
1
- /** Catalog tools: finding cards, products, and what's in a product. */
1
+ /** Catalog tools: finding cards and products, and what a product holds and costs. */
2
2
  import { z } from 'zod';
3
- import { join, money, pageHeader, text, facetLines } from '../format.js';
3
+ import { api } from '../client.js';
4
+ import { count, facetLines, join, money, pageHeader, plural, text } from '../format.js';
5
+ import { optionalIsoDate, uuid } from './args.js';
4
6
  import { DEFAULT_LIMIT, cardFilterShape, paginationShape } from './filters.js';
7
+ import { cardLine, fmv, players, run } from './lines.js';
5
8
  import { READ_ONLY, defineTool } from './types.js';
6
- /** One card on one line. UUID first — it is the only field the model must carry forward. */
7
- export function cardLine(card) {
8
- const players = (card.subjects ?? []).map((s) => join(' / ', s.name, s.team)).filter(Boolean).join(' + ');
9
- const attrs = (card.attributes ?? []).map((a) => a.name).filter(Boolean).join(', ');
10
- const fmv = card.market?.fair_market_value;
11
- return join(' | ', card.uuid, join(' ', card.season ?? card.year, card.brand, card.set_name), card.subset, `#${card.card_number ?? '?'}`, players || undefined, card.finish ?? 'base', card.print_run ? `/${card.print_run}` : undefined, attrs || undefined, fmv !== null && fmv !== undefined
12
- ? `FMV ${money(fmv)}${card.market?.grade_key ? ` (${card.market.grade_key})` : ''}`
13
- : undefined, card.owned_quantity ? `owned x${card.owned_quantity}` : undefined);
14
- }
15
9
  export const searchCards = defineTool({
16
10
  name: 'search_cards',
17
11
  title: 'Search the card catalog',
18
- description: 'Search slab\'s catalog of trading cards. This is the entry point for nearly everything else: ' +
19
- 'the `uuid` on each result is what get_card_pricing and add_copy take, and there is no way to ' +
20
- 'look a card up by UUID directly, so search first and carry the UUID forward.\n\n' +
21
- 'A parallel is its own card — the same slot in a different finish — so a player in one set can ' +
22
- 'return dozens of rows. Narrow with `finish`, `base_only`, or `numbered_max` rather than paging ' +
23
- 'through them.\n\n' +
24
- 'Set `include_market` to attach each card\'s current fair market value. That costs real query ' +
25
- 'time, so leave it off when you are only identifying a card. Set `facets` to get counts per ' +
26
- 'dimension instead of guessing what to filter on next — the cheapest way to explore a big result set.',
12
+ description: "Search slab's catalog of hockey cards, down to the exact parallel. This is the entry point for nearly " +
13
+ 'everything else: the `card:` uuid on each result is what get_card_pricing, get_rainbow, ' +
14
+ 'get_grading_desk and add_copy take, so search first and carry the uuid forward.\n\n' +
15
+ 'A parallel is its own card (the same slot in a different finish), so one player in one set can be ' +
16
+ 'dozens of rows. Set `collapse_parallels` to get one row per slot instead, then get_rainbow for a ' +
17
+ "slot's printings; or narrow with `finish`, `base_only` or `numbered_max`.\n\n" +
18
+ "Set `include_market` to attach each card's headline fair market value (slower; leave it off when you " +
19
+ 'are only identifying a card). Set `facets` for counts per dimension instead of guessing what to filter ' +
20
+ 'on next. `owned` filters to what the user has (true) or is missing (false).',
27
21
  inputSchema: z.object({
28
22
  ...cardFilterShape,
29
23
  ...paginationShape,
24
+ collapse_parallels: z.boolean().optional().describe('One row per card slot (a base card and all its parallels) instead of one per printing.'),
30
25
  include_market: z.boolean().optional().describe('Attach fair market value to each card. Off by default; slower.'),
31
- owned: z.boolean().optional().describe('true = only cards you own a copy of, false = only ones you do not.'),
26
+ owned: z.boolean().optional().describe("true = only cards the user owns a copy of, false = only ones they don't."),
32
27
  facets: z
33
28
  .array(z.string())
34
29
  .optional()
35
- .describe('Return per-value counts for these dimensions alongside the results. The dimensions each search accepts are served by get_vocab (`facet_dimensions`) — read them rather than assuming.'),
36
- sort: z.string().optional().describe('Sort key: year, card_number, numbered, subject, brand, or set. Call get_vocab for the exact grammar.'),
30
+ .describe('Per-value counts for these dimensions alongside the results. The accepted dimensions are `facet_dimensions` in get_vocab.'),
31
+ sort: z.string().optional().describe('Sort key, "-" prefix for descending (e.g. "-release"). The grammar is `card_sort_keys` in get_vocab.'),
37
32
  }),
38
33
  annotations: READ_ONLY,
39
34
  mutates: false,
40
35
  async handler(input, ctx) {
41
- const { limit = DEFAULT_LIMIT, offset = 0, ...rest } = input;
42
- const result = await ctx.client.request('POST', '/cards/search', {
43
- body: { ...rest, limit, offset },
36
+ const { limit = DEFAULT_LIMIT, offset = 0, owned, ...rest } = input;
37
+ // `owned` needs to know whose collection; "me" is the key's own collector.
38
+ const collector = owned === undefined ? undefined : ctx.collector();
39
+ const result = await ctx.client.request('POST', api `/cards/search`, {
40
+ body: { ...rest, owned, collector, limit, offset },
41
+ read: true,
44
42
  });
45
43
  const items = result.items ?? [];
46
44
  return text(pageHeader('cards', result.total, items.length, offset), '', ...items.map(cardLine), ...facetLines(result.facets));
@@ -49,15 +47,16 @@ export const searchCards = defineTool({
49
47
  export const searchSets = defineTool({
50
48
  name: 'search_sets',
51
49
  title: 'Search card products (sets)',
52
- description: 'Find a release — a product like "2025-26 Upper Deck SP Authentic". Returns each set\'s UUID ' +
53
- '(for get_set_detail) and slug (for the `set_slug` filter on search_cards), plus its card count ' +
54
- 'and current sealed hobby box price where one is known.\n\n' +
55
- 'Reach for this when the user names a product rather than a player, or when you need to scope a ' +
56
- 'card search to one release.',
50
+ description: 'Find a release, a product like "2025-26 Upper Deck Series 1". Each result has its `set:` uuid (for ' +
51
+ 'get_set_detail, the `release` filter, and log_break) and slug (for the `set_slug` filter on ' +
52
+ 'search_cards), its release date, how many printings it has and how many are priced, the sales slab ' +
53
+ "saw of its cards in the last 90 days, and its latest hobby box price.\n\n" +
54
+ 'Reach for this when the user names a product rather than a player, or to scope a card search to one ' +
55
+ 'release. Newest releases come first.',
57
56
  inputSchema: z.object({
58
57
  q: z.string().optional().describe('Set name, substring match (e.g. "sp authentic").'),
59
58
  brand: z.array(z.string()).optional().describe('Brand name(s), any-of.'),
60
- year: z.number().int().optional().describe('Season-start year — 2025 means 2025-26.'),
59
+ year: z.number().int().optional().describe('Season-start year: 2025 means 2025-26.'),
61
60
  sport: z.string().optional().describe('Sport name.'),
62
61
  ...paginationShape,
63
62
  }),
@@ -65,38 +64,80 @@ export const searchSets = defineTool({
65
64
  mutates: false,
66
65
  async handler(input, ctx) {
67
66
  const { limit = DEFAULT_LIMIT, offset = 0, ...rest } = input;
68
- const result = await ctx.client.request('POST', '/sets/search', {
67
+ const result = await ctx.client.request('POST', api `/sets/search`, {
69
68
  body: { ...rest, limit, offset },
69
+ read: true,
70
70
  });
71
71
  const items = result.items ?? [];
72
- return text(pageHeader('sets', result.total, items.length, offset), '', ...items.map((set) => join(' | ', set.uuid, set.name ?? set.slug, set.slug, set.card_count ? `${set.card_count} cards` : undefined, set.box_price ? `box ${money(set.box_price)}` : undefined)));
72
+ return text(pageHeader('sets', result.total, items.length, offset), '', ...items.map((set) => join(' | ', `set:${set.uuid}`, set.name ?? set.slug, set.slug, set.release_date ? `released ${set.release_date}` : undefined, set.card_count != null ? plural(set.card_count, 'printing') : undefined, set.priced_count != null ? `${count(set.priced_count)} priced` : undefined, set.sales_90d != null ? `${plural(set.sales_90d, 'sale')} seen in 90d` : undefined, set.box_price ? `hobby box ${money(set.box_price)}` : undefined)));
73
73
  },
74
74
  });
75
+ function sealedLine(product) {
76
+ const config = join(' · ', product.cards_per_pack ? `${product.cards_per_pack}/pack` : undefined, product.packs_per_box ? `${product.packs_per_box} packs/box` : undefined, product.boxes_per_case ? `${product.boxes_per_case} boxes/case` : undefined);
77
+ return join(' | ', `sealed:${product.uuid}`, product.format, product.price_median != null
78
+ ? `${money(product.price_median)}${product.sample_size != null ? ` (${plural(product.sample_size, 'sale')}${product.low_confidence ? ', thin' : ''}${product.stale ? ', stale' : ''})` : ''}`
79
+ : 'no price yet', product.as_of_date ? `as of ${product.as_of_date}` : undefined, product.msrp != null ? `MSRP ${money(product.msrp)}` : undefined, config || undefined);
80
+ }
75
81
  export const getSetDetail = defineTool({
76
82
  name: 'get_set_detail',
77
83
  title: 'Sealed prices and top cards for a set',
78
- description: 'Everything you need to reason about one product: its sealed SKUs (hobby box, case, blaster…) ' +
79
- 'with current market prices, and its most valuable single cards by fair market value.\n\n' +
80
- 'This is the pair of numbers behind "is this box worth ripping" — what the sealed product costs ' +
81
- 'against what the chase cards in it are worth. It is NOT a rip-EV calculation: it does not weight ' +
82
- 'those cards by pull odds, so do not present the top card\'s value as an expected return.\n\n' +
83
- '`set_uuid` comes from search_sets.',
84
+ description: 'One product at a glance: its sealed formats (hobby box, case, blaster...) with what each sells for ' +
85
+ 'and the configuration, and its most valuable single cards.\n\n' +
86
+ 'These are the two numbers behind "is this box worth opening": what the sealed product costs, against ' +
87
+ 'what the best cards in it are worth. It is NOT an expected value: the top cards are not weighted by ' +
88
+ 'pull odds, so never present a top card\'s value as what a box returns.\n\n' +
89
+ 'Pass `sealed_history` with a format (e.g. "hobby_box") to add that product\'s recent sales and its ' +
90
+ 'price series. A sealed price is a trailing-90-day median of real sales, like a card\'s: call ' +
91
+ 'explain_metrics before explaining it. `set_uuid` comes from search_sets.',
84
92
  inputSchema: z.object({
85
- set_uuid: z.string().describe('Set UUID, from search_sets.'),
93
+ set_uuid: uuid('Set UUID, from search_sets.'),
86
94
  top_cards: z.number().int().min(1).max(50).optional().describe('How many top cards to return. Default 10.'),
95
+ sealed_history: z.string().optional().describe('A sealed format to add recent sales and the price series for, e.g. "hobby_box". `sealed_formats` in get_vocab lists them.'),
96
+ history_start: optionalIsoDate('Start of the sealed price series (YYYY-MM-DD). Default: the API\'s.'),
87
97
  }),
88
98
  annotations: READ_ONLY,
89
99
  mutates: false,
90
100
  async handler(input, ctx) {
91
101
  const limit = input.top_cards ?? 10;
92
102
  const [sealed, top] = await Promise.all([
93
- ctx.client.request('GET', `/sets/${input.set_uuid}/sealed`),
94
- ctx.client.request('GET', `/sets/${input.set_uuid}/top-cards`, {
95
- query: { limit },
96
- }),
103
+ ctx.client.request('GET', api `/sets/${input.set_uuid}/sealed`),
104
+ ctx.client.request('GET', api `/sets/${input.set_uuid}/top-cards`, { query: { limit } }),
97
105
  ]);
98
- const sealedLines = (sealed ?? []).map((product) => join(' | ', String(product.uuid ?? ''), String(product.format ?? 'unknown format'), product.market_value != null ? `market ${money(product.market_value)}` : 'market —', product.msrp != null ? `MSRP ${money(product.msrp)}` : undefined));
99
- return text('Sealed products:', ...(sealedLines.length ? sealedLines : [' (none — this set has no sealed SKUs loaded)']), '', `Top ${limit} cards by fair market value:`, ...((top.items ?? []).map(cardLine) ?? []));
106
+ const lines = [
107
+ `${top.set_name ?? 'Set'}${top.season ? ` (${top.season})` : ''}`,
108
+ '',
109
+ 'Sealed products (trailing-90-day median of sales):',
110
+ ...(sealed.length ? sealed.map((p) => ` ${sealedLine(p)}`) : [' (no sealed products recorded for this set)']),
111
+ '',
112
+ `Top ${limit} cards by fair market value (${count(top.total_priced)} of its printings are priced):`,
113
+ ...((top.cards ?? []).map((card) => ' ' +
114
+ join(' | ', `card:${card.card_uuid}`, card.subset, `#${card.card_number}`, players(card.subjects), card.finish ?? 'base', run(card.print_run), fmv(card.market)))),
115
+ ];
116
+ if (input.sealed_history) {
117
+ const product = sealed.find((p) => p.format === input.sealed_history);
118
+ if (!product) {
119
+ lines.push('', `No "${input.sealed_history}" product for this set. It has: ${sealed.map((p) => p.format).join(', ') || 'none'}.`);
120
+ }
121
+ else {
122
+ const [market, history] = await Promise.all([
123
+ ctx.client.request('GET', api `/sealed/${product.uuid}/market`, { query: { comps_limit: 10 } }),
124
+ ctx.client.request('GET', api `/sealed/${product.uuid}/price-history`, {
125
+ query: { start: input.history_start, interval: 'weekly' },
126
+ }),
127
+ ]);
128
+ const comps = market.comps ?? [];
129
+ lines.push('', `${product.format}: recent sales (${comps.length} of ${market.total_comps ?? comps.length}):`);
130
+ lines.push(...comps.map((c) => ' ' + join(' | ', c.sold_date, money(c.sale_price), c.sale_type)));
131
+ if (market.plan_limit != null)
132
+ lines.push(` (your plan shows ${market.plan_limit} sales)`);
133
+ const points = history.points ?? [];
134
+ lines.push('', `${product.format}: weekly price series (${points.length} points; an appraisal, not a ticker):`);
135
+ lines.push(...points.map((p) => ` ${p.date} ${money(p.price_median)}${p.sample_size != null ? ` (${plural(p.sample_size, 'sale')})` : ''}`));
136
+ if (history.plan_history_start)
137
+ lines.push(` (your plan's history starts ${history.plan_history_start})`);
138
+ }
139
+ }
140
+ return text(...lines);
100
141
  },
101
142
  });
102
143
  export const catalogTools = [searchCards, searchSets, getSetDetail];
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Chases: checklists people build and follow (slab's custom sets), from a player's rookie cards to
3
+ * every Calder winner. The user's completion comes with each one.
4
+ */
5
+ import { z } from 'zod';
6
+ export declare const searchChases: import("./types.js").ToolModule<z.ZodObject<{
7
+ limit: z.ZodOptional<z.ZodNumber>;
8
+ offset: z.ZodOptional<z.ZodNumber>;
9
+ q: z.ZodOptional<z.ZodString>;
10
+ card_uuid: z.ZodOptional<z.ZodGUID>;
11
+ sort: z.ZodOptional<z.ZodString>;
12
+ }, z.core.$strip>>;
13
+ export declare const getChase: import("./types.js").ToolModule<z.ZodObject<{
14
+ limit: z.ZodOptional<z.ZodNumber>;
15
+ offset: z.ZodOptional<z.ZodNumber>;
16
+ chase_uuid: z.ZodGUID;
17
+ }, z.core.$strip>>;
18
+ export declare const chaseTools: (import("./types.js").ToolModule<z.ZodObject<{
19
+ limit: z.ZodOptional<z.ZodNumber>;
20
+ offset: z.ZodOptional<z.ZodNumber>;
21
+ q: z.ZodOptional<z.ZodString>;
22
+ card_uuid: z.ZodOptional<z.ZodGUID>;
23
+ sort: z.ZodOptional<z.ZodString>;
24
+ }, z.core.$strip>> | import("./types.js").ToolModule<z.ZodObject<{
25
+ limit: z.ZodOptional<z.ZodNumber>;
26
+ offset: z.ZodOptional<z.ZodNumber>;
27
+ chase_uuid: z.ZodGUID;
28
+ }, z.core.$strip>>)[];
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Chases: checklists people build and follow (slab's custom sets), from a player's rookie cards to
3
+ * every Calder winner. The user's completion comes with each one.
4
+ */
5
+ import { z } from 'zod';
6
+ import { api } from '../client.js';
7
+ import { join, pageHeader, plural, text } from '../format.js';
8
+ import { uuid, optionalUuid } from './args.js';
9
+ import { paginationShape } from './filters.js';
10
+ import { players, run } from './lines.js';
11
+ import { READ_ONLY, defineTool } from './types.js';
12
+ function chaseLine(set) {
13
+ return join(' | ', `chase:${set.uuid}`, set.name, set.creator_name ? `by ${set.creator_name}` : undefined, set.set_type, set.card_count != null ? plural(set.card_count, 'card') : undefined, set.subscriber_count != null ? `${plural(set.subscriber_count, 'follower')}` : undefined, set.is_subscribed ? 'you follow it' : undefined);
14
+ }
15
+ export const searchChases = defineTool({
16
+ name: 'search_chases',
17
+ title: 'Find chases (checklists collectors follow)',
18
+ description: 'Chases are checklists collectors build and follow on slab: a player\'s rookie cards, a team\'s numbered ' +
19
+ 'parallels, every Calder Trophy winner, a set\'s Young Guns. Search them by name, or by a card they ' +
20
+ 'contain, or leave everything empty for the most followed.\n\n' +
21
+ 'Each `chase:` uuid goes to get_chase, which lists its cards and how many the user owns.',
22
+ inputSchema: z.object({
23
+ q: z.string().optional().describe('Words in the chase\'s name.'),
24
+ card_uuid: optionalUuid('Only chases containing this card, from search_cards.'),
25
+ sort: z.string().optional().describe('subscribers (default), name, or newest; "-" prefix to reverse.'),
26
+ ...paginationShape,
27
+ }),
28
+ annotations: READ_ONLY,
29
+ mutates: false,
30
+ async handler(input, ctx) {
31
+ const { limit = 15, offset = 0, ...rest } = input;
32
+ const result = await ctx.client.request('POST', api `/custom-sets/search`, {
33
+ body: { ...rest, sort: rest.sort ?? '-subscribers', collector_uuid: ctx.collector(), limit, offset },
34
+ read: true,
35
+ });
36
+ const items = result.items ?? [];
37
+ return text(pageHeader('chases', result.total, items.length, offset), '', ...items.map(chaseLine));
38
+ },
39
+ });
40
+ export const getChase = defineTool({
41
+ name: 'get_chase',
42
+ title: "A chase's cards and the user's progress",
43
+ description: "One chase: what it is, its cards in order, and which the user owns, with their completion. A slot can " +
44
+ 'be one exact printing or "any card of this player" (a rule the user fills with any matching card), ' +
45
+ 'which the line says.\n\n' +
46
+ '`chase_uuid` comes from search_chases. Page through a long chase with limit and offset. `card:` uuids ' +
47
+ 'go to get_card_pricing and add_target.',
48
+ inputSchema: z.object({
49
+ chase_uuid: uuid('Chase UUID, from search_chases.'),
50
+ ...paginationShape,
51
+ }),
52
+ annotations: READ_ONLY,
53
+ mutates: false,
54
+ async handler(input, ctx) {
55
+ const limit = input.limit ?? 50;
56
+ const offset = input.offset ?? 0;
57
+ const chase = await ctx.client.request('GET', api `/custom-sets/${input.chase_uuid}`, {
58
+ query: { collector_uuid: ctx.collector(), limit, offset },
59
+ });
60
+ const cards = chase.cards ?? [];
61
+ const done = chase.completion;
62
+ return text(chaseLine(chase), chase.description ?? undefined, done ? `You own ${done.owned_cards} of ${done.total_cards} (${done.completion_pct}%).` : undefined, '', pageHeader('slots', chase.card_count ?? undefined, cards.length, offset), ...cards.map((entry) => {
63
+ const card = entry.card;
64
+ return (' ' +
65
+ join(' | ', entry.owned ? 'OWNED' : 'missing', card ? `card:${card.uuid}` : undefined, card
66
+ ? join(' · ', players(card.subjects), card.set_name, join(' ', card.subset, `#${card.card_number}`), card.finish ?? 'base', run(card.print_run))
67
+ : `any card of ${join(', ', entry.subject ?? undefined, entry.subject_team ?? undefined, entry.subject_year ? `${entry.subject_year}` : undefined, entry.subject_attribute ?? undefined)}`, card && entry.match_mode !== 'exact' ? entry.match_mode.replace(/_/g, ' ') : undefined));
68
+ }));
69
+ },
70
+ });
71
+ export const chaseTools = [searchChases, getChase];
72
+ //# sourceMappingURL=chases.js.map
@@ -1,9 +1,10 @@
1
- /** Read tools for the user's own collection. */
1
+ /** Read tools for the user's own collection: their copies, totals, sets, and want list. */
2
2
  import { z } from 'zod';
3
3
  export declare const searchCollection: import("./types.js").ToolModule<z.ZodObject<{
4
4
  status: z.ZodOptional<z.ZodArray<z.ZodString>>;
5
5
  graded: z.ZodOptional<z.ZodBoolean>;
6
6
  grading_company: z.ZodOptional<z.ZodArray<z.ZodString>>;
7
+ favorite: z.ZodOptional<z.ZodBoolean>;
7
8
  acquisition_type: z.ZodOptional<z.ZodArray<z.ZodString>>;
8
9
  acquired_after: z.ZodOptional<z.ZodString>;
9
10
  acquired_before: z.ZodOptional<z.ZodString>;
@@ -15,8 +16,10 @@ export declare const searchCollection: import("./types.js").ToolModule<z.ZodObje
15
16
  q: z.ZodOptional<z.ZodString>;
16
17
  subject: z.ZodOptional<z.ZodString>;
17
18
  subject_exact: z.ZodOptional<z.ZodBoolean>;
19
+ subject_all: z.ZodOptional<z.ZodArray<z.ZodString>>;
18
20
  card_number: z.ZodOptional<z.ZodString>;
19
21
  set_slug: z.ZodOptional<z.ZodArray<z.ZodString>>;
22
+ release: z.ZodOptional<z.ZodArray<z.ZodString>>;
20
23
  brand: z.ZodOptional<z.ZodArray<z.ZodString>>;
21
24
  subset: z.ZodOptional<z.ZodArray<z.ZodString>>;
22
25
  year: z.ZodOptional<z.ZodNumber>;
@@ -24,6 +27,10 @@ export declare const searchCollection: import("./types.js").ToolModule<z.ZodObje
24
27
  year_max: z.ZodOptional<z.ZodNumber>;
25
28
  team: z.ZodOptional<z.ZodArray<z.ZodString>>;
26
29
  league: z.ZodOptional<z.ZodArray<z.ZodString>>;
30
+ sport: z.ZodOptional<z.ZodArray<z.ZodString>>;
31
+ honor: z.ZodOptional<z.ZodArray<z.ZodString>>;
32
+ honor_year_min: z.ZodOptional<z.ZodNumber>;
33
+ honor_year_max: z.ZodOptional<z.ZodNumber>;
27
34
  attribute: z.ZodOptional<z.ZodArray<z.ZodString>>;
28
35
  attribute_all: z.ZodOptional<z.ZodArray<z.ZodString>>;
29
36
  attribute_not: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -37,29 +44,23 @@ export declare const searchCollection: import("./types.js").ToolModule<z.ZodObje
37
44
  numbered_max: z.ZodOptional<z.ZodNumber>;
38
45
  is_numbered: z.ZodOptional<z.ZodBoolean>;
39
46
  is_1of1: z.ZodOptional<z.ZodBoolean>;
40
- collector_uuid: z.ZodOptional<z.ZodString>;
47
+ collector_uuid: z.ZodOptional<z.ZodGUID>;
41
48
  }, z.core.$strip>>;
42
49
  export declare const getDashboard: import("./types.js").ToolModule<z.ZodObject<{
43
- collector_uuid: z.ZodOptional<z.ZodString>;
50
+ collector_uuid: z.ZodOptional<z.ZodGUID>;
44
51
  include_history: z.ZodOptional<z.ZodBoolean>;
45
52
  }, z.core.$strip>>;
46
- export declare const collectionTools: (import("./types.js").ToolModule<z.ZodObject<{
47
- status: z.ZodOptional<z.ZodArray<z.ZodString>>;
48
- graded: z.ZodOptional<z.ZodBoolean>;
49
- grading_company: z.ZodOptional<z.ZodArray<z.ZodString>>;
50
- acquisition_type: z.ZodOptional<z.ZodArray<z.ZodString>>;
51
- acquired_after: z.ZodOptional<z.ZodString>;
52
- acquired_before: z.ZodOptional<z.ZodString>;
53
- storage_location: z.ZodOptional<z.ZodString>;
54
- facets: z.ZodOptional<z.ZodArray<z.ZodString>>;
55
- sort: z.ZodOptional<z.ZodString>;
53
+ export declare const getCollectionSets: import("./types.js").ToolModule<z.ZodObject<{
54
+ group_sort: z.ZodOptional<z.ZodString>;
56
55
  limit: z.ZodOptional<z.ZodNumber>;
57
56
  offset: z.ZodOptional<z.ZodNumber>;
58
57
  q: z.ZodOptional<z.ZodString>;
59
58
  subject: z.ZodOptional<z.ZodString>;
60
59
  subject_exact: z.ZodOptional<z.ZodBoolean>;
60
+ subject_all: z.ZodOptional<z.ZodArray<z.ZodString>>;
61
61
  card_number: z.ZodOptional<z.ZodString>;
62
62
  set_slug: z.ZodOptional<z.ZodArray<z.ZodString>>;
63
+ release: z.ZodOptional<z.ZodArray<z.ZodString>>;
63
64
  brand: z.ZodOptional<z.ZodArray<z.ZodString>>;
64
65
  subset: z.ZodOptional<z.ZodArray<z.ZodString>>;
65
66
  year: z.ZodOptional<z.ZodNumber>;
@@ -67,6 +68,10 @@ export declare const collectionTools: (import("./types.js").ToolModule<z.ZodObje
67
68
  year_max: z.ZodOptional<z.ZodNumber>;
68
69
  team: z.ZodOptional<z.ZodArray<z.ZodString>>;
69
70
  league: z.ZodOptional<z.ZodArray<z.ZodString>>;
71
+ sport: z.ZodOptional<z.ZodArray<z.ZodString>>;
72
+ honor: z.ZodOptional<z.ZodArray<z.ZodString>>;
73
+ honor_year_min: z.ZodOptional<z.ZodNumber>;
74
+ honor_year_max: z.ZodOptional<z.ZodNumber>;
70
75
  attribute: z.ZodOptional<z.ZodArray<z.ZodString>>;
71
76
  attribute_all: z.ZodOptional<z.ZodArray<z.ZodString>>;
72
77
  attribute_not: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -80,8 +85,11 @@ export declare const collectionTools: (import("./types.js").ToolModule<z.ZodObje
80
85
  numbered_max: z.ZodOptional<z.ZodNumber>;
81
86
  is_numbered: z.ZodOptional<z.ZodBoolean>;
82
87
  is_1of1: z.ZodOptional<z.ZodBoolean>;
83
- collector_uuid: z.ZodOptional<z.ZodString>;
84
- }, z.core.$strip>> | import("./types.js").ToolModule<z.ZodObject<{
85
- collector_uuid: z.ZodOptional<z.ZodString>;
86
- include_history: z.ZodOptional<z.ZodBoolean>;
87
- }, z.core.$strip>>)[];
88
+ collector_uuid: z.ZodOptional<z.ZodGUID>;
89
+ }, z.core.$strip>>;
90
+ export declare const getTargets: import("./types.js").ToolModule<z.ZodObject<{
91
+ collector_uuid: z.ZodOptional<z.ZodGUID>;
92
+ }, z.core.$strip>>;
93
+ export declare const collectionTools: import("./types.js").ToolModule<z.ZodObject<{
94
+ collector_uuid: z.ZodOptional<z.ZodGUID>;
95
+ }, z.core.$strip>>[];