slab-mcp 0.2.1 → 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.
- package/README.md +140 -107
- package/dist/client.d.ts +34 -13
- package/dist/client.js +99 -59
- package/dist/config.d.ts +4 -2
- package/dist/config.js +27 -2
- package/dist/context.d.ts +8 -12
- package/dist/context.js +7 -29
- package/dist/errors.js +6 -2
- package/dist/format.d.ts +2 -0
- package/dist/format.js +7 -1
- package/dist/prompts/index.js +31 -6
- package/dist/resources/index.d.ts +2 -1
- package/dist/resources/index.js +4 -3
- package/dist/tools/args.d.ts +18 -0
- package/dist/tools/args.js +26 -0
- package/dist/tools/catalog.d.ts +21 -6
- package/dist/tools/catalog.js +88 -47
- package/dist/tools/chases.d.ts +28 -0
- package/dist/tools/chases.js +72 -0
- package/dist/tools/collection.d.ts +26 -18
- package/dist/tools/collection.js +113 -82
- package/dist/tools/community.d.ts +16 -3
- package/dist/tools/community.js +110 -50
- package/dist/tools/filters.d.ts +6 -0
- package/dist/tools/filters.js +6 -0
- package/dist/tools/index.js +2 -0
- package/dist/tools/lines.d.ts +20 -0
- package/dist/tools/lines.js +31 -0
- package/dist/tools/meta.js +5 -4
- package/dist/tools/pricing.d.ts +21 -16
- package/dist/tools/pricing.js +167 -63
- package/dist/tools/writes.d.ts +43 -47
- package/dist/tools/writes.js +65 -29
- package/dist/types.d.ts +48 -77
- package/dist/types.js +6 -6
- package/package.json +14 -5
- package/dist/client.js.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/context.js.map +0 -1
- package/dist/credentials.js.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/format.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/prompts/index.js.map +0 -1
- package/dist/resources/index.js.map +0 -1
- package/dist/tools/catalog.js.map +0 -1
- package/dist/tools/collection.js.map +0 -1
- package/dist/tools/community.js.map +0 -1
- package/dist/tools/filters.js.map +0 -1
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/meta.js.map +0 -1
- package/dist/tools/pricing.js.map +0 -1
- package/dist/tools/types.js.map +0 -1
- package/dist/tools/writes.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/version.js.map +0 -1
package/dist/tools/collection.js
CHANGED
|
@@ -1,130 +1,161 @@
|
|
|
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
|
-
import {
|
|
3
|
+
import { api } from '../client.js';
|
|
4
|
+
import { facetLines, glossaryLines, join, metric, money, pageHeader, plural, text } from '../format.js';
|
|
5
|
+
import { collectorArg } from './args.js';
|
|
4
6
|
import { DEFAULT_LIMIT, cardFilterShape, paginationShape } from './filters.js';
|
|
7
|
+
import { fmv, players, run } from './lines.js';
|
|
5
8
|
import { READ_ONLY, defineTool } from './types.js';
|
|
6
|
-
const collectorArg = z
|
|
7
|
-
.string()
|
|
8
|
-
.optional()
|
|
9
|
-
.describe('Collector UUID. Omit it — the server uses the collector this API key acts for. Only pass one for a multi-collector account.');
|
|
10
9
|
function copyLine(copy) {
|
|
11
10
|
const card = copy.card;
|
|
12
|
-
const players = (card?.subjects ?? []).map((s) => s.name).filter(Boolean).join(' + ');
|
|
13
11
|
const grade = copy.grading_company ? `${copy.grading_company} ${copy.grade ?? ''}`.trim() : 'raw';
|
|
14
|
-
|
|
15
|
-
return join(' | ', copy.uuid, join(' ', card?.season ?? card?.year, card?.brand, card?.set_name), card?.subset, `#${card?.card_number ?? '?'}`, players || undefined, card?.finish ?? 'base', copy.serial_number && card?.print_run ? `${copy.serial_number}/${card.print_run}` : card?.print_run ? `/${card.print_run}` : undefined, grade, copy.quantity && copy.quantity > 1 ? `x${copy.quantity}` : undefined, `cost ${money(copy.cost_basis)}`, `FMV ${money(fmv)}`, copy.status && copy.status !== 'in_collection' ? copy.status : undefined, copy.storage_location ?? undefined);
|
|
12
|
+
return join(' | ', `copy:${copy.uuid}`, `card:${copy.card_uuid}`, card?.set_name ?? card?.season ?? undefined, card?.subset, card ? `#${card.card_number}` : undefined, players(card?.subjects), card?.finish ?? 'base', copy.serial_number && card?.print_run ? `${copy.serial_number}/${card.print_run}` : run(card?.print_run), grade, copy.quantity > 1 ? `x${copy.quantity}` : undefined, `cost ${money(copy.cost_basis)}`, copy.market?.fair_market_value ? `FMV ${money(copy.market.fair_market_value)}` : 'no value yet', copy.status !== 'in_collection' ? copy.status : undefined, copy.status === 'sold' && copy.sale_price ? `sold ${money(copy.sale_price)}` : undefined, copy.is_favorite ? 'favorite' : undefined, copy.storage_location ?? undefined);
|
|
16
13
|
}
|
|
17
14
|
export const searchCollection = defineTool({
|
|
18
15
|
name: 'search_collection',
|
|
19
16
|
title: "Search the user's collection",
|
|
20
|
-
description: 'Search the physical copies the user owns. Takes the
|
|
21
|
-
'
|
|
22
|
-
'across the
|
|
17
|
+
description: 'Search the physical copies the user owns. Takes the card filter grammar from search_cards plus ' +
|
|
18
|
+
'copy-level filters (grade, status, favorites, acquisition, storage), and ends with a financial ' +
|
|
19
|
+
'summary across every match, not just the page shown.\n\n' +
|
|
23
20
|
'Each row is one physical copy, so the same card owned twice is two rows with two cost bases. ' +
|
|
24
|
-
'The `
|
|
25
|
-
'
|
|
26
|
-
'
|
|
27
|
-
'
|
|
28
|
-
|
|
29
|
-
'The result ends with a financial summary across every match, not just the page shown. Call ' +
|
|
30
|
-
"explain_metrics and use slab's own wording for those figures rather than paraphrasing them.",
|
|
21
|
+
'The `copy:` uuid is what update_copy and remove_copy take; the `card:` uuid is the catalog card, for ' +
|
|
22
|
+
'get_card_pricing and get_rainbow.\n\n' +
|
|
23
|
+
'`cost_basis` is what the copy cost all-in (purchase plus grading, shipping and other logged costs); ' +
|
|
24
|
+
'FMV is the current appraisal. The gap is paper gain, not money made: nothing is realised until a copy ' +
|
|
25
|
+
"is sold. The summary embeds slab's glossary entries; use that wording, or call explain_metrics.",
|
|
31
26
|
inputSchema: z.object({
|
|
32
27
|
collector_uuid: collectorArg,
|
|
33
28
|
...cardFilterShape,
|
|
34
29
|
...paginationShape,
|
|
35
|
-
status: z.array(z.string()).optional().describe('Copy status, any-of
|
|
30
|
+
status: z.array(z.string()).optional().describe('Copy status, any-of. `copy_statuses` in get_vocab lists them.'),
|
|
36
31
|
graded: z.boolean().optional().describe('true = only professionally graded copies, false = only raw.'),
|
|
37
|
-
grading_company: z.array(z.string()).optional().describe('Grading company, any-of
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
grading_company: z.array(z.string()).optional().describe('Grading company, any-of. `grading_companies` in get_vocab lists them.'),
|
|
33
|
+
favorite: z.boolean().optional().describe('true = only the copies the user starred as favorites.'),
|
|
34
|
+
acquisition_type: z.array(z.string()).optional().describe('How it was acquired, any-of. `acquisition_types` in get_vocab lists them.'),
|
|
35
|
+
acquired_after: z.string().optional().describe('ISO date (YYYY-MM-DD): copies acquired on or after it.'),
|
|
36
|
+
acquired_before: z.string().optional().describe('ISO date (YYYY-MM-DD): copies acquired on or before it.'),
|
|
41
37
|
storage_location: z.string().optional().describe('Storage location, substring match.'),
|
|
42
38
|
facets: z
|
|
43
39
|
.array(z.string())
|
|
44
40
|
.optional()
|
|
45
|
-
.describe('
|
|
46
|
-
sort: z.string().optional().describe('Sort key.
|
|
41
|
+
.describe('Per-value counts for these dimensions. `facet_dimensions.collection` in get_vocab lists them.'),
|
|
42
|
+
sort: z.string().optional().describe('Sort key, "-" prefix for descending. `collection_sort_keys` in get_vocab is the grammar.'),
|
|
47
43
|
}),
|
|
48
44
|
annotations: READ_ONLY,
|
|
49
45
|
mutates: false,
|
|
50
46
|
async handler(input, ctx) {
|
|
51
47
|
const { collector_uuid, limit = DEFAULT_LIMIT, offset = 0, ...rest } = input;
|
|
52
|
-
const
|
|
53
|
-
|
|
48
|
+
const result = await ctx.client.request('POST', api `/collectors/${ctx.collector(collector_uuid)}/collection/search`, {
|
|
49
|
+
body: { ...rest, limit, offset },
|
|
50
|
+
read: true,
|
|
51
|
+
});
|
|
54
52
|
const items = result.items ?? [];
|
|
55
53
|
const summary = result.summary
|
|
56
|
-
? [
|
|
57
|
-
'',
|
|
58
|
-
'Financial summary across all matches:',
|
|
59
|
-
...Object.entries(result.summary).map(([k, v]) => ` ${k}: ${metric(k, v)}`),
|
|
60
|
-
'',
|
|
61
|
-
'Call explain_metrics before reporting any of these figures to the user.',
|
|
62
|
-
]
|
|
54
|
+
? ['', 'Financial summary across all matches:', ...Object.entries(result.summary).map(([k, v]) => ` ${k}: ${metric(k, v)}`)]
|
|
63
55
|
: [];
|
|
64
|
-
return text(pageHeader('copies', result.total, items.length, offset), '', ...items.map(copyLine), ...summary, ...facetLines(result.facets));
|
|
56
|
+
return text(pageHeader('copies', result.total, items.length, offset), '', ...items.map(copyLine), ...summary, ...glossaryLines(result.glossary), ...facetLines(result.facets));
|
|
65
57
|
},
|
|
66
58
|
});
|
|
59
|
+
function highlightLine(row) {
|
|
60
|
+
return (' ' +
|
|
61
|
+
join(' | ', `copy:${row.uuid}`, `card:${row.card_uuid}`, players(row.subjects), row.set_name, join(' ', row.subset, `#${row.card_number}`), row.finish ?? 'base', run(row.print_run), row.grade_key, row.fair_market_value ? money(row.fair_market_value) : undefined, row.stale ? 'stale' : undefined));
|
|
62
|
+
}
|
|
67
63
|
export const getDashboard = defineTool({
|
|
68
64
|
name: 'get_dashboard',
|
|
69
|
-
title: 'Collection
|
|
70
|
-
description: "The headline numbers for the user's whole collection:
|
|
71
|
-
'value,
|
|
72
|
-
'
|
|
73
|
-
'
|
|
74
|
-
'
|
|
75
|
-
'
|
|
76
|
-
'
|
|
77
|
-
"Every
|
|
78
|
-
'
|
|
79
|
-
'
|
|
80
|
-
'narrower than their names suggest, and a plausible-sounding paraphrase of them is wrong.',
|
|
65
|
+
title: 'Collection totals, highlights and value over time',
|
|
66
|
+
description: "The headline numbers for the user's whole collection: how many cards, players, teams and sets, its " +
|
|
67
|
+
'make-up (base, parallels, rookies, autos, numbered...), cost basis, current value, paper gain, and ' +
|
|
68
|
+
'its most valuable, rarest and hardest-to-pull cards.\n\n' +
|
|
69
|
+
'Optionally the value series. That series is AS-OF: each point values only the copies owned on that ' +
|
|
70
|
+
'date, so it steps UP when the user buys a card. Differencing two points mixes purchases with price ' +
|
|
71
|
+
'movement and is not a return; for how the collection\'s value moved, use `portfolio_change_7d`, which ' +
|
|
72
|
+
'holds the cards constant.\n\n' +
|
|
73
|
+
"Every figure has a definition in slab's glossary and the response embeds the ones it needs. Use that " +
|
|
74
|
+
'wording, or call explain_metrics: `priced_coverage`, `portfolio_roi` and `portfolio_change_7d` each ' +
|
|
75
|
+
'mean something narrower than their names suggest.',
|
|
81
76
|
inputSchema: z.object({
|
|
82
77
|
collector_uuid: collectorArg,
|
|
83
|
-
include_history: z.boolean().optional().describe('Include the as-of
|
|
78
|
+
include_history: z.boolean().optional().describe('Include the as-of value series. Default false.'),
|
|
84
79
|
}),
|
|
85
80
|
annotations: READ_ONLY,
|
|
86
81
|
mutates: false,
|
|
87
82
|
async handler(input, ctx) {
|
|
88
|
-
const collector =
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
83
|
+
const collector = ctx.collector(input.collector_uuid);
|
|
84
|
+
const [dash, history] = await Promise.all([
|
|
85
|
+
ctx.client.request('GET', api `/collectors/${collector}/dashboard`),
|
|
86
|
+
input.include_history
|
|
87
|
+
? ctx.client.request('GET', api `/collectors/${collector}/portfolio/history`, { query: { interval: 'weekly' } })
|
|
88
|
+
: undefined,
|
|
89
|
+
]);
|
|
90
|
+
const lines = ['Collection:'];
|
|
91
|
+
for (const [key, value] of Object.entries(dash)) {
|
|
92
|
+
if (value === null || value === undefined || typeof value === 'object' || key === 'collector')
|
|
93
93
|
continue;
|
|
94
94
|
lines.push(` ${key}: ${metric(key, value)}`);
|
|
95
95
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
// Prefixing it here is what stops that.
|
|
104
|
-
for (const board of ['most_valuable', 'rarest', 'top_sets']) {
|
|
105
|
-
const rows = dashboard[board];
|
|
106
|
-
if (!Array.isArray(rows) || !rows.length)
|
|
107
|
-
continue;
|
|
108
|
-
lines.push('', `${board}:`);
|
|
109
|
-
for (const row of rows) {
|
|
110
|
-
lines.push(' ' +
|
|
111
|
-
join(' | ', typeof row.uuid === 'string' ? `copy:${row.uuid}` : undefined, Array.isArray(row.subjects) ? row.subjects.join(' + ') : row.label, row.set_name, row.card_number ? `#${row.card_number}` : undefined, row.finish ?? undefined, row.print_run ? `/${row.print_run}` : undefined, row.grade_key, row.fair_market_value != null ? money(row.fair_market_value) : undefined, row.count != null ? `${row.count} cards` : undefined));
|
|
112
|
-
}
|
|
113
|
-
if (board !== 'top_sets') {
|
|
114
|
-
lines.push(' (these are COPY uuids — pass them to update_copy/remove_copy. For pricing, find the ' +
|
|
115
|
-
'card with search_cards first; a copy uuid will 404 on get_card_pricing.)');
|
|
116
|
-
}
|
|
96
|
+
if (dash.makeup?.length)
|
|
97
|
+
lines.push('', 'Make-up:', ...dash.makeup.map((m) => ` ${m.label}: ${m.count}`));
|
|
98
|
+
if (dash.top_sets?.length)
|
|
99
|
+
lines.push('', 'Top sets (copies):', ...dash.top_sets.map((m) => ` ${m.label}: ${m.count}`));
|
|
100
|
+
for (const [board, rows] of [['most_valuable', dash.most_valuable], ['rarest', dash.rarest], ['hardest_pulls', dash.hardest_pulls]]) {
|
|
101
|
+
if (rows?.length)
|
|
102
|
+
lines.push('', `${board}:`, ...rows.map(highlightLine));
|
|
117
103
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
if (input.include_history) {
|
|
121
|
-
const history = await ctx.client.request('GET', `/collectors/${collector}/portfolio/history`);
|
|
104
|
+
lines.push(...glossaryLines(dash.glossary));
|
|
105
|
+
if (history) {
|
|
122
106
|
const points = history.points ?? [];
|
|
123
|
-
lines.push('', `
|
|
124
|
-
lines.push(...points.map((p) => ` ${p.date} ${money(p.
|
|
107
|
+
lines.push('', `Value, as of each date (${points.length} points; steps up on purchases, not a return series):`);
|
|
108
|
+
lines.push(...points.map((p) => ` ${p.date} ${money(p.portfolio_value)} cost ${money(p.cost_basis)} (${p.total_copies} copies, ${p.priced_copies} priced)`));
|
|
125
109
|
}
|
|
126
110
|
return text(...lines);
|
|
127
111
|
},
|
|
128
112
|
});
|
|
129
|
-
export const
|
|
113
|
+
export const getCollectionSets = defineTool({
|
|
114
|
+
name: 'get_collection_sets',
|
|
115
|
+
title: "The user's collection by set",
|
|
116
|
+
description: "The user's collection grouped by product: for each set, how many copies they hold, how many distinct " +
|
|
117
|
+
'printings, how many are priced, and their total value. Answers "which sets do I collect", "where is ' +
|
|
118
|
+
'my value", and, with `set_slug` and a search_cards `owned: false` follow-up, "what am I missing".\n\n' +
|
|
119
|
+
'Takes the same filters as search_collection (narrow to rookies, a player, a team...). Values are ' +
|
|
120
|
+
'appraisals summed over priced copies; an unpriced copy adds nothing rather than zero. Call ' +
|
|
121
|
+
'explain_metrics before explaining a total.',
|
|
122
|
+
inputSchema: z.object({
|
|
123
|
+
collector_uuid: collectorArg,
|
|
124
|
+
...cardFilterShape,
|
|
125
|
+
...paginationShape,
|
|
126
|
+
group_sort: z.string().optional().describe('Order of the sets, e.g. "-total_value" or "-copy_count". Default: the API\'s.'),
|
|
127
|
+
}),
|
|
128
|
+
annotations: READ_ONLY,
|
|
129
|
+
mutates: false,
|
|
130
|
+
async handler(input, ctx) {
|
|
131
|
+
const { collector_uuid, limit = DEFAULT_LIMIT, offset = 0, ...rest } = input;
|
|
132
|
+
const result = await ctx.client.request('POST', api `/collectors/${ctx.collector(collector_uuid)}/collection/sets`, {
|
|
133
|
+
body: { ...rest, limit, offset },
|
|
134
|
+
read: true,
|
|
135
|
+
});
|
|
136
|
+
const items = result.items ?? [];
|
|
137
|
+
return text(pageHeader('sets', result.total, items.length, offset), '', ...items.map((set) => join(' | ', `set:${set.set_uuid}`, set.name, set.set_slug, plural(set.copy_count, 'copy', 'copies'), plural(set.card_count, 'printing'), set.priced_count != null ? `${set.priced_count} priced` : undefined, set.total_value ? `value ${money(set.total_value)}` : 'no value yet')));
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
export const getTargets = defineTool({
|
|
141
|
+
name: 'get_targets',
|
|
142
|
+
title: "The user's want list",
|
|
143
|
+
description: "The cards the user is hunting for (their targets, slab's want list): each printing, the grade they " +
|
|
144
|
+
'want if they named one, its current value, and whether they already own a copy. A target stays on ' +
|
|
145
|
+
'the list after it is bought, so "owned" rows are ones they found.\n\n' +
|
|
146
|
+
'Use it for "what am I looking for", "what would my want list cost", or to check a card against the ' +
|
|
147
|
+
'list. `card:` uuids go to get_card_pricing; add_target and remove_target change the list when writes ' +
|
|
148
|
+
'are on. Values are appraisals: call explain_metrics before explaining one.',
|
|
149
|
+
inputSchema: z.object({
|
|
150
|
+
collector_uuid: collectorArg,
|
|
151
|
+
}),
|
|
152
|
+
annotations: READ_ONLY,
|
|
153
|
+
mutates: false,
|
|
154
|
+
async handler(input, ctx) {
|
|
155
|
+
const list = await ctx.client.request('GET', api `/collectors/${ctx.collector(input.collector_uuid)}/targets`);
|
|
156
|
+
const items = list.items ?? [];
|
|
157
|
+
return text(plural(list.total, 'target'), '', ...items.map((t) => join(' | ', `target:${t.uuid}`, `card:${t.card_uuid}`, t.card ? join(' · ', players(t.card.subjects), t.card.set_name, join(' ', t.card.subset, `#${t.card.card_number}`), t.card.finish ?? 'base') : undefined, t.grade_key ? `wants ${t.grade_key}` : 'any grade', fmv(t.market) ?? 'no value yet', t.owned_quantity ? `owns ${t.owned_quantity}` : undefined, `added ${t.added_on}`)));
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
export const collectionTools = [searchCollection, getDashboard, getCollectionSets, getTargets];
|
|
130
161
|
//# sourceMappingURL=collection.js.map
|
|
@@ -1,10 +1,23 @@
|
|
|
1
|
-
/** The public
|
|
1
|
+
/** The public picture across all of slab: the community board, its featured cards, the market index. */
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
export declare const getCommunity: import("./types.js").ToolModule<z.ZodObject<{
|
|
4
4
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
5
5
|
boards: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
6
6
|
}, z.core.$strip>>;
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const getMarketIndex: import("./types.js").ToolModule<z.ZodObject<{
|
|
8
|
+
universe: z.ZodOptional<z.ZodEnum<{
|
|
9
|
+
raw_cards: "raw_cards";
|
|
10
|
+
hobby_boxes: "hobby_boxes";
|
|
11
|
+
}>>;
|
|
12
|
+
months: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
}, z.core.$strip>>;
|
|
14
|
+
export declare const communityTools: (import("./types.js").ToolModule<z.ZodObject<{
|
|
8
15
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
9
16
|
boards: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
10
|
-
}, z.core.$strip>>
|
|
17
|
+
}, z.core.$strip>> | import("./types.js").ToolModule<z.ZodObject<{
|
|
18
|
+
universe: z.ZodOptional<z.ZodEnum<{
|
|
19
|
+
raw_cards: "raw_cards";
|
|
20
|
+
hobby_boxes: "hobby_boxes";
|
|
21
|
+
}>>;
|
|
22
|
+
months: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
}, z.core.$strip>>)[];
|
package/dist/tools/community.js
CHANGED
|
@@ -1,74 +1,134 @@
|
|
|
1
|
-
/** The public
|
|
1
|
+
/** The public picture across all of slab: the community board, its featured cards, the market index. */
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import {
|
|
3
|
+
import { api } from '../client.js';
|
|
4
|
+
import { count, glossaryLines, join, money, plural, text } from '../format.js';
|
|
5
|
+
import { fmv, players, run } from './lines.js';
|
|
4
6
|
import { READ_ONLY, defineTool } from './types.js';
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
function
|
|
13
|
-
const card =
|
|
14
|
-
const
|
|
7
|
+
/** A community card: uuid, players, set, subset #, finish, run. */
|
|
8
|
+
function cardText(card) {
|
|
9
|
+
if (!card)
|
|
10
|
+
return undefined;
|
|
11
|
+
return join(' | ', card.uuid ? `card:${card.uuid}` : undefined, players(card.subjects), card.set_name ?? card.season ?? undefined, join(' ', card.subset, card.card_number ? `#${card.card_number}` : undefined), card.finish ?? 'base', run(card.print_run));
|
|
12
|
+
}
|
|
13
|
+
/** One row of any board. Boards differ in shape; each piece shows when it's there. */
|
|
14
|
+
function boardLine(row) {
|
|
15
|
+
const card = row.card;
|
|
16
|
+
const observed = row.observed;
|
|
15
17
|
return (' ' +
|
|
16
|
-
join(' | ', typeof
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
join(' | ', cardText(card), typeof row.name === 'string' ? row.name : undefined, fmv(row.market),
|
|
19
|
+
// Hottest players: real sales in a window (the comps lane), so they ARE market activity, but
|
|
20
|
+
// only the sales slab saw: "seen", never "volume".
|
|
21
|
+
observed ? `${plural(observed.sales, 'sale')} seen in ${observed.window_days}d, ${money(observed.dollars)}` : undefined, row.trend ? `price trend ${row.trend}${row.price_trend_pct != null ? ` (${row.price_trend_pct}%)` : ''}` : undefined, typeof row.collector_count === 'number' ? plural(row.collector_count, 'collector') : undefined, typeof row.copy_count === 'number' ? plural(row.copy_count, 'copy', 'copies') : undefined, typeof row.count === 'number' ? (card?.uuid ? plural(row.count, 'reaction') : count(row.count)) : undefined, typeof row.card_count === 'number' ? plural(row.card_count, 'card') : undefined, typeof row.subscriber_count === 'number' ? `${plural(row.subscriber_count, 'follower')}` : undefined));
|
|
22
|
+
}
|
|
23
|
+
/** A featured card (card of the day, favorite, most wanted): the card, then who collects and wants it. */
|
|
24
|
+
function featuredLines(label, f) {
|
|
25
|
+
return [
|
|
26
|
+
'',
|
|
27
|
+
`${label}:`,
|
|
28
|
+
` ${cardText(f.card)}`,
|
|
29
|
+
' ' + join(' | ', fmv(f.card.market), `${plural(f.parallels, 'printing')} in its rainbow`, `owned by ${plural(f.collectors, 'collector')}`, `wanted by ${f.wanted_by}`, typeof f.net_count === 'number' ? `net reactions ${f.net_count}` : undefined, typeof f.featured_on === 'string' ? `featured ${f.featured_on}` : undefined),
|
|
30
|
+
];
|
|
21
31
|
}
|
|
32
|
+
const FEATURED = ['card_of_the_day', 'favorite', 'most_wanted'];
|
|
22
33
|
export const getCommunity = defineTool({
|
|
23
34
|
name: 'get_community',
|
|
24
|
-
title: 'Community
|
|
25
|
-
description: 'The public picture across all of slab in one call: catalog totals,
|
|
26
|
-
'
|
|
27
|
-
'
|
|
28
|
-
'
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"The response embeds slab's glossary entry for each
|
|
33
|
-
'
|
|
34
|
-
'
|
|
35
|
-
'sales in a window, which is not the same thing as an appraisal moving.',
|
|
35
|
+
title: 'Community boards and featured cards',
|
|
36
|
+
description: 'The public picture across all of slab in one call: catalog totals, recent activity, the card of the ' +
|
|
37
|
+
'day, the community favorite (most net-positive reactions) and the most wanted card (on the most ' +
|
|
38
|
+
'want lists), and the boards: most valuable raw and graded, most collected cards and players, hottest ' +
|
|
39
|
+
'players, rarest owned, most reacted, popular chases, and the collector records.\n\n' +
|
|
40
|
+
'Reach for this for "what is hot right now", "what do collectors want", or to show a user where their ' +
|
|
41
|
+
"collection sits against everyone else's. Collectors appear only by their random slab name and a " +
|
|
42
|
+
'count; never describe a person behind one.\n\n' +
|
|
43
|
+
"The response embeds slab's glossary entry for each board: use that wording rather than inferring a " +
|
|
44
|
+
'board from its name, and call explain_metrics for anything else. "Hottest" is counted from real sales ' +
|
|
45
|
+
'in a window (not an appraisal moving), and those are the sales slab saw: say "seen", never "volume".',
|
|
36
46
|
inputSchema: z.object({
|
|
37
|
-
limit: z.number().int().min(1).max(50).optional().describe('Rows per
|
|
47
|
+
limit: z.number().int().min(1).max(50).optional().describe('Rows per board. Default 10.'),
|
|
38
48
|
boards: z
|
|
39
49
|
.array(z.string())
|
|
40
50
|
.optional()
|
|
41
|
-
.describe('Only these boards, e.g. ["hottest_players","
|
|
51
|
+
.describe('Only these boards, e.g. ["hottest_players", "most_wanted"]. Omit for everything; the full payload is large. Includes "stats", "ticker", "card_of_the_day", "favorite", "most_wanted".'),
|
|
42
52
|
}),
|
|
43
53
|
annotations: READ_ONLY,
|
|
44
54
|
mutates: false,
|
|
45
55
|
async handler(input, ctx) {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
56
|
+
const wants = (name) => !input.boards?.length || input.boards.includes(name);
|
|
57
|
+
const [board, cotd, favorite, mostWanted] = await Promise.all([
|
|
58
|
+
ctx.client.request('GET', api `/community`, { query: { limit: input.limit ?? 10 } }),
|
|
59
|
+
// A featured slot can be empty (404 until there's one); that's "none today", not an error.
|
|
60
|
+
wants('card_of_the_day') ? ctx.client.request('GET', api `/community/card-of-the-day`).catch(() => undefined) : undefined,
|
|
61
|
+
wants('favorite') ? ctx.client.request('GET', api `/community/favorite`).catch(() => undefined) : undefined,
|
|
62
|
+
wants('most_wanted') ? ctx.client.request('GET', api `/community/most-wanted`).catch(() => undefined) : undefined,
|
|
63
|
+
]);
|
|
49
64
|
const lines = [];
|
|
50
|
-
if (board.stats && (
|
|
51
|
-
lines.push('Catalog
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
lines.push(...board.ticker.map((entry) => ` ${entry}`));
|
|
65
|
+
if (board.stats && wants('stats')) {
|
|
66
|
+
lines.push('Catalog:');
|
|
67
|
+
// Every catalog figure is a count.
|
|
68
|
+
for (const [key, value] of Object.entries(board.stats)) {
|
|
69
|
+
if (typeof value === 'number')
|
|
70
|
+
lines.push(` ${key}: ${count(value)}`);
|
|
71
|
+
}
|
|
58
72
|
}
|
|
59
|
-
|
|
73
|
+
if (board.ticker?.length && wants('ticker'))
|
|
74
|
+
lines.push('', 'Recent activity:', ...board.ticker.map((item) => ` ${item.text}`));
|
|
75
|
+
if (cotd)
|
|
76
|
+
lines.push(...featuredLines('Card of the day', cotd));
|
|
77
|
+
if (favorite)
|
|
78
|
+
lines.push(...featuredLines('Community favorite', favorite));
|
|
79
|
+
if (mostWanted)
|
|
80
|
+
lines.push(...featuredLines('Most wanted', mostWanted));
|
|
81
|
+
const skip = new Set(['stats', 'ticker', 'glossary', ...FEATURED]);
|
|
60
82
|
for (const [name, value] of Object.entries(board)) {
|
|
61
|
-
if (skip.has(name) || !
|
|
83
|
+
if (skip.has(name) || !wants(name) || value === null || value === undefined)
|
|
62
84
|
continue;
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
85
|
+
if (Array.isArray(value)) {
|
|
86
|
+
if (!value.length)
|
|
87
|
+
continue;
|
|
88
|
+
lines.push('', `${name}:`);
|
|
89
|
+
for (const row of value) {
|
|
90
|
+
// most_reacted is a board per reaction, each with its own cards.
|
|
91
|
+
if (Array.isArray(row.cards)) {
|
|
92
|
+
lines.push(` ${String(row.label ?? row.reaction)}:`, ...row.cards.map((r) => ` ${boardLine(r)}`));
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
lines.push(boardLine(row));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else if (typeof value === 'object') {
|
|
100
|
+
// A record: a card and its count (top_reacted), or a collector's slab name and their count.
|
|
101
|
+
const record = value;
|
|
102
|
+
lines.push('', `${name}:${boardLine(record).replace(/^ +/, ' ')}${typeof record.player === 'string' || typeof record.team === 'string' || typeof record.set_name === 'string'
|
|
103
|
+
? ` | ${String(record.player ?? record.team ?? record.set_name)}` : ''}`);
|
|
104
|
+
}
|
|
67
105
|
}
|
|
68
|
-
// slab ships the definitions with the data — render them, don't drop them.
|
|
69
106
|
lines.push(...glossaryLines(board.glossary));
|
|
70
107
|
return text(...lines);
|
|
71
108
|
},
|
|
72
109
|
});
|
|
73
|
-
export const
|
|
110
|
+
export const getMarketIndex = defineTool({
|
|
111
|
+
name: 'get_market_index',
|
|
112
|
+
title: "The hockey card market's monthly readings",
|
|
113
|
+
description: "slab's market index: for each month, how much hockey cards moved beyond what their age alone predicts. " +
|
|
114
|
+
'Cards lose or gain value on a typical schedule as they age (the lifecycle benchmark); a reading of 0 ' +
|
|
115
|
+
'means aging explains the month, positive means the market paid more than age predicts, negative less. ' +
|
|
116
|
+
'Each reading rests on matched pairs of real sales, and says how many.\n\n' +
|
|
117
|
+
'Reach for this for "how is the hockey card market doing" or "is the market up". `universe` picks ' +
|
|
118
|
+
'raw cards (default) or sealed hobby boxes. These are slab\'s own measure with a precise meaning: the ' +
|
|
119
|
+
'response embeds its glossary entries; quote them, or call explain_metrics, rather than describing the ' +
|
|
120
|
+
'readings as prices rising.',
|
|
121
|
+
inputSchema: z.object({
|
|
122
|
+
universe: z.enum(['raw_cards', 'hobby_boxes']).optional().describe('raw_cards (ungraded singles, the default) or hobby_boxes.'),
|
|
123
|
+
months: z.number().int().min(1).max(60).optional().describe('How many recent months to show. Default 12.'),
|
|
124
|
+
}),
|
|
125
|
+
annotations: READ_ONLY,
|
|
126
|
+
mutates: false,
|
|
127
|
+
async handler(input, ctx) {
|
|
128
|
+
const series = await ctx.client.request('GET', api `/market/readings`, { query: { universe: input.universe } });
|
|
129
|
+
const readings = (series.readings ?? []).slice(-(input.months ?? 12));
|
|
130
|
+
return text(`Market readings, ${series.universe ?? input.universe ?? 'raw_cards'} (move beyond the age benchmark, by month):`, ...readings.map((r) => ` ${r.month.slice(0, 7)} ${r.move_vs_benchmark >= 0 ? '+' : ''}${r.move_vs_benchmark.toFixed(1)}% (${count(r.pairs)} sale pairs${r.in_sample ? '' : ', out of sample'})`), ...glossaryLines(series.glossary, { detail: true }));
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
export const communityTools = [getCommunity, getMarketIndex];
|
|
74
134
|
//# sourceMappingURL=community.js.map
|
package/dist/tools/filters.d.ts
CHANGED
|
@@ -20,8 +20,10 @@ export declare const cardFilterShape: {
|
|
|
20
20
|
readonly q: z.ZodOptional<z.ZodString>;
|
|
21
21
|
readonly subject: z.ZodOptional<z.ZodString>;
|
|
22
22
|
readonly subject_exact: z.ZodOptional<z.ZodBoolean>;
|
|
23
|
+
readonly subject_all: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
23
24
|
readonly card_number: z.ZodOptional<z.ZodString>;
|
|
24
25
|
readonly set_slug: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
26
|
+
readonly release: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
25
27
|
readonly brand: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
26
28
|
readonly subset: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
27
29
|
readonly year: z.ZodOptional<z.ZodNumber>;
|
|
@@ -29,6 +31,10 @@ export declare const cardFilterShape: {
|
|
|
29
31
|
readonly year_max: z.ZodOptional<z.ZodNumber>;
|
|
30
32
|
readonly team: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
31
33
|
readonly league: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
34
|
+
readonly sport: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
35
|
+
readonly honor: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
36
|
+
readonly honor_year_min: z.ZodOptional<z.ZodNumber>;
|
|
37
|
+
readonly honor_year_max: z.ZodOptional<z.ZodNumber>;
|
|
32
38
|
readonly attribute: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
33
39
|
readonly attribute_all: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
34
40
|
readonly attribute_not: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
package/dist/tools/filters.js
CHANGED
|
@@ -22,8 +22,10 @@ export const cardFilterShape = {
|
|
|
22
22
|
q: z.string().optional().describe('Free text across player name, set name, and card number. Start here when the user gave you a phrase rather than structured criteria.'),
|
|
23
23
|
subject: z.string().optional().describe('Player name, case-insensitive substring match (e.g. "mcdavid").'),
|
|
24
24
|
subject_exact: z.boolean().optional().describe('Match `subject` exactly instead of as a substring.'),
|
|
25
|
+
subject_all: list('Player names the card must feature ALL of — dual and combo cards (e.g. ["Bedard", "Celebrini"]).'),
|
|
25
26
|
card_number: z.string().optional().describe('Card number, exact match (e.g. "YG-201").'),
|
|
26
27
|
set_slug: list('Set slug(s), any-of. Precise catalog membership. Slugs come from search_sets.'),
|
|
28
|
+
release: list('Set UUID(s) treated as the box that was opened: matches every card physically pulled from that product, including update cards for older sets that it carries. UUIDs come from search_sets.'),
|
|
27
29
|
brand: list('Brand name(s), any-of. Valid values come from get_vocab.'),
|
|
28
30
|
subset: list('Subset / insert name(s), any-of (e.g. "Young Guns").'),
|
|
29
31
|
year: z.number().int().optional().describe('Exact season-start year — 2025 means the 2025-26 season.'),
|
|
@@ -31,6 +33,10 @@ export const cardFilterShape = {
|
|
|
31
33
|
year_max: z.number().int().optional().describe('Maximum season-start year, inclusive.'),
|
|
32
34
|
team: list('Team name(s), any-of — the team the player is shown with on the card.'),
|
|
33
35
|
league: list('League name(s), any-of.'),
|
|
36
|
+
sport: list('Sport name(s), any-of.'),
|
|
37
|
+
honor: list('Honor(s) the pictured player holds, any-of: a trophy won, a draft position, a milestone club, a Stanley Cup. The live list is `honors` in get_vocab.'),
|
|
38
|
+
honor_year_min: z.number().int().optional().describe('With `honor`: held from this season-start year on.'),
|
|
39
|
+
honor_year_max: z.number().int().optional().describe('With `honor`: held up to this season-start year.'),
|
|
34
40
|
attribute: list('Attribute name(s), any-of (e.g. "Rookie", "Autograph"). Valid values come from get_vocab.'),
|
|
35
41
|
attribute_all: list('Attribute name(s) the card must have ALL of.'),
|
|
36
42
|
attribute_not: list('Attribute name(s) to exclude.'),
|
package/dist/tools/index.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { toToolError } from '../errors.js';
|
|
14
14
|
import { catalogTools } from './catalog.js';
|
|
15
|
+
import { chaseTools } from './chases.js';
|
|
15
16
|
import { collectionTools } from './collection.js';
|
|
16
17
|
import { communityTools } from './community.js';
|
|
17
18
|
import { metaTools } from './meta.js';
|
|
@@ -22,6 +23,7 @@ export const READ_TOOLS = [
|
|
|
22
23
|
...catalogTools,
|
|
23
24
|
...pricingTools,
|
|
24
25
|
...collectionTools,
|
|
26
|
+
...chaseTools,
|
|
25
27
|
...communityTools,
|
|
26
28
|
...metaTools,
|
|
27
29
|
];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One entity on one line — the shapes several tools render.
|
|
3
|
+
*
|
|
4
|
+
* UUID first, labelled by kind (`card:`, `copy:`, `set:`, `chase:`), because it is the only field
|
|
5
|
+
* the model must carry to the next call, and a copy uuid fed to a card tool is a 404.
|
|
6
|
+
*/
|
|
7
|
+
import type { CardOut, FmvSummary } from '../types.js';
|
|
8
|
+
type Subject = string | {
|
|
9
|
+
name?: string | null;
|
|
10
|
+
team?: string | null;
|
|
11
|
+
};
|
|
12
|
+
/** Player names, "A + B". Responses carry either plain names or subject objects. */
|
|
13
|
+
export declare function players(subjects: readonly Subject[] | null | undefined): string | undefined;
|
|
14
|
+
/** A headline value: "$447.00 RAW, 15 sales", flagged when thin or stale. */
|
|
15
|
+
export declare function fmv(market: Pick<FmvSummary, 'fair_market_value' | 'grade_key' | 'sample_size' | 'low_confidence' | 'stale'> | null | undefined): string | undefined;
|
|
16
|
+
/** "/99", or "1/1". */
|
|
17
|
+
export declare function run(printRun: number | null | undefined): string | undefined;
|
|
18
|
+
/** One catalog card. */
|
|
19
|
+
export declare function cardLine(card: CardOut): string;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One entity on one line — the shapes several tools render.
|
|
3
|
+
*
|
|
4
|
+
* UUID first, labelled by kind (`card:`, `copy:`, `set:`, `chase:`), because it is the only field
|
|
5
|
+
* the model must carry to the next call, and a copy uuid fed to a card tool is a 404.
|
|
6
|
+
*/
|
|
7
|
+
import { join, money, plural } from '../format.js';
|
|
8
|
+
/** Player names, "A + B". Responses carry either plain names or subject objects. */
|
|
9
|
+
export function players(subjects) {
|
|
10
|
+
const names = (subjects ?? []).map((s) => (typeof s === 'string' ? s : s.name)).filter(Boolean);
|
|
11
|
+
return names.length ? names.join(' + ') : undefined;
|
|
12
|
+
}
|
|
13
|
+
/** A headline value: "$447.00 RAW, 15 sales", flagged when thin or stale. */
|
|
14
|
+
export function fmv(market) {
|
|
15
|
+
if (!market?.fair_market_value)
|
|
16
|
+
return undefined;
|
|
17
|
+
return join(' ', `FMV ${money(market.fair_market_value)} ${market.grade_key}`, market.sample_size != null ? `(${plural(market.sample_size, 'sale')}${market.low_confidence ? ', thin' : ''}${market.stale ? ', stale' : ''})` : undefined);
|
|
18
|
+
}
|
|
19
|
+
/** "/99", or "1/1". */
|
|
20
|
+
export function run(printRun) {
|
|
21
|
+
if (!printRun)
|
|
22
|
+
return undefined;
|
|
23
|
+
return printRun === 1 ? '1/1' : `/${printRun}`;
|
|
24
|
+
}
|
|
25
|
+
/** One catalog card. */
|
|
26
|
+
export function cardLine(card) {
|
|
27
|
+
const teams = [...new Set((card.subjects ?? []).map((s) => s.team).filter(Boolean))].join(' / ');
|
|
28
|
+
const attrs = (card.attributes ?? []).map((a) => a.name).filter(Boolean).join(', ');
|
|
29
|
+
return join(' | ', `card:${card.uuid}`, card.set_name ?? card.season ?? undefined, card.subset, `#${card.card_number}`, players(card.subjects), teams || undefined, card.finish ?? 'base', run(card.print_run), attrs || undefined, card.printing_count && card.printing_count > 1 ? `${card.printing_count} printings in this slot` : undefined, fmv(card.market), card.owned_quantity ? `you own ${card.owned_quantity}` : undefined);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=lines.js.map
|