@xyz17711/catalog 0.0.0-stage → 0.1.1

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 CHANGED
@@ -1,3 +1,89 @@
1
- # Temporary Holding Version
1
+ # @xyz17711/catalog
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![Publish](https://github.com/17711-services/clients/actions/workflows/publish-node.yml/badge.svg)](https://github.com/17711-services/clients/actions/workflows/publish-node.yml)
4
+ [![npm](https://img.shields.io/npm/v/@xyz17711/catalog)](https://www.npmjs.com/package/@xyz17711/catalog)
5
+ [![License](https://img.shields.io/npm/l/@xyz17711/catalog)](https://github.com/17711-services/clients/blob/main/LICENSE)
6
+
7
+ Typed TypeScript client for **catalog**, part of the
8
+ [17711.xyz](https://api.17711.xyz) microservice fleet -- pay-per-call APIs settled in USDC via
9
+ [x402](https://x402.org), listed on [x402scan](https://www.x402scan.com/server/f1c7b972-3405-4b75-8b4f-d1bfbd6305ff).
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install @xyz17711/catalog
15
+ ```
16
+
17
+ ## Methods
18
+
19
+ | Method | Description |
20
+ | --- | --- |
21
+ | `category` | Lists every registration in one category, paginated (public GET) |
22
+ | `findServicesByCapability` | Ranks registered services/tools by relevance to a free-text query |
23
+ | `search` | Ranks registered services/tools by relevance to a free-text query (public GET) |
24
+
25
+ ## Quickstart
26
+
27
+ ```typescript
28
+ import { Client } from "@xyz17711/catalog";
29
+
30
+ const client = new Client("https://api.17711.xyz/registry/catalog");
31
+ // see the Methods table above for every available call and its request/response type
32
+ ```
33
+
34
+ ## Paying past the free quota
35
+
36
+ Every gated tool allows a small number of free calls per day; beyond that it returns a 402
37
+ challenge. Without a wallet configured, this client throws `PaymentRequiredError` with the price,
38
+ network, and payee address attached:
39
+
40
+ ```typescript
41
+ import { Client, PaymentRequiredError } from "@xyz17711/catalog";
42
+
43
+ const client = new Client("https://api.17711.xyz/registry/catalog");
44
+ try {
45
+ await client.category(/* ... */);
46
+ } catch (e) {
47
+ if (e instanceof PaymentRequiredError) {
48
+ console.log(`needs ${e.priceUsdc} USDC on ${e.network}, payable to ${e.payTo}`);
49
+ }
50
+ }
51
+ ```
52
+
53
+ To pay automatically, configure a wallet on the client -- the private key should come from your
54
+ own environment/secrets manager, never a literal string in source code:
55
+
56
+ ```typescript
57
+ import { Client } from "@xyz17711/catalog";
58
+
59
+ const client = new Client("https://api.17711.xyz/registry/catalog", {
60
+ x402PrivateKey: process.env.X402_PRIVATE_KEY,
61
+ x402ExpectedNetwork: "eip155:8453", // Base mainnet; use eip155:84532 for Base Sepolia testnet
62
+ x402MaxPaymentUsdc: 0.01, // refuse any single call above this
63
+ x402MaxTotalSpendUsdc: 1.0, // refuse once this WALLET's lifetime spend would exceed it
64
+ });
65
+ ```
66
+
67
+ **Never commit a private key.** Both spend caps are required together with the key -- a wallet
68
+ with real funds and no explicit caps refuses to construct at all (`WalletConfigError`), on
69
+ purpose. The cumulative cap is tracked per wallet address, shared by every `Client` you construct
70
+ with that same key in this process.
71
+
72
+ ## LangChain.js
73
+
74
+ ```typescript
75
+ import { Client } from "@xyz17711/catalog";
76
+ import { CatalogToolkit } from "@xyz17711/catalog/langchain";
77
+
78
+ const client = new Client("https://api.17711.xyz/registry/catalog", { /* ...wallet options... */ });
79
+ const tools = new CatalogToolkit(client).getTools();
80
+ ```
81
+
82
+ Requires the optional `@langchain/core`+`zod` peer dependencies (`npm install @langchain/core
83
+ zod`) -- importing the base package above never requires them; only `@xyz17711/catalog/langchain`
84
+ does.
85
+
86
+ ## License
87
+
88
+ MIT -- see [`LICENSE`](../../LICENSE), shared by every language's client library in the
89
+ `clients` repo this package lives in.
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Typed HTTP client and request/response interfaces for catalog.
3
+ */
4
+ import { Client as BaseClient, type ClientOptions } from "@xyz17711/core";
5
+ export interface CatalogCategoryEntry {
6
+ category: string;
7
+ description: string;
8
+ host: string;
9
+ name: string;
10
+ port: number;
11
+ registered_at: number;
12
+ }
13
+ export interface CatalogCategoryResponse {
14
+ /** This page's entries, in no particular order (no ranking -- this is a listing, not a search). */
15
+ entries: CatalogCategoryEntry[];
16
+ limit: number;
17
+ offset: number;
18
+ /** Total number of registrations matching `q`, BEFORE `limit`/`offset` are applied -- lets a caller know whether more pages remain. */
19
+ total_count: number;
20
+ }
21
+ export interface SearchResult {
22
+ description: string;
23
+ host: string;
24
+ method: string;
25
+ port: number;
26
+ /** Decimal USDC string (e.g. `"0.01"`), or `""` if this tool is free -- structural pricing, not just prose in `description`. */
27
+ price_usdc: string;
28
+ route: string;
29
+ /** Similarity score (semantic embedding cosine similarity when available, else keyword overlap in `[0, 1]`) -- higher is a better match. Not comparable across two different searches (the scoring method may differ per-call depending on embedding availability). */
30
+ score: number;
31
+ service_name: string;
32
+ tool_name: string;
33
+ }
34
+ export interface SearchResponse {
35
+ /** Ranked best-match-first, truncated to the request's own `top_k`. */
36
+ results: SearchResult[];
37
+ }
38
+ export interface SearchRequest {
39
+ /** Free-text description of the task to find a service for. */
40
+ query: string;
41
+ /** Max number of results to return. */
42
+ top_k?: number;
43
+ }
44
+ export interface CatalogSearchResult {
45
+ category: string;
46
+ description: string;
47
+ host: string;
48
+ method: string;
49
+ port: number;
50
+ /** Decimal USDC string (e.g. `"0.01"`), or `""` if this tool is free -- structural pricing, not just prose in `description`. */
51
+ price_usdc: string;
52
+ route: string;
53
+ /** Similarity score (semantic embedding cosine similarity when available, else keyword overlap in `[0, 1]`) -- higher is a better match. Not comparable across two different searches (the scoring method may differ per-call depending on embedding availability). */
54
+ score: number;
55
+ service_name: string;
56
+ tool_name: string;
57
+ }
58
+ export interface CatalogSearchResponse {
59
+ /** Ranked best-match-first, truncated to the request's own `limit`. */
60
+ results: CatalogSearchResult[];
61
+ }
62
+ /** Typed client for catalog, e.g. `client.category(...)`. */
63
+ export declare class Client extends BaseClient {
64
+ /** Lists every registration in one category, paginated (public GET) */
65
+ category(params: {
66
+ q: string;
67
+ limit?: number;
68
+ offset?: number;
69
+ }): Promise<CatalogCategoryResponse>;
70
+ /** Ranks registered services/tools by relevance to a free-text query */
71
+ findServicesByCapability(request: SearchRequest): Promise<SearchResponse>;
72
+ /** Ranks registered services/tools by relevance to a free-text query (public GET) */
73
+ search(params: {
74
+ q: string;
75
+ category?: string | null;
76
+ limit?: number;
77
+ }): Promise<CatalogSearchResponse>;
78
+ }
79
+ export { ClientOptions };
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Typed HTTP client and request/response interfaces for catalog.
3
+ */
4
+ import { Client as BaseClient } from "@xyz17711/core";
5
+ /** Typed client for catalog, e.g. `client.category(...)`. */
6
+ export class Client extends BaseClient {
7
+ /** Lists every registration in one category, paginated (public GET) */
8
+ async category(params) {
9
+ return this.get("/v1/catalog/category", { q: params.q, limit: params.limit, offset: params.offset });
10
+ }
11
+ /** Ranks registered services/tools by relevance to a free-text query */
12
+ async findServicesByCapability(request) {
13
+ return this.post("/v1/catalog/find_services_by_capability", request);
14
+ }
15
+ /** Ranks registered services/tools by relevance to a free-text query (public GET) */
16
+ async search(params) {
17
+ return this.get("/v1/catalog/search", { q: params.q, category: params.category, limit: params.limit });
18
+ }
19
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * LangChain.js tools for catalog, grouped in one Toolkit -- one tool per operation, each just an async function (JS has no separate sync form to generate). Requires the `@langchain/core`+`zod` peer dependencies declared in this package's own package.json -- imported from `catalog/langchain`, never from the package root, so importing the base client never requires them installed.
3
+ */
4
+ import { z } from "zod";
5
+ import { Client } from "./index.js";
6
+ export declare class CatalogToolkit {
7
+ private client;
8
+ constructor(client: Client);
9
+ getTools(): (import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
10
+ q: z.ZodString;
11
+ limit: z.ZodOptional<z.ZodNumber>;
12
+ offset: z.ZodOptional<z.ZodNumber>;
13
+ }, z.core.$strip>, {
14
+ q: string;
15
+ limit?: number | undefined;
16
+ offset?: number | undefined;
17
+ }, {
18
+ q: string;
19
+ limit?: number | undefined;
20
+ offset?: number | undefined;
21
+ }, import("./index.js").CatalogCategoryResponse, unknown, "category"> | import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
22
+ query: z.ZodString;
23
+ top_k: z.ZodOptional<z.ZodNumber>;
24
+ }, z.core.$strip>, {
25
+ query: string;
26
+ top_k?: number | undefined;
27
+ }, {
28
+ query: string;
29
+ top_k?: number | undefined;
30
+ }, import("./index.js").SearchResponse, unknown, "findServicesByCapability"> | import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
31
+ q: z.ZodString;
32
+ category: z.ZodOptional<z.ZodNullable<z.ZodString>>;
33
+ limit: z.ZodOptional<z.ZodNumber>;
34
+ }, z.core.$strip>, {
35
+ q: string;
36
+ category?: string | null | undefined;
37
+ limit?: number | undefined;
38
+ }, {
39
+ q: string;
40
+ category?: string | null | undefined;
41
+ limit?: number | undefined;
42
+ }, import("./index.js").CatalogSearchResponse, unknown, "search">)[];
43
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * LangChain.js tools for catalog, grouped in one Toolkit -- one tool per operation, each just an async function (JS has no separate sync form to generate). Requires the `@langchain/core`+`zod` peer dependencies declared in this package's own package.json -- imported from `catalog/langchain`, never from the package root, so importing the base client never requires them installed.
3
+ */
4
+ import { tool } from "@langchain/core/tools";
5
+ import { z } from "zod";
6
+ export class CatalogToolkit {
7
+ constructor(client) {
8
+ this.client = client;
9
+ }
10
+ getTools() {
11
+ return [
12
+ tool(async (input) => this.client.category(input), {
13
+ name: "category",
14
+ description: "Lists every registration in one category, paginated (public GET)",
15
+ schema: z.object({ q: z.string(), limit: z.number().optional(), offset: z.number().optional() }),
16
+ }),
17
+ tool(async (input) => this.client.findServicesByCapability(input), {
18
+ name: "findServicesByCapability",
19
+ description: "Ranks registered services/tools by relevance to a free-text query",
20
+ schema: z.object({ query: z.string(), top_k: z.number().optional() }),
21
+ }),
22
+ tool(async (input) => this.client.search(input), {
23
+ name: "search",
24
+ description: "Ranks registered services/tools by relevance to a free-text query (public GET)",
25
+ schema: z.object({ q: z.string(), category: z.string().nullable().optional(), limit: z.number().optional() }),
26
+ }),
27
+ ];
28
+ }
29
+ }
package/package.json CHANGED
@@ -1,6 +1,70 @@
1
1
  {
2
2
  "name": "@xyz17711/catalog",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "Typed TypeScript client for the 17711.xyz Catalog API: pay-per-call, settled in USDC via x402.",
5
+ "license": "MIT",
6
+ "author": "17711 Services",
7
+ "homepage": "https://api.17711.xyz",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/17711-services/clients.git",
11
+ "directory": "node/packages/catalog"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/17711-services/clients/issues"
15
+ },
16
+ "keywords": [
17
+ "x402",
18
+ "usdc",
19
+ "api-client",
20
+ "pay-per-call",
21
+ "ai-agents",
22
+ "mcp",
23
+ "langchain",
24
+ "catalog"
25
+ ],
26
+ "files": [
27
+ "dist",
28
+ "README.md"
29
+ ],
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "type": "module",
34
+ "main": "dist/index.js",
35
+ "types": "dist/index.d.ts",
36
+ "exports": {
37
+ ".": {
38
+ "types": "./dist/index.d.ts",
39
+ "default": "./dist/index.js"
40
+ },
41
+ "./langchain": {
42
+ "types": "./dist/langchain.d.ts",
43
+ "default": "./dist/langchain.js"
44
+ }
45
+ },
46
+ "scripts": {
47
+ "build": "tsc -p .",
48
+ "test": "npm run build && node --test test/*.test.mjs"
49
+ },
50
+ "dependencies": {
51
+ "@xyz17711/core": "^0.1.0"
52
+ },
53
+ "peerDependencies": {
54
+ "@langchain/core": ">=0.3",
55
+ "zod": "^3 || ^4"
56
+ },
57
+ "peerDependenciesMeta": {
58
+ "@langchain/core": {
59
+ "optional": true
60
+ },
61
+ "zod": {
62
+ "optional": true
63
+ }
64
+ },
65
+ "devDependencies": {
66
+ "typescript": "^5",
67
+ "@langchain/core": "^1.2",
68
+ "zod": "^4"
69
+ }
70
+ }