Files
cc-connect/Makefile
T
72d6fb617d Integrate WPS Agentspace platform with auto-login and token encryption (#1439)
* feat: add WPS Agentspace platform integration

Add wps-agentspace platform that connects to WPS Digital Employee (数字员工)
via WebSocket, enabling users to interact with Claude Code through WPS Xiezuo
without creating a WPS application.

Features:
- WebSocket connection to agentspace.wps.cn
- Token decryption (AES-256-GCM) for OpenClaw-encrypted tokens
- Message deduplication
- Auto-reconnection with exponential backoff
- Heartbeat keep-alive
- Typing indicator support

Co-Authored-By: fengjianxiong <fengjianxing@kingsoft.com>

* chore: add wps-agentspace to ALL_PLATFORMS in Makefile

Co-Authored-By: fengjianxiong <fengjianxing@kingsoft.com>

* feat: add auto-login for wps-agentspace platform

When wps_sid is empty, automatically open browser for WPS OAuth login
and poll for the token. This provides a smoother setup experience.

Co-Authored-By: fengjianxiong <fengjianxing@kingsoft.com>

* feat: encrypt wps_sid after auto-login

After OAuth login, encrypt the token using AES-256-GCM and display
the encrypted value for safe storage in config.toml.

Co-Authored-By: fengjianxiong <fengjianxing@kingsoft.com>

* feat: auto-set environment variable after login

After OAuth login, automatically display encrypted token and instructions
for setting WPS_SID environment variable. Also add Windows browser support.

Co-Authored-By: fengjianxiong <fengjianxing@kingsoft.com>

* feat: auto-save token to config file after login

After OAuth login, automatically save encrypted token to config.toml.
Falls back to displaying token for manual environment variable setup.

Co-Authored-By: fengjianxiong <fengjianxing@kingsoft.com>

* chore: remove sensitive data from test file

Co-Authored-By: fengjianxiong <fengjianxing@kingsoft.com>

* fix: resolve lint errors (govet, errcheck)

- Remove redundant newline in fmt.Println
- Check error return values with _ = for non-critical calls
- Fix return and defer statements

Co-Authored-By: fengjianxiong <fengjianxing@kingsoft.com>

* fix: remove unused statFile function

Co-Authored-By: fengjianxiong <fengjianxing@kingsoft.com>

* fix: check error return in defer statement

Co-Authored-By: fengjianxiong <fengjianxing@kingsoft.com>

* feat: support file/media attachments in incoming messages

Parse media_urls and media_url fields from WPS messages and append
file URLs to the message content so Claude can access attachments.

Co-Authored-By: fengjianxiong <fengjianxing@kingsoft.com>

* fix(wps-agentspace): address PR review feedback

- Re-enable token decryption in Start(); remove token prefix from logs
- Rewrite saveToConfig with TOML validation + surgical line replacement
- Fix autoLogin connection leak (http.Client + deferred Body.Close)
- Fix openBrowser Windows path (cmd /c start  url)
- findConfigFile: prefer config.ConfigPath (honours --config flag)
- decryptWpsSid: fallback to defaultKeySource when appID key fails
- generateUUID: use google/uuid v4 instead of custom implementation
- expandPath: support ~user/... via os/user.Lookup
- gofmt: fix struct alignment, trailing blank lines
- Add 6 new tests (11 total): Start decrypt, handleFrame dispatch,
  fatal errors, saveToConfig surgical update, autoLogin HTTP flow,
  decrypt fallback to defaultKeySource

Generated with Kscc
Co-Authored-By: fengjianxiong <fengjianxing@kingsoft.com>

* fix(wps-agentspace): resolve lint errors

- Remove unused userInfoAPI variable
- Check errcheck: json.NewEncoder.Encode and p.Stop() return values

Generated with Kscc
Co-Authored-By: fengjianxiong <fengjianxing@kingsoft.com>

* fix(wps-agentspace): fix race condition on Platform.stopped field

Use atomic.Bool for stopped flag to avoid data race between
connectLoop goroutine reading stopped and Stop() writing it.
Detected by go test -race.

Generated with Kscc
Co-Authored-By: fengjianxiong <fengjianxing@kingsoft.com>

---------

Co-authored-by: fengjianxiong <fengjianxiong@kingsoft.com>
Co-authored-by: fengjianxiong <fengjianxing@kingsoft.com>
2026-07-14 06:45:46 +08:00

185 lines
6.2 KiB
Makefile

APP := cc-connect
MODULE := github.com/chenhg5/cc-connect
CMD := ./cmd/cc-connect
DIST := dist
VERSION := v1.3.3
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "none")
BUILD_TIME := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
LDFLAGS := -s -w \
-X main.version=$(VERSION) \
-X main.commit=$(COMMIT) \
-X main.buildTime=$(BUILD_TIME)
PLATFORMS := \
linux/amd64 \
linux/arm64 \
darwin/amd64 \
darwin/arm64 \
windows/amd64 \
windows/arm64
# ---------------------------------------------------------------------------
# Selective compilation via build tags.
#
# By default all agents and platforms are included. To build with only
# specific ones, set AGENTS and/or PLATFORMS_INCLUDE:
#
# make build AGENTS=claudecode PLATFORMS_INCLUDE=feishu,telegram
#
# You can also exclude specific ones:
#
# make build EXCLUDE=discord,dingtalk,qq,qqbot,line
# ---------------------------------------------------------------------------
ALL_AGENTS := acp antigravity claudecode codex copilot cursor devin gemini iflow kimi opencode pi qoder tmux
ALL_PLATFORMS := feishu telegram discord slack dingtalk wecom weixin qq qqbot line weibo max matrix webex wps-agentspace
ALL_AGENTS := acp antigravity claudecode codex copilot cursor devin gemini iflow kimi opencode pi qoder reasonix tmux
ALL_PLATFORMS := feishu telegram discord slack dingtalk wecom weixin qq qqbot line weibo max matrix webex cloud_web
ALL_EXTRAS := web
COMMA := ,
# Compute exclusion tags from AGENTS / PLATFORMS_INCLUDE / EXCLUDE variables
_EXCLUDE_TAGS :=
ifdef AGENTS
_WANTED_AGENTS := $(subst $(COMMA), ,$(AGENTS))
_EXCLUDE_AGENTS := $(filter-out $(_WANTED_AGENTS),$(ALL_AGENTS))
_EXCLUDE_TAGS += $(addprefix no_,$(_EXCLUDE_AGENTS))
endif
ifdef PLATFORMS_INCLUDE
_WANTED_PLATFORMS := $(subst $(COMMA), ,$(PLATFORMS_INCLUDE))
_EXCLUDE_PLATFORMS := $(filter-out $(_WANTED_PLATFORMS),$(ALL_PLATFORMS))
_EXCLUDE_TAGS += $(addprefix no_,$(_EXCLUDE_PLATFORMS))
endif
ifdef EXCLUDE
_EXCLUDE_TAGS += $(addprefix no_,$(subst $(COMMA), ,$(EXCLUDE)))
endif
ifdef NO_WEB
_EXCLUDE_TAGS += no_web
endif
_BUILD_TAGS := $(strip $(_EXCLUDE_TAGS) goolm)
_TAGS_FLAG := $(if $(_BUILD_TAGS),-tags '$(_BUILD_TAGS)',)
.PHONY: build run clean test test-fast test-full test-smoke test-e2e test-release test-release-local test-performance pre-test lint release release-all web
web:
@if [ ! -d web/node_modules ]; then cd web && npm install; fi
cd web && npm run build
build: web
go build $(_TAGS_FLAG) -ldflags "$(LDFLAGS)" -o $(APP) $(CMD)
build-noweb:
go build $(_TAGS_FLAG) -tags 'no_web' -ldflags "$(LDFLAGS)" -o $(APP) $(CMD)
run: build
./$(APP)
clean:
rm -f $(APP)
rm -rf $(DIST)
# ---------------------------------------------------------------------------
# Testing targets.
#
# test-fast: Unit tests + smoke tests (< 2 min). Runs on every push.
# test-full: Full test suite including regression (< 10 min). PR requirement.
# test-smoke: Smoke tests only (< 1 min). Quick sanity check.
# test-e2e: E2E and regression tests only.
# test-release: Full + performance benchmarks. Before release.
# pre-test: Prerequisites (build + vet) before running tests.
# ---------------------------------------------------------------------------
pre-test:
go build ./...
go vet ./...
# Fast test: unit tests + smoke tests
test-fast: pre-test
go test -parallel=4 -race ./...
go test -parallel=4 -tags=smoke ./tests/e2e/...
# Full test: unit + smoke + regression (PR requirement)
test-full: pre-test
go test -parallel=4 -race ./...
go test -parallel=4 -tags=smoke ./tests/e2e/...
go test -parallel=2 -tags=regression ./tests/e2e/...
# Smoke tests only
test-smoke: pre-test
go test -v -tags=smoke ./tests/e2e/...
# E2E/regression tests only
test-e2e: pre-test
go test -v -tags=regression ./tests/e2e/...
# Performance benchmarks only
test-performance: pre-test
go test -bench=. -benchmem -tags=performance ./tests/performance/...
# Release test: full + performance benchmarks
test-release: pre-test
go test -parallel=4 -race ./...
go test -parallel=4 -tags=smoke ./tests/e2e/...
go test -parallel=2 -tags=regression ./tests/e2e/...
go test -bench=. -benchmem -tags=performance ./tests/performance/...
# Release-local gate: deterministic release checks that do not require real IM
# credentials, real provider accounts, or supervisor-managed services.
test-release-local:
go test ./tests/release_local/...
go test ./config
go test ./core -run 'TestEngineSendToSessionWithAttachments|TestProcessInteractiveEvents_SuppressesDuplicateSideChannelText|TestCmdList_AllSessionsVisibleAfterRepeatedNew|TestCmdList_SessionVisibleDuringAgentProcessing|TestEngine_Alias|TestEngine_BannedWords|TestEngine_DisabledCommands'
go test ./platform/feishu -run 'TestUserIDFromEventFallsBackToUserID|TestResolveUserNameSkipsInvalidLookupID|TestNew_CanDisableInteractiveCards'
# Legacy: runs unit tests only
test:
go test -v ./...
lint:
golangci-lint run ./...
release-all: web clean
@mkdir -p $(DIST)
@$(foreach platform,$(PLATFORMS), \
$(eval GOOS := $(word 1,$(subst /, ,$(platform)))) \
$(eval GOARCH := $(word 2,$(subst /, ,$(platform)))) \
$(eval EXT := $(if $(filter windows,$(GOOS)),.exe,)) \
$(eval OUT := $(DIST)/$(APP)-$(VERSION)-$(GOOS)-$(GOARCH)$(EXT)) \
echo "Building $(OUT)" && \
GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 \
go build $(_TAGS_FLAG) -ldflags "$(LDFLAGS)" -o $(OUT) $(CMD) && \
) true
@echo "Packaging archives..."
@cd $(DIST) && for f in $(APP)-*; do \
case "$$f" in \
*.tar.gz|*.zip) continue ;; \
*.exe) zip "$${f%.exe}.zip" "$$f" ;; \
*) tar czf "$$f.tar.gz" "$$f" ;; \
esac; \
done
@cd $(DIST) && sha256sum * > checksums.txt
@echo "Done. Binaries and archives in $(DIST)/"
release:
@if [ -z "$(TARGET)" ]; then \
echo "Usage: make release TARGET=linux/amd64"; \
echo "Available: $(PLATFORMS)"; \
exit 1; \
fi
@mkdir -p $(DIST)
$(eval GOOS := $(word 1,$(subst /, ,$(TARGET))))
$(eval GOARCH := $(word 2,$(subst /, ,$(TARGET))))
$(eval EXT := $(if $(filter windows,$(GOOS)),.exe,))
$(eval OUT := $(DIST)/$(APP)-$(VERSION)-$(GOOS)-$(GOARCH)$(EXT))
GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 \
go build $(_TAGS_FLAG) -ldflags "$(LDFLAGS)" -o $(OUT) $(CMD)
@echo "Built: $(OUT)"