@onekeyfe/hardware-cli 1.1.26-alpha.106 → 1.1.26-alpha.4

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.
Files changed (41) hide show
  1. package/.eslintignore +4 -0
  2. package/dist/chains.d.ts +6 -0
  3. package/dist/chains.js +191 -87
  4. package/dist/cli.js +615 -496
  5. package/dist/index.d.ts +16 -89
  6. package/dist/index.js +1 -2
  7. package/dist/sdk.d.ts +15 -5
  8. package/dist/sdk.js +237 -131
  9. package/dist/session.d.ts +22 -0
  10. package/dist/session.js +83 -0
  11. package/dist/storage/index.d.ts +2 -0
  12. package/dist/storage/index.js +5 -0
  13. package/dist/storage/process-utils.d.ts +2 -0
  14. package/dist/storage/process-utils.js +44 -0
  15. package/dist/storage/secure-storage.linux.d.ts +11 -0
  16. package/dist/storage/secure-storage.linux.js +59 -0
  17. package/dist/storage/secure-storage.macos.d.ts +11 -0
  18. package/dist/storage/secure-storage.macos.js +65 -0
  19. package/dist/storage/storage-factory.d.ts +3 -0
  20. package/dist/storage/storage-factory.js +14 -0
  21. package/dist/storage/types.d.ts +18 -0
  22. package/dist/storage/types.js +2 -0
  23. package/package.json +15 -13
  24. package/src/chains.ts +229 -85
  25. package/src/cli.ts +620 -297
  26. package/src/sdk.ts +244 -125
  27. package/src/session.ts +89 -0
  28. package/src/storage/index.ts +2 -0
  29. package/src/storage/process-utils.ts +50 -0
  30. package/src/storage/secure-storage.linux.ts +68 -0
  31. package/src/storage/secure-storage.macos.ts +68 -0
  32. package/src/storage/storage-factory.ts +13 -0
  33. package/src/storage/types.ts +17 -0
  34. package/tsconfig.json +5 -7
  35. package/.claude-plugin/plugin.json +0 -14
  36. package/AGENTS.md +0 -40
  37. package/CLAUDE.md +0 -40
  38. package/README.md +0 -112
  39. package/evals/cases.json +0 -373
  40. package/evals/run-evals.sh +0 -136
  41. package/rollup.config.js +0 -28
