@dominusnode/gemini-functions 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Dominus Node
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,234 @@
1
+ # DomiNode Google Gemini / Vertex AI Function Declarations
2
+
3
+ Gemini-format function declarations and handler implementations for the DomiNode rotating proxy-as-a-service platform. These declarations allow Google Gemini and Vertex AI models to interact with DomiNode's proxy network, wallet, agentic wallet, and team APIs via function calling.
4
+
5
+ ## What This Is
6
+
7
+ This directory contains:
8
+
9
+ | File | Description |
10
+ |------|-------------|
11
+ | `functions.json` | Array of 22 Gemini `FunctionDeclaration` objects |
12
+ | `handler.ts` | TypeScript handler that dispatches function calls to the DomiNode API |
13
+ | `handler.py` | Python handler that dispatches function calls to the DomiNode API |
14
+
15
+ The function declarations follow the [Gemini function calling specification](https://ai.google.dev/docs/function_calling), using uppercase types (`STRING`, `INTEGER`, `OBJECT`, `BOOLEAN`, `ARRAY`) and embedding constraints in description text rather than using JSON Schema keywords like `minimum`, `maximum`, `enum`, or `default`.
16
+
17
+ ## Available Functions (22)
18
+
19
+ | Function | Description | Auth Required |
20
+ |----------|-------------|---------------|
21
+ | `dominusnode_proxied_fetch` | Make an HTTP request through DomiNode's rotating proxy network | Yes |
22
+ | `dominusnode_check_balance` | Check wallet balance (cents, USD, currency) | Yes |
23
+ | `dominusnode_check_usage` | Check usage stats for a time period (day/week/month) | Yes |
24
+ | `dominusnode_get_proxy_config` | Get proxy endpoints, supported countries, geo-targeting info | Yes |
25
+ | `dominusnode_list_sessions` | List currently active proxy sessions | Yes |
26
+ | `dominusnode_create_agentic_wallet` | Create a sub-wallet for an AI agent with spending limits | Yes |
27
+ | `dominusnode_fund_agentic_wallet` | Transfer funds from main wallet to an agentic wallet | Yes |
28
+ | `dominusnode_agentic_wallet_balance` | Check an agentic wallet's balance and status | Yes |
29
+ | `dominusnode_list_agentic_wallets` | List all agentic wallets | Yes |
30
+ | `dominusnode_agentic_transactions` | Get agentic wallet transaction history | Yes |
31
+ | `dominusnode_freeze_agentic_wallet` | Freeze an agentic wallet | Yes |
32
+ | `dominusnode_unfreeze_agentic_wallet` | Unfreeze an agentic wallet | Yes |
33
+ | `dominusnode_delete_agentic_wallet` | Delete an agentic wallet (refunds balance) | Yes |
34
+ | `dominusnode_create_team` | Create a team for shared proxy billing | Yes |
35
+ | `dominusnode_list_teams` | List teams you belong to | Yes |
36
+ | `dominusnode_team_details` | Get team details | Yes |
37
+ | `dominusnode_team_fund` | Fund a team wallet | Yes |
38
+ | `dominusnode_team_create_key` | Create a shared team API key | Yes |
39
+ | `dominusnode_team_usage` | Get team wallet transaction history | Yes |
40
+ | `dominusnode_update_team` | Update team settings | Yes |
41
+ | `dominusnode_update_team_member_role` | Update a team member's role | Yes |
42
+ | `dominusnode_topup_paypal` | Create a PayPal wallet top-up session | Yes |
43
+
44
+ ## Usage with Google Gemini (Python)
45
+
46
+ ```python
47
+ import json
48
+ import google.generativeai as genai
49
+ from handler import create_dominusnode_function_handler
50
+
51
+ # Load Gemini function declarations
52
+ with open("functions.json") as f:
53
+ declarations = json.load(f)
54
+
55
+ # Create the DomiNode handler
56
+ dominusnode = create_dominusnode_function_handler(
57
+ api_key="dn_live_your_api_key_here",
58
+ base_url="https://api.dominusnode.com",
59
+ )
60
+
61
+ # Configure Gemini with function declarations
62
+ genai.configure(api_key="YOUR_GEMINI_API_KEY")
63
+ model = genai.GenerativeModel(
64
+ "gemini-2.0-flash",
65
+ tools=[{"function_declarations": declarations}],
66
+ )
67
+
68
+ # Start a chat
69
+ chat = model.start_chat()
70
+ response = chat.send_message("What is my DomiNode proxy balance?")
71
+
72
+ # Handle function calls
73
+ for part in response.parts:
74
+ if fn := part.function_call:
75
+ result = await dominusnode(fn.name, dict(fn.args))
76
+ response = chat.send_message(
77
+ genai.protos.Content(
78
+ parts=[
79
+ genai.protos.Part(
80
+ function_response=genai.protos.FunctionResponse(
81
+ name=fn.name,
82
+ response={"result": json.loads(result)},
83
+ )
84
+ )
85
+ ]
86
+ )
87
+ )
88
+ print(response.text)
89
+ ```
90
+
91
+ ## Usage with Vertex AI (Python)
92
+
93
+ ```python
94
+ import json
95
+ import vertexai
96
+ from vertexai.generative_models import GenerativeModel, Tool, FunctionDeclaration
97
+ from handler import create_dominusnode_function_handler
98
+
99
+ # Load function declarations
100
+ with open("functions.json") as f:
101
+ declarations = json.load(f)
102
+
103
+ # Convert to Vertex AI FunctionDeclaration objects
104
+ vertex_declarations = [
105
+ FunctionDeclaration(
106
+ name=d["name"],
107
+ description=d["description"],
108
+ parameters=d["parameters"],
109
+ )
110
+ for d in declarations
111
+ ]
112
+
113
+ # Create handler and model
114
+ dominusnode = create_dominusnode_function_handler(api_key="dn_live_your_key")
115
+ vertexai.init(project="your-project", location="us-central1")
116
+ model = GenerativeModel(
117
+ "gemini-2.0-flash",
118
+ tools=[Tool(function_declarations=vertex_declarations)],
119
+ )
120
+
121
+ # Use in a chat session
122
+ chat = model.start_chat()
123
+ response = chat.send_message("Check my proxy usage this week")
124
+ # ... handle function calls as above
125
+ ```
126
+
127
+ ## Usage with TypeScript / Node.js
128
+
129
+ ```typescript
130
+ import { readFileSync } from "fs";
131
+ import { createDominusNodeFunctionHandler } from "./handler";
132
+
133
+ // Load function declarations
134
+ const declarations = JSON.parse(readFileSync("functions.json", "utf-8"));
135
+
136
+ // Create the handler
137
+ const handler = createDominusNodeFunctionHandler({
138
+ apiKey: "dn_live_your_api_key_here",
139
+ baseUrl: "https://api.dominusnode.com",
140
+ });
141
+
142
+ // Example: direct function call
143
+ const balance = await handler("dominusnode_check_balance", {});
144
+ console.log(JSON.parse(balance));
145
+
146
+ // Example: proxied fetch with geo-targeting
147
+ const fetchResult = await handler("dominusnode_proxied_fetch", {
148
+ url: "https://httpbin.org/ip",
149
+ method: "GET",
150
+ country: "US",
151
+ proxy_type: "residential",
152
+ });
153
+ console.log(JSON.parse(fetchResult));
154
+
155
+ // Example: PayPal top-up
156
+ const topup = await handler("dominusnode_topup_paypal", {
157
+ amount_cents: 5000, // $50.00
158
+ });
159
+ console.log(JSON.parse(topup));
160
+ ```
161
+
162
+ ## Gemini Schema Restrictions
163
+
164
+ Gemini function declarations differ from OpenAI's JSON Schema format:
165
+
166
+ | Feature | OpenAI/JSON Schema | Gemini |
167
+ |---------|-------------------|--------|
168
+ | Type names | `"string"`, `"integer"` | `"STRING"`, `"INTEGER"` |
169
+ | `default` | Supported | Not supported -- moved to description |
170
+ | `minimum`/`maximum` | Supported | Not supported -- moved to description |
171
+ | `enum` | Supported | Not supported -- listed in description |
172
+ | `minLength`/`maxLength` | Supported | Not supported -- moved to description |
173
+ | `additionalProperties` | Supported | Not supported -- omitted |
174
+
175
+ All constraints are expressed in the `description` field text for Gemini compatibility.
176
+
177
+ ## Security
178
+
179
+ ### SSRF Prevention
180
+
181
+ Both handlers include comprehensive SSRF prevention that blocks:
182
+
183
+ - **Private IP ranges**: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 127.0.0.0/8, 0.0.0.0/8, 169.254.0.0/16, 100.64.0.0/10 (CGNAT)
184
+ - **Non-standard IP representations**: Hex (0x7f000001), octal (0177.0.0.1), decimal integer (2130706433)
185
+ - **IPv6 private ranges**: ::1, fc00::/7, fe80::/10, ::ffff:-mapped private IPs
186
+ - **Internal hostnames**: .localhost, .local, .internal, .arpa TLDs
187
+ - **Protocol restriction**: Only http:// and https:// are allowed
188
+ - **DNS rebinding protection**: Resolves hostnames and checks all IPs
189
+
190
+ ### Sanctioned Countries (OFAC)
191
+
192
+ Requests targeting CU, IR, KP, RU, SY are blocked at the handler level.
193
+
194
+ ### Input Validation
195
+
196
+ - Integer overflow protection: amount/limit values capped at 2,147,483,647
197
+ - Label length validation: max 100 characters
198
+ - Control character blocking in labels and names
199
+ - URL-encoding of path parameters to prevent path traversal
200
+ - Prototype pollution prevention in JSON parsing
201
+ - Response body size limit: 10 MB max
202
+ - HTTP method restriction: only GET, HEAD, OPTIONS for proxied fetch
203
+
204
+ ### Credential Scrubbing
205
+
206
+ API keys (`dn_live_*`, `dn_test_*`) are scrubbed from all error messages returned to the LLM.
207
+
208
+ ## Proxy Pricing
209
+
210
+ | Proxy Type | Price | Best For |
211
+ |------------|-------|----------|
212
+ | Datacenter (`dc`) | $3.00/GB | General scraping, speed-critical tasks |
213
+ | Residential | $5.00/GB | Anti-detection, geo-restricted content |
214
+
215
+ ## Dependencies
216
+
217
+ ### TypeScript Handler
218
+ - Node.js 18+ (uses native `fetch` and `AbortSignal.timeout`)
219
+ - No external dependencies
220
+
221
+ ### Python Handler
222
+ - Python 3.8+
223
+ - `httpx` (`pip install httpx`)
224
+
225
+ ## Related Integrations
226
+
227
+ - `integrations/openai-functions/` -- OpenAI-compatible function schemas (21 functions)
228
+ - `integrations/langchain/` -- LangChain tools integration
229
+ - `integrations/vercel-ai/` -- Vercel AI SDK provider
230
+ - `integrations/crewai/` -- CrewAI tools integration
231
+ - `integrations/openclaw/` -- OpenClaw plugin
232
+ - `packages/mcp-server/` -- Model Context Protocol server (56 tools)
233
+ - `sdks/node/` -- Full Node.js SDK
234
+ - `sdks/python/` -- Full Python SDK
@@ -0,0 +1,80 @@
1
+ /**
2
+ * DomiNode Gemini / Vertex AI function calling handler (TypeScript).
3
+ *
4
+ * Provides a factory function that creates a handler for dispatching
5
+ * Google Gemini function calls to the DomiNode REST API. Works with
6
+ * Gemini, Vertex AI, or any system that uses Gemini-format function
7
+ * declarations.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import { createDominusNodeFunctionHandler } from "./handler";
12
+ *
13
+ * const handler = createDominusNodeFunctionHandler({
14
+ * apiKey: "dn_live_...",
15
+ * baseUrl: "https://api.dominusnode.com",
16
+ * });
17
+ *
18
+ * // Dispatch a function call from a Gemini response
19
+ * const result = await handler("dominusnode_check_balance", {});
20
+ * console.log(result); // JSON string with balance info
21
+ * ```
22
+ *
23
+ * @module
24
+ */
25
+ /**
26
+ * Normalize non-standard IPv4 representations (hex, octal, decimal integer)
27
+ * to standard dotted-decimal to prevent SSRF bypasses like 0x7f000001,
28
+ * 2130706433, or 0177.0.0.1.
29
+ */
30
+ declare function normalizeIpv4(hostname: string): string | null;
31
+ declare function isPrivateIp(hostname: string): boolean;
32
+ /**
33
+ * Validate a URL for safety before sending through the proxy.
34
+ * Blocks private IPs, localhost, internal hostnames, and non-HTTP(S) protocols.
35
+ *
36
+ * @throws {Error} If the URL is invalid or targets a private/blocked address.
37
+ */
38
+ declare function validateUrl(url: string): URL;
39
+ declare function stripDangerousKeys(obj: unknown, depth?: number): void;
40
+ declare function safeJsonParse<T>(text: string): T;
41
+ declare function sanitizeError(message: string): string;
42
+ export interface DominusNodeFunctionConfig {
43
+ /** DomiNode API key (starts with dn_live_ or dn_test_). */
44
+ apiKey: string;
45
+ /** Base URL of the DomiNode REST API. Defaults to https://api.dominusnode.com */
46
+ baseUrl?: string;
47
+ /** Request timeout in milliseconds. Defaults to 30000. */
48
+ timeoutMs?: number;
49
+ }
50
+ /**
51
+ * Handler function type returned by createDominusNodeFunctionHandler.
52
+ * Dispatches function calls to the DomiNode API and returns JSON string results.
53
+ */
54
+ export type FunctionHandler = (name: string, args: Record<string, unknown>) => Promise<string>;
55
+ /**
56
+ * Create a DomiNode function handler for Gemini / Vertex AI function calling.
57
+ *
58
+ * Authenticates using the provided API key, then returns a handler function
59
+ * that dispatches function calls to the appropriate DomiNode REST API endpoint.
60
+ *
61
+ * @param config - API key and optional base URL / timeout.
62
+ * @returns A handler function: (name, args) => Promise<string>
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * import { createDominusNodeFunctionHandler } from "./handler";
67
+ *
68
+ * const handler = createDominusNodeFunctionHandler({
69
+ * apiKey: "dn_live_abc123",
70
+ * baseUrl: "https://api.dominusnode.com",
71
+ * });
72
+ *
73
+ * // Handle a function call from Gemini
74
+ * const result = await handler("dominusnode_check_balance", {});
75
+ * console.log(JSON.parse(result));
76
+ * // { balanceCents: 5000, balanceUsd: 50.00, currency: "USD", lastToppedUp: "..." }
77
+ * ```
78
+ */
79
+ export { isPrivateIp, validateUrl, normalizeIpv4, sanitizeError, stripDangerousKeys, safeJsonParse, };
80
+ export declare function createDominusNodeFunctionHandler(config: DominusNodeFunctionConfig): FunctionHandler;