@hedge-layer/cli 4.0.0 → 5.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/README.md +101 -72
- package/dist/index.mjs +151 -1568
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -9
package/README.md
CHANGED
|
@@ -1,113 +1,142 @@
|
|
|
1
1
|
# @hedge-layer/cli
|
|
2
2
|
|
|
3
|
-
[
|
|
4
|
-
|
|
3
|
+
[Hedge Layer](https://github.com/hedge-layer/hedge-layer) is a unified layer for
|
|
4
|
+
financial data and trade execution. Its main service exposes tools through MCP
|
|
5
|
+
at `/mcp` and the HTTP API. The `hl` CLI calls that API to offer the same
|
|
6
|
+
operations to agents and scripts that prefer command-line tools. The web app
|
|
7
|
+
provides connection instructions and API token management.
|
|
5
8
|
|
|
6
|
-
|
|
9
|
+
[Agent H](https://github.com/hedge-layer/agent-h) is the native MCP agent and an
|
|
10
|
+
optional client. You can use Codex, Claude Code, Python, or any other compatible
|
|
11
|
+
client. Research workflows belong to the chosen agent; the CLI discovers tool
|
|
12
|
+
schemas from the service and forwards the arguments you supply.
|
|
7
13
|
|
|
8
|
-
|
|
9
|
-
|
|
14
|
+
Current tools cover Polymarket and Hyperliquid market search, Polymarket market
|
|
15
|
+
data and order books, web evidence search, and locally signed Polymarket order
|
|
16
|
+
submission, lookup, and cancellation. Matching and settlement stay at the venue.
|
|
10
17
|
|
|
11
18
|
## Install
|
|
12
19
|
|
|
13
20
|
```bash
|
|
14
|
-
npm install -g @hedge-layer/cli
|
|
21
|
+
npm install -g @hedge-layer/cli@5
|
|
15
22
|
```
|
|
16
23
|
|
|
17
|
-
|
|
24
|
+
CLI 5.x requires Node.js 22 or later and a Hedge Layer server providing the
|
|
25
|
+
`/api/v1/tools` API. To build from source, follow the
|
|
26
|
+
[development instructions](#development) and replace `hl` in the examples with
|
|
27
|
+
`node dist/index.mjs`.
|
|
18
28
|
|
|
19
|
-
|
|
29
|
+
## Quick start
|
|
20
30
|
|
|
21
|
-
|
|
22
|
-
your npm prefix points at a root-owned directory (e.g. `/usr/lib/node_modules`) and you
|
|
23
|
-
don't have `sudo`. Install into a user-writable prefix instead:
|
|
31
|
+
Create an API token in your Hedge Layer account settings, then:
|
|
24
32
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
```bash
|
|
34
|
+
hl auth login
|
|
35
|
+
hl tools
|
|
36
|
+
hl tools search_markets
|
|
37
|
+
hl call search_markets --args '{"query":"bitcoin","venues":["polymarket","hyperliquid"],"limit":5}'
|
|
38
|
+
hl call list_polymarket_markets
|
|
39
|
+
hl call get_polymarket_orderbook --args '{"token_id":"<token-id>"}'
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`hl auth login` hides token input. For scripts, provide `HL_TOKEN` through your
|
|
43
|
+
shell or secret manager. Set `HL_API_URL` to use another server, or pass
|
|
44
|
+
`--api-url http://localhost:3000` for local development.
|
|
31
45
|
|
|
32
|
-
|
|
33
|
-
this is harmless shell-init noise from `nvm` (not from `hl`) that appears after setting a
|
|
34
|
-
custom npm prefix as above — the CLI still works. To avoid it entirely under `nvm`, install
|
|
35
|
-
without a custom prefix (nvm's per-version `bin/` is already user-writable):
|
|
46
|
+
## Commands
|
|
36
47
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
48
|
+
| Command | Behavior |
|
|
49
|
+
| --- | --- |
|
|
50
|
+
| `hl tools [name]` | List the server's tools and JSON Schemas, or inspect one tool |
|
|
51
|
+
| `hl call <name> [--args <json> \| --file <path> \| --stdin]` | Invoke a tool with a JSON object; defaults to `{}` |
|
|
52
|
+
| `hl auth login` | Validate and save an API token |
|
|
53
|
+
| `hl auth status` | Validate the active token against the tool catalog |
|
|
54
|
+
| `hl auth logout` | Remove the saved token; environment variables and flags still apply |
|
|
43
55
|
|
|
44
|
-
|
|
56
|
+
All successful command output is JSON on stdout. Prompts and diagnostics go to
|
|
57
|
+
stderr. `hl call` preserves the complete MCP result, including `content`,
|
|
58
|
+
`structuredContent`, and `isError`. Tool errors (`isError: true`) retain their
|
|
59
|
+
JSON output and exit with status 1. HTTP, network, and input errors also exit
|
|
60
|
+
with status 1, with a JSON error on stderr. Command-line usage errors are
|
|
61
|
+
printed by the argument parser.
|
|
45
62
|
|
|
46
|
-
|
|
63
|
+
Arguments must be a JSON object, using exactly one input source:
|
|
47
64
|
|
|
48
65
|
```bash
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
hl
|
|
52
|
-
|
|
53
|
-
# 3. Generate a Market Brief
|
|
54
|
-
hl brief "US China trade war tariffs"
|
|
66
|
+
hl call search_markets --file query.json
|
|
67
|
+
cat query.json | hl call search_markets --stdin
|
|
68
|
+
hl call search_markets --args '{"query":"bitcoin"}' | jq '.structuredContent'
|
|
69
|
+
```
|
|
55
70
|
|
|
56
|
-
|
|
57
|
-
|
|
71
|
+
Use `hl tools` as the authoritative list for your server. Tool names, schemas,
|
|
72
|
+
and `requiredScope` come from the API, so the CLI does not need a release when
|
|
73
|
+
a provider adds a tool.
|
|
58
74
|
|
|
59
|
-
|
|
60
|
-
hl quote "example-market" --action buy --outcome yes --cash 25
|
|
75
|
+
## Execution
|
|
61
76
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
77
|
+
Polymarket order submission, cancellation, and order lookup use locally signed
|
|
78
|
+
venue requests. Create a Hedge Layer token with `read` and `trade` scopes for
|
|
79
|
+
submission and cancellation; order lookup requires `read`. New tokens are
|
|
80
|
+
read-only by default. Inspect the exact schemas first:
|
|
65
81
|
|
|
66
|
-
|
|
67
|
-
hl
|
|
82
|
+
```bash
|
|
83
|
+
hl tools submit_polymarket_order
|
|
84
|
+
hl tools cancel_polymarket_order
|
|
85
|
+
hl tools get_polymarket_order
|
|
68
86
|
```
|
|
69
87
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
Directional quote previews are available with `hl quote`:
|
|
88
|
+
Use the venue SDK locally to sign the order and its request authentication.
|
|
89
|
+
Your signing code should produce an arguments object containing `signed_body`
|
|
90
|
+
(the exact signed request body as a string) and `auth` (address, API key,
|
|
91
|
+
passphrase, timestamp, and signature). Pass that object through stdin or a
|
|
92
|
+
private file so credentials do not enter shell history:
|
|
76
93
|
|
|
77
94
|
```bash
|
|
78
|
-
hl
|
|
79
|
-
hl
|
|
80
|
-
hl
|
|
81
|
-
hl --json quote example-market --action buy --outcome yes --cash 25
|
|
95
|
+
hl call submit_polymarket_order --stdin < signed-order-arguments.json
|
|
96
|
+
hl call cancel_polymarket_order --stdin < signed-cancellation-arguments.json
|
|
97
|
+
hl call get_polymarket_order --stdin < signed-order-lookup-arguments.json
|
|
82
98
|
```
|
|
83
99
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
100
|
+
Order lookup arguments contain `order_id` and `auth` instead of `signed_body`.
|
|
101
|
+
The CLI preserves the exact `signed_body` string. It never signs requests,
|
|
102
|
+
requests wallet private keys or CLOB API secrets, or retries calls. If a
|
|
103
|
+
submission times out, reconcile its status with the venue before submitting
|
|
104
|
+
again. See the [Hedge Layer execution guide](https://hedgelayer.ai/docs/execution)
|
|
105
|
+
for the server contract and signing workflow.
|
|
88
106
|
|
|
89
|
-
|
|
90
|
-
official `hl` CLI.
|
|
107
|
+
## Configuration
|
|
91
108
|
|
|
92
|
-
|
|
93
|
-
(liquid core, active volume, movers, new markets, uncertainty, and LP quality),
|
|
94
|
-
de-duplicates by slug, and writes a ranked candidate file:
|
|
109
|
+
Options take precedence over environment variables, then saved configuration:
|
|
95
110
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
111
|
+
| Setting | Flag | Environment | Default |
|
|
112
|
+
| --- | --- | --- | --- |
|
|
113
|
+
| API origin | `--api-url` | `HL_API_URL` | `https://hedgelayer.ai` |
|
|
114
|
+
| API token | `--token` | `HL_TOKEN` | Token saved by `hl auth login` |
|
|
115
|
+
| HTTP diagnostics | `--verbose` | — | Off |
|
|
116
|
+
|
|
117
|
+
The CLI does not load `.env` files. Export variables in your shell or secret
|
|
118
|
+
manager. Configuration is saved to `~/.hedgelayer/config.json` with file mode
|
|
119
|
+
`0600`. URLs must use HTTPS, except HTTP loopback servers for development.
|
|
120
|
+
Redirects are rejected. Verbose output includes method, URL, and status only.
|
|
99
121
|
|
|
100
|
-
|
|
122
|
+
## Development
|
|
101
123
|
|
|
102
124
|
```bash
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
125
|
+
npm ci
|
|
126
|
+
npm run typecheck
|
|
127
|
+
npm run lint
|
|
128
|
+
npm test
|
|
129
|
+
npm run build
|
|
130
|
+
node dist/index.mjs --help
|
|
106
131
|
```
|
|
107
132
|
|
|
108
|
-
|
|
133
|
+
Tests cover the HTTP contract, the built binary against a local API server,
|
|
134
|
+
authentication, signed payload preservation, error exits, redirects, and
|
|
135
|
+
configuration permissions. They do not place live orders.
|
|
109
136
|
|
|
110
|
-
|
|
137
|
+
This is a fresh command surface: the former `brief`, `research`, `feed`,
|
|
138
|
+
`signal`, `quote`, and `profile` commands have been removed. Use the server's
|
|
139
|
+
tools directly and let your chosen agent handle research workflows.
|
|
111
140
|
|
|
112
141
|
## License
|
|
113
142
|
|