@kmmao/happy-agent 0.2.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 +156 -0
- package/bin/happy-agent.mjs +38 -0
- package/dist/index.cjs +1037 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +1035 -0
- package/package.json +65 -0
package/README.md
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# Happy Agent
|
|
2
|
+
|
|
3
|
+
CLI client for controlling Happy Coder agents remotely.
|
|
4
|
+
|
|
5
|
+
Unlike `happy-cli` which both runs and controls agents, `happy-agent` only controls them — creating sessions, sending messages, reading history, monitoring state, and stopping sessions.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
From the monorepo:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
yarn workspace happy-agent build
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Or link globally:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
cd packages/happy-agent && npm link
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Authentication
|
|
22
|
+
|
|
23
|
+
Happy Agent uses account authentication via QR code, the same flow as linking a device in the Happy mobile app.
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Authenticate by scanning QR code with the Happy mobile app
|
|
27
|
+
happy-agent auth login
|
|
28
|
+
|
|
29
|
+
# Check authentication status
|
|
30
|
+
happy-agent auth status
|
|
31
|
+
|
|
32
|
+
# Clear stored credentials
|
|
33
|
+
happy-agent auth logout
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Credentials are stored at `~/.happy/agent.key`.
|
|
37
|
+
|
|
38
|
+
## Commands
|
|
39
|
+
|
|
40
|
+
### List sessions
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# List all sessions
|
|
44
|
+
happy-agent list
|
|
45
|
+
|
|
46
|
+
# List only active sessions
|
|
47
|
+
happy-agent list --active
|
|
48
|
+
|
|
49
|
+
# Output as JSON
|
|
50
|
+
happy-agent list --json
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Session status
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# Get live session state (supports ID prefix matching)
|
|
57
|
+
happy-agent status <session-id>
|
|
58
|
+
|
|
59
|
+
# Output as JSON
|
|
60
|
+
happy-agent status <session-id> --json
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Create a session
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Create a new session with a tag
|
|
67
|
+
happy-agent create --tag my-project
|
|
68
|
+
|
|
69
|
+
# Specify a working directory
|
|
70
|
+
happy-agent create --tag my-project --path /home/user/project
|
|
71
|
+
|
|
72
|
+
# Output as JSON
|
|
73
|
+
happy-agent create --tag my-project --json
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Send a message
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# Send a message to a session
|
|
80
|
+
happy-agent send <session-id> "Fix the login bug"
|
|
81
|
+
|
|
82
|
+
# Send and wait for the agent to finish
|
|
83
|
+
happy-agent send <session-id> "Run the tests" --wait
|
|
84
|
+
|
|
85
|
+
# Output as JSON
|
|
86
|
+
happy-agent send <session-id> "Hello" --json
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Message history
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# View message history
|
|
93
|
+
happy-agent history <session-id>
|
|
94
|
+
|
|
95
|
+
# Limit to last N messages
|
|
96
|
+
happy-agent history <session-id> --limit 10
|
|
97
|
+
|
|
98
|
+
# Output as JSON
|
|
99
|
+
happy-agent history <session-id> --json
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Stop a session
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
happy-agent stop <session-id>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Wait for idle
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Wait for agent to become idle (default 300s timeout)
|
|
112
|
+
happy-agent wait <session-id>
|
|
113
|
+
|
|
114
|
+
# Custom timeout
|
|
115
|
+
happy-agent wait <session-id> --timeout 60
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Exit code 0 when agent becomes idle, 1 on timeout.
|
|
119
|
+
|
|
120
|
+
## Environment Variables
|
|
121
|
+
|
|
122
|
+
- `HAPPY_SERVER_URL` - API server URL (default: `https://api.cluster-fluster.com`)
|
|
123
|
+
- `HAPPY_HOME_DIR` - Home directory for credential storage (default: `~/.happy`)
|
|
124
|
+
|
|
125
|
+
## Session ID Matching
|
|
126
|
+
|
|
127
|
+
All commands that accept a `<session-id>` support prefix matching. You can provide the first few characters of a session ID and the CLI will resolve the full ID.
|
|
128
|
+
|
|
129
|
+
## Encryption
|
|
130
|
+
|
|
131
|
+
All session data is end-to-end encrypted. New sessions use AES-256-GCM with per-session keys. Existing sessions created by other clients are decrypted using the appropriate key scheme (AES-256-GCM or legacy NaCl secretbox).
|
|
132
|
+
|
|
133
|
+
## Requirements
|
|
134
|
+
|
|
135
|
+
- Node.js >= 20.0.0
|
|
136
|
+
- A Happy mobile app account for authentication
|
|
137
|
+
|
|
138
|
+
## Publishing to npm
|
|
139
|
+
|
|
140
|
+
Maintainers can publish a new version:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
yarn release # From repo root: choose library to release
|
|
144
|
+
# or directly:
|
|
145
|
+
yarn workspace happy-agent release
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
This flow:
|
|
149
|
+
- runs tests/build checks via `prepublishOnly`
|
|
150
|
+
- creates a release commit and `happy-agent-vX.Y.Z` tag
|
|
151
|
+
- creates a GitHub release with generated notes
|
|
152
|
+
- publishes `happy-agent` to npm
|
|
153
|
+
|
|
154
|
+
## License
|
|
155
|
+
|
|
156
|
+
MIT
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { execFileSync } from 'child_process';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import { join, dirname } from 'path';
|
|
6
|
+
|
|
7
|
+
// Check if we're already running with the flags
|
|
8
|
+
const hasNoWarnings = process.execArgv.includes('--no-warnings');
|
|
9
|
+
const hasNoDeprecation = process.execArgv.includes('--no-deprecation');
|
|
10
|
+
|
|
11
|
+
if (!hasNoWarnings || !hasNoDeprecation) {
|
|
12
|
+
// Get path to the actual CLI entrypoint
|
|
13
|
+
const projectRoot = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
14
|
+
const entrypoint = join(projectRoot, 'dist', 'index.mjs');
|
|
15
|
+
|
|
16
|
+
// Execute the actual CLI directly with the correct flags
|
|
17
|
+
try {
|
|
18
|
+
execFileSync(process.execPath, [
|
|
19
|
+
'--no-warnings',
|
|
20
|
+
'--no-deprecation',
|
|
21
|
+
entrypoint,
|
|
22
|
+
...process.argv.slice(2)
|
|
23
|
+
], {
|
|
24
|
+
stdio: 'inherit',
|
|
25
|
+
env: process.env
|
|
26
|
+
});
|
|
27
|
+
} catch (error) {
|
|
28
|
+
// execFileSync throws if the process exits with non-zero
|
|
29
|
+
// If there's no exit status, this is a spawn error (e.g. ENOENT) - show the message
|
|
30
|
+
if (error.status == null) {
|
|
31
|
+
console.error(error.message);
|
|
32
|
+
}
|
|
33
|
+
process.exit(error.status ?? 1);
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
// We're running Node with the flags we wanted, import the CLI entrypoint
|
|
37
|
+
import("../dist/index.mjs");
|
|
38
|
+
}
|