@aiagenta2z/onekey-gateway 0.1.0 → 0.1.2

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
@@ -128,15 +128,26 @@ https://us-static.aiagenta2z.com/local/files-wd/user_2177/7629e198-b10c-4a8b-8f6
128
128
 
129
129
  <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
130
 
131
+ #### Example 3: 3D Generation Step By Step Assembly Charts Build Plans
132
+
133
+ prompt:
134
+
135
+ ```bash
136
+ export DEEPNLP_ONEKEY_ROUTER_ACCESS=YOUR_ACCESS_KEY
137
+ 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
138
+ ```
139
+
140
+ 3D Step by Step Assembly Charts
141
+
142
+ <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">
143
+
144
+
131
145
 
132
146
  ## Tutorial
133
147
 
134
148
  ### CLI Usage
135
149
  ```bash
136
150
  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
151
  ```
141
152
 
142
153
  Supported ids can be found in the table below.
@@ -146,7 +157,7 @@ Supported ids can be found in the table below.
146
157
  **CLI**
147
158
 
148
159
  ```bash
149
- onekey agent google-maps/google-maps maps_search_places '{"query":"New York City Italian Restaurants"}'
160
+ onekey agent google-maps/google-maps maps_search_places '{"query":"New York City Italian Restaurants"}' --timeout 30000
150
161
  ```
151
162
 
152
163
  **Skills**
@@ -163,6 +174,12 @@ npx skills add https://github.com/aiagenta2z/onekey-agent-router
163
174
  npx skills add https://github.com/aiagenta2z/onekey-agent-router --skill amap-maps-streamableHTTP
164
175
  ```
165
176
 
177
+ Run onekey skills with hint
178
+ ```bash
179
+ npx agtm run nano # -> guide you through gemini-nano-banana tools
180
+ npx agtm run nano aiagenta2z/onekey-gateway nano # -> Find the cli of generation or generation with reference images
181
+ ```
182
+
166
183
  ### OneKey MCP Config
167
184
 
168
185
  ```bash
@@ -182,7 +199,7 @@ Put below config into your clients
182
199
  ### OneKey LLM Router
183
200
  Call Gemini 3 LLM and Image Nano Banana model
184
201
  ```bash
185
- onekey llm --provider gemini --model gemini-3-flash-preview --messages @messages.json --temperature 0.7 --response-format json
202
+ onekey llm --provider gemini --model gemini-3-flash-preview --messages @messages.json --temperature 0.7 --response-format json --timeout 30000
186
203
  ```
187
204
 
188
205
  ## Gateway Categories
@@ -201,7 +218,7 @@ onekey llm --provider gemini --model gemini-3-flash-preview --messages @messages
201
218
  | 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
219
  | 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
220
  | 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 |
221
+ | 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 |
205
222
 
206
223
 
207
224
  #### Example 1: Google Maps Search
@@ -242,4 +259,12 @@ https://us-static.aiagenta2z.com/local/files-wd/user_2177/7629e198-b10c-4a8b-8f6
242
259
 
243
260
 
244
261
  ### Related
262
+ [OneKey Gateway Documentation](https://www.deepnlp.org/doc/onekey_gateway)
263
+ [AI Agent Marketplace](https://www.deepnlp.org/store/ai-agent)
264
+ [GitHub Agtm](https://github.com/aiagenta2z/agtm)
265
+ [Submit AI Agent](https://www.deepnlp.org/workspace/my_ai_services)
266
+ [Agent Infra Deployment](https://www.deepnlp.org/workspace/deploy)
267
+ [A2Z Payment SDK](https://www.deepnlp.org/agent/agent-a2z-payment)
268
+
269
+
245
270
 
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 = 30000;
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,9 +1,14 @@
1
1
  {
2
2
  "name": "@aiagenta2z/onekey-gateway",
3
- "version": "0.1.0",
4
- "description": "OneKey Gateway CLI and SDK for routing AI agent, MCP, and LLM requests.",
3
+ "version": "0.1.2",
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
+ "homepage": "https://www.deepnlp.org/doc/onekey_gateway",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/aiagenta2z/onekey-gateway.git"
11
+ },
7
12
  "type": "commonjs",
8
13
  "main": "dist/index.js",
9
14
  "types": "dist/index.d.ts",
@@ -32,5 +37,8 @@
32
37
  "mcp",
33
38
  "llm",
34
39
  "router"
35
- ]
40
+ ],
41
+ "dependencies": {
42
+ "@aiagenta2z/onekey-gateway": "^0.1.0"
43
+ }
36
44
  }