afk-code 0.1.0 → 0.1.3
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/LICENSE +21 -0
- package/README.md +64 -97
- package/dist/cli/index.js +1972 -0
- package/package.json +13 -9
- package/slack-manifest.json +3 -3
- package/src/cli/discord.ts +0 -183
- package/src/cli/index.ts +0 -83
- package/src/cli/run.ts +0 -126
- package/src/cli/slack.ts +0 -193
- package/src/discord/channel-manager.ts +0 -191
- package/src/discord/discord-app.ts +0 -359
- package/src/discord/types.ts +0 -4
- package/src/slack/channel-manager.ts +0 -175
- package/src/slack/index.ts +0 -58
- package/src/slack/message-formatter.ts +0 -91
- package/src/slack/session-manager.ts +0 -567
- package/src/slack/slack-app.ts +0 -443
- package/src/slack/types.ts +0 -6
- package/src/types/index.ts +0 -6
- package/src/utils/image-extractor.ts +0 -72
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Colin Harman
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,133 +1,100 @@
|
|
|
1
1
|
# AFK Code
|
|
2
2
|
|
|
3
|
-
Monitor
|
|
3
|
+
Monitor and interact with Claude Code sessions from Slack or Discord. Respond from your phone while AFK.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
1. Run `afk-code slack` or `afk-code discord` to start the bot
|
|
8
|
-
2. Run `afk-code run -- claude` to start a monitored Claude Code session
|
|
9
|
-
3. A new thread (Slack) or channel (Discord) is created for the session
|
|
10
|
-
4. All messages are relayed bidirectionally - respond from your phone while AFK
|
|
11
|
-
|
|
12
|
-
## Installation
|
|
5
|
+
## Quick Start (Slack)
|
|
13
6
|
|
|
14
7
|
```bash
|
|
15
|
-
#
|
|
16
|
-
|
|
17
|
-
cd afk-code
|
|
18
|
-
|
|
19
|
-
# Install dependencies
|
|
20
|
-
bun install
|
|
21
|
-
|
|
22
|
-
# Link the CLI globally (optional)
|
|
23
|
-
bun link
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
Requires [Bun](https://bun.sh) runtime.
|
|
27
|
-
|
|
28
|
-
## Slack Setup
|
|
29
|
-
|
|
30
|
-
### 1. Create a Slack App
|
|
31
|
-
|
|
32
|
-
Go to [api.slack.com/apps](https://api.slack.com/apps) and click **Create New App** → **From manifest**.
|
|
33
|
-
|
|
34
|
-
Paste the contents of `slack-manifest.json` from this repo, then click **Create**.
|
|
8
|
+
# 1. Create a Slack app at https://api.slack.com/apps
|
|
9
|
+
# Click "Create New App" → "From manifest" → paste slack-manifest.json
|
|
35
10
|
|
|
36
|
-
|
|
11
|
+
# 2. Install to your workspace and get credentials:
|
|
12
|
+
# - Bot Token (xoxb-...) from OAuth & Permissions
|
|
13
|
+
# - App Token (xapp-...) from Basic Information → App-Level Tokens (needs connections:write)
|
|
14
|
+
# - Your User ID from your Slack profile → "..." → Copy member ID
|
|
37
15
|
|
|
38
|
-
|
|
16
|
+
# 3. Configure and run
|
|
17
|
+
npx afk-code slack setup # Enter your credentials
|
|
18
|
+
npx afk-code slack # Start the bot
|
|
39
19
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
- **Bot Token**: OAuth & Permissions → Bot User OAuth Token (`xoxb-...`)
|
|
43
|
-
- **App Token**: Basic Information → App-Level Tokens → Generate Token with `connections:write` scope (`xapp-...`)
|
|
44
|
-
- **Signing Secret**: Basic Information → Signing Secret
|
|
45
|
-
- **Your User ID**: In Slack, click your profile → three dots → Copy member ID
|
|
46
|
-
|
|
47
|
-
### 4. Configure AFK Code
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
afk-code slack setup
|
|
20
|
+
# 4. In another terminal, start a monitored Claude session
|
|
21
|
+
npx afk-code run -- claude
|
|
51
22
|
```
|
|
52
23
|
|
|
53
|
-
|
|
24
|
+
A new channel is created for each session. Messages relay bidirectionally.
|
|
54
25
|
|
|
55
|
-
|
|
26
|
+
## Quick Start (Discord)
|
|
56
27
|
|
|
57
28
|
```bash
|
|
58
|
-
#
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
#
|
|
62
|
-
|
|
63
|
-
|
|
29
|
+
# 1. Create a Discord app at https://discord.com/developers/applications
|
|
30
|
+
# - Go to Bot → Reset Token → copy it
|
|
31
|
+
# - Enable "Message Content Intent"
|
|
32
|
+
# - Go to OAuth2 → URL Generator → select "bot" scope
|
|
33
|
+
# - Select permissions: Send Messages, Manage Channels, Read Message History
|
|
34
|
+
# - Open the generated URL to invite the bot
|
|
64
35
|
|
|
65
|
-
|
|
36
|
+
# 2. Get your User ID (enable Developer Mode, right-click your name → Copy User ID)
|
|
66
37
|
|
|
67
|
-
|
|
38
|
+
# 3. Configure and run
|
|
39
|
+
npx afk-code discord setup # Enter your credentials
|
|
40
|
+
npx afk-code discord # Start the bot
|
|
68
41
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
### 2. Create a Bot
|
|
74
|
-
|
|
75
|
-
- Go to **Bot** in the sidebar
|
|
76
|
-
- Click **Reset Token** and copy it
|
|
77
|
-
- Enable **Message Content Intent** under Privileged Gateway Intents
|
|
42
|
+
# 4. In another terminal, start a monitored Claude session
|
|
43
|
+
npx afk-code run -- claude
|
|
44
|
+
```
|
|
78
45
|
|
|
79
|
-
|
|
46
|
+
## Commands
|
|
80
47
|
|
|
81
|
-
|
|
82
|
-
-
|
|
83
|
-
-
|
|
84
|
-
-
|
|
48
|
+
```
|
|
49
|
+
afk-code slack setup Configure Slack credentials
|
|
50
|
+
afk-code slack Run the Slack bot
|
|
51
|
+
afk-code discord setup Configure Discord credentials
|
|
52
|
+
afk-code discord Run the Discord bot
|
|
53
|
+
afk-code run -- <command> Start a monitored session
|
|
54
|
+
afk-code help Show help
|
|
55
|
+
```
|
|
85
56
|
|
|
86
|
-
###
|
|
57
|
+
### Slack Slash Commands
|
|
87
58
|
|
|
88
|
-
|
|
59
|
+
- `/afk` - List active sessions
|
|
60
|
+
- `/background` - Send Ctrl+B (background signal)
|
|
61
|
+
- `/interrupt` - Send Escape (interrupt signal)
|
|
62
|
+
- `/mode` - Send Shift+Tab (toggle mode)
|
|
63
|
+
- Not recommended since you don't get feedback on what mode you're in
|
|
89
64
|
|
|
90
|
-
|
|
65
|
+
## Installation Options
|
|
91
66
|
|
|
92
67
|
```bash
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
Enter your bot token and user ID. Config is saved to `~/.afk-code/discord.env`.
|
|
68
|
+
# Global install
|
|
69
|
+
npm install -g afk-code
|
|
97
70
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
```bash
|
|
101
|
-
# Terminal 1: Start the Discord bot
|
|
102
|
-
afk-code discord
|
|
71
|
+
# Or use npx (no install)
|
|
72
|
+
npx afk-code <command>
|
|
103
73
|
|
|
104
|
-
#
|
|
105
|
-
afk-code
|
|
74
|
+
# Or run from source
|
|
75
|
+
git clone https://github.com/clharman/afk-code.git
|
|
76
|
+
cd afk-code && npm install
|
|
77
|
+
npm run dev -- slack
|
|
78
|
+
npm run dev -- run -- claude
|
|
106
79
|
```
|
|
107
80
|
|
|
108
|
-
|
|
81
|
+
Requires Node.js 18+.
|
|
109
82
|
|
|
110
|
-
##
|
|
83
|
+
## How It Works
|
|
111
84
|
|
|
112
|
-
|
|
113
|
-
afk-code run --
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
afk-code discord Run the Discord bot
|
|
117
|
-
afk-code discord setup Configure Discord credentials
|
|
118
|
-
afk-code help Show help
|
|
119
|
-
```
|
|
85
|
+
1. `afk-code slack` or `afk-code discord` starts a bot that listens for sessions
|
|
86
|
+
2. `afk-code run -- claude` spawns Claude in a PTY and connects to the bot via Unix socket
|
|
87
|
+
3. The bot watches Claude's JSONL files for messages and relays them to chat
|
|
88
|
+
4. Messages you send in chat are forwarded to the terminal
|
|
120
89
|
|
|
121
|
-
##
|
|
90
|
+
## Limitations
|
|
122
91
|
|
|
123
|
-
|
|
92
|
+
- Does not support plan mode or responding to Claude Code's form-based questions (AskUserQuestion)
|
|
93
|
+
- Does not send tool calls or results
|
|
124
94
|
|
|
125
|
-
|
|
126
|
-
2. Connects to the running Slack/Discord bot via Unix socket
|
|
127
|
-
3. Watches the Claude Code JSONL file for new messages
|
|
128
|
-
4. Relays messages bidirectionally between terminal and chat
|
|
95
|
+
## Disclaimer
|
|
129
96
|
|
|
130
|
-
|
|
97
|
+
This project is not affiliated with Anthropic. Use at your own risk.
|
|
131
98
|
|
|
132
99
|
## License
|
|
133
100
|
|