@port66/langchain 0.0.0-stage → 0.1.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 +21 -2
- package/dist/index.d.ts +86 -0
- package/dist/index.js +49 -0
- package/package.json +47 -3
package/README.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @port66/langchain
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[Port66](https://port66.xyz) tools for LangChain and LangGraph agents. Search authenticated luxury, streetwear and collectibles, and buy a listing in **one x402 request** with USDC on Base, paid straight to the seller.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @port66/langchain @langchain/core zod
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { createReactAgent } from "@langchain/langgraph/prebuilt";
|
|
11
|
+
import { port66Tools } from "@port66/langchain";
|
|
12
|
+
|
|
13
|
+
const tools = port66Tools({
|
|
14
|
+
maxPurchaseUsd: 200, // buying is off without a cap
|
|
15
|
+
wallet: process.env.AGENT_KEY as `0x${string}`, // EOA on Base holding USDC; only needed to buy
|
|
16
|
+
});
|
|
17
|
+
const agent = createReactAgent({ llm, tools });
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Tools: `port66_search_listings` and `port66_get_listing` (free), and `port66_buy_listing` (pays the listing's total). Leave out `wallet` and `maxPurchaseUsd` for a browse-only agent.
|
|
21
|
+
|
|
22
|
+
How buying works, and its safety checks: see [`@port66/sdk`](https://www.npmjs.com/package/@port66/sdk). More: [port66.xyz/ai](https://port66.xyz/ai) · MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { type Port66Config, type Port66Wallet } from "@port66/sdk";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export interface Port66ToolsOptions extends Port66Config {
|
|
4
|
+
/** The agent's wallet: a private key (EOA on Base holding USDC) or a Port66Wallet. Needed only to buy. */
|
|
5
|
+
wallet?: `0x${string}` | Port66Wallet;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Port66 tools for LangChain and LangGraph agents: search listings and get a
|
|
9
|
+
* listing (free), and buy a listing in one x402 request with USDC on Base.
|
|
10
|
+
* Buying stays off until `maxPurchaseUsd` is set and a `wallet` is given.
|
|
11
|
+
*/
|
|
12
|
+
export declare function port66Tools(options?: Port66ToolsOptions): (import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
13
|
+
query: z.ZodOptional<z.ZodString>;
|
|
14
|
+
brand: z.ZodOptional<z.ZodString>;
|
|
15
|
+
category: z.ZodOptional<z.ZodString>;
|
|
16
|
+
size: z.ZodOptional<z.ZodString>;
|
|
17
|
+
maxPriceUsd: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
sort: z.ZodOptional<z.ZodEnum<{
|
|
19
|
+
newest: "newest";
|
|
20
|
+
price_asc: "price_asc";
|
|
21
|
+
price_desc: "price_desc";
|
|
22
|
+
}>>;
|
|
23
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
24
|
+
}, z.core.$strip>, {
|
|
25
|
+
query?: string | undefined;
|
|
26
|
+
brand?: string | undefined;
|
|
27
|
+
category?: string | undefined;
|
|
28
|
+
size?: string | undefined;
|
|
29
|
+
maxPriceUsd?: number | undefined;
|
|
30
|
+
sort?: "newest" | "price_asc" | "price_desc" | undefined;
|
|
31
|
+
limit?: number | undefined;
|
|
32
|
+
}, {
|
|
33
|
+
query?: string | undefined;
|
|
34
|
+
brand?: string | undefined;
|
|
35
|
+
category?: string | undefined;
|
|
36
|
+
size?: string | undefined;
|
|
37
|
+
maxPriceUsd?: number | undefined;
|
|
38
|
+
sort?: "newest" | "price_asc" | "price_desc" | undefined;
|
|
39
|
+
limit?: number | undefined;
|
|
40
|
+
}, string, unknown, "port66_search_listings"> | import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
41
|
+
id: z.ZodString;
|
|
42
|
+
}, z.core.$strip>, {
|
|
43
|
+
id: string;
|
|
44
|
+
}, {
|
|
45
|
+
id: string;
|
|
46
|
+
}, string, unknown, "port66_get_listing"> | import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
47
|
+
id: z.ZodString;
|
|
48
|
+
maxPriceUsd: z.ZodNumber;
|
|
49
|
+
shippingAddress: z.ZodObject<{
|
|
50
|
+
name: z.ZodString;
|
|
51
|
+
line1: z.ZodString;
|
|
52
|
+
line2: z.ZodOptional<z.ZodString>;
|
|
53
|
+
city: z.ZodString;
|
|
54
|
+
region: z.ZodOptional<z.ZodString>;
|
|
55
|
+
postal: z.ZodString;
|
|
56
|
+
country: z.ZodString;
|
|
57
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
58
|
+
}, z.core.$strip>;
|
|
59
|
+
}, z.core.$strip>, {
|
|
60
|
+
id: string;
|
|
61
|
+
maxPriceUsd: number;
|
|
62
|
+
shippingAddress: {
|
|
63
|
+
name: string;
|
|
64
|
+
line1: string;
|
|
65
|
+
city: string;
|
|
66
|
+
postal: string;
|
|
67
|
+
country: string;
|
|
68
|
+
line2?: string | undefined;
|
|
69
|
+
region?: string | undefined;
|
|
70
|
+
phone?: string | undefined;
|
|
71
|
+
};
|
|
72
|
+
}, {
|
|
73
|
+
id: string;
|
|
74
|
+
maxPriceUsd: number;
|
|
75
|
+
shippingAddress: {
|
|
76
|
+
name: string;
|
|
77
|
+
line1: string;
|
|
78
|
+
city: string;
|
|
79
|
+
postal: string;
|
|
80
|
+
country: string;
|
|
81
|
+
line2?: string | undefined;
|
|
82
|
+
region?: string | undefined;
|
|
83
|
+
phone?: string | undefined;
|
|
84
|
+
};
|
|
85
|
+
}, string, unknown, "port66_buy_listing">)[];
|
|
86
|
+
export { Port66, walletFromPrivateKey, type Port66Config, type Port66Wallet } from "@port66/sdk";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { tool } from "@langchain/core/tools";
|
|
2
|
+
import { FIELDS, Port66, TOOLS, walletFromPrivateKey } from "@port66/sdk";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
const ShippingAddress = z.object({
|
|
5
|
+
name: z.string().min(1).describe("Recipient's full name"),
|
|
6
|
+
line1: z.string().min(1).describe("Street address"),
|
|
7
|
+
line2: z.string().optional().describe("Apartment, suite, etc."),
|
|
8
|
+
city: z.string().min(1),
|
|
9
|
+
region: z.string().optional().describe("State, province or region"),
|
|
10
|
+
postal: z.string().min(1).describe("Postal or ZIP code"),
|
|
11
|
+
country: z.string().min(1).describe("Country, e.g. 'US' or 'Canada'"),
|
|
12
|
+
phone: z.string().optional(),
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* Port66 tools for LangChain and LangGraph agents: search listings and get a
|
|
16
|
+
* listing (free), and buy a listing in one x402 request with USDC on Base.
|
|
17
|
+
* Buying stays off until `maxPurchaseUsd` is set and a `wallet` is given.
|
|
18
|
+
*/
|
|
19
|
+
export function port66Tools(options = {}) {
|
|
20
|
+
const { wallet, ...config } = options;
|
|
21
|
+
const port66 = new Port66(config);
|
|
22
|
+
const agentWallet = typeof wallet === "string" ? walletFromPrivateKey(wallet) : wallet;
|
|
23
|
+
const search = tool((args) => port66.search(args), {
|
|
24
|
+
...TOOLS.search,
|
|
25
|
+
schema: z.object({
|
|
26
|
+
query: z.string().optional().describe(FIELDS.query),
|
|
27
|
+
brand: z.string().optional().describe(FIELDS.brand),
|
|
28
|
+
category: z.string().optional().describe(FIELDS.category),
|
|
29
|
+
size: z.string().optional().describe(FIELDS.size),
|
|
30
|
+
maxPriceUsd: z.number().positive().optional().describe(FIELDS.searchMaxPriceUsd),
|
|
31
|
+
sort: z.enum(["newest", "price_asc", "price_desc"]).optional().describe(FIELDS.sort),
|
|
32
|
+
limit: z.number().int().min(1).max(20).optional().describe(FIELDS.limit),
|
|
33
|
+
}),
|
|
34
|
+
});
|
|
35
|
+
const getListing = tool(({ id }) => port66.getListing(id), {
|
|
36
|
+
...TOOLS.get,
|
|
37
|
+
schema: z.object({ id: z.string().min(1).describe(FIELDS.id) }),
|
|
38
|
+
});
|
|
39
|
+
const buy = tool((args) => port66.buy(agentWallet, args), {
|
|
40
|
+
...TOOLS.buy,
|
|
41
|
+
schema: z.object({
|
|
42
|
+
id: z.string().min(1).describe(FIELDS.id),
|
|
43
|
+
maxPriceUsd: z.number().positive().describe(FIELDS.buyMaxPriceUsd),
|
|
44
|
+
shippingAddress: ShippingAddress.describe(FIELDS.shippingAddress),
|
|
45
|
+
}),
|
|
46
|
+
});
|
|
47
|
+
return [search, getListing, buy];
|
|
48
|
+
}
|
|
49
|
+
export { Port66, walletFromPrivateKey } from "@port66/sdk";
|
package/package.json
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@port66/langchain",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "LangChain tools for Port66: search authenticated luxury and collectibles, and buy a listing in one x402 request with USDC on Base",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
12
|
+
"keywords": [
|
|
13
|
+
"langchain",
|
|
14
|
+
"langgraph",
|
|
15
|
+
"tools",
|
|
16
|
+
"port66",
|
|
17
|
+
"x402",
|
|
18
|
+
"ai-agents",
|
|
19
|
+
"marketplace",
|
|
20
|
+
"usdc",
|
|
21
|
+
"base"
|
|
22
|
+
],
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/port66-official/port66",
|
|
27
|
+
"directory": "integrations/langchain"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://port66.xyz/ai",
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"@langchain/core": ">=0.3.0",
|
|
32
|
+
"zod": ">=3.25.0"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@port66/sdk": "^0.1.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@langchain/core": "1.4.2",
|
|
39
|
+
"zod": "^4.1.0",
|
|
40
|
+
"@types/node": "^22.0.0",
|
|
41
|
+
"tsx": "^4.19.2",
|
|
42
|
+
"typescript": "^5.9.3",
|
|
43
|
+
"viem": "^2.38.3"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "tsc -p tsconfig.json",
|
|
47
|
+
"test": "tsx --test test/*.test.ts",
|
|
48
|
+
"typecheck": "tsc --noEmit"
|
|
49
|
+
}
|
|
6
50
|
}
|