@radnine/claude-session-daemon 0.2.6 → 0.2.8
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/.dockerignore +6 -0
- package/Dockerfile +34 -0
- package/README.md +118 -0
- package/docker-entrypoint.sh +24 -0
- package/package.json +5 -2
package/.dockerignore
ADDED
package/Dockerfile
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
FROM node:20-slim
|
|
2
|
+
|
|
3
|
+
# Install Claude CLI globally (unpinned — always latest)
|
|
4
|
+
RUN npm install -g @anthropic-ai/claude-code
|
|
5
|
+
|
|
6
|
+
# Create workspace mount point
|
|
7
|
+
RUN mkdir -p /workspace
|
|
8
|
+
|
|
9
|
+
WORKDIR /app
|
|
10
|
+
|
|
11
|
+
# Copy dependency manifests first for layer caching
|
|
12
|
+
COPY package.json package-lock.json ./
|
|
13
|
+
RUN npm ci --production
|
|
14
|
+
|
|
15
|
+
# Copy daemon source
|
|
16
|
+
COPY src/ ./src/
|
|
17
|
+
|
|
18
|
+
# Copy entrypoint
|
|
19
|
+
COPY docker-entrypoint.sh /usr/local/bin/
|
|
20
|
+
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
|
21
|
+
|
|
22
|
+
# Default environment for standalone Docker usage
|
|
23
|
+
ENV CLAUDE_DAEMON_MODE=standalone \
|
|
24
|
+
CLAUDE_WORKING_DIR=/workspace \
|
|
25
|
+
CLAUDE_DAEMON_PORT=3001
|
|
26
|
+
|
|
27
|
+
EXPOSE 3001
|
|
28
|
+
|
|
29
|
+
# Health check using Node.js TCP probe (no curl in slim image)
|
|
30
|
+
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
|
31
|
+
CMD node -e "const s=require('net').createConnection({port:process.env.CLAUDE_DAEMON_PORT||3001},()=>{s.end();process.exit(0)});s.on('error',()=>process.exit(1))"
|
|
32
|
+
|
|
33
|
+
ENTRYPOINT ["docker-entrypoint.sh"]
|
|
34
|
+
CMD ["node", "src/index.js"]
|
package/README.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# @radnine/claude-session-daemon
|
|
2
|
+
|
|
3
|
+
Node.js daemon that manages Claude CLI sessions over WebSocket. Pairs with [@radnine/storybook-addon-claude](https://www.npmjs.com/package/@radnine/storybook-addon-claude) to give designers and developers an AI chat panel inside Storybook.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @radnine/storybook-addon-claude @radnine/claude-session-daemon
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Configure Storybook
|
|
12
|
+
|
|
13
|
+
In your `.storybook/main.js`:
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
export default {
|
|
17
|
+
addons: [
|
|
18
|
+
'@radnine/storybook-addon-claude',
|
|
19
|
+
// ... other addons
|
|
20
|
+
],
|
|
21
|
+
};
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Run the Daemon
|
|
25
|
+
|
|
26
|
+
### Option A: Docker (recommended)
|
|
27
|
+
|
|
28
|
+
Docker runs Claude inside a container with filesystem isolation. Claude can only access your mounted project directory, so file edits happen automatically without permission prompts.
|
|
29
|
+
|
|
30
|
+
1. Create a `docker-compose.yml` in your project root:
|
|
31
|
+
|
|
32
|
+
```yaml
|
|
33
|
+
services:
|
|
34
|
+
claude-daemon:
|
|
35
|
+
build:
|
|
36
|
+
context: ./node_modules/@radnine/claude-session-daemon
|
|
37
|
+
ports:
|
|
38
|
+
- "${CLAUDE_DAEMON_PORT:-3001}:3001"
|
|
39
|
+
volumes:
|
|
40
|
+
- .:/workspace
|
|
41
|
+
environment:
|
|
42
|
+
- ANTHROPIC_API_KEY
|
|
43
|
+
- CLAUDE_DAEMON_MODE=standalone
|
|
44
|
+
- CLAUDE_WORKING_DIR=/workspace
|
|
45
|
+
- CLAUDE_DAEMON_PORT=3001
|
|
46
|
+
- CLAUDE_SKIP_PERMISSIONS=true
|
|
47
|
+
- CLAUDE_DISABLE_AUTH=true
|
|
48
|
+
stop_grace_period: 10s
|
|
49
|
+
restart: unless-stopped
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
2. Add your API key to a `.env` file:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
ANTHROPIC_API_KEY=sk-ant-...
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Get an API key from https://console.anthropic.com/settings/keys
|
|
59
|
+
|
|
60
|
+
3. Start it:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
docker compose up -d
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Stop with `docker compose down`.
|
|
67
|
+
|
|
68
|
+
### Option B: Host mode
|
|
69
|
+
|
|
70
|
+
Runs the daemon directly on your machine. Claude will prompt for permission on each file edit since there's no filesystem isolation.
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
npx @radnine/claude-session-daemon start
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Or add to your `package.json` scripts:
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"scripts": {
|
|
81
|
+
"claude-daemon": "claude-session-daemon start",
|
|
82
|
+
"claude-daemon:stop": "claude-session-daemon stop",
|
|
83
|
+
"claude-daemon:restart": "claude-session-daemon restart",
|
|
84
|
+
"claude-daemon:status": "claude-session-daemon status"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The daemon manages a `.claude-daemon.pid` file in your project root. Add it to your `.gitignore`.
|
|
90
|
+
|
|
91
|
+
### Authentication (host mode only)
|
|
92
|
+
|
|
93
|
+
Docker mode uses the `ANTHROPIC_API_KEY` environment variable. For host mode, choose one:
|
|
94
|
+
|
|
95
|
+
**API Key** — Set `ANTHROPIC_API_KEY` before starting the daemon, or add it to a `.env` file.
|
|
96
|
+
|
|
97
|
+
**Claude Login** — If you have a Claude Pro, Team, or Enterprise subscription:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
npx @anthropic-ai/claude-code login
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
This authenticates via your browser. Credentials are stored locally and the daemon uses them automatically.
|
|
104
|
+
|
|
105
|
+
## Environment Variables
|
|
106
|
+
|
|
107
|
+
| Variable | Default | Description |
|
|
108
|
+
|---|---|---|
|
|
109
|
+
| `ANTHROPIC_API_KEY` | — | Required for Docker mode |
|
|
110
|
+
| `CLAUDE_DAEMON_PORT` | `3001` | WebSocket server port |
|
|
111
|
+
| `CLAUDE_MAX_SESSIONS` | `10` | Max concurrent Claude sessions |
|
|
112
|
+
| `CLAUDE_LOG_LEVEL` | `info` | Log level (`debug`, `info`, `warn`, `error`) |
|
|
113
|
+
| `CLAUDE_SKIP_PERMISSIONS` | `false` | Skip Claude CLI permission prompts (Docker only) |
|
|
114
|
+
| `CLAUDE_DISABLE_AUTH` | `false` | Disable WebSocket auth (Docker only) |
|
|
115
|
+
|
|
116
|
+
## License
|
|
117
|
+
|
|
118
|
+
Proprietary. See [LICENSE](./LICENSE) for terms.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
# Validate required environment
|
|
5
|
+
if [ -z "$ANTHROPIC_API_KEY" ]; then
|
|
6
|
+
echo "ERROR: ANTHROPIC_API_KEY is required but not set." >&2
|
|
7
|
+
echo "Set it in .env or pass via: docker compose run -e ANTHROPIC_API_KEY=sk-... claude-daemon" >&2
|
|
8
|
+
exit 1
|
|
9
|
+
fi
|
|
10
|
+
|
|
11
|
+
# Validate workspace directory exists
|
|
12
|
+
if [ ! -d "$CLAUDE_WORKING_DIR" ] && [ ! -d "/workspace" ]; then
|
|
13
|
+
echo "ERROR: Workspace directory not found. Mount your project with -v .:/workspace" >&2
|
|
14
|
+
exit 1
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
# Validate claude CLI is available
|
|
18
|
+
if ! command -v claude >/dev/null 2>&1; then
|
|
19
|
+
echo "ERROR: claude CLI not found in PATH." >&2
|
|
20
|
+
exit 1
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
# Use exec so signals propagate directly to the Node process
|
|
24
|
+
exec "$@"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radnine/claude-session-daemon",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"description": "Node.js daemon for managing Claude CLI sessions",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"repository": {
|
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"src/**",
|
|
17
|
-
"LICENSE"
|
|
17
|
+
"LICENSE",
|
|
18
|
+
"Dockerfile",
|
|
19
|
+
"docker-entrypoint.sh",
|
|
20
|
+
".dockerignore"
|
|
18
21
|
],
|
|
19
22
|
"scripts": {
|
|
20
23
|
"start": "node src/index.js",
|