openbroker 1.9.1 → 1.9.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/CHANGELOG.md CHANGED
@@ -5,6 +5,7 @@ All notable changes to Open Broker will be documented in this file.
5
5
  ## [1.9.1] - 2026-06-22
6
6
 
7
7
  ### Changed
8
+ - Added `openbroker install --codex` and `npx openbroker@latest install --codex` for one-command Codex skill installation, persistent CLI installation, and restricted API-wallet onboarding.
8
9
  - Made restricted API-wallet onboarding the recommended interactive default.
9
10
  - Added `openbroker setup --api-wallet` for deterministic agent setup without the wallet-selection prompt.
10
11
  - Updated the Codex skill to install the CLI, hand the browser approval URL to the user, wait for authorization, and verify the connected master account without exposing private keys.
package/README.md CHANGED
@@ -8,6 +8,16 @@ Hyperliquid trading CLI. Execute orders, manage positions, and run trading strat
8
8
  npm install -g openbroker
9
9
  ```
10
10
 
11
+ ### Codex: one-command install
12
+
13
+ Install the Codex skill, persistent CLI, and restricted API-wallet onboarding flow:
14
+
15
+ ```bash
16
+ npx openbroker@latest install --codex
17
+ ```
18
+
19
+ When the command prints an approval URL, open it and connect the funded master Hyperliquid account you want OpenBroker to trade on. Restart Codex or start a new thread when setup finishes, then invoke `$openbroker`.
20
+
11
21
  ## Quick Start
12
22
 
13
23
  ```bash
@@ -27,6 +37,7 @@ openbroker search --query GOLD # Find markets
27
37
  ### Setup
28
38
 
29
39
  ```bash
40
+ npx openbroker@latest install --codex # Codex skill + CLI + API-wallet onboarding
30
41
  openbroker setup --api-wallet # Recommended: restricted agent wallet + browser approval
31
42
  openbroker setup # Interactive; API wallet is the default
32
43
  ```
package/SKILL.md CHANGED
@@ -21,7 +21,15 @@ Use the `openbroker` CLI as the canonical interface. Prefer structured JSON outp
21
21
 
22
22
  Use the following flow when the user asks to install, set up, or use OpenBroker. Do not ask the user for a private key.
23
23
 
24
- First check whether Node.js 22+ and the CLI are installed:
24
+ For a fresh Codex installation, prefer the unified harness installer:
25
+
26
+ ```bash
27
+ npx --yes openbroker@latest install --codex
28
+ ```
29
+
30
+ This installs or updates the Codex skill, installs the persistent `openbroker` CLI, and starts restricted API-wallet onboarding. Keep the command attached while it prints the browser approval link and polls for authorization.
31
+
32
+ If the unified installer is unavailable or the skill is already installed, first check whether Node.js 22+ and the CLI are installed:
25
33
 
