@dominusnode/ai-tools 1.0.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 +188 -0
- package/dist/create-tools.d.ts +100 -0
- package/dist/create-tools.d.ts.map +1 -0
- package/dist/create-tools.js +88 -0
- package/dist/create-tools.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/tools.d.ts +86 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +857 -0
- package/dist/tools.js.map +1 -0
- package/package.json +32 -0
package/README.md
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# @dominusnode/ai-tools
|
|
2
|
+
|
|
3
|
+
Vercel AI SDK tools for the [DomiNode](https://dominusnode.com) rotating proxy-as-a-service platform. Gives AI agents the ability to make proxied HTTP requests, check wallet balance, monitor usage, and manage proxy sessions.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @dominusnode/ai-tools ai zod @dominusnode/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
### Next.js Route Handler
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
// app/api/chat/route.ts
|
|
17
|
+
import { streamText } from "ai";
|
|
18
|
+
import { openai } from "@ai-sdk/openai";
|
|
19
|
+
import { createDominusNodeTools } from "@dominusnode/ai-tools";
|
|
20
|
+
|
|
21
|
+
export async function POST(req: Request) {
|
|
22
|
+
const { messages } = await req.json();
|
|
23
|
+
|
|
24
|
+
const tools = await createDominusNodeTools({
|
|
25
|
+
apiKey: process.env.DOMINUSNODE_API_KEY!,
|
|
26
|
+
baseUrl: process.env.DOMINUSNODE_BASE_URL, // optional
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const result = streamText({
|
|
30
|
+
model: openai("gpt-4o"),
|
|
31
|
+
messages,
|
|
32
|
+
tools,
|
|
33
|
+
maxSteps: 5,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return result.toDataStreamResponse();
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Standalone with `generateText`
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { generateText } from "ai";
|
|
44
|
+
import { openai } from "@ai-sdk/openai";
|
|
45
|
+
import { createDominusNodeTools } from "@dominusnode/ai-tools";
|
|
46
|
+
|
|
47
|
+
const tools = await createDominusNodeTools({
|
|
48
|
+
apiKey: "dn_live_your_api_key_here",
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const { text } = await generateText({
|
|
52
|
+
model: openai("gpt-4o"),
|
|
53
|
+
tools,
|
|
54
|
+
maxSteps: 10,
|
|
55
|
+
prompt: "Fetch https://httpbin.org/ip through a US datacenter proxy and tell me the IP",
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
console.log(text);
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Tools
|
|
62
|
+
|
|
63
|
+
### `proxiedFetch`
|
|
64
|
+
|
|
65
|
+
Make HTTP requests through DomiNode's rotating proxy network with geo-targeting support.
|
|
66
|
+
|
|
67
|
+
| Parameter | Type | Required | Description |
|
|
68
|
+
|-------------|-----------------------------------------|----------|----------------------------------------------|
|
|
69
|
+
| `url` | `string` (URL) | Yes | The URL to fetch through the proxy |
|
|
70
|
+
| `method` | `"GET" \| "POST" \| "PUT" \| "DELETE"` | No | HTTP method (default: `GET`) |
|
|
71
|
+
| `country` | `string` (2-letter ISO) | No | Country code for geo-targeting |
|
|
72
|
+
| `proxyType` | `"dc" \| "residential"` | No | Proxy type (default: `dc`) |
|
|
73
|
+
| `headers` | `Record<string, string>` | No | Additional HTTP headers |
|
|
74
|
+
| `body` | `string` | No | Request body for POST/PUT |
|
|
75
|
+
|
|
76
|
+
**Returns:** `{ status, statusText, headers, body, proxyType, country }`
|
|
77
|
+
|
|
78
|
+
**Security:** URLs are validated to prevent SSRF attacks. Blocked targets include localhost, private IP ranges (10.x, 172.16-31.x, 192.168.x), link-local (169.254.x), IPv6 loopback/ULA, and non-HTTP protocols. Response bodies are truncated to 4,000 characters. API keys are scrubbed from error messages.
|
|
79
|
+
|
|
80
|
+
### `checkBalance`
|
|
81
|
+
|
|
82
|
+
Check the current DomiNode wallet balance.
|
|
83
|
+
|
|
84
|
+
**Parameters:** None
|
|
85
|
+
|
|
86
|
+
**Returns:** `{ balanceCents, balanceUsd, currency, lastToppedUp }`
|
|
87
|
+
|
|
88
|
+
### `checkUsage`
|
|
89
|
+
|
|
90
|
+
Check proxy usage statistics for a given time period.
|
|
91
|
+
|
|
92
|
+
| Parameter | Type | Required | Description |
|
|
93
|
+
|-----------|---------------------------------|----------|--------------------------|
|
|
94
|
+
| `period` | `"day" \| "week" \| "month"` | No | Time window for stats |
|
|
95
|
+
|
|
96
|
+
**Returns:** `{ summary: { totalBytes, totalGB, totalCostCents, totalCostUsd, requestCount }, period, recordCount }`
|
|
97
|
+
|
|
98
|
+
### `getProxyConfig`
|
|
99
|
+
|
|
100
|
+
Get proxy endpoint configuration and supported countries.
|
|
101
|
+
|
|
102
|
+
**Parameters:** None
|
|
103
|
+
|
|
104
|
+
**Returns:** `{ endpoints: { http, socks5 }, supportedCountries, blockedCountries, geoTargeting }`
|
|
105
|
+
|
|
106
|
+
### `listSessions`
|
|
107
|
+
|
|
108
|
+
List all active proxy sessions.
|
|
109
|
+
|
|
110
|
+
**Parameters:** None
|
|
111
|
+
|
|
112
|
+
**Returns:** `{ sessions: [{ id, startedAt, status }], count }`
|
|
113
|
+
|
|
114
|
+
## Advanced Usage
|
|
115
|
+
|
|
116
|
+
### Using an Existing Client
|
|
117
|
+
|
|
118
|
+
If you already manage a `DominusNodeClient` instance:
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
import { DominusNodeClient } from "@dominusnode/sdk";
|
|
122
|
+
import { createDominusNodeToolsFromClient } from "@dominusnode/ai-tools";
|
|
123
|
+
|
|
124
|
+
const client = new DominusNodeClient({ baseUrl: "http://localhost:3000" });
|
|
125
|
+
await client.connectWithKey("dn_live_your_key");
|
|
126
|
+
|
|
127
|
+
const tools = createDominusNodeToolsFromClient(client, "dn_live_your_key");
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Using Individual Tool Creators
|
|
131
|
+
|
|
132
|
+
For fine-grained control, import individual tool factory functions:
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
import {
|
|
136
|
+
createProxiedFetchTool,
|
|
137
|
+
createCheckBalanceTool,
|
|
138
|
+
} from "@dominusnode/ai-tools";
|
|
139
|
+
import { DominusNodeClient } from "@dominusnode/sdk";
|
|
140
|
+
|
|
141
|
+
const client = new DominusNodeClient();
|
|
142
|
+
await client.connectWithKey("dn_live_your_key");
|
|
143
|
+
|
|
144
|
+
// Only expose the tools you need
|
|
145
|
+
const tools = {
|
|
146
|
+
proxiedFetch: createProxiedFetchTool(client, "dn_live_your_key"),
|
|
147
|
+
checkBalance: createCheckBalanceTool(client),
|
|
148
|
+
};
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### With Anthropic Claude
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
import { generateText } from "ai";
|
|
155
|
+
import { anthropic } from "@ai-sdk/anthropic";
|
|
156
|
+
import { createDominusNodeTools } from "@dominusnode/ai-tools";
|
|
157
|
+
|
|
158
|
+
const tools = await createDominusNodeTools({
|
|
159
|
+
apiKey: process.env.DOMINUSNODE_API_KEY!,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
const { text } = await generateText({
|
|
163
|
+
model: anthropic("claude-sonnet-4-20250514"),
|
|
164
|
+
tools,
|
|
165
|
+
maxSteps: 5,
|
|
166
|
+
prompt: "Check my balance, then fetch https://example.com through a German proxy",
|
|
167
|
+
});
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Environment Variables
|
|
171
|
+
|
|
172
|
+
| Variable | Description | Default |
|
|
173
|
+
|-------------------------|---------------------------------------|---------------------------------|
|
|
174
|
+
| `DOMINUSNODE_API_KEY` | DomiNode API key | Required |
|
|
175
|
+
| `DOMINUSNODE_BASE_URL` | DomiNode API base URL | `https://api.dominusnode.com` |
|
|
176
|
+
|
|
177
|
+
## Pricing
|
|
178
|
+
|
|
179
|
+
Proxy usage is billed from your DomiNode wallet:
|
|
180
|
+
|
|
181
|
+
- **Datacenter (dc):** $3.00/GB
|
|
182
|
+
- **Residential:** $5.00/GB
|
|
183
|
+
|
|
184
|
+
Check your balance with the `checkBalance` tool before heavy usage.
|
|
185
|
+
|
|
186
|
+
## License
|
|
187
|
+
|
|
188
|
+
MIT
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { DominusNodeClient } from "@dominusnode/sdk";
|
|
2
|
+
import { createProxiedFetchTool, createCheckBalanceTool, createCheckUsageTool, createGetProxyConfigTool, createListSessionsTool, createTopupPaypalTool, createX402InfoTool, createCreateAgenticWalletTool, createFundAgenticWalletTool, createAgenticWalletBalanceTool, createListAgenticWalletsTool, createAgenticTransactionsTool, createFreezeAgenticWalletTool, createUnfreezeAgenticWalletTool, createDeleteAgenticWalletTool, createUpdateWalletPolicyTool } from "./tools.js";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for creating DomiNode AI tools.
|
|
5
|
+
*/
|
|
6
|
+
export interface DominusNodeToolsConfig {
|
|
7
|
+
/**
|
|
8
|
+
* DomiNode API key for authentication.
|
|
9
|
+
* Must start with "dn_live_" or "dn_test_".
|
|
10
|
+
*/
|
|
11
|
+
apiKey: string;
|
|
12
|
+
/**
|
|
13
|
+
* Base URL for the DomiNode API.
|
|
14
|
+
* @default "https://api.dominusnode.com"
|
|
15
|
+
*/
|
|
16
|
+
baseUrl?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Proxy host override.
|
|
19
|
+
* @default "proxy.dominusnode.com"
|
|
20
|
+
*/
|
|
21
|
+
proxyHost?: string;
|
|
22
|
+
/**
|
|
23
|
+
* HTTP proxy port override.
|
|
24
|
+
* @default 8080
|
|
25
|
+
*/
|
|
26
|
+
httpProxyPort?: number;
|
|
27
|
+
/**
|
|
28
|
+
* SOCKS5 proxy port override.
|
|
29
|
+
* @default 1080
|
|
30
|
+
*/
|
|
31
|
+
socks5ProxyPort?: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The set of DomiNode tools for use with the Vercel AI SDK.
|
|
35
|
+
*/
|
|
36
|
+
export interface DominusNodeTools {
|
|
37
|
+
/** Make HTTP requests through DomiNode's rotating proxy network. */
|
|
38
|
+
proxiedFetch: ReturnType<typeof createProxiedFetchTool>;
|
|
39
|
+
/** Check the current wallet balance. */
|
|
40
|
+
checkBalance: ReturnType<typeof createCheckBalanceTool>;
|
|
41
|
+
/** Check proxy usage statistics for a given period. */
|
|
42
|
+
checkUsage: ReturnType<typeof createCheckUsageTool>;
|
|
43
|
+
/** Get proxy endpoint configuration and supported countries. */
|
|
44
|
+
getProxyConfig: ReturnType<typeof createGetProxyConfigTool>;
|
|
45
|
+
/** List all active proxy sessions. */
|
|
46
|
+
listSessions: ReturnType<typeof createListSessionsTool>;
|
|
47
|
+
/** Top up wallet balance via PayPal. */
|
|
48
|
+
topupPaypal: ReturnType<typeof createTopupPaypalTool>;
|
|
49
|
+
/** Get x402 micropayment protocol information. */
|
|
50
|
+
x402Info: ReturnType<typeof createX402InfoTool>;
|
|
51
|
+
/** Create a new agentic sub-wallet. */
|
|
52
|
+
createAgenticWallet: ReturnType<typeof createCreateAgenticWalletTool>;
|
|
53
|
+
/** Fund an agentic sub-wallet from the main wallet. */
|
|
54
|
+
fundAgenticWallet: ReturnType<typeof createFundAgenticWalletTool>;
|
|
55
|
+
/** Check the balance of an agentic sub-wallet. */
|
|
56
|
+
agenticWalletBalance: ReturnType<typeof createAgenticWalletBalanceTool>;
|
|
57
|
+
/** List all agentic sub-wallets. */
|
|
58
|
+
listAgenticWallets: ReturnType<typeof createListAgenticWalletsTool>;
|
|
59
|
+
/** List transactions for an agentic sub-wallet. */
|
|
60
|
+
agenticTransactions: ReturnType<typeof createAgenticTransactionsTool>;
|
|
61
|
+
/** Freeze an agentic sub-wallet. */
|
|
62
|
+
freezeAgenticWallet: ReturnType<typeof createFreezeAgenticWalletTool>;
|
|
63
|
+
/** Unfreeze an agentic sub-wallet. */
|
|
64
|
+
unfreezeAgenticWallet: ReturnType<typeof createUnfreezeAgenticWalletTool>;
|
|
65
|
+
/** Delete an agentic sub-wallet. */
|
|
66
|
+
deleteAgenticWallet: ReturnType<typeof createDeleteAgenticWalletTool>;
|
|
67
|
+
/** Update the policy of an agentic sub-wallet. */
|
|
68
|
+
updateWalletPolicy: ReturnType<typeof createUpdateWalletPolicyTool>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Create a set of Vercel AI SDK tools for interacting with the DomiNode
|
|
72
|
+
* rotating proxy service.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* import { createDominusNodeTools } from "@dominusnode/ai-tools";
|
|
77
|
+
* import { generateText } from "ai";
|
|
78
|
+
* import { openai } from "@ai-sdk/openai";
|
|
79
|
+
*
|
|
80
|
+
* const tools = await createDominusNodeTools({
|
|
81
|
+
* apiKey: process.env.DOMINUSNODE_API_KEY!,
|
|
82
|
+
* });
|
|
83
|
+
*
|
|
84
|
+
* const result = await generateText({
|
|
85
|
+
* model: openai("gpt-4o"),
|
|
86
|
+
* tools,
|
|
87
|
+
* prompt: "Check my proxy balance and fetch https://httpbin.org/ip through a US proxy",
|
|
88
|
+
* });
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export declare function createDominusNodeTools(config: DominusNodeToolsConfig): Promise<DominusNodeTools>;
|
|
92
|
+
/**
|
|
93
|
+
* Create DomiNode AI tools from an already-authenticated client instance.
|
|
94
|
+
* Use this when you manage the DominusNodeClient lifecycle yourself.
|
|
95
|
+
*
|
|
96
|
+
* @param client - An already-authenticated DominusNodeClient.
|
|
97
|
+
* @param apiKey - The API key (needed for building proxy URLs).
|
|
98
|
+
*/
|
|
99
|
+
export declare function createDominusNodeToolsFromClient(client: DominusNodeClient, apiKey: string): DominusNodeTools;
|
|
100
|
+
//# sourceMappingURL=create-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-tools.d.ts","sourceRoot":"","sources":["../src/create-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EAClB,6BAA6B,EAC7B,2BAA2B,EAC3B,8BAA8B,EAC9B,4BAA4B,EAC5B,6BAA6B,EAC7B,6BAA6B,EAC7B,+BAA+B,EAC/B,6BAA6B,EAC7B,4BAA4B,EAC7B,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oEAAoE;IACpE,YAAY,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;IACxD,wCAAwC;IACxC,YAAY,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;IACxD,uDAAuD;IACvD,UAAU,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC;IACpD,gEAAgE;IAChE,cAAc,EAAE,UAAU,CAAC,OAAO,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edFetchTool, createCheckBalanceTool, createCheckUsageTool, createGetProxyConfigTool, createListSessionsTool, createTopupPaypalTool, createX402InfoTool, createCreateAgenticWalletTool, createFundAgenticWalletTool, createAgenticWalletBalanceTool, createListAgenticWalletsTool, createAgenticTransactionsTool, createFreezeAgenticWalletTool, createUnfreezeAgenticWalletTool, createDeleteAgenticWalletTool, createUpdateWalletPolicyTool, } from "./tools.js";
|
|
3
|
+
/**
|
|
4
|
+
* Create a set of Vercel AI SDK tools for interacting with the DomiNode
|
|
5
|
+
* rotating proxy service.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createDominusNodeTools } from "@dominusnode/ai-tools";
|
|
10
|
+
* import { generateText } from "ai";
|
|
11
|
+
* import { openai } from "@ai-sdk/openai";
|
|
12
|
+
*
|
|
13
|
+
* const tools = await createDominusNodeTools({
|
|
14
|
+
* apiKey: process.env.DOMINUSNODE_API_KEY!,
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* const result = await generateText({
|
|
18
|
+
* model: openai("gpt-4o"),
|
|
19
|
+
* tools,
|
|
20
|
+
* prompt: "Check my proxy balance and fetch https://httpbin.org/ip through a US proxy",
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export async function createDominusNodeTools(config) {
|
|
25
|
+
// Validate API key format
|
|
26
|
+
if (!config.apiKey || typeof config.apiKey !== "string") {
|
|
27
|
+
throw new Error("apiKey is required and must be a non-empty string");
|
|
28
|
+
}
|
|
29
|
+
if (!config.apiKey.startsWith("dn_live_") && !config.apiKey.startsWith("dn_test_")) {
|
|
30
|
+
throw new Error('apiKey must start with "dn_live_" or "dn_test_"');
|
|
31
|
+
}
|
|
32
|
+
// Create and authenticate the client
|
|
33
|
+
const client = new DominusNodeClient({
|
|
34
|
+
apiKey: config.apiKey,
|
|
35
|
+
baseUrl: config.baseUrl,
|
|
36
|
+
proxyHost: config.proxyHost,
|
|
37
|
+
});
|
|
38
|
+
await client.connectWithKey(config.apiKey);
|
|
39
|
+
return {
|
|
40
|
+
proxiedFetch: createProxiedFetchTool(client, config.apiKey),
|
|
41
|
+
checkBalance: createCheckBalanceTool(client),
|
|
42
|
+
checkUsage: createCheckUsageTool(client),
|
|
43
|
+
getProxyConfig: createGetProxyConfigTool(client),
|
|
44
|
+
listSessions: createListSessionsTool(client),
|
|
45
|
+
topupPaypal: createTopupPaypalTool(client),
|
|
46
|
+
x402Info: createX402InfoTool(client),
|
|
47
|
+
createAgenticWallet: createCreateAgenticWalletTool(client),
|
|
48
|
+
fundAgenticWallet: createFundAgenticWalletTool(client),
|
|
49
|
+
agenticWalletBalance: createAgenticWalletBalanceTool(client),
|
|
50
|
+
listAgenticWallets: createListAgenticWalletsTool(client),
|
|
51
|
+
agenticTransactions: createAgenticTransactionsTool(client),
|
|
52
|
+
freezeAgenticWallet: createFreezeAgenticWalletTool(client),
|
|
53
|
+
unfreezeAgenticWallet: createUnfreezeAgenticWalletTool(client),
|
|
54
|
+
deleteAgenticWallet: createDeleteAgenticWalletTool(client),
|
|
55
|
+
updateWalletPolicy: createUpdateWalletPolicyTool(client),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Create DomiNode AI tools from an already-authenticated client instance.
|
|
60
|
+
* Use this when you manage the DominusNodeClient lifecycle yourself.
|
|
61
|
+
*
|
|
62
|
+
* @param client - An already-authenticated DominusNodeClient.
|
|
63
|
+
* @param apiKey - The API key (needed for building proxy URLs).
|
|
64
|
+
*/
|
|
65
|
+
export function createDominusNodeToolsFromClient(client, apiKey) {
|
|
66
|
+
if (!apiKey || typeof apiKey !== "string") {
|
|
67
|
+
throw new Error("apiKey is required and must be a non-empty string");
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
proxiedFetch: createProxiedFetchTool(client, apiKey),
|
|
71
|
+
checkBalance: createCheckBalanceTool(client),
|
|
72
|
+
checkUsage: createCheckUsageTool(client),
|
|
73
|
+
getProxyConfig: createGetProxyConfigTool(client),
|
|
74
|
+
listSessions: createListSessionsTool(client),
|
|
75
|
+
topupPaypal: createTopupPaypalTool(client),
|
|
76
|
+
x402Info: createX402InfoTool(client),
|
|
77
|
+
createAgenticWallet: createCreateAgenticWalletTool(client),
|
|
78
|
+
fundAgenticWallet: createFundAgenticWalletTool(client),
|
|
79
|
+
agenticWalletBalance: createAgenticWalletBalanceTool(client),
|
|
80
|
+
listAgenticWallets: createListAgenticWalletsTool(client),
|
|
81
|
+
agenticTransactions: createAgenticTransactionsTool(client),
|
|
82
|
+
freezeAgenticWallet: createFreezeAgenticWalletTool(client),
|
|
83
|
+
unfreezeAgenticWallet: createUnfreezeAgenticWalletTool(client),
|
|
84
|
+
deleteAgenticWallet: createDeleteAgenticWalletTool(client),
|
|
85
|
+
updateWalletPolicy: createUpdateWalletPolicyTool(client),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=create-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-tools.js","sourceRoot":"","sources":["../src/create-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EAClB,6BAA6B,EAC7B,2BAA2B,EAC3B,8BAA8B,EAC9B,4BAA4B,EAC5B,6BAA6B,EAC7B,6BAA6B,EAC7B,+BAA+B,EAC/B,6BAA6B,EAC7B,4BAA4B,GAC7B,MAAM,YAAY,CAAC;AA2EpB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,MAA8B;IAE9B,0BAA0B;IAC1B,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,EAAE,CA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,CAAC,MAAM,CAAC;QAC1D,kBAAkB,EAAE,4BAA4B,CAAC,MAAM,CAAC;KACzD,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gCAAgC,CAC9C,MAAyB,EACzB,MAAc;IAEd,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IAED,OAAO;QACL,YAAY,EAAE,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC;QACpD,YAAY,EAAE,sBAAsB,CAAC,MAAM,CAAC;QAC5C,UAAU,EAAE,oBAAoB,CAAC,MAAM,CAAC;QACxC,cAAc,EAAE,wBAAwB,CAAC,MAAM,CAAC;QAChD,YAAY,EAAE,sBAAsB,CAAC,MAAM,CAAC;QAC5C,WAAW,EAAE,qBAAqB,CAAC,MAAM,CAAC;QAC1C,QAAQ,EAAE,kBAAkB,CAAC,MAAM,CAAC;QACpC,mBAAmB,EAAE,6BAA6B,CAAC,MAAM,CAAC;QAC1D,iBAAiB,EAAE,2BAA2B,CAAC,MAAM,CAAC;QACtD,oBAAoB,EAAE,8BAA8B,CAAC,MAAM,CAAC;QAC5D,kBAAkB,EAAE,4BAA4B,CAAC,MAAM,CAAC;QACxD,mBAAmB,EAAE,6BAA6B,CAAC,MAAM,CAAC;QAC1D,mBAAmB,EAAE,6BAA6B,CAAC,MAAM,CAAC;QAC1D,qBAAqB,EAAE,+BAA+B,CAAC,MAAM,CAAC;QAC9D,mBAAmB,EAAE,6BAA6B,CAAC,MAAM,CAAC;QAC1D,kBAAkB,EAAE,4BAA4B,CAAC,MAAM,CAAC;KACzD,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createDominusNodeTools, createDominusNodeToolsFromClient, } from "./create-tools.js";
|
|
2
|
+
export type { DominusNodeToolsConfig, DominusNodeTools, } from "./create-tools.js";
|
|
3
|
+
export { createProxiedFetchTool, createCheckBalanceTool, createCheckUsageTool, createGetProxyConfigTool, createListSessionsTool, createTopupPaypalTool, createX402InfoTool, createCreateAgenticWalletTool, createFundAgenticWalletTool, createAgenticWalletBalanceTool, createListAgenticWalletsTool, createAgenticTransactionsTool, createFreezeAgenticWalletTool, createUnfreezeAgenticWalletTool, createDeleteAgenticWalletTool, createUpdateWalletPolicyTool, } from "./tools.js";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,EACtB,gCAAgC,GACjC,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EAClB,6BAA6B,EAC7B,2BAA2B,EAC3B,8BAA8B,EAC9B,4BAA4B,EAC5B,6BAA6B,EAC7B,6BAA6B,EAC7B,+BAA+B,EAC/B,6BAA6B,EAC7B,4BAA4B,GAC7B,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Factory functions
|
|
2
|
+
export { createDominusNodeTools, createDominusNodeToolsFromClient, } from "./create-tools.js";
|
|
3
|
+
// Individual tool creators (for advanced use cases)
|
|
4
|
+
export { createProxiedFetchTool, createCheckBalanceTool, createCheckUsageTool, createGetProxyConfigTool, createListSessionsTool, createTopupPaypalTool, createX402InfoTool, createCreateAgenticWalletTool, createFundAgenticWalletTool, createAgenticWalletBalanceTool, createListAgenticWalletsTool, createAgenticTransactionsTool, createFreezeAgenticWalletTool, createUnfreezeAgenticWalletTool, createDeleteAgenticWalletTool, createUpdateWalletPolicyTool, } from "./tools.js";
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,OAAO,EACL,sBAAsB,EACtB,gCAAgC,GACjC,MAAM,mBAAmB,CAAC;AAM3B,oDAAoD;AACpD,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EAClB,6BAA6B,EAC7B,2BAA2B,EAC3B,8BAA8B,EAC9B,4BAA4B,EAC5B,6BAA6B,EAC7B,6BAA6B,EAC7B,+BAA+B,EAC/B,6BAA6B,EAC7B,4BAA4B,GAC7B,MAAM,YAAY,CAAC"}
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { DominusNodeClient } from "@dominusnode/sdk";
|
|
2
|
+
/** RFC-1918, loopback, link-local, and other non-routable CIDRs. */
|
|
3
|
+
declare function isPrivateIp(hostname: string): boolean;
|
|
4
|
+
/** Validate a URL is safe to fetch through the proxy. */
|
|
5
|
+
declare function validateUrl(urlStr: string): {
|
|
6
|
+
valid: true;
|
|
7
|
+
url: URL;
|
|
8
|
+
} | {
|
|
9
|
+
valid: false;
|
|
10
|
+
error: string;
|
|
11
|
+
};
|
|
12
|
+
/** Truncate a string and append a notice if it exceeds the limit. */
|
|
13
|
+
declare function truncateBody(body: string): string;
|
|
14
|
+
declare function filterHeaders(headers: Record<string, string>): Record<string, string>;
|
|
15
|
+
declare const UUID_RE: RegExp;
|
|
16
|
+
declare const DOMAIN_RE: RegExp;
|
|
17
|
+
/**
|
|
18
|
+
* Creates the `proxiedFetch` tool that makes HTTP requests through DomiNode's
|
|
19
|
+
* rotating proxy network.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createProxiedFetchTool(client: DominusNodeClient, apiKey: string): any;
|
|
22
|
+
/**
|
|
23
|
+
* Creates the `checkBalance` tool that retrieves the current wallet balance.
|
|
24
|
+
*/
|
|
25
|
+
export declare function createCheckBalanceTool(client: DominusNodeClient): any;
|
|
26
|
+
/**
|
|
27
|
+
* Creates the `checkUsage` tool that retrieves usage statistics.
|
|
28
|
+
*/
|
|
29
|
+
export declare function createCheckUsageTool(client: DominusNodeClient): any;
|
|
30
|
+
/**
|
|
31
|
+
* Creates the `getProxyConfig` tool that retrieves proxy endpoint configuration.
|
|
32
|
+
*/
|
|
33
|
+
export declare function createGetProxyConfigTool(client: DominusNodeClient): any;
|
|
34
|
+
/**
|
|
35
|
+
* Creates the `listSessions` tool that lists active proxy sessions.
|
|
36
|
+
*/
|
|
37
|
+
export declare function createListSessionsTool(client: DominusNodeClient): any;
|
|
38
|
+
/**
|
|
39
|
+
* Creates the `topupPaypal` tool that initiates a PayPal wallet top-up.
|
|
40
|
+
*/
|
|
41
|
+
export declare function createTopupPaypalTool(client: DominusNodeClient): any;
|
|
42
|
+
/**
|
|
43
|
+
* Creates the `x402Info` tool that retrieves x402 micropayment protocol information.
|
|
44
|
+
*/
|
|
45
|
+
export declare function createX402InfoTool(client: DominusNodeClient): any;
|
|
46
|
+
/** Make an authenticated JSON request to the DomiNode REST API. */
|
|
47
|
+
declare function apiRequest(client: DominusNodeClient, method: "GET" | "POST" | "DELETE" | "PATCH", path: string, body?: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a tool to create a new agentic sub-wallet with a spending limit.
|
|
50
|
+
*/
|
|
51
|
+
export declare function createCreateAgenticWalletTool(client: DominusNodeClient): any;
|
|
52
|
+
/**
|
|
53
|
+
* Creates a tool to transfer funds from the main wallet to an agentic sub-wallet.
|
|
54
|
+
*/
|
|
55
|
+
export declare function createFundAgenticWalletTool(client: DominusNodeClient): any;
|
|
56
|
+
/**
|
|
57
|
+
* Creates a tool to check the balance and details of an agentic sub-wallet.
|
|
58
|
+
*/
|
|
59
|
+
export declare function createAgenticWalletBalanceTool(client: DominusNodeClient): any;
|
|
60
|
+
/**
|
|
61
|
+
* Creates a tool to list all agentic sub-wallets for the current user.
|
|
62
|
+
*/
|
|
63
|
+
export declare function createListAgenticWalletsTool(client: DominusNodeClient): any;
|
|
64
|
+
/**
|
|
65
|
+
* Creates a tool to list recent transactions for an agentic sub-wallet.
|
|
66
|
+
*/
|
|
67
|
+
export declare function createAgenticTransactionsTool(client: DominusNodeClient): any;
|
|
68
|
+
/**
|
|
69
|
+
* Creates a tool to freeze an agentic sub-wallet to prevent further spending.
|
|
70
|
+
*/
|
|
71
|
+
export declare function createFreezeAgenticWalletTool(client: DominusNodeClient): any;
|
|
72
|
+
/**
|
|
73
|
+
* Creates a tool to unfreeze a previously frozen agentic sub-wallet.
|
|
74
|
+
*/
|
|
75
|
+
export declare function createUnfreezeAgenticWalletTool(client: DominusNodeClient): any;
|
|
76
|
+
/**
|
|
77
|
+
* Creates a tool to delete an agentic sub-wallet. Must be active (not frozen).
|
|
78
|
+
* Remaining balance returns to main wallet.
|
|
79
|
+
*/
|
|
80
|
+
export declare function createDeleteAgenticWalletTool(client: DominusNodeClient): any;
|
|
81
|
+
/**
|
|
82
|
+
* Creates a tool to update the policy (daily limit, allowed domains) of an agentic sub-wallet.
|
|
83
|
+
*/
|
|
84
|
+
export declare function createUpdateWalletPolicyTool(client: DominusNodeClient): any;
|
|
85
|
+
export { validateUrl, isPrivateIp, truncateBody, filterHeaders, apiRequest, UUID_RE, DOMAIN_RE };
|
|
86
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAM1D,oEAAoE;AACpE,iBAAS,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAoD9C;AAED,yDA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