@aiagenta2z/onekey-gateway 0.1.1 → 0.1.3

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 CHANGED
@@ -12,11 +12,16 @@ you can eliminate multiple expensive subscriptions and maximize your benefits. M
12
12
 
13
13
  OneKey Gateway provides CLI tool, Restful API, MCP, Skills and Python/Typescript methods for Agent and human to use commercial Agent APIs.
14
14
 
15
- | Gateway Type | Description | BASE URL | CLI |
16
- |-------------|---------------------------------------------------------------------------------------------------------------|----------------------------------------|----------------|
17
- | Agent APIs | Allow your AI Agent to Access APIs [OneKey Agent Router Doc](https://www.deepnlp.org/doc/onekey_agent_router) | https://agent.deepnlp.org/agent_router | `onekey agent` |
18
- | MCP | Allow your AI clients to connect to commercial Http MCP [OneKey MCP Router Doc](https://www.deepnlp.org/doc/onekey_mcp_router) | https://agent.deepnlp.org/mcp | `onekey mcp` |
19
- | LLM | Allow your AI clients to call LLM endpoint proxy [OneKey LLM Router Doc](https://www.deepnlp.org/doc/onekey_llm_router) | https://agent.deepnlp.org/llm | `onekey llm` |
15
+ | Gateway Type | Description | BASE URL | CLI |
16
+ |-------------|--------------------------------------------------------------------------------------------------------------------------------|----------------------------------------|----------------|
17
+ | Agent APIs | Allow your AI Agent to Access APIs [OneKey Agent Router Doc](https://www.deepnlp.org/doc/onekey_agent_router) | https://agent.deepnlp.org/agent_router | `onekey agent` |
18
+ | MCP | Allow your AI clients to connect to commercial Http MCP [OneKey MCP Router Doc](https://www.deepnlp.org/doc/onekey_mcp_router) | https://agent.deepnlp.org/mcp | `onekey mcp` |
19
+ | LLM | Allow your AI clients to call LLM endpoint proxy [OneKey LLM Router Doc](https://www.deepnlp.org/doc/onekey_llm_router) | https://agent.deepnlp.org/llm | `onekey llm` |
20
+
21
+
22
+ | Gateway Type | Description |
23
+ |---------------------------------------------------|----------------------------------------------------------------------------------------|
24
+ | Register Your New API | [OneKey Gateway Registry Documents](https://www.deepnlp.org/doc/onekey_agent_registry) |
20
25
 
21
26
 
22
27
  ### Architecture
@@ -101,7 +106,7 @@ prompt: New York City Italian Restaurants
101
106
 
102
107
  ```bash
103
108
 
104
- onekey agent google-maps/google-maps maps_search_places '{"query":"New York City Italian Restaurants"}'
109
+ npx onekey agent google-maps/google-maps maps_search_places '{"query":"New York City Italian Restaurants"}'
105
110
  ```
106
111
  Result
107
112
  ```shell
@@ -128,15 +133,26 @@ https://us-static.aiagenta2z.com/local/files-wd/user_2177/7629e198-b10c-4a8b-8f6
128
133
 
129
134
  <img src="https://raw.githubusercontent.com/aiagenta2z/onekey-agent-router/refs/heads/main/docs/onekey-gateway-example-gemini.jpg" style="width:500px" alt="Image generation">
130
135
 
136
+ #### Example 3: 3D Generation Step By Step Assembly Charts Build Plans
137
+
138
+ prompt:
139
+
140
+ ```bash
141
+ export DEEPNLP_ONEKEY_ROUTER_ACCESS=YOUR_ACCESS_KEY
142
+ onekey agent craftsman-agent/craftsman-agent generate_lego_build_plan '{"prompt":"Build Lego yacht with 5 decks using blue and white bricks","images":[],"mode":"basic"}' --timeout 30000
143
+ ```
144
+
145
+ 3D Step by Step Assembly Charts
146
+
147
+ <img src="https://raw.githubusercontent.com/AI-Hub-Admin/Craftsman-Agent/refs/heads/main/docs/craftsman_agent_2.jpg" style="width:500px" alt="Image generation">
148
+
149
+
131
150
 
132
151
  ## Tutorial
133
152
 
134
153
  ### CLI Usage
135
154
  ```bash
136
155
  onekey agent <unique_id> <api_id> <data_json|@file>
137
- onekey mcp <server_name> [--name config_name]
138
- onekey llm --provider <provider> --model <model> --messages <json|@file> [--temperature <num>] [--response-format <format>] [--options <json|@file>]
139
- onekey llm --payload <json|@file>
140
156
  ```
141
157
 
142
158
  Supported ids can be found in the table below.
@@ -146,15 +162,15 @@ Supported ids can be found in the table below.
146
162
  **CLI**
147
163
 
148
164
  ```bash
149
- onekey agent google-maps/google-maps maps_search_places '{"query":"New York City Italian Restaurants"}'
165
+ onekey agent google-maps/google-maps maps_search_places '{"query":"New York City Italian Restaurants"}' --timeout 30000
150
166
  ```
151
167
 
152
168
  **Skills**
153
169
 
154
170
  `agtm` package
155
171
  ```bash
156
- npx agtm add https://github.com/aiagenta2z/onekey-gateway ## add all onekey router skills
157
- npx agtm add aiagenta2z/onekey-gateway --skill google-maps -g ## install to global path
172
+ npx agtm skills add https://github.com/aiagenta2z/onekey-gateway ## add all onekey router skills
173
+ npx agtm skills add aiagenta2z/onekey-gateway --skill google-maps -g ## install to global path
158
174
  ```
159
175
  `skills` package
160
176
  ```
@@ -163,6 +179,12 @@ npx skills add https://github.com/aiagenta2z/onekey-agent-router
163
179
  npx skills add https://github.com/aiagenta2z/onekey-agent-router --skill amap-maps-streamableHTTP
164
180
  ```
165
181
 
182
+ Run onekey skills with hint
183
+ ```bash
184
+ npx agtm run nano # -> guide you through gemini-nano-banana tools
185
+ npx agtm run nano aiagenta2z/onekey-gateway nano # -> Find the cli of generation or generation with reference images
186
+ ```
187
+
166
188
  ### OneKey MCP Config
167
189
 
168
190
  ```bash
@@ -182,7 +204,7 @@ Put below config into your clients
182
204
  ### OneKey LLM Router
183
205
  Call Gemini 3 LLM and Image Nano Banana model
184
206
  ```bash
185
- onekey llm --provider gemini --model gemini-3-flash-preview --messages @messages.json --temperature 0.7 --response-format json
207
+ onekey llm --provider gemini --model gemini-3-flash-preview --messages @messages.json --temperature 0.7 --response-format json --timeout 30000
186
208
  ```
187
209
 
188
210
  ## Gateway Categories
@@ -201,7 +223,9 @@ onekey llm --provider gemini --model gemini-3-flash-preview --messages @messages
201
223
  | Image Generation | gemini-nano-banana/gemini-nano-banana [Doc](./docs/gemini-nano-banana/README.md) | gemini-nano-banana | generate_image_gemini<br>generate_image_nano_banana<br>generate_image_nano_banana_with_reference<br>ocr_extract_text_from_image<br>list_items_from_image |
202
224
  | Charts | mcp-server-chart/mcp-server-chart [Doc](./docs/mcp-server-chart/README.md) | mcp-server-chart | generate_area_chart<br>generate_bar_chart<br>generate_boxplot_chart<br>generate_column_chart<br>generate_district_map<br>generate_dual_axes_chart<br>generate_fishbone_diagram<br>generate_flow_diagram<br>generate_funnel_chart<br>generate_histogram_chart<br>generate_line_chart<br>generate_liquid_chart<br>generate_mind_map<br>generate_network_graph<br>generate_organization_chart<br>generate_path_map<br>generate_pie_chart<br>generate_pin_map<br>generate_radar_chart<br>generate_sankey_chart<br>generate_scatter_chart<br>generate_spreadsheet<br>generate_treemap_chart<br>generate_venn_chart<br>generate_violin_chart<br>generate_waterfall_chart<br>generate_word_cloud_chart |
203
225
  | Research QA | perplexity/perplexity [Doc](./docs/perplexity/README.md) | perplexity | perplexity_ask<br>perplexity_reason<br>perplexity_research<br>perplexity_search |
204
- | 3D Generation | craftsman-agent/craftsman-agent [Doc](./docs/craftsman-agent/README.md) | craftsman-agent | generate_lego_build_plan<br>generate_minecraft_build_plan |
226
+ | 3D Generation | craftsman-agent/craftsman-agent [Doc](./docs/craftsman-agent/README.md) | craftsman-agent | generate_lego_build_plan<br>generate_minecraft_build_plan<br>generate_tesla_wraps |
227
+ | Finance | aiagenta2z/financeagent [Doc](./docs//README.md) | financeagent | get_hk_stock_market_hkex<br>get_cn_stock_market_shanghai_shenzhen<br>get_us_stock_market_nyse_nasdaq_dow<br>get_uk_stock_market_lse<br>get_india_stock_market_nse_india |
228
+
205
229
 
206
230
 
207
231
  #### Example 1: Google Maps Search
@@ -242,4 +266,12 @@ https://us-static.aiagenta2z.com/local/files-wd/user_2177/7629e198-b10c-4a8b-8f6
242
266
 
243
267
 
244
268
  ### Related
269
+ [OneKey Gateway Documentation](https://www.deepnlp.org/doc/onekey_gateway)
270
+ [AI Agent Marketplace](https://www.deepnlp.org/store/ai-agent)
271
+ [GitHub Agtm](https://github.com/aiagenta2z/agtm)
272
+ [Submit AI Agent](https://www.deepnlp.org/workspace/my_ai_services)
273
+ [Agent Infra Deployment](https://www.deepnlp.org/workspace/deploy)
274
+ [A2Z Payment SDK](https://www.deepnlp.org/agent/agent-a2z-payment)
275
+
276
+
245
277
 
package/dist/cli.js CHANGED
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const client_1 = require("./client");
5
5
  const fs_1 = require("fs");
6
+ const DEFAULT_TIMEOUT_MS = 60000;
6
7
  function parseArgs(argv) {
7
8
  const flags = {};
8
9
  const positionals = [];
@@ -76,22 +77,44 @@ function printHelp() {
76
77
  const text = `OneKey Gateway CLI
77
78
 
78
79
  Usage:
79
- onekey agent <unique_id> <api_id> <data_json|@file>
80
- onekey mcp <server_name> [--name config_name]
81
- onekey llm --provider <provider> --model <model> --messages <json|@file> [--temperature <num>] [--response-format <format>] [--options <json|@file>]
82
- onekey llm --payload <json|@file>
80
+ onekey agent <unique_id> <api_id> <data_json|@file> [--timeout <ms>]
81
+ onekey mcp <server_name> [--name config_name] [--timeout <ms>]
82
+ onekey llm --provider <provider> --model <model> --messages <json|@file> [--temperature <num>] [--response-format <format>] [--options <json|@file>] [--timeout <ms>]
83
+ onekey llm --payload <json|@file> [--timeout <ms>]
83
84
 
84
85
  Flags:
85
86
  --key <access_key> Override DEEPNLP_ONEKEY_ROUTER_ACCESS
87
+ --timeout <ms> Request timeout in milliseconds (float, default ${DEFAULT_TIMEOUT_MS})
86
88
  --help Show help
87
89
 
88
90
  Examples:
89
91
  onekey agent google-maps/google-maps maps_search_places '{"query":"New York City Italian Restaurants"}'
90
92
  onekey mcp google-maps
91
- onekey llm --provider gemini --model gemini-3-flash-preview --messages @messages.json --temperature 0.7 --response-format json
93
+ onekey llm --provider gemini --model gemini-3-flash-preview --messages @messages.json --temperature 0.7 --response-format json --timeout 30000
92
94
  `;
93
95
  process.stdout.write(text);
94
96
  }
97
+ function parseTimeoutMs(flags) {
98
+ const raw = flags.timeout;
99
+ if (raw === undefined)
100
+ return DEFAULT_TIMEOUT_MS;
101
+ if (raw === true) {
102
+ throw new Error("--timeout requires a value (milliseconds)");
103
+ }
104
+ if (typeof raw !== "string") {
105
+ throw new Error("--timeout must be a number (milliseconds)");
106
+ }
107
+ const trimmed = raw.trim();
108
+ const normalized = trimmed.includes(",") && !trimmed.includes(".") ? trimmed.replace(",", ".") : trimmed;
109
+ const ms = Number(normalized);
110
+ if (!Number.isFinite(ms)) {
111
+ throw new Error("--timeout must be a finite number (milliseconds)");
112
+ }
113
+ if (ms <= 0) {
114
+ throw new Error("--timeout must be greater than 0");
115
+ }
116
+ return Math.ceil(ms);
117
+ }
95
118
  async function runAgent(positionals, flags) {
96
119
  const [uniqueId, apiId, dataInput] = positionals;
97
120
  if (!uniqueId || !apiId || !dataInput) {
@@ -99,12 +122,13 @@ async function runAgent(positionals, flags) {
99
122
  }
100
123
  const accessKey = resolveAccessKey(flags);
101
124
  warnIfUsingDefault(accessKey, flags);
125
+ const timeoutMs = parseTimeoutMs(flags);
102
126
  const data = parseJsonInput(dataInput, "data");
103
127
  const result = await (0, client_1.agentRouter)({
104
128
  unique_id: uniqueId,
105
129
  api_id: apiId,
106
130
  data
107
- }, accessKey);
131
+ }, accessKey, { timeoutMs });
108
132
  process.stdout.write(`${JSON.stringify(result)}\n`);
109
133
  }
110
134
  async function runMcp(positionals, flags) {
@@ -129,6 +153,7 @@ async function runLlm(positionals, flags) {
129
153
  // }
130
154
  const accessKey = resolveAccessKey(flags);
131
155
  warnIfUsingDefault(accessKey, flags);
156
+ const timeoutMs = parseTimeoutMs(flags);
132
157
  let payload;
133
158
  if (typeof flags.payload === "string") {
134
159
  payload = parseJsonInput(flags.payload, "payload");
@@ -168,7 +193,7 @@ async function runLlm(positionals, flags) {
168
193
  }
169
194
  }
170
195
  // payload.request_id = requestId;
171
- const result = await (0, client_1.llmRouter)(payload, accessKey);
196
+ const result = await (0, client_1.llmRouter)(payload, accessKey, { timeoutMs });
172
197
  process.stdout.write(`${JSON.stringify(result)}\n`);
173
198
  }
174
199
  async function main() {
package/dist/client.d.ts CHANGED
@@ -25,8 +25,11 @@ export type McpConfigOptions = {
25
25
  accessKey?: string;
26
26
  configName?: string;
27
27
  };
28
- export declare function agentRouter(request: AgentRequest, accessKey?: string): Promise<RouterResponse>;
29
- export declare function llmRouter(request: LlmRequest, accessKey?: string): Promise<RouterResponse>;
28
+ export type RequestOptions = {
29
+ timeoutMs?: number;
30
+ };
31
+ export declare function agentRouter(request: AgentRequest, accessKey?: string, options?: RequestOptions): Promise<RouterResponse>;
32
+ export declare function llmRouter(request: LlmRequest, accessKey?: string, options?: RequestOptions): Promise<RouterResponse>;
30
33
  export declare function buildMcpConfig(options: McpConfigOptions): {
31
34
  mcpServers: {
32
35
  [x: string]: {
@@ -39,4 +42,5 @@ export declare const constants: {
39
42
  MCP_ROUTER_BASE_URL: string;
40
43
  LLM_ROUTER_URL: string;
41
44
  DEFAULT_ACCESS_KEY: string;
45
+ DEFAULT_TIMEOUT_MS: number;
42
46
  };
package/dist/client.js CHANGED
@@ -5,22 +5,50 @@ exports.agentRouter = agentRouter;
5
5
  exports.llmRouter = llmRouter;
6
6
  exports.buildMcpConfig = buildMcpConfig;
7
7
  const DEFAULT_ACCESS_KEY = "BETA_TEST_KEY_MARCH_2026";
8
+ const DEFAULT_TIMEOUT_MS = 30000;
8
9
  const AGENT_ROUTER_URL = "https://agent.deepnlp.org/agent_router";
9
10
  const MCP_ROUTER_BASE_URL = "https://agent.deepnlp.org/mcp";
10
11
  const LLM_ROUTER_URL = "https://agent.deepnlp.org/llm";
11
12
  function resolveAccessKey(accessKey) {
12
13
  return accessKey && accessKey.trim().length > 0 ? accessKey : DEFAULT_ACCESS_KEY;
13
14
  }
14
- async function postJson(url, body, accessKey) {
15
+ async function postJson(url, body, accessKey, options) {
15
16
  const key = resolveAccessKey(accessKey);
16
- const response = await fetch(url, {
17
- method: "POST",
18
- headers: {
19
- "Content-Type": "application/json",
20
- "X-OneKey": key
21
- },
22
- body: JSON.stringify(body)
23
- });
17
+ const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
18
+ const controller = new AbortController();
19
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
20
+ let response;
21
+ try {
22
+ response = await fetch(url, {
23
+ method: "POST",
24
+ headers: {
25
+ "Content-Type": "application/json",
26
+ "X-OneKey": key
27
+ },
28
+ body: JSON.stringify(body),
29
+ signal: controller.signal
30
+ });
31
+ }
32
+ catch (error) {
33
+ clearTimeout(timer);
34
+ const isAbortError = !!error && typeof error === "object" && "name" in error && error.name === "AbortError";
35
+ if (isAbortError) {
36
+ return {
37
+ success: false,
38
+ data: null,
39
+ error: `Request timed out after ${timeoutMs} ms`
40
+ };
41
+ }
42
+ const message = error instanceof Error ? error.message : String(error);
43
+ return {
44
+ success: false,
45
+ data: null,
46
+ error: message
47
+ };
48
+ }
49
+ finally {
50
+ clearTimeout(timer);
51
+ }
24
52
  const text = await response.text();
25
53
  try {
26
54
  return JSON.parse(text);
@@ -33,11 +61,11 @@ async function postJson(url, body, accessKey) {
33
61
  };
34
62
  }
35
63
  }
36
- async function agentRouter(request, accessKey) {
37
- return postJson(AGENT_ROUTER_URL, request, accessKey);
64
+ async function agentRouter(request, accessKey, options) {
65
+ return postJson(AGENT_ROUTER_URL, request, accessKey, options);
38
66
  }
39
- async function llmRouter(request, accessKey) {
40
- return postJson(LLM_ROUTER_URL, request, accessKey);
67
+ async function llmRouter(request, accessKey, options) {
68
+ return postJson(LLM_ROUTER_URL, request, accessKey, options);
41
69
  }
42
70
  function buildMcpConfig(options) {
43
71
  const key = resolveAccessKey(options.accessKey);
@@ -55,5 +83,6 @@ exports.constants = {
55
83
  AGENT_ROUTER_URL,
56
84
  MCP_ROUTER_BASE_URL,
57
85
  LLM_ROUTER_URL,
58
- DEFAULT_ACCESS_KEY
86
+ DEFAULT_ACCESS_KEY,
87
+ DEFAULT_TIMEOUT_MS
59
88
  };
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { agentRouter, llmRouter, buildMcpConfig, type AgentRequest, type LlmRequest, type McpConfigOptions, type RouterResponse } from "./client";
1
+ export { agentRouter, llmRouter, buildMcpConfig, type AgentRequest, type LlmRequest, type McpConfigOptions, type RequestOptions, type RouterResponse } from "./client";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aiagenta2z/onekey-gateway",
3
- "version": "0.1.1",
4
- "description": "OneKey Gateway CLI and SDK for routing AI agent, MCP, and LLM requests by DeepNLP x AI Agent A2Z",
3
+ "version": "0.1.3",
4
+ "description": "OneKey Gateway CLI and SDK for routing AI agent, MCP, Skills and LLM requests by DeepNLP x AI Agent A2Z",
5
5
  "license": "MIT",
6
6
  "author": "aiagenta2z",
7
7
  "homepage": "https://www.deepnlp.org/doc/onekey_gateway",