26
34
  ```bash
27
35
  node --version
package/bin/cli.ts CHANGED
@@ -11,6 +11,7 @@ const scriptsDir = path.resolve(__dirname, '../scripts');
11
11
 
12
12
  const commands: Record<string, { script: string; description: string }> = {
13
13
  // Setup
14
+ 'install': { script: 'setup/install.ts', description: 'Install OpenBroker for an agent harness' },
14
15
  'setup': { script: 'setup/onboard.ts', description: 'Interactive setup wizard' },
15
16
  'onboard': { script: 'setup/onboard.ts', description: 'Interactive setup wizard' },
16
17
  'approve-builder': { script: 'setup/approve-builder.ts', description: 'Approve builder fee' },
@@ -68,6 +69,7 @@ Open Broker - Hyperliquid Trading CLI
68
69
  Usage: openbroker <command> [options]
69
70
 
70
71
  Setup:
72
+ install Install OpenBroker for Codex or another agent harness
71
73
  setup One-command setup (wallet + config + builder approval)
72
74
 
73
75
  Info Commands:
@@ -136,6 +138,7 @@ Utility:
136
138
  approve-builder Check or retry builder fee approval
137
139
 
138
140
  Examples:
141
+ npx openbroker@latest install --codex # Install skill + CLI + API-wallet setup
139
142
  openbroker setup --api-wallet # Recommended restricted API-wallet setup
140
143
  openbroker account # View account info
141
144
  openbroker buy --coin ETH --size 0.1 # Market buy 0.1 ETH
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env npx tsx
2
+ export {};
3
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../scripts/setup/install.ts"],"names":[],"mappings":""}
@@ -0,0 +1,113 @@
1
+ #!/usr/bin/env npx tsx
2
+ // Harness-aware OpenBroker installer.
3
+ import * as fs from 'fs';
4
+ import * as path from 'path';
5
+ import { homedir } from 'os';
6
+ import { fileURLToPath } from 'url';
7
+ import { spawnSync } from 'child_process';
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = path.dirname(__filename);
10
+ const packageRoot = path.resolve(__dirname, '../..');
11
+ const args = new Set(process.argv.slice(2));
12
+ function printUsage() {
13
+ console.log(`
14
+ OpenBroker Harness Installer
15
+ ============================
16
+
17
+ Usage:
18
+ openbroker install --codex [options]
19
+ npx openbroker@latest install --codex [options]
20
+
21
+ Harnesses:
22
+ --codex Install the OpenBroker skill for Codex
23
+
24
+ Options:
25
+ --skip-cli Do not install the persistent global CLI
26
+ --skip-setup Install files without starting API-wallet onboarding
27
+ --help Show this help
28
+
29
+ The default Codex flow installs the global CLI, writes the skill under
30
+ $CODEX_HOME/skills/openbroker (default: ~/.codex/skills/openbroker), and starts
31
+ restricted API-wallet onboarding.
32
+ `);
33
+ }
34
+ function fail(message) {
35
+ console.error(`Error: ${message}`);
36
+ process.exit(1);
37
+ }
38
+ function assertOpenBrokerSkill(skillPath) {
39
+ if (!fs.existsSync(skillPath))
40
+ return;
41
+ const existing = fs.readFileSync(skillPath, 'utf8');
42
+ if (!/^name:\s*openbroker\s*$/m.test(existing)) {
43
+ fail(`refusing to overwrite unrelated skill at ${skillPath}`);
44
+ }
45
+ }
46
+ function copyManagedFile(source, destination) {
47
+ if (!fs.existsSync(source)) {
48
+ fail(`packaged installer asset is missing: ${source}`);
49
+ }
50
+ fs.mkdirSync(path.dirname(destination), { recursive: true, mode: 0o755 });
51
+ fs.copyFileSync(source, destination);
52
+ fs.chmodSync(destination, 0o644);
53
+ }
54
+ function installCodexSkill() {
55
+ const codexHome = process.env.CODEX_HOME || path.join(homedir(), '.codex');
56
+ const destination = path.join(codexHome, 'skills', 'openbroker');
57
+ const skillPath = path.join(destination, 'SKILL.md');
58
+ assertOpenBrokerSkill(skillPath);
59
+ copyManagedFile(path.join(packageRoot, 'SKILL.md'), skillPath);
60
+ copyManagedFile(path.join(packageRoot, 'agents', 'openai.yaml'), path.join(destination, 'agents', 'openai.yaml'));
61
+ console.log(`✅ Codex skill installed: ${destination}`);
62
+ return destination;
63
+ }
64
+ function installGlobalCli() {
65
+ const npmCommand = process.platform === 'win32' ? 'npm.cmd' : 'npm';
66
+ console.log('\nInstalling the persistent OpenBroker CLI...');
67
+ const result = spawnSync(npmCommand, ['install', '-g', 'openbroker@latest'], {
68
+ stdio: 'inherit',
69
+ });
70
+ if (result.error) {
71
+ fail(`could not start npm: ${result.error.message}`);
72
+ }
73
+ if (result.status !== 0) {
74
+ fail('global CLI installation failed. Fix the npm permission error, then rerun with --skip-cli.');
75
+ }
76
+ }
77
+ function runApiWalletSetup() {
78
+ const onboardPath = path.join(packageRoot, 'scripts', 'setup', 'onboard.ts');
79
+ console.log('\nStarting restricted API-wallet onboarding...\n');
80
+ const result = spawnSync(process.execPath, ['--import', 'tsx', onboardPath, '--api-wallet'], {
81
+ stdio: 'inherit',
82
+ cwd: packageRoot,
83
+ env: process.env,
84
+ });
85
+ if (result.error) {
86
+ fail(`could not start onboarding: ${result.error.message}`);
87
+ }
88
+ if (result.status !== 0) {
89
+ fail('API-wallet onboarding did not complete. Rerun `openbroker setup --api-wallet`.');
90
+ }
91
+ }
92
+ function main() {
93
+ if (args.has('--help') || args.has('-h')) {
94
+ printUsage();
95
+ return;
96
+ }
97
+ if (!args.has('--codex')) {
98
+ printUsage();
99
+ fail('choose a supported harness flag such as --codex');
100
+ }
101
+ console.log('OpenBroker — Codex Installation');
102
+ console.log('================================\n');
103
+ installCodexSkill();
104
+ if (!args.has('--skip-cli')) {
105
+ installGlobalCli();
106
+ }
107
+ if (!args.has('--skip-setup')) {
108
+ runApiWalletSetup();
109
+ }
110
+ console.log('\n✅ OpenBroker installation complete.');
111
+ console.log('Restart Codex or start a new thread, then invoke $openbroker.');
112
+ }
113
+ main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openbroker",
3
- "version": "1.9.1",
3
+ "version": "1.9.2",
4
4
  "description": "Hyperliquid trading CLI - execute orders, manage positions, and run trading strategies",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,146 @@
1
+ #!/usr/bin/env npx tsx
2
+ // Harness-aware OpenBroker installer.
3
+
4
+ import * as fs from 'fs';
5
+ import * as path from 'path';
6
+ import { homedir } from 'os';
7
+ import { fileURLToPath } from 'url';
8
+ import { spawnSync } from 'child_process';
9
+
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ const __dirname = path.dirname(__filename);
12
+ const packageRoot = path.resolve(__dirname, '../..');
13
+ const args = new Set(process.argv.slice(2));
14
+
15
+ function printUsage(): void {
16
+ console.log(`
17
+ OpenBroker Harness Installer
18
+ ============================
19
+
20
+ Usage:
21
+ openbroker install --codex [options]
22
+ npx openbroker@latest install --codex [options]
23
+
24
+ Harnesses:
25
+ --codex Install the OpenBroker skill for Codex
26
+
27
+ Options:
28
+ --skip-cli Do not install the persistent global CLI
29
+ --skip-setup Install files without starting API-wallet onboarding
30
+ --help Show this help
31
+
32
+ The default Codex flow installs the global CLI, writes the skill under
33
+ $CODEX_HOME/skills/openbroker (default: ~/.codex/skills/openbroker), and starts
34
+ restricted API-wallet onboarding.
35
+ `);
36
+ }
37
+
38
+ function fail(message: string): never {
39
+ console.error(`Error: ${message}`);
40
+ process.exit(1);
41
+ }
42
+
43
+ function assertOpenBrokerSkill(skillPath: string): void {
44
+ if (!fs.existsSync(skillPath)) return;
45
+
46
+ const existing = fs.readFileSync(skillPath, 'utf8');
47
+ if (!/^name:\s*openbroker\s*$/m.test(existing)) {
48
+ fail(`refusing to overwrite unrelated skill at ${skillPath}`);
49
+ }
50
+ }
51
+
52
+ function copyManagedFile(source: string, destination: string): void {
53
+ if (!fs.existsSync(source)) {
54
+ fail(`packaged installer asset is missing: ${source}`);
55
+ }
56
+
57
+ fs.mkdirSync(path.dirname(destination), { recursive: true, mode: 0o755 });
58
+ fs.copyFileSync(source, destination);
59
+ fs.chmodSync(destination, 0o644);
60
+ }
61
+
62
+ function installCodexSkill(): string {
63
+ const codexHome = process.env.CODEX_HOME || path.join(homedir(), '.codex');
64
+ const destination = path.join(codexHome, 'skills', 'openbroker');
65
+ const skillPath = path.join(destination, 'SKILL.md');
66
+
67
+ assertOpenBrokerSkill(skillPath);
68
+ copyManagedFile(path.join(packageRoot, 'SKILL.md'), skillPath);
69
+ copyManagedFile(
70
+ path.join(packageRoot, 'agents', 'openai.yaml'),
71
+ path.join(destination, 'agents', 'openai.yaml'),
72
+ );
73
+
74
+ console.log(`✅ Codex skill installed: ${destination}`);
75
+ return destination;
76
+ }
77
+
78
+ function installGlobalCli(): void {
79
+ const npmCommand = process.platform === 'win32' ? 'npm.cmd' : 'npm';
80
+
81
+ console.log('\nInstalling the persistent OpenBroker CLI...');
82
+ const result = spawnSync(npmCommand, ['install', '-g', 'openbroker@latest'], {
83
+ stdio: 'inherit',
84
+ });
85
+
86
+ if (result.error) {
87
+ fail(`could not start npm: ${result.error.message}`);
88
+ }
89
+ if (result.status !== 0) {
90
+ fail(
91
+ 'global CLI installation failed. Fix the npm permission error, then rerun with --skip-cli.',
92
+ );
93
+ }
94
+ }
95
+
96
+ function runApiWalletSetup(): void {
97
+ const onboardPath = path.join(packageRoot, 'scripts', 'setup', 'onboard.ts');
98
+
99
+ console.log('\nStarting restricted API-wallet onboarding...\n');
100
+ const result = spawnSync(
101
+ process.execPath,
102
+ ['--import', 'tsx', onboardPath, '--api-wallet'],
103
+ {
104
+ stdio: 'inherit',
105
+ cwd: packageRoot,
106
+ env: process.env,
107
+ },
108
+ );
109
+
110
+ if (result.error) {
111
+ fail(`could not start onboarding: ${result.error.message}`);
112
+ }
113
+ if (result.status !== 0) {
114
+ fail('API-wallet onboarding did not complete. Rerun `openbroker setup --api-wallet`.');
115
+ }
116
+ }
117
+
118
+ function main(): void {
119
+ if (args.has('--help') || args.has('-h')) {
120
+ printUsage();
121
+ return;
122
+ }
123
+
124
+ if (!args.has('--codex')) {
125
+ printUsage();
126
+ fail('choose a supported harness flag such as --codex');
127
+ }
128
+
129
+ console.log('OpenBroker — Codex Installation');
130
+ console.log('================================\n');
131
+
132
+ installCodexSkill();
133
+
134
+ if (!args.has('--skip-cli')) {
135
+ installGlobalCli();
136
+ }
137
+
138
+ if (!args.has('--skip-setup')) {
139
+ runApiWalletSetup();
140
+ }
141
+
142
+ console.log('\n✅ OpenBroker installation complete.');
143
+ console.log('Restart Codex or start a new thread, then invoke $openbroker.');
144
+ }
145
+
146
+ main();