Files
cc-connect/.gitignore
T
Aleksey BondarenkoandClaude Opus 4.7 cb2fb67875 feat(platform/max): webhook delivery mode + deployment docs (#818)
* feat(platform/max): webhook mode, typing presence, long-poll tuning

Adds webhook delivery as an alternative to long-polling (required by
MAX from 2026-05-11, when long-poll is throttled to 2 RPS):

- New `webhook_url` / `webhook_listen` config options. When `webhook_url`
  is set, the platform registers a subscription with MAX, runs an HTTP
  listener on `webhook_listen`, and skips the long-poll loop. Stop()
  best-effort unsubscribes so MAX stops delivering to a dead URL.
- Webhook handler ack's MAX with a fast 200 and processes updates
  asynchronously so agent latency never back-pressures delivery.

Adds typing/read presence indicators:

- `StartTyping` drives MAX's `typing_on` action on a 4s ticker.
- Incoming messages get fire-and-forget `mark_seen` so the user sees
  the read tick.

Tightens long-poll timeouts to prevent retry storms:

- `pollTimeout` 20 → 30 (matches MAX dev docs default)
- `httpTimeout` 35s → 90s (must exceed pollTimeout with margin so
  transient backend lag doesn't trip client cancellation).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(platform/max): add webhook_path and webhook_secret options + deployment docs

New config options for hardening webhook deployments:

- `webhook_path` (default "/webhook") — lets multiple bots share one
  domain (e.g. /bot1, /bot2). Leading slash is normalized.
- `webhook_secret` — optional shared secret. If set, incoming requests
  must carry it in the `X-Webhook-Secret` header or `?s=` query param;
  mismatches return 401. Compared with `subtle.ConstantTimeCompare` to
  resist timing attacks. Recommended pattern: set the secret as an
  nginx `proxy_set_header` so it never appears in URLs or upstream logs.

Adds `docs/max-webhook.md` with three deployment topologies (VPS +
reverse proxy, home + VPS SSH-tunnel, long-poll), copy-paste nginx /
Caddy / systemd samples, a config field reference, mode-switching
notes, and troubleshooting. Updates `config.example.toml` to point
users at the doc and show the new fields.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* chore: ignore manual cc-connect.bak backups and runtime *.toml.lock files

The bot acquires a *.toml.lock at startup to prevent multiple instances
fighting over the same config. These are runtime artifacts, not source.

cc-connect.bak-* is the manual backup naming convention used during
local development (cc-connect.bak-deadlock-fix-..., cc-connect.bak-pre-
webhook-..., etc.). Each is a 30 MB binary; keeping them out of
`git status` makes the working tree readable again.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(platform/max): correct webhook secret header + periodic resubscribe

The handler was checking X-Webhook-Secret, but MAX sends the configured
secret as X-Max-Bot-Api-Secret per dev.max.ru/docs-api — which meant the
existing webhook_secret option silently rejected every legitimate webhook
with 401. Also propagate the secret in POST /subscriptions so MAX actually
includes the header.

Add a periodic re-subscribe loop (default 5m, configurable via
webhook_resubscribe_interval) to work around server-side subscription
drops observed on 2026-05-04 (three drops in ~1.5h on a single run, all
POST /webhook responses 200). MAX overwrites in place, so re-subscribing
is idempotent.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-05 17:19:58 +08:00

142 lines
2.9 KiB
Plaintext

# ============================================================================
# Binary outputs
# ============================================================================
/cc-connect
cc-connect.bak-*
*.exe
*.exe~
*.dll
*.so
*.dylib
*.test
*.out
*.old
# ============================================================================
# Go workspace & tooling
# ============================================================================
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool
coverage.html
coverage.txt
*.out
# Go workspace files (go.work)
go.work
go.work.sum
# Go module environment (local proxy settings)
go.env
# Dependency directories
vendor/
# ============================================================================
# Project-specific
# ============================================================================
# Runtime configuration (contains secrets)
config.toml
config.*.toml
!config.example.toml
.env
*.local.toml
# Instance lock files (created at startup, released on shutdown)
*.toml.lock
# CC-Connect runtime state
.cc-connect/
# npm / pnpm (for npm package distribution and web admin)
.npmrc
package-lock.json
node_modules/
.vite/
# ============================================================================
# Build & distribution
# ============================================================================
dist/
build/
bin/
release/
# Keep web/dist directory (for embedded admin UI) but ignore build artifacts
web/dist/*
!web/dist/.keep
# ============================================================================
# Testing & temporary files
# ============================================================================
test/
scripts/
tmp/
temp/
*.tmp
*.swp
*.swo
*~
*.pid
*.log
# ============================================================================
# IDE & Editor
# ============================================================================
.vscode/
.idea/
*.iml
*.ipr
*.iws
.vs/
*.suo
*.user
*.userosscache
*.sln.docstates
# Emacs
*~
\#*\#
.\#*
# Vim
*.swp
*.swo
*.swn
# macOS
.DS_Store
.AppleDouble
.LSOverride
# ============================================================================
# Documentation (drafts)
# ============================================================================
RELEASE.md
DRAFTS.md
NOTES.md
# ============================================================================
# System
# ============================================================================
# Thumbs.db on Windows
Thumbs.db
ehthumbs.db
Desktop.ini
# ============================================================================
# AI agent planning artifacts
# ============================================================================
.planning/
# ============================================================================
# Security
# ============================================================================
# Never commit secrets or credentials
*.key
*.pem
*.p12
*.pfx
secrets/
credentials/