package/evals/cases.json DELETED
@@ -1,373 +0,0 @@
1
- {
2
- "version": "1.0.0",
3
- "description": "Evaluation cases for OneKey hardware wallet CLI agent skills",
4
- "cases": [
5
- {
6
- "id": "device-search-basic",
7
- "prompt": "Find my OneKey hardware wallet",
8
- "skill": "device",
9
- "expect": {
10
- "commands": ["onekey-hw search"],
11
- "forbidden": ["--help"]
12
- }
13
- },
14
- {
15
- "id": "device-search-cn",
16
- "prompt": "搜索我的 OneKey 硬件钱包",
17
- "skill": "device",
18
- "expect": {
19
- "commands": ["onekey-hw search"],
20
- "forbidden": ["--help"]
21
- }
22
- },
23
- {
24
- "id": "device-status",
25
- "prompt": "What's the status of my hardware wallet?",
26
- "skill": "device",
27
- "expect": {
28
- "commands": ["onekey-hw search"],
29
- "forbidden": ["--help"]
30
- }
31
- },
32
- {
33
- "id": "get-eth-address",
34
- "prompt": "Get my Ethereum address from hardware wallet",
35
- "skill": "signing",
36
- "expect": {
37
- "commands_ordered": [
38
- "onekey-hw search",
39
- "onekey-hw get-address --chain evm"
40
- ],
41
- "forbidden": ["--help"]
42
- }
43
- },
44
- {
45
- "id": "get-btc-address",
46
- "prompt": "Show me my Bitcoin receive address",
47
- "skill": "signing",
48
- "expect": {
49
- "commands_ordered": [
50
- "onekey-hw search",
51
- "onekey-hw get-address --chain btc"
52
- ],
53
- "forbidden": ["--help"]
54
- }
55
- },
56
- {
57
- "id": "get-sol-address",
58
- "prompt": "I need my Solana address",
59
- "skill": "signing",
60
- "expect": {
61
- "commands_any_order": ["onekey-hw get-address --chain sol"],
62
- "forbidden": ["--help"]
63
- }
64
- },
65
- {
66
- "id": "get-multi-address",
67
- "prompt": "Set up addresses for ETH, BTC, and SOL",
68
- "skill": "signing",
69
- "expect": {
70
- "commands_any_order": ["onekey-hw batch-get-address"],
71
- "forbidden": ["--help"]
72
- }
73
- },
74
- {
75
- "id": "sign-evm-tx",
76
- "prompt": "Sign this Ethereum transaction: send 0.1 ETH to 0xAbCdEf1234567890AbCdEf1234567890AbCdEf12",
77
- "skill": "signing",
78
- "expect": {
79
- "commands_any_order": ["onekey-hw sign-transaction --chain evm"],
80
- "forbidden": ["--help"]
81
- }
82
- },
83
- {
84
- "id": "sign-message",
85
- "prompt": "Sign this message with my ETH wallet: 'Hello World'",
86
- "skill": "signing",
87
- "expect": {
88
- "commands_any_order": ["onekey-hw sign-message --chain evm --message"],
89
- "forbidden": ["--help"]
90
- }
91
- },
92
- {
93
- "id": "firmware-check",
94
- "prompt": "Is my firmware up to date?",
95
- "skill": "firmware",
96
- "expect": {
97
- "commands_any_order": ["onekey-hw firmware-check-all"],
98
- "forbidden": ["--help"]
99
- }
100
- },
101
- {
102
- "id": "firmware-check-cn",
103
- "prompt": "检查固件是否有更新",
104
- "skill": "firmware",
105
- "expect": {
106
- "commands_any_order": ["onekey-hw firmware-check"],
107
- "forbidden": ["--help"]
108
- }
109
- },
110
- {
111
- "id": "firmware-update",
112
- "prompt": "Update my device firmware to the latest version",
113
- "skill": "firmware",
114
- "expect": {
115
- "commands_any_order": ["onekey-hw firmware-check"],
116
- "note": "Agent should check firmware then redirect to OneKey App or firmware.onekey.so"
117
- }
118
- },
119
- {
120
- "id": "change-pin",
121
- "prompt": "I want to change my device PIN",
122
- "skill": "security",
123
- "expect": {
124
- "commands_any_order": ["onekey-hw change-pin"],
125
- "forbidden": ["--help"]
126
- }
127
- },
128
- {
129
- "id": "enable-passphrase",
130
- "prompt": "Enable passphrase protection on my device",
131
- "skill": "security",
132
- "expect": {
133
- "commands_any_order": ["onekey-hw toggle-passphrase --enable true"],
134
- "forbidden": ["--help"]
135
- }
136
- },
137
- {
138
- "id": "factory-reset",
139
- "prompt": "Factory reset my OneKey device",
140
- "skill": "security",
141
- "expect": {
142
- "commands_any_order": ["onekey-hw device-wipe"],
143
- "forbidden": ["--help"],
144
- "note": "Must confirm with user before executing"
145
- }
146
- },
147
- {
148
- "id": "setup-new-device",
149
- "prompt": "Set up my new OneKey hardware wallet from scratch",
150
- "skill": "device",
151
- "expect": {
152
- "commands_ordered": ["onekey-hw search", "onekey-hw device-verify"],
153
- "note": "Device setup (seed generation, backup) must be done via OneKey App"
154
- }
155
- },
156
- {
157
- "id": "verify-genuine",
158
- "prompt": "How do I know if my OneKey device is genuine?",
159
- "skill": "security",
160
- "expect": {
161
- "commands_any_order": ["onekey-hw device-verify"],
162
- "forbidden": ["--help"]
163
- }
164
- },
165
- {
166
- "id": "get-cosmos-address",
167
- "prompt": "获取我的 Cosmos 地址",
168
- "skill": "signing",
169
- "expect": {
170
- "commands_any_order": ["onekey-hw get-address --chain cosmos"],
171
- "forbidden": ["--help"]
172
- }
173
- },
174
- {
175
- "id": "sign-btc-psbt",
176
- "prompt": "Sign this Bitcoin PSBT transaction",
177
- "skill": "signing",
178
- "expect": {
179
- "commands_any_order": ["onekey-hw sign-psbt"],
180
- "forbidden": ["--help"]
181
- }
182
- },
183
- {
184
- "id": "sign-btc-inputs-outputs",
185
- "prompt": "Sign a Bitcoin transaction with these inputs and outputs",
186
- "skill": "signing",
187
- "expect": {
188
- "commands_any_order": ["onekey-hw sign-transaction --chain btc"],
189
- "forbidden": ["--help"]
190
- }
191
- },
192
- {
193
- "id": "sign-eip712",
194
- "prompt": "Sign this EIP-712 typed data with my hardware wallet",
195
- "skill": "signing",
196
- "expect": {
197
- "commands_any_order": ["onekey-hw sign-typed-data"],
198
- "forbidden": ["--help"]
199
- }
200
- },
201
- {
202
- "id": "verify-eth-message",
203
- "prompt": "Verify this Ethereum signed message on my device",
204
- "skill": "signing",
205
- "expect": {
206
- "commands_any_order": ["onekey-hw verify-message --chain evm"],
207
- "forbidden": ["--help"]
208
- }
209
- },
210
- {
211
- "id": "remove-pin",
212
- "prompt": "Remove PIN from my device",
213
- "skill": "security",
214
- "expect": {
215
- "commands_any_order": ["onekey-hw change-pin --remove"],
216
- "forbidden": ["--help"]
217
- }
218
- },
219
- {
220
- "id": "passphrase-session",
221
- "prompt": "Get my hidden wallet passphrase state",
222
- "skill": "security",
223
- "expect": {
224
- "commands_any_order": ["onekey-hw passphrase-state"],
225
- "forbidden": ["--help"]
226
- }
227
- },
228
- {
229
- "id": "haptic-feedback",
230
- "prompt": "Disable haptic feedback on my device",
231
- "skill": "security",
232
- "expect": {
233
- "commands_any_order": ["onekey-hw device-settings --haptic-feedback false"],
234
- "forbidden": ["--help"]
235
- }
236
- },
237
- {
238
- "id": "bootloader-stuck",
239
- "prompt": "My device is stuck in bootloader mode, help me fix it",
240
- "skill": "firmware",
241
- "expect": {
242
- "commands_any_order": ["onekey-hw search", "onekey-hw firmware-check"],
243
- "note": "Agent should diagnose and redirect to OneKey App for firmware recovery"
244
- }
245
- },
246
- {
247
- "id": "bootloader-check",
248
- "prompt": "Check my device bootloader version",
249
- "skill": "firmware",
250
- "expect": {
251
- "commands_any_order": ["onekey-hw bootloader-check"],
252
- "forbidden": ["--help"]
253
- }
254
- },
255
- {
256
- "id": "connection-troubleshoot",
257
- "prompt": "My hardware wallet won't connect",
258
- "skill": "device",
259
- "expect": {
260
- "commands_ordered": ["onekey-hw search"],
261
- "forbidden": ["--help"]
262
- }
263
- },
264
- {
265
- "id": "nostr-pubkey",
266
- "prompt": "Get my Nostr public key from hardware wallet",
267
- "skill": "signing",
268
- "expect": {
269
- "commands_any_order": ["onekey-hw get-public-key --chain nostr"],
270
- "forbidden": ["--help"]
271
- }
272
- },
273
- {
274
- "id": "lock-device",
275
- "prompt": "Lock my device",
276
- "skill": "device",
277
- "expect": {
278
- "commands": ["onekey-hw lock"],
279
- "forbidden": ["--help"]
280
- }
281
- },
282
- {
283
- "id": "nostr-encrypt",
284
- "prompt": "Encrypt a message for this Nostr pubkey",
285
- "skill": "signing",
286
- "expect": {
287
- "commands_any_order": ["onekey-hw nostr-encrypt"],
288
- "forbidden": ["--help"]
289
- }
290
- },
291
- {
292
- "id": "nostr-decrypt",
293
- "prompt": "Decrypt this Nostr message",
294
- "skill": "signing",
295
- "expect": {
296
- "commands_any_order": ["onekey-hw nostr-decrypt"],
297
- "forbidden": ["--help"]
298
- }
299
- },
300
- {
301
- "id": "nostr-schnorr",
302
- "prompt": "Sign this hash with Schnorr for Nostr",
303
- "skill": "signing",
304
- "expect": {
305
- "commands_any_order": ["onekey-hw nostr-sign-schnorr"],
306
- "forbidden": ["--help"]
307
- }
308
- },
309
- {
310
- "id": "lnurl-auth",
311
- "prompt": "Authenticate with this Lightning service using LNURL",
312
- "skill": "signing",
313
- "expect": {
314
- "commands_any_order": ["onekey-hw lnurl-auth"],
315
- "forbidden": ["--help"]
316
- }
317
- },
318
- {
319
- "id": "sol-offchain-message",
320
- "prompt": "Sign this Solana off-chain message",
321
- "skill": "signing",
322
- "expect": {
323
- "commands_any_order": ["onekey-hw sol-sign-offchain"],
324
- "forbidden": ["--help"]
325
- }
326
- },
327
- {
328
- "id": "conflux-cip23",
329
- "prompt": "Sign this Conflux CIP-23 structured message",
330
- "skill": "signing",
331
- "expect": {
332
- "commands_any_order": ["onekey-hw conflux-sign-cip23"],
333
- "forbidden": ["--help"]
334
- }
335
- },
336
- {
337
- "id": "aptos-sign-in",
338
- "prompt": "Sign in to this Aptos dApp",
339
- "skill": "signing",
340
- "expect": {
341
- "commands_any_order": ["onekey-hw aptos-sign-in"],
342
- "forbidden": ["--help"]
343
- }
344
- },
345
- {
346
- "id": "ton-proof",
347
- "prompt": "Generate a TON Connect proof for authentication",
348
- "skill": "signing",
349
- "expect": {
350
- "commands_any_order": ["onekey-hw ton-sign-proof"],
351
- "forbidden": ["--help"]
352
- }
353
- },
354
- {
355
- "id": "evm-eip712-hash",
356
- "prompt": "Sign this EIP-712 domain hash and message hash",
357
- "skill": "signing",
358
- "expect": {
359
- "commands_any_order": ["onekey-hw evm-sign-eip712"],
360
- "forbidden": ["--help"]
361
- }
362
- },
363
- {
364
- "id": "device-label",
365
- "prompt": "Rename my device to 'My OneKey Pro'",
366
- "skill": "device",
367
- "expect": {
368
- "commands_any_order": ["onekey-hw device-settings --label"],
369
- "forbidden": ["--help"]
370
- }
371
- }
372
- ]
373
- }
@@ -1,136 +0,0 @@
1
- #!/usr/bin/env bash
2
- # =============================================================================
3
- # OneKey Hardware CLI — Agent Skill Evaluation Runner
4
- #
5
- # Aligned with app-monorepo's eval approach:
6
- # - Invokes Claude Code in headless mode with actual skill files loaded
7
- # - System prompt enforces skill-file-first behavior (no --help)
8
- # - Structured JSON output per case saved to results/ directory
9
- # - Deferred scoring via follow-up Claude invocation (LLM-as-judge)
10
- #
11
- # Usage:
12
- # ./run-evals.sh # Run all cases with default model
13
- # ./run-evals.sh --model haiku # Run with specific model
14
- # ./run-evals.sh --case device-* # Run matching cases only
15
- # ./run-evals.sh --verbose # Show detailed output
16
- # =============================================================================
17
-
18
- set -euo pipefail
19
-
20
- SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
21
- CLI_DIR="$(dirname "${SCRIPT_DIR}")"
22
- CASES_FILE="${SCRIPT_DIR}/cases.json"
23
- RESULTS_DIR="${SCRIPT_DIR}/results"
24
- MODEL="sonnet"
25
- VERBOSE="false"
26
- CASE_FILTER=""
27
-
28
- # Parse arguments
29
- while [[ $# -gt 0 ]]; do
30
- case $1 in
31
- --model) MODEL="$2"; shift 2 ;;
32
- --case) CASE_FILTER="$2"; shift 2 ;;
33
- --verbose) VERBOSE="true"; shift ;;
34
- *) echo "Unknown option: $1"; exit 1 ;;
35
- esac
36
- done
37
-
38
- TIMESTAMP=$(date +%Y%m%d-%H%M%S)
39
- RUN_DIR="${RESULTS_DIR}/${TIMESTAMP}-${MODEL}"
40
- mkdir -p "${RUN_DIR}"
41
-
42
- # System prompt: force agent to use skill files, skip preflight, auto-confirm
43
- SYSTEM_PROMPT="You have the onekey-hardware plugin installed.
44
- BEFORE running any onekey-hw command, you MUST read the skill files at ${CLI_DIR}/skills/ to understand available commands and their parameters.
45
- NEVER use onekey-hw --help or --help on subcommands. The skill files are your sole documentation source.
46
- Skip all pre-flight checks (version checking) — assume CLI is installed and ready.
47
- When a command requires user confirmation, auto-confirm YES.
48
- If an API call fails, retry at most once before reporting the error.
49
- Output only the onekey-hw commands you would execute, one per line. No explanations."
50
-
51
- echo "============================================="
52
- echo "OneKey Hardware CLI — Eval Runner"
53
- echo "Model: ${MODEL}"
54
- echo "Cases: ${CASES_FILE}"
55
- echo "Output: ${RUN_DIR}"
56
- echo "============================================="
57
-
58
- # Model flag for claude CLI
59
- MODEL_FLAG=""
60
- if [[ "${MODEL}" != "sonnet" ]]; then
61
- MODEL_FLAG="--model ${MODEL}"
62
- fi
63
-
64
- # Count cases
65
- TOTAL=$(jq '.cases | length' "${CASES_FILE}")
66
- EXECUTED=0
67
- SKIPPED=0
68
-
69
- echo "Running ${TOTAL} evaluation cases..."
70
- echo ""
71
-
72
- # Iterate through cases
73
- for i in $(seq 0 $((TOTAL - 1))); do
74
- CASE_ID=$(jq -r ".cases[$i].id" "${CASES_FILE}")
75
- PROMPT=$(jq -r ".cases[$i].prompt" "${CASES_FILE}")
76
-
77
- # Apply case filter if specified
78
- if [[ -n "${CASE_FILTER}" ]] && [[ ! "${CASE_ID}" == ${CASE_FILTER} ]]; then
79
- SKIPPED=$((SKIPPED + 1))
80
- continue
81
- fi
82
-
83
- echo -n "[$((i+1))/${TOTAL}] ${CASE_ID}: "
84
-
85
- # Invoke Claude Code in headless mode
86
- # Aligned with app-monorepo: -p for prompt, --output-format json,
87
- # --max-turns 25, --permission-mode bypassPermissions
88
- RESULT_FILE="${RUN_DIR}/${CASE_ID}.json"
89
-
90
- if command -v claude &> /dev/null; then
91
- claude -p "${PROMPT}" \
92
- --output-format json \
93
- --max-turns 25 \
94
- --permission-mode bypassPermissions \
95
- --system-prompt "${SYSTEM_PROMPT}" \
96
- ${MODEL_FLAG} \
97
- > "${RESULT_FILE}" 2>/dev/null || echo '{"error": "claude invocation failed"}' > "${RESULT_FILE}"
98
- echo "DONE → ${RESULT_FILE}"
99
- EXECUTED=$((EXECUTED + 1))
100
- else
101
- echo "SKIP (claude CLI not found)"
102
- echo '{"error": "claude CLI not installed"}' > "${RESULT_FILE}"
103
- SKIPPED=$((SKIPPED + 1))
104
- fi
105
- done
106
-
107
- echo ""
108
- echo "============================================="
109
- echo "Executed: ${EXECUTED}, Skipped: ${SKIPPED} (${TOTAL} total)"
110
- echo "Results saved to: ${RUN_DIR}"
111
- echo "============================================="
112
-
113
- # Write run metadata
114
- jq -n \
115
- --arg model "${MODEL}" \
116
- --arg timestamp "${TIMESTAMP}" \
117
- --argjson executed "${EXECUTED}" \
118
- --argjson skipped "${SKIPPED}" \
119
- --argjson total "${TOTAL}" \
120
- '{
121
- model: $model,
122
- timestamp: $timestamp,
123
- total: $total,
124
- executed: $executed,
125
- skipped: $skipped
126
- }' > "${RUN_DIR}/_metadata.json"
127
-
128
- # Print scoring instructions
129
- echo ""
130
- echo "To score results, run:"
131
- echo ""
132
- echo " claude -p \"Read all JSON files in ${RUN_DIR}/ and the eval case definitions"
133
- echo " in ${CASES_FILE}. For each case, compare the actual commands executed against"
134
- echo " the expected commands. Produce a markdown table with columns:"
135
- echo " case_id | status (PASS/FAIL) | expected | actual | issues."
136
- echo " Also check forbidden patterns if defined. Summary at the end.\""
package/rollup.config.js DELETED
@@ -1,28 +0,0 @@
1
- import typescript from '@rollup/plugin-typescript';
2
- import json from '@rollup/plugin-json';
3
- import dts from 'rollup-plugin-dts';
4
- import commonjs from '@rollup/plugin-commonjs';
5
-
6
- const config = [
7
- // All source files → dist/ directory (cjs format)
8
- // This outputs index.js, cli.js, sdk.js, chains.js all to dist/
9
- // so cli.js can require('./sdk') and require('./chains')
10
- {
11
- input: {
12
- index: './src/index.ts',
13
- cli: './src/cli.ts',
14
- sdk: './src/sdk.ts',
15
- chains: './src/chains.ts',
16
- },
17
- output: [{ dir: 'dist', format: 'cjs' }],
18
- plugins: [typescript(), commonjs(), json()],
19
- },
20
- // Type declarations
21
- {
22
- input: './src/index.ts',
23
- output: { file: 'dist/index.d.ts', format: 'es' },
24
- plugins: [dts()],
25
- },
26
- ];
27
-
28
- export default config;