@dominusnode/openai-functions 1.0.0 → 1.0.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 +13 -13
- package/dist/handler.d.ts +7 -7
- package/dist/handler.js +6 -6
- package/functions.json +6 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Dominus Node OpenAI-Compatible Function Calling Schemas
|
|
2
2
|
|
|
3
|
-
OpenAI function-calling schemas and handler implementations for the
|
|
3
|
+
OpenAI function-calling schemas and handler implementations for the Dominus Node rotating proxy-as-a-service platform. These schemas allow any LLM with function/tool calling support to interact with Dominus Node's proxy network, wallet, and agentic wallet APIs.
|
|
4
4
|
|
|
5
5
|
## What This Is
|
|
6
6
|
|
|
@@ -9,8 +9,8 @@ This directory contains:
|
|
|
9
9
|
| File | Description |
|
|
10
10
|
|------|-------------|
|
|
11
11
|
| `functions.json` | Array of 8 OpenAI function definitions (JSON Schema format) |
|
|
12
|
-
| `handler.ts` | TypeScript handler that dispatches function calls to the
|
|
13
|
-
| `handler.py` | Python handler that dispatches function calls to the
|
|
12
|
+
| `handler.ts` | TypeScript handler that dispatches function calls to the Dominus Node API |
|
|
13
|
+
| `handler.py` | Python handler that dispatches function calls to the Dominus Node API |
|
|
14
14
|
|
|
15
15
|
The function schemas follow the [OpenAI function calling specification](https://platform.openai.com/docs/guides/function-calling), which has become a de facto standard adopted by Claude (tool_use), Gemini, Mistral, Llama, and others.
|
|
16
16
|
|
|
@@ -18,7 +18,7 @@ The function schemas follow the [OpenAI function calling specification](https://
|
|
|
18
18
|
|
|
19
19
|
| Function | Description | Auth Required |
|
|
20
20
|
|----------|-------------|---------------|
|
|
21
|
-
| `dominusnode_proxied_fetch` | Make an HTTP request through
|
|
21
|
+
| `dominusnode_proxied_fetch` | Make an HTTP request through Dominus Node's rotating proxy network | Yes |
|
|
22
22
|
| `dominusnode_check_balance` | Check wallet balance (cents, USD, currency) | Yes |
|
|
23
23
|
| `dominusnode_check_usage` | Check usage stats for a time period (day/week/month) | Yes |
|
|
24
24
|
| `dominusnode_get_proxy_config` | Get proxy endpoints, supported countries, geo-targeting info | Yes |
|
|
@@ -38,7 +38,7 @@ from handler import create_dominusnode_function_handler
|
|
|
38
38
|
with open("functions.json") as f:
|
|
39
39
|
functions = json.load(f)
|
|
40
40
|
|
|
41
|
-
# Create the
|
|
41
|
+
# Create the Dominus Node handler
|
|
42
42
|
dominusnode = create_dominusnode_function_handler(
|
|
43
43
|
api_key="dn_live_your_api_key_here",
|
|
44
44
|
base_url="https://api.dominusnode.com",
|
|
@@ -49,7 +49,7 @@ client = openai.OpenAI()
|
|
|
49
49
|
response = client.chat.completions.create(
|
|
50
50
|
model="gpt-4o",
|
|
51
51
|
messages=[
|
|
52
|
-
{"role": "system", "content": "You have access to
|
|
52
|
+
{"role": "system", "content": "You have access to Dominus Node proxy tools."},
|
|
53
53
|
{"role": "user", "content": "What is my current proxy balance?"},
|
|
54
54
|
],
|
|
55
55
|
functions=functions,
|
|
@@ -62,14 +62,14 @@ if message.function_call:
|
|
|
62
62
|
name = message.function_call.name
|
|
63
63
|
args = json.loads(message.function_call.arguments)
|
|
64
64
|
|
|
65
|
-
# Dispatch to
|
|
65
|
+
# Dispatch to Dominus Node handler
|
|
66
66
|
result = await dominusnode(name, args)
|
|
67
67
|
|
|
68
68
|
# Send the result back to the LLM
|
|
69
69
|
response = client.chat.completions.create(
|
|
70
70
|
model="gpt-4o",
|
|
71
71
|
messages=[
|
|
72
|
-
{"role": "system", "content": "You have access to
|
|
72
|
+
{"role": "system", "content": "You have access to Dominus Node proxy tools."},
|
|
73
73
|
{"role": "user", "content": "What is my current proxy balance?"},
|
|
74
74
|
message,
|
|
75
75
|
{"role": "function", "name": name, "content": result},
|
|
@@ -100,7 +100,7 @@ tools = [
|
|
|
100
100
|
for fn in functions
|
|
101
101
|
]
|
|
102
102
|
|
|
103
|
-
# Create the
|
|
103
|
+
# Create the Dominus Node handler
|
|
104
104
|
dominusnode = create_dominusnode_function_handler(
|
|
105
105
|
api_key="dn_live_your_api_key_here",
|
|
106
106
|
)
|
|
@@ -112,7 +112,7 @@ response = client.messages.create(
|
|
|
112
112
|
max_tokens=1024,
|
|
113
113
|
tools=tools,
|
|
114
114
|
messages=[
|
|
115
|
-
{"role": "user", "content": "Check my
|
|
115
|
+
{"role": "user", "content": "Check my Dominus Node proxy balance and usage this week."},
|
|
116
116
|
],
|
|
117
117
|
)
|
|
118
118
|
|
|
@@ -127,7 +127,7 @@ for block in response.content:
|
|
|
127
127
|
max_tokens=1024,
|
|
128
128
|
tools=tools,
|
|
129
129
|
messages=[
|
|
130
|
-
{"role": "user", "content": "Check my
|
|
130
|
+
{"role": "user", "content": "Check my Dominus Node proxy balance and usage this week."},
|
|
131
131
|
{"role": "assistant", "content": response.content},
|
|
132
132
|
{
|
|
133
133
|
"role": "user",
|
|
@@ -204,7 +204,7 @@ The `functions.json` file follows the standard OpenAI function definition schema
|
|
|
204
204
|
| **OpenAI SDK** | Pass `functions` directly to `chat.completions.create()` |
|
|
205
205
|
| **Anthropic SDK** | Convert to `tools` format (rename `parameters` to `input_schema`) |
|
|
206
206
|
| **Google Gemini** | Convert to `FunctionDeclaration` objects |
|
|
207
|
-
| **LangChain** | Use `StructuredTool.from_function()` or the
|
|
207
|
+
| **LangChain** | Use `StructuredTool.from_function()` or the Dominus Node LangChain integration |
|
|
208
208
|
| **Vercel AI SDK** | See the `integrations/vercel-ai/` package |
|
|
209
209
|
| **LlamaIndex** | Use `FunctionTool.from_defaults()` with the handler |
|
|
210
210
|
| **Ollama** | Pass as `tools` parameter in chat API |
|
package/dist/handler.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Dominus Node OpenAI-compatible function calling handler (TypeScript).
|
|
3
3
|
*
|
|
4
4
|
* Provides a factory function that creates a handler for dispatching
|
|
5
|
-
* OpenAI function calls to the
|
|
5
|
+
* OpenAI function calls to the Dominus Node REST API. Works with any
|
|
6
6
|
* function-calling LLM system: OpenAI GPT, Anthropic Claude tool_use,
|
|
7
7
|
* Google Gemini, or custom implementations.
|
|
8
8
|
*
|
|
@@ -40,23 +40,23 @@ declare function stripDangerousKeys(obj: unknown, depth?: number): void;
|
|
|
40
40
|
declare function safeJsonParse<T>(text: string): T;
|
|
41
41
|
declare function sanitizeError(message: string): string;
|
|
42
42
|
export interface DominusNodeFunctionConfig {
|
|
43
|
-
/**
|
|
43
|
+
/** Dominus Node API key (starts with dn_live_ or dn_test_). */
|
|
44
44
|
apiKey: string;
|
|
45
|
-
/** Base URL of the
|
|
45
|
+
/** Base URL of the Dominus Node REST API. Defaults to https://api.dominusnode.com */
|
|
46
46
|
baseUrl?: string;
|
|
47
47
|
/** Request timeout in milliseconds. Defaults to 30000. */
|
|
48
48
|
timeoutMs?: number;
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* Handler function type returned by createDominusNodeFunctionHandler.
|
|
52
|
-
* Dispatches function calls to the
|
|
52
|
+
* Dispatches function calls to the Dominus Node API and returns JSON string results.
|
|
53
53
|
*/
|
|
54
54
|
export type FunctionHandler = (name: string, args: Record<string, unknown>) => Promise<string>;
|
|
55
55
|
/**
|
|
56
|
-
* Create a
|
|
56
|
+
* Create a Dominus Node function handler for OpenAI-compatible function calling.
|
|
57
57
|
*
|
|
58
58
|
* Authenticates using the provided API key, then returns a handler function
|
|
59
|
-
* that dispatches function calls to the appropriate
|
|
59
|
+
* that dispatches function calls to the appropriate Dominus Node REST API endpoint.
|
|
60
60
|
*
|
|
61
61
|
* @param config - API key and optional base URL / timeout.
|
|
62
62
|
* @returns A handler function: (name, args) => Promise<string>
|
package/dist/handler.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Dominus Node OpenAI-compatible function calling handler (TypeScript).
|
|
3
3
|
*
|
|
4
4
|
* Provides a factory function that creates a handler for dispatching
|
|
5
|
-
* OpenAI function calls to the
|
|
5
|
+
* OpenAI function calls to the Dominus Node REST API. Works with any
|
|
6
6
|
* function-calling LLM system: OpenAI GPT, Anthropic Claude tool_use,
|
|
7
7
|
* Google Gemini, or custom implementations.
|
|
8
8
|
*
|
|
@@ -364,10 +364,10 @@ function periodToDateRange(period) {
|
|
|
364
364
|
return { since: since.toISOString(), until };
|
|
365
365
|
}
|
|
366
366
|
/**
|
|
367
|
-
* Create a
|
|
367
|
+
* Create a Dominus Node function handler for OpenAI-compatible function calling.
|
|
368
368
|
*
|
|
369
369
|
* Authenticates using the provided API key, then returns a handler function
|
|
370
|
-
* that dispatches function calls to the appropriate
|
|
370
|
+
* that dispatches function calls to the appropriate Dominus Node REST API endpoint.
|
|
371
371
|
*
|
|
372
372
|
* @param config - API key and optional base URL / timeout.
|
|
373
373
|
* @returns A handler function: (name, args) => Promise<string>
|
|
@@ -487,7 +487,7 @@ export function createDominusNodeFunctionHandler(config) {
|
|
|
487
487
|
}
|
|
488
488
|
const username = userParts.join("-");
|
|
489
489
|
// Use the proxy gateway for the actual request
|
|
490
|
-
// The handler routes through the
|
|
490
|
+
// The handler routes through the Dominus Node proxy endpoint
|
|
491
491
|
try {
|
|
492
492
|
// Strip security-sensitive headers from user-provided headers
|
|
493
493
|
const BLOCKED_HEADERS = new Set([
|
|
@@ -640,7 +640,7 @@ export function createDominusNodeFunctionHandler(config) {
|
|
|
640
640
|
catch (err) {
|
|
641
641
|
return JSON.stringify({
|
|
642
642
|
error: `Proxy fetch failed: ${sanitizeError(err instanceof Error ? err.message : String(err))}`,
|
|
643
|
-
hint: "Ensure the
|
|
643
|
+
hint: "Ensure the Dominus Node proxy gateway is running and accessible.",
|
|
644
644
|
});
|
|
645
645
|
}
|
|
646
646
|
}
|
package/functions.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
3
|
"name": "dominusnode_proxied_fetch",
|
|
4
|
-
"description": "Make an HTTP request through
|
|
4
|
+
"description": "Make an HTTP request through Dominus Node's rotating proxy network. Routes traffic through datacenter ($3/GB) or residential ($5/GB) proxies with optional geo-targeting. Useful for accessing geo-restricted content, avoiding IP blocks, or web scraping. Private/internal IPs and sanctioned countries (CU, IR, KP, RU, SY) are blocked.",
|
|
5
5
|
"parameters": {
|
|
6
6
|
"type": "object",
|
|
7
7
|
"properties": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
40
|
"name": "dominusnode_check_balance",
|
|
41
|
-
"description": "Check the current wallet balance for the authenticated
|
|
41
|
+
"description": "Check the current wallet balance for the authenticated Dominus Node account. Returns balance in cents and USD, currency, and last top-up timestamp. The wallet uses a prepaid model -- top up first, then usage is debited automatically.",
|
|
42
42
|
"parameters": {
|
|
43
43
|
"type": "object",
|
|
44
44
|
"properties": {},
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
49
|
"name": "dominusnode_check_usage",
|
|
50
|
-
"description": "Check proxy usage statistics for the authenticated
|
|
50
|
+
"description": "Check proxy usage statistics for the authenticated Dominus Node account. Returns total bytes transferred, total cost, and request count for the specified period. Useful for monitoring bandwidth consumption and spending.",
|
|
51
51
|
"parameters": {
|
|
52
52
|
"type": "object",
|
|
53
53
|
"properties": {
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
65
|
"name": "dominusnode_get_proxy_config",
|
|
66
|
-
"description": "Get
|
|
66
|
+
"description": "Get Dominus Node proxy endpoint configuration and supported features. Returns HTTP and SOCKS5 proxy connection details, list of supported countries for geo-targeting, blocked/sanctioned countries, and geo-targeting capabilities. Use this to discover available proxy endpoints before making proxied requests.",
|
|
67
67
|
"parameters": {
|
|
68
68
|
"type": "object",
|
|
69
69
|
"properties": {},
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
},
|
|
73
73
|
{
|
|
74
74
|
"name": "dominusnode_list_sessions",
|
|
75
|
-
"description": "List all currently active proxy sessions for the authenticated
|
|
75
|
+
"description": "List all currently active proxy sessions for the authenticated Dominus Node account. Returns session IDs, start times, and status. Useful for monitoring concurrent connections and debugging active proxy usage.",
|
|
76
76
|
"parameters": {
|
|
77
77
|
"type": "object",
|
|
78
78
|
"properties": {},
|
|
@@ -402,7 +402,7 @@
|
|
|
402
402
|
},
|
|
403
403
|
{
|
|
404
404
|
"name": "dominusnode_topup_paypal",
|
|
405
|
-
"description": "Create a PayPal payment order to top up your
|
|
405
|
+
"description": "Create a PayPal payment order to top up your Dominus Node wallet. Returns an approval URL where you complete the payment. After approval, the wallet is credited automatically. Lower fees than Stripe for PayPal users. Minimum $5 (500 cents), maximum $1,000 (100,000 cents).",
|
|
406
406
|
"parameters": {
|
|
407
407
|
"type": "object",
|
|
408
408
|
"properties": {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dominusnode/openai-functions",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Dominus Node OpenAI-compatible function calling handler — dispatches LLM function calls to the Dominus Node REST API",
|
|
5
5
|
"main": "dist/handler.js",
|
|
6
6
|
"types": "dist/handler.d.ts",
|
|
7
7
|
"type": "module",
|