mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-04-28 03:49:31 +00:00
feat: SPA — Spawn's Personal Agent (#1825)
* feat: add Slack issue bot for #proj-spawn
Socket Mode bot that listens for @mentions in a configured Slack channel,
files GitHub issues via `gh` CLI, and syncs thread replies as issue comments.
State persisted to ~/.config/spawn/slack-issues.json.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: rewrite Spawnis to pipe threads into Claude Code sessions
- @mention triggers Claude Code with full thread as prompt
- Subsequent thread replies in tracked threads auto-trigger new runs
- System prompt focuses on GitHub issue management via `gh` CLI
- Streams Claude Code responses back to Slack in real-time
- Bot resolves own user ID at startup to skip self-messages
- Adds slack-manifest.yml for one-click Slack app creation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: lowercase display name to spawnis
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: rename to SPA — Spawn Processes Autonomously
Display name: spa
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: SPA — Spawn's Personal Agent
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: lowercase app name to Spa
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: add biome config and fix lint/format to match CLI rules
Adds local biome.json mirroring cli/biome.json rules (minus GritQL
plugins). Fixes all useBlockStatements errors and applies expand:always
formatting to match the project style.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: share biome config via root biome.json + extends
Move shared linter rules, formatter, and JS formatter settings to a
root-level biome.json. Both cli/ and .claude/skills/slack-bot/ extend
from it — CLI adds its GritQL plugins and test overrides, slack-bot
just overrides includes and disables VCS.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: move GritQL lint rules to repo root lint/
Move no-type-assertion.grit and no-typeof-string-number.grit from
cli/lint/ to lint/ at the repo root. Both cli/ and slack-bot share
the no-type-assertion rule; cli/ additionally uses no-typeof-string-number.
Plugin paths live in each child biome.json (not root) because biome
resolves plugin paths relative to the consumer config, not the extended
config.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: move shared biome.json into lint/
All shared lint config now lives under lint/:
lint/biome.json
lint/no-type-assertion.grit
lint/no-typeof-string-number.grit
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: add no-banner-comments lint rule, fix slack-bot
GritQL can't match comments (they're trivia in biome's CST), so this
is a Bun script at lint/no-banner-comments.ts that catches decorative
// --------- separator blocks and suggests /** Section */ or #region.
Replace all 9 banner blocks in slack-bot.ts with /** */ headers.
Usage: bun run lint/no-banner-comments.ts [files...]
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: use // #region instead of /** */ section headers
Switch slack-bot.ts to // #region / // #endregion for all section
markers (collapsible in most editors). Update no-banner-comments lint
script to recommend #region as the preferred style.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: replace lint script with PostToolUse hook for banner comments
Move banner comment detection into the existing PostToolUse hook on
Write|Edit in .claude/settings.json. Runs inline on every .ts file
edit — no separate bun script needed. Delete lint/no-banner-comments.ts.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: simplify Slack manifest description
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: rename skill from slack-bot to setup-spa
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: use named import for @slack/bolt App class
Bun resolves `import App from "@slack/bolt"` as the App constructor
directly, not a module with a `.default` property. Switch to named
import `{ App }` and remove all `.default` usage.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: add --verbose flag required by stream-json output format
Claude Code requires --verbose when using --output-format=stream-json
with --print. Also fix systemd PATH to include ~/.local/bin for claude.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: stream all Claude Code events to Slack (tools, results, text)
Replace text-only streaming with full event parsing:
- Tool use: shows 🛠️ *ToolName*
- Tool result: shows truncated output in code block
- Text delta: accumulates as before
- Errors: shows ❌ prefix
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: enforce issue title templates in system prompt
Add mandatory bracket prefix format matching the repo's issue templates:
[Bug]:, [CLI]:, [Agent]:, [Cloud]:, [Team]:. Also instructs Claude to
apply matching labels (bug + pending-review, cli + enhancement, etc.).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: reference issue templates at runtime instead of hardcoding
Tell Claude to read .github/ISSUE_TEMPLATE/ for the correct title
prefix, labels, and fields rather than hardcoding them in the prompt.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude <claude@anthropic.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
34161f7175
commit
6a5e0c5161
11 changed files with 1069 additions and 74 deletions
|
|
@ -23,7 +23,7 @@
|
|||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "bash -c 'FILE=\"$CLAUDE_FILE\"; if [[ \"$FILE\" == *.sh ]]; then bash -n \"$FILE\" 2>&1 || { echo \"SYNTAX ERROR in $FILE\"; exit 2; }; if grep -qn \"source \\.\\./\\|source \\./\" \"$FILE\" 2>/dev/null; then echo \"RELATIVE SOURCE detected in $FILE — breaks curl|bash execution\"; exit 2; fi; if grep -qn \"echo -e \" \"$FILE\" 2>/dev/null; then echo \"echo -e detected in $FILE — use printf instead (macOS bash 3.x compat)\"; exit 2; fi; if grep -qn \"set -.*u\" \"$FILE\" 2>/dev/null && ! grep -qn \"set -eo pipefail\" \"$FILE\" 2>/dev/null; then echo \"set -u (nounset) detected in $FILE — use set -eo pipefail instead\"; exit 2; fi; fi'"
|
||||
"command": "bash -c 'FILE=\"$CLAUDE_FILE\"; if [[ \"$FILE\" == *.sh ]]; then bash -n \"$FILE\" 2>&1 || { echo \"SYNTAX ERROR in $FILE\"; exit 2; }; if grep -qn \"source \\.\\./\\|source \\./\" \"$FILE\" 2>/dev/null; then echo \"RELATIVE SOURCE detected in $FILE — breaks curl|bash execution\"; exit 2; fi; if grep -qn \"echo -e \" \"$FILE\" 2>/dev/null; then echo \"echo -e detected in $FILE — use printf instead (macOS bash 3.x compat)\"; exit 2; fi; if grep -qn \"set -.*u\" \"$FILE\" 2>/dev/null && ! grep -qn \"set -eo pipefail\" \"$FILE\" 2>/dev/null; then echo \"set -u (nounset) detected in $FILE — use set -eo pipefail instead\"; exit 2; fi; fi; if [[ \"$FILE\" == *.ts ]]; then if grep -Pn \"^\\s*//\\s*[-=*#]{10,}\\s*$\" \"$FILE\" 2>/dev/null; then echo \"BANNER COMMENT in $FILE — use // #region Name / // #endregion instead\"; exit 2; fi; fi'"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
128
.claude/skills/setup-spa/SKILL.md
Normal file
128
.claude/skills/setup-spa/SKILL.md
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
---
|
||||
name: setup-spa
|
||||
description: "SPA (Spawn's Personal Agent) — Slack bot that pipes threads into Claude Code sessions"
|
||||
disable-model-invocation: true
|
||||
---
|
||||
|
||||
# SPA — Spawn's Personal Agent
|
||||
|
||||
Slack bot that listens in `#proj-spawn` via Socket Mode. When @mentioned, it collects the full thread, pipes it into a `claude -p` session, and streams Claude Code's responses back to the Slack thread in real-time.
|
||||
|
||||
Subsequent thread replies in tracked threads auto-trigger new Claude Code runs.
|
||||
|
||||
## Slack App Setup
|
||||
|
||||
### Option A: Create from manifest (recommended)
|
||||
|
||||
1. Go to https://api.slack.com/apps
|
||||
2. Click **Create New App** > **From a manifest**
|
||||
3. Select your workspace
|
||||
4. Paste the contents of `slack-manifest.yml` from this directory
|
||||
5. Click **Create**
|
||||
6. **Socket Mode**: Settings > Basic Information > scroll to "App-Level Tokens" > **Generate Token and Scopes** > add `connections:write` scope > copy the `xapp-...` token
|
||||
7. **Install to Workspace**: Features > OAuth & Permissions > Install > copy the `xoxb-...` Bot User OAuth Token
|
||||
8. **Invite the bot** to the target channel: `/invite @spa`
|
||||
9. **Get the channel ID**: Right-click channel name > View channel details > copy the ID (starts with `C`)
|
||||
|
||||
### Option B: Manual setup
|
||||
|
||||
1. Go to https://api.slack.com/apps > **Create New App** > **From scratch**
|
||||
2. Name it `SPA`, select the workspace
|
||||
3. **Socket Mode**: Settings > Socket Mode > Enable > generate app-level token with `connections:write` scope > save `xapp-...`
|
||||
4. **Event Subscriptions**: Features > Event Subscriptions > Enable > subscribe to bot events: `app_mention`, `message.channels`
|
||||
5. **OAuth Scopes**: Features > OAuth & Permissions > Bot Token Scopes: `app_mentions:read`, `channels:history`, `channels:read`, `chat:write`, `reactions:write`
|
||||
6. **Install to Workspace** > save `xoxb-...` token
|
||||
7. **Invite** bot to channel, get channel ID
|
||||
|
||||
## Env Vars
|
||||
|
||||
| Var | Description |
|
||||
|-----|-------------|
|
||||
| `SLACK_BOT_TOKEN` | Bot User OAuth Token (`xoxb-...`) |
|
||||
| `SLACK_APP_TOKEN` | App-Level Token for Socket Mode (`xapp-...`) |
|
||||
| `SLACK_CHANNEL_ID` | Channel ID to listen in (e.g. `C0123456789`) |
|
||||
| `GITHUB_REPO` | Target repo context (default: `OpenRouterTeam/spawn`) |
|
||||
| `REPO_ROOT` | Working directory for Claude Code (default: cwd) |
|
||||
|
||||
GitHub auth uses the `gh` CLI — run `gh auth login` before starting.
|
||||
|
||||
## `start-spa.sh` Template
|
||||
|
||||
Create `.claude/skills/setup-spa/start-spa.sh` (gitignored):
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
set -eo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
export SLACK_BOT_TOKEN="xoxb-YOUR-BOT-TOKEN"
|
||||
export SLACK_APP_TOKEN="xapp-YOUR-APP-TOKEN"
|
||||
export SLACK_CHANNEL_ID="C0000000000"
|
||||
export GITHUB_REPO="OpenRouterTeam/spawn"
|
||||
export REPO_ROOT="/home/lab/spawn"
|
||||
|
||||
exec bun run "${SCRIPT_DIR}/slack-bot.ts"
|
||||
```
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
cd .claude/skills/setup-spa && bun install
|
||||
```
|
||||
|
||||
## Systemd Service
|
||||
|
||||
Create `/etc/systemd/system/spawn-spa.service`:
|
||||
|
||||
```ini
|
||||
[Unit]
|
||||
Description=SPA — Spawn's Personal Agent
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=lab
|
||||
Group=lab
|
||||
WorkingDirectory=/home/lab/spawn/.claude/skills/setup-spa
|
||||
ExecStart=/bin/bash /home/lab/spawn/.claude/skills/setup-spa/start-spa.sh
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
Environment="PATH=/home/lab/.local/bin:/home/lab/.bun/bin:/usr/local/bin:/usr/bin:/bin"
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
Then:
|
||||
|
||||
```bash
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable --now spawn-spa
|
||||
```
|
||||
|
||||
## Verify
|
||||
|
||||
```bash
|
||||
sudo systemctl status spawn-spa
|
||||
journalctl -u spawn-spa -f
|
||||
|
||||
# Test: @mention spa in channel → Claude Code runs, response streams back
|
||||
# Test: Reply and @mention again → resumes same session
|
||||
```
|
||||
|
||||
## State
|
||||
|
||||
Thread-to-session mappings are persisted at `~/.config/spawn/slack-issues.json`.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
| Symptom | Fix |
|
||||
|---------|-----|
|
||||
| `ERROR: SLACK_BOT_TOKEN env var is required` | Set all required env vars in `start-spa.sh` |
|
||||
| Bot doesn't respond to @mentions | Verify bot is invited to the channel; check `SLACK_CHANNEL_ID` |
|
||||
| Claude errors with permission denied | Ensure `--dangerously-skip-permissions` is working, or run in a sandbox |
|
||||
| Responses truncated | Slack has ~4000 char limit per message; long responses show the tail |
|
||||
| Hourglass reaction | A Claude run is already active for that thread; wait for it to finish |
|
||||
11
.claude/skills/setup-spa/biome.json
Normal file
11
.claude/skills/setup-spa/biome.json
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"$schema": "https://biomejs.dev/schemas/2.4.3/schema.json",
|
||||
"extends": ["../../../lint/biome.json"],
|
||||
"vcs": {
|
||||
"enabled": false
|
||||
},
|
||||
"files": {
|
||||
"includes": ["**/*.ts"]
|
||||
},
|
||||
"plugins": ["../../../lint/no-type-assertion.grit"]
|
||||
}
|
||||
260
.claude/skills/setup-spa/bun.lock
Normal file
260
.claude/skills/setup-spa/bun.lock
Normal file
|
|
@ -0,0 +1,260 @@
|
|||
{
|
||||
"lockfileVersion": 1,
|
||||
"configVersion": 1,
|
||||
"workspaces": {
|
||||
"": {
|
||||
"name": "spawn-slack-bot",
|
||||
"dependencies": {
|
||||
"@slack/bolt": "^4.3.0",
|
||||
"valibot": "^1.0.0",
|
||||
},
|
||||
},
|
||||
},
|
||||
"packages": {
|
||||
"@slack/bolt": ["@slack/bolt@4.6.0", "", { "dependencies": { "@slack/logger": "^4.0.0", "@slack/oauth": "^3.0.4", "@slack/socket-mode": "^2.0.5", "@slack/types": "^2.18.0", "@slack/web-api": "^7.12.0", "axios": "^1.12.0", "express": "^5.0.0", "path-to-regexp": "^8.1.0", "raw-body": "^3", "tsscmp": "^1.0.6" }, "peerDependencies": { "@types/express": "^5.0.0" } }, "sha512-xPgfUs2+OXSugz54Ky07pA890+Qydk22SYToi8uGpXeHSt1JWwFJkRyd/9Vlg5I1AdfdpGXExDpwnbuN9Q/2dQ=="],
|
||||
|
||||
"@slack/logger": ["@slack/logger@4.0.0", "", { "dependencies": { "@types/node": ">=18.0.0" } }, "sha512-Wz7QYfPAlG/DR+DfABddUZeNgoeY7d1J39OCR2jR+v7VBsB8ezulDK5szTnDDPDwLH5IWhLvXIHlCFZV7MSKgA=="],
|
||||
|
||||
"@slack/oauth": ["@slack/oauth@3.0.4", "", { "dependencies": { "@slack/logger": "^4", "@slack/web-api": "^7.10.0", "@types/jsonwebtoken": "^9", "@types/node": ">=18", "jsonwebtoken": "^9" } }, "sha512-+8H0g7mbrHndEUbYCP7uYyBCbwqmm3E6Mo3nfsDvZZW74zKk1ochfH/fWSvGInYNCVvaBUbg3RZBbTp0j8yJCg=="],
|
||||
|
||||
"@slack/socket-mode": ["@slack/socket-mode@2.0.5", "", { "dependencies": { "@slack/logger": "^4", "@slack/web-api": "^7.10.0", "@types/node": ">=18", "@types/ws": "^8", "eventemitter3": "^5", "ws": "^8" } }, "sha512-VaapvmrAifeFLAFaDPfGhEwwunTKsI6bQhYzxRXw7BSujZUae5sANO76WqlVsLXuhVtCVrBWPiS2snAQR2RHJQ=="],
|
||||
|
||||
"@slack/types": ["@slack/types@2.20.0", "", {}, "sha512-PVF6P6nxzDMrzPC8fSCsnwaI+kF8YfEpxf3MqXmdyjyWTYsZQURpkK7WWUWvP5QpH55pB7zyYL9Qem/xSgc5VA=="],
|
||||
|
||||
"@slack/web-api": ["@slack/web-api@7.14.1", "", { "dependencies": { "@slack/logger": "^4.0.0", "@slack/types": "^2.20.0", "@types/node": ">=18.0.0", "@types/retry": "0.12.0", "axios": "^1.13.5", "eventemitter3": "^5.0.1", "form-data": "^4.0.4", "is-electron": "2.2.2", "is-stream": "^2", "p-queue": "^6", "p-retry": "^4", "retry": "^0.13.1" } }, "sha512-RoygyteJeFswxDPJjUMESn9dldWVMD2xUcHHd9DenVavSfVC6FeVnSdDerOO7m8LLvw4Q132nQM4hX8JiF7dng=="],
|
||||
|
||||
"@types/body-parser": ["@types/body-parser@1.19.6", "", { "dependencies": { "@types/connect": "*", "@types/node": "*" } }, "sha512-HLFeCYgz89uk22N5Qg3dvGvsv46B8GLvKKo1zKG4NybA8U2DiEO3w9lqGg29t/tfLRJpJ6iQxnVw4OnB7MoM9g=="],
|
||||
|
||||
"@types/connect": ["@types/connect@3.4.38", "", { "dependencies": { "@types/node": "*" } }, "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug=="],
|
||||
|
||||
"@types/express": ["@types/express@5.0.6", "", { "dependencies": { "@types/body-parser": "*", "@types/express-serve-static-core": "^5.0.0", "@types/serve-static": "^2" } }, "sha512-sKYVuV7Sv9fbPIt/442koC7+IIwK5olP1KWeD88e/idgoJqDm3JV/YUiPwkoKK92ylff2MGxSz1CSjsXelx0YA=="],
|
||||
|
||||
"@types/express-serve-static-core": ["@types/express-serve-static-core@5.1.1", "", { "dependencies": { "@types/node": "*", "@types/qs": "*", "@types/range-parser": "*", "@types/send": "*" } }, "sha512-v4zIMr/cX7/d2BpAEX3KNKL/JrT1s43s96lLvvdTmza1oEvDudCqK9aF/djc/SWgy8Yh0h30TZx5VpzqFCxk5A=="],
|
||||
|
||||
"@types/http-errors": ["@types/http-errors@2.0.5", "", {}, "sha512-r8Tayk8HJnX0FztbZN7oVqGccWgw98T/0neJphO91KkmOzug1KkofZURD4UaD5uH8AqcFLfdPErnBod0u71/qg=="],
|
||||
|
||||
"@types/jsonwebtoken": ["@types/jsonwebtoken@9.0.10", "", { "dependencies": { "@types/ms": "*", "@types/node": "*" } }, "sha512-asx5hIG9Qmf/1oStypjanR7iKTv0gXQ1Ov/jfrX6kS/EO0OFni8orbmGCn0672NHR3kXHwpAwR+B368ZGN/2rA=="],
|
||||
|
||||
"@types/ms": ["@types/ms@2.1.0", "", {}, "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA=="],
|
||||
|
||||
"@types/node": ["@types/node@25.3.0", "", { "dependencies": { "undici-types": "~7.18.0" } }, "sha512-4K3bqJpXpqfg2XKGK9bpDTc6xO/xoUP/RBWS7AtRMug6zZFaRekiLzjVtAoZMquxoAbzBvy5nxQ7veS5eYzf8A=="],
|
||||
|
||||
"@types/qs": ["@types/qs@6.14.0", "", {}, "sha512-eOunJqu0K1923aExK6y8p6fsihYEn/BYuQ4g0CxAAgFc4b/ZLN4CrsRZ55srTdqoiLzU2B2evC+apEIxprEzkQ=="],
|
||||
|
||||
"@types/range-parser": ["@types/range-parser@1.2.7", "", {}, "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ=="],
|
||||
|
||||
"@types/retry": ["@types/retry@0.12.0", "", {}, "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA=="],
|
||||
|
||||
"@types/send": ["@types/send@1.2.1", "", { "dependencies": { "@types/node": "*" } }, "sha512-arsCikDvlU99zl1g69TcAB3mzZPpxgw0UQnaHeC1Nwb015xp8bknZv5rIfri9xTOcMuaVgvabfIRA7PSZVuZIQ=="],
|
||||
|
||||
"@types/serve-static": ["@types/serve-static@2.2.0", "", { "dependencies": { "@types/http-errors": "*", "@types/node": "*" } }, "sha512-8mam4H1NHLtu7nmtalF7eyBH14QyOASmcxHhSfEoRyr0nP/YdoesEtU+uSRvMe96TW/HPTtkoKqQLl53N7UXMQ=="],
|
||||
|
||||
"@types/ws": ["@types/ws@8.18.1", "", { "dependencies": { "@types/node": "*" } }, "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg=="],
|
||||
|
||||
"accepts": ["accepts@2.0.0", "", { "dependencies": { "mime-types": "^3.0.0", "negotiator": "^1.0.0" } }, "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng=="],
|
||||
|
||||
"asynckit": ["asynckit@0.4.0", "", {}, "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="],
|
||||
|
||||
"axios": ["axios@1.13.5", "", { "dependencies": { "follow-redirects": "^1.15.11", "form-data": "^4.0.5", "proxy-from-env": "^1.1.0" } }, "sha512-cz4ur7Vb0xS4/KUN0tPWe44eqxrIu31me+fbang3ijiNscE129POzipJJA6zniq2C/Z6sJCjMimjS8Lc/GAs8Q=="],
|
||||
|
||||
"body-parser": ["body-parser@2.2.2", "", { "dependencies": { "bytes": "^3.1.2", "content-type": "^1.0.5", "debug": "^4.4.3", "http-errors": "^2.0.0", "iconv-lite": "^0.7.0", "on-finished": "^2.4.1", "qs": "^6.14.1", "raw-body": "^3.0.1", "type-is": "^2.0.1" } }, "sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA=="],
|
||||
|
||||
"buffer-equal-constant-time": ["buffer-equal-constant-time@1.0.1", "", {}, "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA=="],
|
||||
|
||||
"bytes": ["bytes@3.1.2", "", {}, "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg=="],
|
||||
|
||||
"call-bind-apply-helpers": ["call-bind-apply-helpers@1.0.2", "", { "dependencies": { "es-errors": "^1.3.0", "function-bind": "^1.1.2" } }, "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ=="],
|
||||
|
||||
"call-bound": ["call-bound@1.0.4", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.2", "get-intrinsic": "^1.3.0" } }, "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg=="],
|
||||
|
||||
"combined-stream": ["combined-stream@1.0.8", "", { "dependencies": { "delayed-stream": "~1.0.0" } }, "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg=="],
|
||||
|
||||
"content-disposition": ["content-disposition@1.0.1", "", {}, "sha512-oIXISMynqSqm241k6kcQ5UwttDILMK4BiurCfGEREw6+X9jkkpEe5T9FZaApyLGGOnFuyMWZpdolTXMtvEJ08Q=="],
|
||||
|
||||
"content-type": ["content-type@1.0.5", "", {}, "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA=="],
|
||||
|
||||
"cookie": ["cookie@0.7.2", "", {}, "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w=="],
|
||||
|
||||
"cookie-signature": ["cookie-signature@1.2.2", "", {}, "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg=="],
|
||||
|
||||
"debug": ["debug@4.4.3", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="],
|
||||
|
||||
"delayed-stream": ["delayed-stream@1.0.0", "", {}, "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ=="],
|
||||
|
||||
"depd": ["depd@2.0.0", "", {}, "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw=="],
|
||||
|
||||
"dunder-proto": ["dunder-proto@1.0.1", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.1", "es-errors": "^1.3.0", "gopd": "^1.2.0" } }, "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A=="],
|
||||
|
||||
"ecdsa-sig-formatter": ["ecdsa-sig-formatter@1.0.11", "", { "dependencies": { "safe-buffer": "^5.0.1" } }, "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ=="],
|
||||
|
||||
"ee-first": ["ee-first@1.1.1", "", {}, "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow=="],
|
||||
|
||||
"encodeurl": ["encodeurl@2.0.0", "", {}, "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg=="],
|
||||
|
||||
"es-define-property": ["es-define-property@1.0.1", "", {}, "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g=="],
|
||||
|
||||
"es-errors": ["es-errors@1.3.0", "", {}, "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw=="],
|
||||
|
||||
"es-object-atoms": ["es-object-atoms@1.1.1", "", { "dependencies": { "es-errors": "^1.3.0" } }, "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA=="],
|
||||
|
||||
"es-set-tostringtag": ["es-set-tostringtag@2.1.0", "", { "dependencies": { "es-errors": "^1.3.0", "get-intrinsic": "^1.2.6", "has-tostringtag": "^1.0.2", "hasown": "^2.0.2" } }, "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA=="],
|
||||
|
||||
"escape-html": ["escape-html@1.0.3", "", {}, "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow=="],
|
||||
|
||||
"etag": ["etag@1.8.1", "", {}, "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg=="],
|
||||
|
||||
"eventemitter3": ["eventemitter3@5.0.4", "", {}, "sha512-mlsTRyGaPBjPedk6Bvw+aqbsXDtoAyAzm5MO7JgU+yVRyMQ5O8bD4Kcci7BS85f93veegeCPkL8R4GLClnjLFw=="],
|
||||
|
||||
"express": ["express@5.2.1", "", { "dependencies": { "accepts": "^2.0.0", "body-parser": "^2.2.1", "content-disposition": "^1.0.0", "content-type": "^1.0.5", "cookie": "^0.7.1", "cookie-signature": "^1.2.1", "debug": "^4.4.0", "depd": "^2.0.0", "encodeurl": "^2.0.0", "escape-html": "^1.0.3", "etag": "^1.8.1", "finalhandler": "^2.1.0", "fresh": "^2.0.0", "http-errors": "^2.0.0", "merge-descriptors": "^2.0.0", "mime-types": "^3.0.0", "on-finished": "^2.4.1", "once": "^1.4.0", "parseurl": "^1.3.3", "proxy-addr": "^2.0.7", "qs": "^6.14.0", "range-parser": "^1.2.1", "router": "^2.2.0", "send": "^1.1.0", "serve-static": "^2.2.0", "statuses": "^2.0.1", "type-is": "^2.0.1", "vary": "^1.1.2" } }, "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw=="],
|
||||
|
||||
"finalhandler": ["finalhandler@2.1.1", "", { "dependencies": { "debug": "^4.4.0", "encodeurl": "^2.0.0", "escape-html": "^1.0.3", "on-finished": "^2.4.1", "parseurl": "^1.3.3", "statuses": "^2.0.1" } }, "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA=="],
|
||||
|
||||
"follow-redirects": ["follow-redirects@1.15.11", "", {}, "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ=="],
|
||||
|
||||
"form-data": ["form-data@4.0.5", "", { "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "es-set-tostringtag": "^2.1.0", "hasown": "^2.0.2", "mime-types": "^2.1.12" } }, "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w=="],
|
||||
|
||||
"forwarded": ["forwarded@0.2.0", "", {}, "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow=="],
|
||||
|
||||
"fresh": ["fresh@2.0.0", "", {}, "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A=="],
|
||||
|
||||
"function-bind": ["function-bind@1.1.2", "", {}, "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA=="],
|
||||
|
||||
"get-intrinsic": ["get-intrinsic@1.3.0", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.2", "es-define-property": "^1.0.1", "es-errors": "^1.3.0", "es-object-atoms": "^1.1.1", "function-bind": "^1.1.2", "get-proto": "^1.0.1", "gopd": "^1.2.0", "has-symbols": "^1.1.0", "hasown": "^2.0.2", "math-intrinsics": "^1.1.0" } }, "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ=="],
|
||||
|
||||
"get-proto": ["get-proto@1.0.1", "", { "dependencies": { "dunder-proto": "^1.0.1", "es-object-atoms": "^1.0.0" } }, "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g=="],
|
||||
|
||||
"gopd": ["gopd@1.2.0", "", {}, "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg=="],
|
||||
|
||||
"has-symbols": ["has-symbols@1.1.0", "", {}, "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ=="],
|
||||
|
||||
"has-tostringtag": ["has-tostringtag@1.0.2", "", { "dependencies": { "has-symbols": "^1.0.3" } }, "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw=="],
|
||||
|
||||
"hasown": ["hasown@2.0.2", "", { "dependencies": { "function-bind": "^1.1.2" } }, "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ=="],
|
||||
|
||||
"http-errors": ["http-errors@2.0.1", "", { "dependencies": { "depd": "~2.0.0", "inherits": "~2.0.4", "setprototypeof": "~1.2.0", "statuses": "~2.0.2", "toidentifier": "~1.0.1" } }, "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ=="],
|
||||
|
||||
"iconv-lite": ["iconv-lite@0.7.2", "", { "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" } }, "sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw=="],
|
||||
|
||||
"inherits": ["inherits@2.0.4", "", {}, "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="],
|
||||
|
||||
"ipaddr.js": ["ipaddr.js@1.9.1", "", {}, "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g=="],
|
||||
|
||||
"is-electron": ["is-electron@2.2.2", "", {}, "sha512-FO/Rhvz5tuw4MCWkpMzHFKWD2LsfHzIb7i6MdPYZ/KW7AlxawyLkqdy+jPZP1WubqEADE3O4FUENlJHDfQASRg=="],
|
||||
|
||||
"is-promise": ["is-promise@4.0.0", "", {}, "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ=="],
|
||||
|
||||
"is-stream": ["is-stream@2.0.1", "", {}, "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg=="],
|
||||
|
||||
"jsonwebtoken": ["jsonwebtoken@9.0.3", "", { "dependencies": { "jws": "^4.0.1", "lodash.includes": "^4.3.0", "lodash.isboolean": "^3.0.3", "lodash.isinteger": "^4.0.4", "lodash.isnumber": "^3.0.3", "lodash.isplainobject": "^4.0.6", "lodash.isstring": "^4.0.1", "lodash.once": "^4.0.0", "ms": "^2.1.1", "semver": "^7.5.4" } }, "sha512-MT/xP0CrubFRNLNKvxJ2BYfy53Zkm++5bX9dtuPbqAeQpTVe0MQTFhao8+Cp//EmJp244xt6Drw/GVEGCUj40g=="],
|
||||
|
||||
"jwa": ["jwa@2.0.1", "", { "dependencies": { "buffer-equal-constant-time": "^1.0.1", "ecdsa-sig-formatter": "1.0.11", "safe-buffer": "^5.0.1" } }, "sha512-hRF04fqJIP8Abbkq5NKGN0Bbr3JxlQ+qhZufXVr0DvujKy93ZCbXZMHDL4EOtodSbCWxOqR8MS1tXA5hwqCXDg=="],
|
||||
|
||||
"jws": ["jws@4.0.1", "", { "dependencies": { "jwa": "^2.0.1", "safe-buffer": "^5.0.1" } }, "sha512-EKI/M/yqPncGUUh44xz0PxSidXFr/+r0pA70+gIYhjv+et7yxM+s29Y+VGDkovRofQem0fs7Uvf4+YmAdyRduA=="],
|
||||
|
||||
"lodash.includes": ["lodash.includes@4.3.0", "", {}, "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w=="],
|
||||
|
||||
"lodash.isboolean": ["lodash.isboolean@3.0.3", "", {}, "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg=="],
|
||||
|
||||
"lodash.isinteger": ["lodash.isinteger@4.0.4", "", {}, "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA=="],
|
||||
|
||||
"lodash.isnumber": ["lodash.isnumber@3.0.3", "", {}, "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw=="],
|
||||
|
||||
"lodash.isplainobject": ["lodash.isplainobject@4.0.6", "", {}, "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA=="],
|
||||
|
||||
"lodash.isstring": ["lodash.isstring@4.0.1", "", {}, "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw=="],
|
||||
|
||||
"lodash.once": ["lodash.once@4.1.1", "", {}, "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg=="],
|
||||
|
||||
"math-intrinsics": ["math-intrinsics@1.1.0", "", {}, "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g=="],
|
||||
|
||||
"media-typer": ["media-typer@1.1.0", "", {}, "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw=="],
|
||||
|
||||
"merge-descriptors": ["merge-descriptors@2.0.0", "", {}, "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g=="],
|
||||
|
||||
"mime-db": ["mime-db@1.54.0", "", {}, "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ=="],
|
||||
|
||||
"mime-types": ["mime-types@3.0.2", "", { "dependencies": { "mime-db": "^1.54.0" } }, "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A=="],
|
||||
|
||||
"ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
|
||||
|
||||
"negotiator": ["negotiator@1.0.0", "", {}, "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg=="],
|
||||
|
||||
"object-inspect": ["object-inspect@1.13.4", "", {}, "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew=="],
|
||||
|
||||
"on-finished": ["on-finished@2.4.1", "", { "dependencies": { "ee-first": "1.1.1" } }, "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg=="],
|
||||
|
||||
"once": ["once@1.4.0", "", { "dependencies": { "wrappy": "1" } }, "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w=="],
|
||||
|
||||
"p-finally": ["p-finally@1.0.0", "", {}, "sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow=="],
|
||||
|
||||
"p-queue": ["p-queue@6.6.2", "", { "dependencies": { "eventemitter3": "^4.0.4", "p-timeout": "^3.2.0" } }, "sha512-RwFpb72c/BhQLEXIZ5K2e+AhgNVmIejGlTgiB9MzZ0e93GRvqZ7uSi0dvRF7/XIXDeNkra2fNHBxTyPDGySpjQ=="],
|
||||
|
||||
"p-retry": ["p-retry@4.6.2", "", { "dependencies": { "@types/retry": "0.12.0", "retry": "^0.13.1" } }, "sha512-312Id396EbJdvRONlngUx0NydfrIQ5lsYu0znKVUzVvArzEIt08V1qhtyESbGVd1FGX7UKtiFp5uwKZdM8wIuQ=="],
|
||||
|
||||
"p-timeout": ["p-timeout@3.2.0", "", { "dependencies": { "p-finally": "^1.0.0" } }, "sha512-rhIwUycgwwKcP9yTOOFK/AKsAopjjCakVqLHePO3CC6Mir1Z99xT+R63jZxAT5lFZLa2inS5h+ZS2GvR99/FBg=="],
|
||||
|
||||
"parseurl": ["parseurl@1.3.3", "", {}, "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ=="],
|
||||
|
||||
"path-to-regexp": ["path-to-regexp@8.3.0", "", {}, "sha512-7jdwVIRtsP8MYpdXSwOS0YdD0Du+qOoF/AEPIt88PcCFrZCzx41oxku1jD88hZBwbNUIEfpqvuhjFaMAqMTWnA=="],
|
||||
|
||||
"proxy-addr": ["proxy-addr@2.0.7", "", { "dependencies": { "forwarded": "0.2.0", "ipaddr.js": "1.9.1" } }, "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg=="],
|
||||
|
||||
"proxy-from-env": ["proxy-from-env@1.1.0", "", {}, "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="],
|
||||
|
||||
"qs": ["qs@6.15.0", "", { "dependencies": { "side-channel": "^1.1.0" } }, "sha512-mAZTtNCeetKMH+pSjrb76NAM8V9a05I9aBZOHztWy/UqcJdQYNsf59vrRKWnojAT9Y+GbIvoTBC++CPHqpDBhQ=="],
|
||||
|
||||
"range-parser": ["range-parser@1.2.1", "", {}, "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg=="],
|
||||
|
||||
"raw-body": ["raw-body@3.0.2", "", { "dependencies": { "bytes": "~3.1.2", "http-errors": "~2.0.1", "iconv-lite": "~0.7.0", "unpipe": "~1.0.0" } }, "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA=="],
|
||||
|
||||
"retry": ["retry@0.13.1", "", {}, "sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg=="],
|
||||
|
||||
"router": ["router@2.2.0", "", { "dependencies": { "debug": "^4.4.0", "depd": "^2.0.0", "is-promise": "^4.0.0", "parseurl": "^1.3.3", "path-to-regexp": "^8.0.0" } }, "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ=="],
|
||||
|
||||
"safe-buffer": ["safe-buffer@5.2.1", "", {}, "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="],
|
||||
|
||||
"safer-buffer": ["safer-buffer@2.1.2", "", {}, "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="],
|
||||
|
||||
"semver": ["semver@7.7.4", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA=="],
|
||||
|
||||
"send": ["send@1.2.1", "", { "dependencies": { "debug": "^4.4.3", "encodeurl": "^2.0.0", "escape-html": "^1.0.3", "etag": "^1.8.1", "fresh": "^2.0.0", "http-errors": "^2.0.1", "mime-types": "^3.0.2", "ms": "^2.1.3", "on-finished": "^2.4.1", "range-parser": "^1.2.1", "statuses": "^2.0.2" } }, "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ=="],
|
||||
|
||||
"serve-static": ["serve-static@2.2.1", "", { "dependencies": { "encodeurl": "^2.0.0", "escape-html": "^1.0.3", "parseurl": "^1.3.3", "send": "^1.2.0" } }, "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw=="],
|
||||
|
||||
"setprototypeof": ["setprototypeof@1.2.0", "", {}, "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw=="],
|
||||
|
||||
"side-channel": ["side-channel@1.1.0", "", { "dependencies": { "es-errors": "^1.3.0", "object-inspect": "^1.13.3", "side-channel-list": "^1.0.0", "side-channel-map": "^1.0.1", "side-channel-weakmap": "^1.0.2" } }, "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw=="],
|
||||
|
||||
"side-channel-list": ["side-channel-list@1.0.0", "", { "dependencies": { "es-errors": "^1.3.0", "object-inspect": "^1.13.3" } }, "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA=="],
|
||||
|
||||
"side-channel-map": ["side-channel-map@1.0.1", "", { "dependencies": { "call-bound": "^1.0.2", "es-errors": "^1.3.0", "get-intrinsic": "^1.2.5", "object-inspect": "^1.13.3" } }, "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA=="],
|
||||
|
||||
"side-channel-weakmap": ["side-channel-weakmap@1.0.2", "", { "dependencies": { "call-bound": "^1.0.2", "es-errors": "^1.3.0", "get-intrinsic": "^1.2.5", "object-inspect": "^1.13.3", "side-channel-map": "^1.0.1" } }, "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A=="],
|
||||
|
||||
"statuses": ["statuses@2.0.2", "", {}, "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw=="],
|
||||
|
||||
"toidentifier": ["toidentifier@1.0.1", "", {}, "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA=="],
|
||||
|
||||
"tsscmp": ["tsscmp@1.0.6", "", {}, "sha512-LxhtAkPDTkVCMQjt2h6eBVY28KCjikZqZfMcC15YBeNjkgUpdCfBu5HoiOTDu86v6smE8yOjyEktJ8hlbANHQA=="],
|
||||
|
||||
"type-is": ["type-is@2.0.1", "", { "dependencies": { "content-type": "^1.0.5", "media-typer": "^1.1.0", "mime-types": "^3.0.0" } }, "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw=="],
|
||||
|
||||
"undici-types": ["undici-types@7.18.2", "", {}, "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w=="],
|
||||
|
||||
"unpipe": ["unpipe@1.0.0", "", {}, "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ=="],
|
||||
|
||||
"valibot": ["valibot@1.2.0", "", { "peerDependencies": { "typescript": ">=5" }, "optionalPeers": ["typescript"] }, "sha512-mm1rxUsmOxzrwnX5arGS+U4T25RdvpPjPN4yR0u9pUBov9+zGVtO84tif1eY4r6zWxVxu3KzIyknJy3rxfRZZg=="],
|
||||
|
||||
"vary": ["vary@1.1.2", "", {}, "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg=="],
|
||||
|
||||
"wrappy": ["wrappy@1.0.2", "", {}, "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ=="],
|
||||
|
||||
"ws": ["ws@8.19.0", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-blAT2mjOEIi0ZzruJfIhb3nps74PRWTCz1IjglWEEpQl5XS/UNama6u2/rjFkDDouqr4L67ry+1aGIALViWjDg=="],
|
||||
|
||||
"form-data/mime-types": ["mime-types@2.1.35", "", { "dependencies": { "mime-db": "1.52.0" } }, "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw=="],
|
||||
|
||||
"p-queue/eventemitter3": ["eventemitter3@4.0.7", "", {}, "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw=="],
|
||||
|
||||
"form-data/mime-types/mime-db": ["mime-db@1.52.0", "", {}, "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg=="],
|
||||
}
|
||||
}
|
||||
12
.claude/skills/setup-spa/package.json
Normal file
12
.claude/skills/setup-spa/package.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "spawn-slack-bot",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "bun run slack-bot.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@slack/bolt": "^4.3.0",
|
||||
"valibot": "^1.0.0"
|
||||
}
|
||||
}
|
||||
553
.claude/skills/setup-spa/slack-bot.ts
Normal file
553
.claude/skills/setup-spa/slack-bot.ts
Normal file
|
|
@ -0,0 +1,553 @@
|
|||
import { App } from "@slack/bolt";
|
||||
import { mkdirSync, readFileSync, writeFileSync, existsSync } from "node:fs";
|
||||
import { dirname } from "node:path";
|
||||
import * as v from "valibot";
|
||||
|
||||
// #region Environment
|
||||
|
||||
const SLACK_BOT_TOKEN = process.env.SLACK_BOT_TOKEN ?? "";
|
||||
const SLACK_APP_TOKEN = process.env.SLACK_APP_TOKEN ?? "";
|
||||
const SLACK_CHANNEL_ID = process.env.SLACK_CHANNEL_ID ?? "";
|
||||
const GITHUB_REPO = process.env.GITHUB_REPO ?? "OpenRouterTeam/spawn";
|
||||
|
||||
const REQUIRED_VARS = {
|
||||
SLACK_BOT_TOKEN,
|
||||
SLACK_APP_TOKEN,
|
||||
SLACK_CHANNEL_ID,
|
||||
};
|
||||
|
||||
for (const [name, value] of Object.entries(REQUIRED_VARS)) {
|
||||
if (!value) {
|
||||
console.error(`ERROR: ${name} env var is required`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region Bot identity
|
||||
|
||||
let BOT_USER_ID = "";
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region State
|
||||
|
||||
const STATE_PATH = process.env.STATE_PATH ?? `${process.env.HOME ?? "/root"}/.config/spawn/slack-issues.json`;
|
||||
|
||||
const MappingSchema = v.object({
|
||||
channel: v.string(),
|
||||
threadTs: v.string(),
|
||||
sessionId: v.string(),
|
||||
createdAt: v.string(),
|
||||
});
|
||||
|
||||
const StateSchema = v.object({
|
||||
mappings: v.array(MappingSchema),
|
||||
});
|
||||
|
||||
type Mapping = v.InferOutput<typeof MappingSchema>;
|
||||
type State = v.InferOutput<typeof StateSchema>;
|
||||
|
||||
function loadState(): State {
|
||||
try {
|
||||
if (!existsSync(STATE_PATH)) {
|
||||
return {
|
||||
mappings: [],
|
||||
};
|
||||
}
|
||||
const raw = readFileSync(STATE_PATH, "utf-8");
|
||||
const parsed = v.parse(StateSchema, JSON.parse(raw));
|
||||
return parsed;
|
||||
} catch {
|
||||
console.warn("[spa] Could not load state, starting fresh");
|
||||
return {
|
||||
mappings: [],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function saveState(s: State): void {
|
||||
const dir = dirname(STATE_PATH);
|
||||
mkdirSync(dir, {
|
||||
recursive: true,
|
||||
});
|
||||
writeFileSync(STATE_PATH, `${JSON.stringify(s, null, 2)}\n`);
|
||||
}
|
||||
|
||||
function findMapping(s: State, channel: string, threadTs: string): Mapping | undefined {
|
||||
return s.mappings.find((m) => m.channel === channel && m.threadTs === threadTs);
|
||||
}
|
||||
|
||||
function addMapping(s: State, mapping: Mapping): void {
|
||||
s.mappings.push(mapping);
|
||||
saveState(s);
|
||||
}
|
||||
|
||||
const state = loadState();
|
||||
|
||||
// Active Claude Code processes — keyed by threadTs
|
||||
const activeRuns = new Map<
|
||||
string,
|
||||
{
|
||||
proc: ReturnType<typeof Bun.spawn>;
|
||||
startedAt: number;
|
||||
}
|
||||
>();
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region Claude Code helpers
|
||||
|
||||
const ResultSchema = v.object({
|
||||
type: v.literal("result"),
|
||||
session_id: v.string(),
|
||||
});
|
||||
|
||||
function toObj(val: unknown): Record<string, unknown> | null {
|
||||
if (typeof val !== "object" || val === null || Array.isArray(val)) {
|
||||
return null;
|
||||
}
|
||||
// val is narrowed to `object` — safe to index
|
||||
const obj: Record<string, unknown> = {};
|
||||
for (const [k, v] of Object.entries(val)) {
|
||||
obj[k] = v;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
/** Format a parsed stream event into a Slack-friendly text segment, or null to skip. */
|
||||
function formatStreamEvent(event: Record<string, unknown>): string | null {
|
||||
const type = event.type;
|
||||
|
||||
// stream_event wraps Anthropic API events
|
||||
if (type === "stream_event") {
|
||||
const inner = toObj(event.event);
|
||||
if (!inner) {
|
||||
return null;
|
||||
}
|
||||
const innerType = inner.type;
|
||||
|
||||
// Tool use start — show tool name
|
||||
if (innerType === "content_block_start") {
|
||||
const block = toObj(inner.content_block);
|
||||
if (block?.type === "tool_use" && typeof block.name === "string") {
|
||||
return `\n:hammer_and_wrench: *${block.name}*\n`;
|
||||
}
|
||||
}
|
||||
|
||||
// Text delta — accumulate text
|
||||
if (innerType === "content_block_delta") {
|
||||
const delta = toObj(inner.delta);
|
||||
if (delta?.type === "text_delta" && typeof delta.text === "string") {
|
||||
return delta.text;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Tool result — show output (truncated)
|
||||
if (type === "tool_result") {
|
||||
const result = typeof event.result === "string" ? event.result : "";
|
||||
const isError = event.is_error === true;
|
||||
const prefix = isError ? ":x: Error" : ":white_check_mark: Result";
|
||||
const truncated = result.length > 500 ? `${result.slice(0, 500)}...` : result;
|
||||
if (!truncated) {
|
||||
return `${prefix}: (empty)\n`;
|
||||
}
|
||||
return `${prefix}:\n\`\`\`\n${truncated}\n\`\`\`\n`;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
const SYSTEM_PROMPT = `You are SPA (Spawn's Personal Agent), a Slack bot for the Spawn project (${GITHUB_REPO}).
|
||||
|
||||
Your primary job is to help manage GitHub issues based on Slack conversations:
|
||||
|
||||
1. **Create issues**: When a thread describes a bug, feature request, or task — create a GitHub issue with \`gh issue create --repo ${GITHUB_REPO}\`. Use a clear title and include the Slack context in the body.
|
||||
2. **Update issues**: When a thread references an existing issue (by number like #123) — add comments, update labels, or close issues as appropriate using \`gh issue comment\`, \`gh issue edit\`, etc.
|
||||
3. **Search issues**: When asked about existing issues, search with \`gh issue list --repo ${GITHUB_REPO}\` or \`gh issue view\`.
|
||||
4. **General help**: Answer questions about the Spawn codebase, suggest fixes, or help triage.
|
||||
|
||||
Always use the \`gh\` CLI for GitHub operations. You are already authenticated.
|
||||
|
||||
**Issue title format — MANDATORY.** Before creating an issue, read the issue templates in \`.github/ISSUE_TEMPLATE/\` to determine the correct title prefix, labels, and required fields. Each template specifies a bracket prefix (e.g. \`[Bug]:\`, \`[CLI]:\`) — always use the matching one. Apply the labels defined in the template's \`labels:\` field.
|
||||
|
||||
When creating issues, include a footer: "_Filed from Slack by SPA_"
|
||||
|
||||
Below is the full Slack thread. The most recent message is the one you should respond to. Prior messages are context.`;
|
||||
|
||||
/**
|
||||
* Fetch full thread history from Slack and format as a prompt.
|
||||
*/
|
||||
async function buildThreadPrompt(
|
||||
client: InstanceType<typeof App>["client"],
|
||||
channel: string,
|
||||
threadTs: string,
|
||||
): Promise<string> {
|
||||
const result = await client.conversations.replies({
|
||||
channel,
|
||||
ts: threadTs,
|
||||
inclusive: true,
|
||||
limit: 100,
|
||||
});
|
||||
|
||||
const messages = result.messages ?? [];
|
||||
const lines: string[] = [];
|
||||
|
||||
for (const msg of messages) {
|
||||
// Skip our own bot messages
|
||||
if (msg.user === BOT_USER_ID) {
|
||||
continue;
|
||||
}
|
||||
if (msg.bot_id) {
|
||||
continue;
|
||||
}
|
||||
const text = stripMention(msg.text ?? "");
|
||||
if (!text) {
|
||||
continue;
|
||||
}
|
||||
lines.push(text);
|
||||
}
|
||||
|
||||
return lines.join("\n\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Run `claude -p` with stream-json output, collect assistant text,
|
||||
* and post chunked updates to a Slack thread.
|
||||
*/
|
||||
async function runClaudeAndStream(
|
||||
client: InstanceType<typeof App>["client"],
|
||||
channel: string,
|
||||
threadTs: string,
|
||||
prompt: string,
|
||||
sessionId: string | undefined,
|
||||
): Promise<string | null> {
|
||||
const args = [
|
||||
"claude",
|
||||
"-p",
|
||||
"--verbose",
|
||||
"--output-format",
|
||||
"stream-json",
|
||||
"--dangerously-skip-permissions",
|
||||
"--no-session-persistence",
|
||||
"--system-prompt",
|
||||
SYSTEM_PROMPT,
|
||||
];
|
||||
|
||||
if (sessionId) {
|
||||
args.push("--resume", sessionId);
|
||||
}
|
||||
|
||||
args.push(prompt);
|
||||
|
||||
console.log(`[spa] Starting claude session (thread=${threadTs}, resume=${sessionId ?? "new"})`);
|
||||
|
||||
const proc = Bun.spawn(args, {
|
||||
stdout: "pipe",
|
||||
stderr: "pipe",
|
||||
cwd: process.env.REPO_ROOT ?? process.cwd(),
|
||||
});
|
||||
|
||||
activeRuns.set(threadTs, {
|
||||
proc,
|
||||
startedAt: Date.now(),
|
||||
});
|
||||
|
||||
// Post initial "thinking" message
|
||||
const thinkingMsg = await client.chat
|
||||
.postMessage({
|
||||
channel,
|
||||
thread_ts: threadTs,
|
||||
text: ":brain: Thinking...",
|
||||
})
|
||||
.catch(() => null);
|
||||
|
||||
const updateTs = thinkingMsg?.ts;
|
||||
let fullText = "";
|
||||
let lastUpdateLen = 0;
|
||||
let returnedSessionId: string | null = null;
|
||||
|
||||
// Throttle Slack updates — update at most every 2s
|
||||
let lastUpdateTime = 0;
|
||||
const UPDATE_INTERVAL_MS = 2000;
|
||||
const MAX_MSG_LEN = 3900; // Slack limit ~4000, leave room
|
||||
|
||||
const decoder = new TextDecoder();
|
||||
const reader = proc.stdout.getReader();
|
||||
let buffer = "";
|
||||
|
||||
try {
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
if (done) {
|
||||
break;
|
||||
}
|
||||
|
||||
buffer += decoder.decode(value, {
|
||||
stream: true,
|
||||
});
|
||||
const lines = buffer.split("\n");
|
||||
buffer = lines.pop() ?? "";
|
||||
|
||||
for (const line of lines) {
|
||||
const trimmed = line.trim();
|
||||
if (!trimmed) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let parsed: unknown;
|
||||
try {
|
||||
parsed = JSON.parse(trimmed);
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
|
||||
const obj = toObj(parsed);
|
||||
if (!obj) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Capture session ID from result event
|
||||
const resultEvent = v.safeParse(ResultSchema, obj);
|
||||
if (resultEvent.success) {
|
||||
returnedSessionId = resultEvent.output.session_id;
|
||||
}
|
||||
|
||||
// Format event for Slack display
|
||||
const segment = formatStreamEvent(obj);
|
||||
if (segment) {
|
||||
fullText += segment;
|
||||
}
|
||||
}
|
||||
|
||||
// Throttled Slack update
|
||||
const now = Date.now();
|
||||
if (updateTs && fullText.length > lastUpdateLen && now - lastUpdateTime >= UPDATE_INTERVAL_MS) {
|
||||
const displayText = fullText.length > MAX_MSG_LEN ? `...${fullText.slice(-MAX_MSG_LEN)}` : fullText;
|
||||
|
||||
await client.chat
|
||||
.update({
|
||||
channel,
|
||||
ts: updateTs,
|
||||
text: displayText,
|
||||
})
|
||||
.catch(() => {});
|
||||
|
||||
lastUpdateLen = fullText.length;
|
||||
lastUpdateTime = now;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
activeRuns.delete(threadTs);
|
||||
}
|
||||
|
||||
// Read stderr for errors
|
||||
const stderr = await new Response(proc.stderr).text();
|
||||
const exitCode = await proc.exited;
|
||||
|
||||
if (exitCode !== 0 && !fullText) {
|
||||
console.error(`[spa] claude exited ${exitCode}: ${stderr}`);
|
||||
if (updateTs) {
|
||||
await client.chat
|
||||
.update({
|
||||
channel,
|
||||
ts: updateTs,
|
||||
text: `:x: Claude Code errored (exit ${exitCode}):\n\`\`\`\n${stderr.slice(0, 1500)}\n\`\`\``,
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Final update with complete text
|
||||
if (updateTs && fullText) {
|
||||
const displayText = fullText.length > MAX_MSG_LEN ? `...${fullText.slice(-MAX_MSG_LEN)}` : fullText;
|
||||
|
||||
await client.chat
|
||||
.update({
|
||||
channel,
|
||||
ts: updateTs,
|
||||
text: displayText,
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
|
||||
if (!fullText && updateTs) {
|
||||
await client.chat
|
||||
.update({
|
||||
channel,
|
||||
ts: updateTs,
|
||||
text: ":white_check_mark: Done (no text output)",
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
|
||||
console.log(`[spa] Claude done (thread=${threadTs}, session=${returnedSessionId}, len=${fullText.length})`);
|
||||
|
||||
return returnedSessionId;
|
||||
}
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region Text helpers
|
||||
|
||||
function stripMention(text: string): string {
|
||||
return text.replace(/<@[A-Z0-9]+>/g, "").trim();
|
||||
}
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region Core handler
|
||||
|
||||
async function handleThread(
|
||||
client: InstanceType<typeof App>["client"],
|
||||
channel: string,
|
||||
threadTs: string,
|
||||
eventTs: string,
|
||||
): Promise<void> {
|
||||
// Prevent concurrent runs on the same thread
|
||||
if (activeRuns.has(threadTs)) {
|
||||
await client.reactions
|
||||
.add({
|
||||
channel,
|
||||
timestamp: eventTs,
|
||||
name: "hourglass_flowing_sand",
|
||||
})
|
||||
.catch(() => {});
|
||||
return;
|
||||
}
|
||||
|
||||
// Build prompt from full thread (skipping bot messages)
|
||||
const prompt = await buildThreadPrompt(client, channel, threadTs);
|
||||
if (!prompt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for existing session to resume
|
||||
const existing = findMapping(state, channel, threadTs);
|
||||
|
||||
await client.reactions
|
||||
.add({
|
||||
channel,
|
||||
timestamp: eventTs,
|
||||
name: "robot_face",
|
||||
})
|
||||
.catch(() => {});
|
||||
|
||||
// Run Claude Code and stream back
|
||||
const sessionId = await runClaudeAndStream(client, channel, threadTs, prompt, existing?.sessionId);
|
||||
|
||||
// Save session mapping
|
||||
if (sessionId && !existing) {
|
||||
addMapping(state, {
|
||||
channel,
|
||||
threadTs,
|
||||
sessionId,
|
||||
createdAt: new Date().toISOString(),
|
||||
});
|
||||
} else if (sessionId && existing) {
|
||||
existing.sessionId = sessionId;
|
||||
saveState(state);
|
||||
}
|
||||
}
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region Slack App
|
||||
|
||||
const app = new App({
|
||||
token: SLACK_BOT_TOKEN,
|
||||
appToken: SLACK_APP_TOKEN,
|
||||
socketMode: true,
|
||||
logLevel: "INFO",
|
||||
});
|
||||
|
||||
// --- app_mention: @Spawnis triggers a Claude run on this thread ---
|
||||
app.event("app_mention", async ({ event, client }) => {
|
||||
if (event.channel !== SLACK_CHANNEL_ID) {
|
||||
return;
|
||||
}
|
||||
const threadTs = event.thread_ts ?? event.ts;
|
||||
await handleThread(client, event.channel, threadTs, event.ts);
|
||||
});
|
||||
|
||||
// --- message: new thread replies in tracked threads trigger Claude ---
|
||||
app.event("message", async ({ event, client }) => {
|
||||
if (!("channel" in event) || event.channel !== SLACK_CHANNEL_ID) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only thread replies
|
||||
const threadTs = "thread_ts" in event && typeof event.thread_ts === "string" ? event.thread_ts : undefined;
|
||||
if (!threadTs) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip our own messages
|
||||
if ("user" in event && event.user === BOT_USER_ID) {
|
||||
return;
|
||||
}
|
||||
if ("bot_id" in event && event.bot_id) {
|
||||
return;
|
||||
}
|
||||
if ("subtype" in event && event.subtype === "bot_message") {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only respond in threads we're already tracking
|
||||
const mapping = findMapping(state, event.channel, threadTs);
|
||||
if (!mapping) {
|
||||
return;
|
||||
}
|
||||
|
||||
const ts = "ts" in event && typeof event.ts === "string" ? event.ts : "";
|
||||
if (!ts) {
|
||||
return;
|
||||
}
|
||||
|
||||
await handleThread(client, event.channel, threadTs, ts);
|
||||
});
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region Graceful shutdown
|
||||
|
||||
function shutdown(signal: string): void {
|
||||
console.log(`[spa] Received ${signal}, shutting down...`);
|
||||
|
||||
for (const [threadTs, run] of activeRuns) {
|
||||
console.log(`[spa] Killing active run for thread ${threadTs}`);
|
||||
run.proc.kill("SIGTERM");
|
||||
}
|
||||
|
||||
saveState(state);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
process.on("SIGTERM", () => shutdown("SIGTERM"));
|
||||
process.on("SIGINT", () => shutdown("SIGINT"));
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region Start
|
||||
|
||||
(async () => {
|
||||
// Resolve our own bot user ID
|
||||
const authResult = await app.client.auth.test({
|
||||
token: SLACK_BOT_TOKEN,
|
||||
});
|
||||
BOT_USER_ID = authResult.user_id ?? "";
|
||||
if (BOT_USER_ID) {
|
||||
console.log(`[spa] Bot user ID: ${BOT_USER_ID}`);
|
||||
} else {
|
||||
console.warn("[spa] Could not resolve bot user ID — may echo own messages");
|
||||
}
|
||||
|
||||
await app.start();
|
||||
console.log(`[spa] Running (channel=${SLACK_CHANNEL_ID}, repo=${GITHUB_REPO})`);
|
||||
})();
|
||||
// #endregion
|
||||
27
.claude/skills/setup-spa/slack-manifest.yml
Normal file
27
.claude/skills/setup-spa/slack-manifest.yml
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
_metadata:
|
||||
major_version: 1
|
||||
display_information:
|
||||
name: Spa
|
||||
description: "Spawn's Personal Agent"
|
||||
background_color: "#1a1a2e"
|
||||
features:
|
||||
bot_user:
|
||||
display_name: spa
|
||||
always_online: true
|
||||
oauth_config:
|
||||
scopes:
|
||||
bot:
|
||||
- app_mentions:read
|
||||
- channels:history
|
||||
- channels:read
|
||||
- chat:write
|
||||
- reactions:write
|
||||
settings:
|
||||
event_subscriptions:
|
||||
bot_events:
|
||||
- app_mention
|
||||
- message.channels
|
||||
org_deploy_enabled: false
|
||||
socket_mode_enabled: true
|
||||
is_hosted: false
|
||||
token_rotation_enabled: false
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"$schema": "https://biomejs.dev/schemas/2.4.3/schema.json",
|
||||
"extends": ["../lint/biome.json"],
|
||||
"vcs": {
|
||||
"enabled": true,
|
||||
"clientKind": "git",
|
||||
|
|
@ -10,64 +11,6 @@
|
|||
"ignoreUnknown": false,
|
||||
"includes": ["src/**/*.ts"]
|
||||
},
|
||||
"formatter": {
|
||||
"enabled": true,
|
||||
"indentStyle": "space",
|
||||
"indentWidth": 2,
|
||||
"lineWidth": 120
|
||||
},
|
||||
"linter": {
|
||||
"enabled": true,
|
||||
"rules": {
|
||||
"recommended": true,
|
||||
"complexity": {
|
||||
"useLiteralKeys": "off",
|
||||
"noForEach": "off",
|
||||
"noUselessSwitchCase": "off"
|
||||
},
|
||||
"style": {
|
||||
"noNonNullAssertion": "off",
|
||||
"useNodejsImportProtocol": "error",
|
||||
"useTemplate": "off",
|
||||
"useBlockStatements": "error",
|
||||
"noParameterAssign": "off",
|
||||
"useConst": "error",
|
||||
"useDefaultParameterLast": "error",
|
||||
"useSelfClosingElements": "error",
|
||||
"useSingleVarDeclarator": "error",
|
||||
"noUnusedTemplateLiteral": "error",
|
||||
"useNumberNamespace": "error",
|
||||
"noInferrableTypes": "error",
|
||||
"noUselessElse": "error",
|
||||
"useImportType": "error"
|
||||
},
|
||||
"correctness": {
|
||||
"noUnusedImports": "error",
|
||||
"noUnusedVariables": "error",
|
||||
"noUnusedFunctionParameters": "warn",
|
||||
"noInnerDeclarations": "error"
|
||||
},
|
||||
"suspicious": {
|
||||
"noExplicitAny": "warn",
|
||||
"noAssignInExpressions": "error",
|
||||
"noFallthroughSwitchClause": "error",
|
||||
"noDoubleEquals": "error",
|
||||
"noExtraNonNullAssertion": "error",
|
||||
"noTemplateCurlyInString": "off",
|
||||
"noImplicitAnyLet": "error",
|
||||
"noGlobalIsNan": "error",
|
||||
"noGlobalIsFinite": "error",
|
||||
"noControlCharactersInRegex": "off"
|
||||
},
|
||||
"performance": {
|
||||
"recommended": true,
|
||||
"noAccumulatingSpread": "error"
|
||||
},
|
||||
"security": {
|
||||
"recommended": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"includes": ["src/__tests__/**"],
|
||||
|
|
@ -86,19 +29,5 @@
|
|||
}
|
||||
}
|
||||
],
|
||||
"javascript": {
|
||||
"formatter": {
|
||||
"expand": "always",
|
||||
"arrowParentheses": "always",
|
||||
"quoteStyle": "double",
|
||||
"trailingCommas": "all",
|
||||
"semicolons": "always",
|
||||
"bracketSpacing": true,
|
||||
"bracketSameLine": false
|
||||
}
|
||||
},
|
||||
"plugins": ["./lint/no-type-assertion.grit", "./lint/no-typeof-string-number.grit"],
|
||||
"assist": {
|
||||
"enabled": false
|
||||
}
|
||||
"plugins": ["../lint/no-type-assertion.grit", "../lint/no-typeof-string-number.grit"]
|
||||
}
|
||||
|
|
|
|||
75
lint/biome.json
Normal file
75
lint/biome.json
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
{
|
||||
"$schema": "https://biomejs.dev/schemas/2.4.3/schema.json",
|
||||
"formatter": {
|
||||
"enabled": true,
|
||||
"indentStyle": "space",
|
||||
"indentWidth": 2,
|
||||
"lineWidth": 120
|
||||
},
|
||||
"linter": {
|
||||
"enabled": true,
|
||||
"rules": {
|
||||
"recommended": true,
|
||||
"complexity": {
|
||||
"useLiteralKeys": "off",
|
||||
"noForEach": "off",
|
||||
"noUselessSwitchCase": "off"
|
||||
},
|
||||
"style": {
|
||||
"noNonNullAssertion": "off",
|
||||
"useNodejsImportProtocol": "error",
|
||||
"useTemplate": "off",
|
||||
"useBlockStatements": "error",
|
||||
"noParameterAssign": "off",
|
||||
"useConst": "error",
|
||||
"useDefaultParameterLast": "error",
|
||||
"useSelfClosingElements": "error",
|
||||
"useSingleVarDeclarator": "error",
|
||||
"noUnusedTemplateLiteral": "error",
|
||||
"useNumberNamespace": "error",
|
||||
"noInferrableTypes": "error",
|
||||
"noUselessElse": "error",
|
||||
"useImportType": "error"
|
||||
},
|
||||
"correctness": {
|
||||
"noUnusedImports": "error",
|
||||
"noUnusedVariables": "error",
|
||||
"noUnusedFunctionParameters": "warn",
|
||||
"noInnerDeclarations": "error"
|
||||
},
|
||||
"suspicious": {
|
||||
"noExplicitAny": "warn",
|
||||
"noAssignInExpressions": "error",
|
||||
"noFallthroughSwitchClause": "error",
|
||||
"noDoubleEquals": "error",
|
||||
"noExtraNonNullAssertion": "error",
|
||||
"noTemplateCurlyInString": "off",
|
||||
"noImplicitAnyLet": "error",
|
||||
"noGlobalIsNan": "error",
|
||||
"noGlobalIsFinite": "error",
|
||||
"noControlCharactersInRegex": "off"
|
||||
},
|
||||
"performance": {
|
||||
"recommended": true,
|
||||
"noAccumulatingSpread": "error"
|
||||
},
|
||||
"security": {
|
||||
"recommended": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"javascript": {
|
||||
"formatter": {
|
||||
"expand": "always",
|
||||
"arrowParentheses": "always",
|
||||
"quoteStyle": "double",
|
||||
"trailingCommas": "all",
|
||||
"semicolons": "always",
|
||||
"bracketSpacing": true,
|
||||
"bracketSameLine": false
|
||||
}
|
||||
},
|
||||
"assist": {
|
||||
"enabled": false
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue