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/config.d.ts
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { type KeySource } from './credentials.js';
|
|
9
9
|
export declare const DEFAULT_API_URL = "https://api.slab.dev-jeb.com";
|
|
10
|
+
/** The API's name for "the collector this key acts for" (its default collector). */
|
|
11
|
+
export declare const ME = "me";
|
|
10
12
|
export interface Config {
|
|
11
13
|
/** Base URL of the slab API, no trailing slash. */
|
|
12
14
|
apiUrl: string;
|
|
@@ -14,8 +16,8 @@ export interface Config {
|
|
|
14
16
|
apiKey: string;
|
|
15
17
|
/** Which mechanism supplied the key. Logged at startup; never the key itself. */
|
|
16
18
|
keySource: KeySource;
|
|
17
|
-
/** Collector the key acts for
|
|
18
|
-
collectorUuid: string
|
|
19
|
+
/** Collector the key acts for: SLAB_COLLECTOR, else `me` (the account's default collector). */
|
|
20
|
+
collectorUuid: string;
|
|
19
21
|
/** Whether mutating tools are registered at all. Off unless SLAB_MCP_WRITE=1. */
|
|
20
22
|
writesEnabled: boolean;
|
|
21
23
|
/** Per-request HTTP timeout. */
|
package/dist/config.js
CHANGED
|
@@ -8,11 +8,32 @@
|
|
|
8
8
|
import { resolveApiKey } from './credentials.js';
|
|
9
9
|
import { ConfigError } from './errors.js';
|
|
10
10
|
export const DEFAULT_API_URL = 'https://api.slab.dev-jeb.com';
|
|
11
|
+
/** The API's name for "the collector this key acts for" (its default collector). */
|
|
12
|
+
export const ME = 'me';
|
|
11
13
|
function truthy(value) {
|
|
12
14
|
if (!value)
|
|
13
15
|
return false;
|
|
14
16
|
return ['1', 'true', 'yes', 'on'].includes(value.trim().toLowerCase());
|
|
15
17
|
}
|
|
18
|
+
/** The key travels in a header on every request, so it only travels encrypted — except to a
|
|
19
|
+
* server on this machine, which is how the API is developed. */
|
|
20
|
+
function apiUrlFrom(raw) {
|
|
21
|
+
const value = (raw?.trim() || DEFAULT_API_URL).replace(/\/+$/, '');
|
|
22
|
+
let url;
|
|
23
|
+
try {
|
|
24
|
+
url = new URL(value);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
throw new ConfigError(`SLAB_API_URL is not a URL: "${value}".`);
|
|
28
|
+
}
|
|
29
|
+
const local = ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname);
|
|
30
|
+
if (url.protocol !== 'https:' && !(local && url.protocol === 'http:')) {
|
|
31
|
+
throw new ConfigError(`SLAB_API_URL must be https (http only for localhost), got "${value}". The API key is sent with every request.`);
|
|
32
|
+
}
|
|
33
|
+
if (url.search || url.hash)
|
|
34
|
+
throw new ConfigError(`SLAB_API_URL must be a base URL with no query or fragment, got "${value}".`);
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
16
37
|
export function loadConfig(env = process.env) {
|
|
17
38
|
const { key: apiKey, source: keySource } = resolveApiKey(env);
|
|
18
39
|
const timeoutRaw = env.SLAB_MCP_TIMEOUT_MS?.trim();
|
|
@@ -20,11 +41,15 @@ export function loadConfig(env = process.env) {
|
|
|
20
41
|
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
21
42
|
throw new ConfigError(`SLAB_MCP_TIMEOUT_MS must be a positive number of milliseconds, got "${timeoutRaw}".`);
|
|
22
43
|
}
|
|
44
|
+
const collector = env.SLAB_COLLECTOR?.trim();
|
|
45
|
+
if (collector && !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(collector)) {
|
|
46
|
+
throw new ConfigError(`SLAB_COLLECTOR must be a collector UUID, got "${collector}". Leave it unset to use your account's default collector.`);
|
|
47
|
+
}
|
|
23
48
|
return {
|
|
24
|
-
apiUrl: (env.SLAB_API_URL
|
|
49
|
+
apiUrl: apiUrlFrom(env.SLAB_API_URL),
|
|
25
50
|
apiKey,
|
|
26
51
|
keySource,
|
|
27
|
-
collectorUuid:
|
|
52
|
+
collectorUuid: collector || ME,
|
|
28
53
|
writesEnabled: truthy(env.SLAB_MCP_WRITE),
|
|
29
54
|
timeoutMs,
|
|
30
55
|
};
|
package/dist/context.d.ts
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The object every tool handler receives.
|
|
2
|
+
* The object every tool handler receives: the client, the config, and the collector to act as.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* SLAB_COLLECTOR, or from `GET /account` once, memoised for the process.
|
|
4
|
+
* A model cannot invent a collector UUID, so no collection tool requires one: the acting collector
|
|
5
|
+
* is SLAB_COLLECTOR, or `me`, which the API reads as this key's default collector (a 404 when the
|
|
6
|
+
* account has none, which `errors.ts` explains).
|
|
8
7
|
*/
|
|
9
|
-
import { SlabClient } from './client.js';
|
|
8
|
+
import { type ClientDeps, SlabClient } from './client.js';
|
|
10
9
|
import type { Config } from './config.js';
|
|
11
10
|
export interface ToolContext {
|
|
12
11
|
client: SlabClient;
|
|
13
12
|
config: Config;
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
* expose an optional `collector_uuid` for multi-collector accounts).
|
|
17
|
-
*/
|
|
18
|
-
collector(override?: string): Promise<string>;
|
|
13
|
+
/** The collector to act as: an explicit UUID (multi-collector accounts), else the configured one. */
|
|
14
|
+
collector(override?: string): string;
|
|
19
15
|
}
|
|
20
|
-
export declare function createContext(config: Config): ToolContext;
|
|
16
|
+
export declare function createContext(config: Config, deps?: ClientDeps): ToolContext;
|
package/dist/context.js
CHANGED
|
@@ -1,39 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The object every tool handler receives.
|
|
2
|
+
* The object every tool handler receives: the client, the config, and the collector to act as.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* SLAB_COLLECTOR, or from `GET /account` once, memoised for the process.
|
|
4
|
+
* A model cannot invent a collector UUID, so no collection tool requires one: the acting collector
|
|
5
|
+
* is SLAB_COLLECTOR, or `me`, which the API reads as this key's default collector (a 404 when the
|
|
6
|
+
* account has none, which `errors.ts` explains).
|
|
8
7
|
*/
|
|
9
8
|
import { SlabClient } from './client.js';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const client = new SlabClient(config);
|
|
13
|
-
let resolved;
|
|
14
|
-
async function resolveDefault() {
|
|
15
|
-
const account = await client.request('GET', '/account');
|
|
16
|
-
const uuid = account.default_collector_uuid ?? account.collectors?.[0]?.uuid;
|
|
17
|
-
if (!uuid) {
|
|
18
|
-
throw new ApiError(404, 'This API key resolves to an account with no collectors. Create one in the slab portal or with `slab collector create`, then retry.', 'GET', '/account');
|
|
19
|
-
}
|
|
20
|
-
return uuid;
|
|
21
|
-
}
|
|
9
|
+
export function createContext(config, deps = {}) {
|
|
10
|
+
const client = new SlabClient(config, deps);
|
|
22
11
|
return {
|
|
23
12
|
client,
|
|
24
13
|
config,
|
|
25
|
-
|
|
26
|
-
if (override)
|
|
27
|
-
return override;
|
|
28
|
-
if (config.collectorUuid)
|
|
29
|
-
return config.collectorUuid;
|
|
30
|
-
// Memoise the promise, not the value, so concurrent first calls share one request.
|
|
31
|
-
resolved ??= resolveDefault().catch((err) => {
|
|
32
|
-
resolved = undefined; // let a later call retry after a transient failure
|
|
33
|
-
throw err;
|
|
34
|
-
});
|
|
35
|
-
return resolved;
|
|
36
|
-
},
|
|
14
|
+
collector: (override) => override || config.collectorUuid,
|
|
37
15
|
};
|
|
38
16
|
}
|
|
39
17
|
//# sourceMappingURL=context.js.map
|
package/dist/errors.js
CHANGED
|
@@ -45,10 +45,14 @@ export class ApiConnectionError extends Error {
|
|
|
45
45
|
*/
|
|
46
46
|
const STATUS_HINTS = {
|
|
47
47
|
401: 'The API key is missing, unknown, revoked, or disabled. This is a configuration problem on the user\'s machine — tell them to check SLAB_API_KEY in their MCP client config. Do not retry.',
|
|
48
|
-
404: 'Either the UUID does not exist or it belongs to another account. slab does not distinguish the two, on purpose. Re-run the matching search tool to get a current UUID rather than guessing one.',
|
|
48
|
+
404: 'Either the UUID does not exist or it belongs to another account. slab does not distinguish the two, on purpose. Re-run the matching search tool to get a current UUID rather than guessing one. On a collection tool it can also mean this account has no collector yet: the user creates one by signing in at collection.slab.dev-jeb.com.',
|
|
49
49
|
409: 'The request conflicts with existing data (usually a duplicate). Read the current state before writing again.',
|
|
50
50
|
422: 'The request body failed validation. Check the field names and value vocabularies with get_vocab, then retry.',
|
|
51
|
-
429: 'Rate limited. Wait before retrying, and batch work into fewer, larger calls.',
|
|
51
|
+
429: 'Rate limited, and still limited after the server waited and retried. Wait before retrying, and batch work into fewer, larger calls.',
|
|
52
|
+
500: 'The slab API failed on this request. Retrying the identical call is unlikely to help; tell the user, and try a narrower request.',
|
|
53
|
+
502: 'The slab API was unreachable for a moment, and still was after two retries. Try again shortly.',
|
|
54
|
+
503: 'The slab API was unavailable, and still was after two retries. Try again shortly.',
|
|
55
|
+
504: 'The slab API took too long, and still did after two retries. Try a narrower request (a smaller limit, fewer filters at once).',
|
|
52
56
|
};
|
|
53
57
|
/**
|
|
54
58
|
* Turn any thrown value into a tool result. Never leaks the API key: the key
|
package/dist/format.d.ts
CHANGED
|
@@ -25,6 +25,8 @@ export interface ToolResult {
|
|
|
25
25
|
export declare function text(...parts: Array<string | undefined | null | false>): ToolResult;
|
|
26
26
|
/** Money, rendered the way a person reads it. `null` becomes an em dash. */
|
|
27
27
|
export declare function money(value: number | string | null | undefined): string;
|
|
28
|
+
/** "1 sale", "3 sales", "1,204 sales". */
|
|
29
|
+
export declare function plural(n: number | null | undefined, noun: string, nouns?: string): string;
|
|
28
30
|
/** A 0-1 ratio as a percentage. `portfolio_roi: 0.0645` reads as `6.45%`. */
|
|
29
31
|
export declare function percent(value: number | string | null | undefined): string;
|
|
30
32
|
/** A count, rendered as an integer with no currency symbol. */
|
package/dist/format.js
CHANGED
|
@@ -27,7 +27,13 @@ export function money(value) {
|
|
|
27
27
|
const n = typeof value === 'string' ? Number(value) : value;
|
|
28
28
|
if (!Number.isFinite(n))
|
|
29
29
|
return '—';
|
|
30
|
-
|
|
30
|
+
const abs = Math.abs(n).toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
31
|
+
return n < 0 ? `-$${abs}` : `$${abs}`;
|
|
32
|
+
}
|
|
33
|
+
/** "1 sale", "3 sales", "1,204 sales". */
|
|
34
|
+
export function plural(n, noun, nouns = `${noun}s`) {
|
|
35
|
+
const value = n ?? 0;
|
|
36
|
+
return `${value.toLocaleString('en-US')} ${value === 1 ? noun : nouns}`;
|
|
31
37
|
}
|
|
32
38
|
/** A 0-1 ratio as a percentage. `portfolio_roi: 0.0645` reads as `6.45%`. */
|
|
33
39
|
export function percent(value) {
|
package/dist/prompts/index.js
CHANGED
|
@@ -49,9 +49,10 @@ export const PROMPTS = [
|
|
|
49
49
|
`Research ${args.player}'s trading cards.`,
|
|
50
50
|
args.budget ? `I am working with a budget of about ${args.budget}.` : '',
|
|
51
51
|
'',
|
|
52
|
-
'Start with search_cards filtered by subject
|
|
53
|
-
'year
|
|
54
|
-
'the
|
|
52
|
+
'Start with search_cards filtered by subject with `collapse_parallels` and facets, to see how the',
|
|
53
|
+
'cards break down by year and set rather than paging through every parallel. Use get_rainbow on',
|
|
54
|
+
'the slots worth a closer look to see their parallels, print runs and odds, then get_card_pricing',
|
|
55
|
+
'on the printings that matter.',
|
|
55
56
|
'',
|
|
56
57
|
'Tell me: what the notable cards are, which are genuinely scarce (print run, not vibes), and',
|
|
57
58
|
'what recent sales actually show. When you talk about movement, count real sales from the comps',
|
|
@@ -73,9 +74,9 @@ export const PROMPTS = [
|
|
|
73
74
|
`Help me decide whether to grade: ${args.card}.`,
|
|
74
75
|
args.grading_cost ? `Grading would cost about ${args.grading_cost}.` : '',
|
|
75
76
|
'',
|
|
76
|
-
'Find the card, then use
|
|
77
|
-
'
|
|
78
|
-
'at a grade the card would realistically receive.',
|
|
77
|
+
'Find the card, then use get_grading_desk: its raw value beside what it sells for at each grade',
|
|
78
|
+
'and grading company. The gap is the grading uplift, and it only pays if it exceeds the grading',
|
|
79
|
+
'cost at a grade the card would realistically receive. A grade marked ESTIMATE has no sales.',
|
|
79
80
|
'',
|
|
80
81
|
'Be honest about the uncertainty: I do not know what grade it would get, and the graded value',
|
|
81
82
|
'may rest on very few sales. Give me the break-even grade rather than a single recommendation,',
|
|
@@ -84,6 +85,30 @@ export const PROMPTS = [
|
|
|
84
85
|
.filter(Boolean)
|
|
85
86
|
.join('\n'),
|
|
86
87
|
},
|
|
88
|
+
{
|
|
89
|
+
name: 'whats-hot',
|
|
90
|
+
title: "What's hot in hockey cards",
|
|
91
|
+
description: 'A read on the hockey card market right now: who is selling, what collectors want, how the market moved.',
|
|
92
|
+
argsSchema: z.object({
|
|
93
|
+
focus: z.string().optional().describe('Optional narrowing, e.g. "rookies", "this year\'s Young Guns", "hobby boxes".'),
|
|
94
|
+
}),
|
|
95
|
+
render: (args) => [
|
|
96
|
+
"Tell me what's happening in hockey cards right now.",
|
|
97
|
+
args.focus ? `Focus on: ${args.focus}.` : '',
|
|
98
|
+
'',
|
|
99
|
+
'Use get_community for the hottest players, the most wanted and most collected cards and the',
|
|
100
|
+
'card of the day, and get_market_index for how the market moved beyond what card age explains.',
|
|
101
|
+
'Then look closer at two or three of the cards with get_card_pricing.',
|
|
102
|
+
'',
|
|
103
|
+
'Constraints on how you report it:',
|
|
104
|
+
'- Hottest players are counted from sales slab saw. Say "sales seen", never "volume".',
|
|
105
|
+
"- The market index is slab's own measure; quote its glossary wording rather than calling it",
|
|
106
|
+
' prices rising or falling.',
|
|
107
|
+
'- A value resting on one or two sales is thin. Say so.',
|
|
108
|
+
]
|
|
109
|
+
.filter(Boolean)
|
|
110
|
+
.join('\n'),
|
|
111
|
+
},
|
|
87
112
|
];
|
|
88
113
|
export function registerPrompts(server) {
|
|
89
114
|
for (const prompt of PROMPTS) {
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* Adding a resource: one entry in RESOURCES.
|
|
11
11
|
*/
|
|
12
12
|
import type { McpServer } from '@modelcontextprotocol/server';
|
|
13
|
+
import { type ApiPath } from '../client.js';
|
|
13
14
|
import type { ToolContext } from '../context.js';
|
|
14
15
|
interface ResourceModule {
|
|
15
16
|
name: string;
|
|
@@ -18,7 +19,7 @@ interface ResourceModule {
|
|
|
18
19
|
description: string;
|
|
19
20
|
mimeType: string;
|
|
20
21
|
/** Path on the slab API whose body is served verbatim. */
|
|
21
|
-
path:
|
|
22
|
+
path: ApiPath;
|
|
22
23
|
}
|
|
23
24
|
export declare const RESOURCES: ResourceModule[];
|
|
24
25
|
export declare function registerResources(server: McpServer, ctx: ToolContext): void;
|
package/dist/resources/index.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Adding a resource: one entry in RESOURCES.
|
|
11
11
|
*/
|
|
12
|
+
import { api } from '../client.js';
|
|
12
13
|
export const RESOURCES = [
|
|
13
14
|
{
|
|
14
15
|
name: 'vocab',
|
|
@@ -18,7 +19,7 @@ export const RESOURCES = [
|
|
|
18
19
|
'dimensions (brands, teams, attributes, finishes, grading companies) that grow as sets are ' +
|
|
19
20
|
'seeded. Read this instead of assuming a filter value.',
|
|
20
21
|
mimeType: 'application/json',
|
|
21
|
-
path:
|
|
22
|
+
path: api `/vocab`,
|
|
22
23
|
},
|
|
23
24
|
{
|
|
24
25
|
name: 'glossary',
|
|
@@ -27,7 +28,7 @@ export const RESOURCES = [
|
|
|
27
28
|
description: 'Plain-language definition of every metric the slab API returns, keyed by namespaced id. Use ' +
|
|
28
29
|
"slab's wording when explaining a number to a user rather than composing your own.",
|
|
29
30
|
mimeType: 'application/json',
|
|
30
|
-
path:
|
|
31
|
+
path: api `/glossary`,
|
|
31
32
|
},
|
|
32
33
|
{
|
|
33
34
|
name: 'openapi',
|
|
@@ -37,7 +38,7 @@ export const RESOURCES = [
|
|
|
37
38
|
'read this when you need to know exactly what a field means or what an endpoint returns. Large ' +
|
|
38
39
|
'— fetch it deliberately, not by default.',
|
|
39
40
|
mimeType: 'application/json',
|
|
40
|
-
path:
|
|
41
|
+
path: api `/openapi.json`,
|
|
41
42
|
},
|
|
42
43
|
];
|
|
43
44
|
export function registerResources(server, ctx) {
|
|
@@ -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
|
package/dist/tools/catalog.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
/** Catalog tools: finding cards
|
|
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.
|
|
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.
|
|
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>>)[];
|