@xyz17711/catalog 0.1.0 → 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/package.json +30 -2
- package/src/index.ts +0 -89
- package/src/langchain.ts +0 -44
- package/test/index.test.mjs +0 -58
- package/test/langchain.test.mjs +0 -32
- package/tsconfig.json +0 -16
package/package.json
CHANGED
|
@@ -1,7 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyz17711/catalog",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
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
|
+
},
|
|
5
33
|
"type": "module",
|
|
6
34
|
"main": "dist/index.js",
|
|
7
35
|
"types": "dist/index.d.ts",
|
package/src/index.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Typed HTTP client and request/response interfaces for catalog.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { Client as BaseClient, type ClientOptions } from "@xyz17711/core";
|
|
6
|
-
|
|
7
|
-
export interface CatalogCategoryEntry {
|
|
8
|
-
category: string;
|
|
9
|
-
description: string;
|
|
10
|
-
host: string;
|
|
11
|
-
name: string;
|
|
12
|
-
port: number;
|
|
13
|
-
registered_at: number;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface CatalogCategoryResponse {
|
|
17
|
-
/** This page's entries, in no particular order (no ranking -- this is a listing, not a search). */
|
|
18
|
-
entries: CatalogCategoryEntry[];
|
|
19
|
-
limit: number;
|
|
20
|
-
offset: number;
|
|
21
|
-
/** Total number of registrations matching `q`, BEFORE `limit`/`offset` are applied -- lets a caller know whether more pages remain. */
|
|
22
|
-
total_count: number;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface SearchResult {
|
|
26
|
-
description: string;
|
|
27
|
-
host: string;
|
|
28
|
-
method: string;
|
|
29
|
-
port: number;
|
|
30
|
-
/** Decimal USDC string (e.g. `"0.01"`), or `""` if this tool is free -- structural pricing, not just prose in `description`. */
|
|
31
|
-
price_usdc: string;
|
|
32
|
-
route: string;
|
|
33
|
-
/** 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). */
|
|
34
|
-
score: number;
|
|
35
|
-
service_name: string;
|
|
36
|
-
tool_name: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface SearchResponse {
|
|
40
|
-
/** Ranked best-match-first, truncated to the request's own `top_k`. */
|
|
41
|
-
results: SearchResult[];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface SearchRequest {
|
|
45
|
-
/** Free-text description of the task to find a service for. */
|
|
46
|
-
query: string;
|
|
47
|
-
/** Max number of results to return. */
|
|
48
|
-
top_k?: number;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export interface CatalogSearchResult {
|
|
52
|
-
category: string;
|
|
53
|
-
description: string;
|
|
54
|
-
host: string;
|
|
55
|
-
method: string;
|
|
56
|
-
port: number;
|
|
57
|
-
/** Decimal USDC string (e.g. `"0.01"`), or `""` if this tool is free -- structural pricing, not just prose in `description`. */
|
|
58
|
-
price_usdc: string;
|
|
59
|
-
route: string;
|
|
60
|
-
/** 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). */
|
|
61
|
-
score: number;
|
|
62
|
-
service_name: string;
|
|
63
|
-
tool_name: string;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export interface CatalogSearchResponse {
|
|
67
|
-
/** Ranked best-match-first, truncated to the request's own `limit`. */
|
|
68
|
-
results: CatalogSearchResult[];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/** Typed client for catalog, e.g. `client.category(...)`. */
|
|
72
|
-
export class Client extends BaseClient {
|
|
73
|
-
/** Lists every registration in one category, paginated (public GET) */
|
|
74
|
-
async category(params: { q: string; limit?: number; offset?: number }): Promise<CatalogCategoryResponse> {
|
|
75
|
-
return this.get<CatalogCategoryResponse>("/v1/catalog/category", { q: params.q, limit: params.limit, offset: params.offset });
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/** Ranks registered services/tools by relevance to a free-text query */
|
|
79
|
-
async findServicesByCapability(request: SearchRequest): Promise<SearchResponse> {
|
|
80
|
-
return this.post<SearchResponse>("/v1/catalog/find_services_by_capability", request);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/** Ranks registered services/tools by relevance to a free-text query (public GET) */
|
|
84
|
-
async search(params: { q: string; category?: string | null; limit?: number }): Promise<CatalogSearchResponse> {
|
|
85
|
-
return this.get<CatalogSearchResponse>("/v1/catalog/search", { q: params.q, category: params.category, limit: params.limit });
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export { ClientOptions };
|
package/src/langchain.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
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
|
-
|
|
5
|
-
import { tool } from "@langchain/core/tools";
|
|
6
|
-
import { z } from "zod";
|
|
7
|
-
import { Client } from "./index.js";
|
|
8
|
-
|
|
9
|
-
export class CatalogToolkit {
|
|
10
|
-
private client: Client;
|
|
11
|
-
|
|
12
|
-
constructor(client: Client) {
|
|
13
|
-
this.client = client;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
getTools() {
|
|
17
|
-
return [
|
|
18
|
-
tool(
|
|
19
|
-
async (input) => this.client.category(input),
|
|
20
|
-
{
|
|
21
|
-
name: "category",
|
|
22
|
-
description: "Lists every registration in one category, paginated (public GET)",
|
|
23
|
-
schema: z.object({ q: z.string(), limit: z.number().optional(), offset: z.number().optional() }),
|
|
24
|
-
},
|
|
25
|
-
),
|
|
26
|
-
tool(
|
|
27
|
-
async (input) => this.client.findServicesByCapability(input),
|
|
28
|
-
{
|
|
29
|
-
name: "findServicesByCapability",
|
|
30
|
-
description: "Ranks registered services/tools by relevance to a free-text query",
|
|
31
|
-
schema: z.object({ query: z.string(), top_k: z.number().optional() }),
|
|
32
|
-
},
|
|
33
|
-
),
|
|
34
|
-
tool(
|
|
35
|
-
async (input) => this.client.search(input),
|
|
36
|
-
{
|
|
37
|
-
name: "search",
|
|
38
|
-
description: "Ranks registered services/tools by relevance to a free-text query (public GET)",
|
|
39
|
-
schema: z.object({ q: z.string(), category: z.string().nullable().optional(), limit: z.number().optional() }),
|
|
40
|
-
},
|
|
41
|
-
),
|
|
42
|
-
];
|
|
43
|
-
}
|
|
44
|
-
}
|
package/test/index.test.mjs
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Verifies every catalog client method sends a request to the expected path/HTTP verb and parses a well-formed response -- one test per operation, real fetch mocked via a plain reassignment of `globalThis.fetch` (no extra test/mocking dependency). Runs against the COMPILED package (`../dist/index.js`) -- build before testing.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { test } from "node:test";
|
|
6
|
-
import assert from "node:assert/strict";
|
|
7
|
-
import { Client } from "../dist/index.js";
|
|
8
|
-
|
|
9
|
-
test("category calls the expected path", async () => {
|
|
10
|
-
const originalFetch = globalThis.fetch;
|
|
11
|
-
globalThis.fetch = async (url, init = {}) => {
|
|
12
|
-
const parsed = new URL(url);
|
|
13
|
-
assert.equal((init.method ?? "GET").toUpperCase(), "GET");
|
|
14
|
-
assert.equal(parsed.pathname, "/v1/catalog/category");
|
|
15
|
-
return new Response(JSON.stringify({ entries: [], limit: 0, offset: 0, total_count: 0 }), { status: 200 });
|
|
16
|
-
};
|
|
17
|
-
try {
|
|
18
|
-
const client = new Client("https://example.test");
|
|
19
|
-
const result = await client.category({ q: "test", limit: null, offset: null });
|
|
20
|
-
assert.ok(result !== undefined);
|
|
21
|
-
} finally {
|
|
22
|
-
globalThis.fetch = originalFetch;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test("findServicesByCapability calls the expected path", async () => {
|
|
27
|
-
const originalFetch = globalThis.fetch;
|
|
28
|
-
globalThis.fetch = async (url, init = {}) => {
|
|
29
|
-
const parsed = new URL(url);
|
|
30
|
-
assert.equal((init.method ?? "GET").toUpperCase(), "POST");
|
|
31
|
-
assert.equal(parsed.pathname, "/v1/catalog/find_services_by_capability");
|
|
32
|
-
return new Response(JSON.stringify({ results: [] }), { status: 200 });
|
|
33
|
-
};
|
|
34
|
-
try {
|
|
35
|
-
const client = new Client("https://example.test");
|
|
36
|
-
const result = await client.findServicesByCapability({ query: "test", top_k: null });
|
|
37
|
-
assert.ok(result !== undefined);
|
|
38
|
-
} finally {
|
|
39
|
-
globalThis.fetch = originalFetch;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test("search calls the expected path", async () => {
|
|
44
|
-
const originalFetch = globalThis.fetch;
|
|
45
|
-
globalThis.fetch = async (url, init = {}) => {
|
|
46
|
-
const parsed = new URL(url);
|
|
47
|
-
assert.equal((init.method ?? "GET").toUpperCase(), "GET");
|
|
48
|
-
assert.equal(parsed.pathname, "/v1/catalog/search");
|
|
49
|
-
return new Response(JSON.stringify({ results: [] }), { status: 200 });
|
|
50
|
-
};
|
|
51
|
-
try {
|
|
52
|
-
const client = new Client("https://example.test");
|
|
53
|
-
const result = await client.search({ q: "test", category: null, limit: null });
|
|
54
|
-
assert.ok(result !== undefined);
|
|
55
|
-
} finally {
|
|
56
|
-
globalThis.fetch = originalFetch;
|
|
57
|
-
}
|
|
58
|
-
});
|
package/test/langchain.test.mjs
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Verifies every catalog LangChain tool through the real StructuredTool (`.invoke()`), not just the underlying client method -- catches schema-shape bugs a plain client-method test would miss. Requires the `langchain`/`zod` dev dependencies.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { test } from "node:test";
|
|
6
|
-
import assert from "node:assert/strict";
|
|
7
|
-
import { Client } from "../dist/index.js";
|
|
8
|
-
import { CatalogToolkit } from "../dist/langchain.js";
|
|
9
|
-
|
|
10
|
-
test("category tool invoke", async () => {
|
|
11
|
-
globalThis.fetch = async () => new Response(JSON.stringify({ entries: [], limit: 0, offset: 0, total_count: 0 }), { status: 200 });
|
|
12
|
-
const toolkit = new CatalogToolkit(new Client("https://example.test"));
|
|
13
|
-
const t = toolkit.getTools().find((x) => x.name === "category");
|
|
14
|
-
const result = await t.invoke({ q: "test", limit: 0, offset: 0 });
|
|
15
|
-
assert.ok(result !== undefined);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test("findServicesByCapability tool invoke", async () => {
|
|
19
|
-
globalThis.fetch = async () => new Response(JSON.stringify({ results: [] }), { status: 200 });
|
|
20
|
-
const toolkit = new CatalogToolkit(new Client("https://example.test"));
|
|
21
|
-
const t = toolkit.getTools().find((x) => x.name === "findServicesByCapability");
|
|
22
|
-
const result = await t.invoke({ query: "test", top_k: 0 });
|
|
23
|
-
assert.ok(result !== undefined);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test("search tool invoke", async () => {
|
|
27
|
-
globalThis.fetch = async () => new Response(JSON.stringify({ results: [] }), { status: 200 });
|
|
28
|
-
const toolkit = new CatalogToolkit(new Client("https://example.test"));
|
|
29
|
-
const t = toolkit.getTools().find((x) => x.name === "search");
|
|
30
|
-
const result = await t.invoke({ q: "test", category: "test", limit: 0 });
|
|
31
|
-
assert.ok(result !== undefined);
|
|
32
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"module": "ES2020",
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"outDir": "dist",
|
|
8
|
-
"rootDir": "src",
|
|
9
|
-
"strict": true,
|
|
10
|
-
"esModuleInterop": true,
|
|
11
|
-
"skipLibCheck": true
|
|
12
|
-
},
|
|
13
|
-
"include": [
|
|
14
|
-
"src"
|
|
15
|
-
]
|
|
16
|
-
}
|