Plexum ProviderPlugin that serves MiniMax models through MiniMax's Anthropic-compatible HTTP endpoint (https://api.minimax.io/anthropic, or CN api.minimaxi.com). Inspired by openclaw's extensions/minimax provider-registration, but rewritten in Go for Plexum's SDK. internal/anthropic/ (~210 LOC + 6 tests): - minimal HTTP+SSE Anthropic Messages client (POST /v1/messages, stream:true, parses event:/data: SSE frames) - handles non-2xx as HTTP error; stream errors land as Event{Type:"error"} - 1 MiB SSE line cap; per-conn 5min timeout internal/translate/ (~220 LOC): - CanonicalToAnthropic: canonical.TurnRequest → MessagesRequest - blockToAnthropic: TextBlock / ToolUseBlock / ToolResultBlock / ThinkingBlock → loose ContentBlock map; preserves signatures + cache control - Translator: per-turn state machine; consumes anthropic.Event stream and emits canonical.TurnEvent stream (handles thinking blocks + tool_use input_json_delta accumulation + signature_delta capture) cmd/plexum-minimax-provider-plugin/: - Plugin manifest declares provider.models = [MiniMax-M2.7, MiniMax-M2.7-highspeed] - Backend fixed to "api" (per scope); region "global"|"cn" + base_url override supported via config - HostConfig from <profile>/plugins/plexum-minimax-provider/config.json {api_key, region?, base_url?, max_tokens_default?} scripts/install.sh: build + manifest emit; operator writes config.json + allows plugin + adds an agent + restarts. End-to-end verified against the real key: 1. plexum say --agent-id mini ... → "Hi, I'm MiniMax!" 2. Multi-turn continuity: agent recalled the prior reply 3. Via gateway socket: {"outcome":"text","text":"\n\npong"} 4. Via Fabric channel (alice posts → plugin inbound → mini agent → MiniMax → outbound REST → reply visible in bt2-clean seq=11): "Hi there! 👋 Fun fact: Octopuses have three hearts, blue blood, and neurons distributed throughout their arms—so their tentacles can 'think'" The MiniMax-M2.7-highspeed variant works the same way but hit a Code Plan rate-limit ceiling during testing (not a plugin issue). Deferred: - OAuth (Code Plan portal) — not in v1 scope per request - MiniMax Portal provider (separate provider id minimax-portal) - Image / TTS / video / music providers (separate plugins later) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
78 lines
2.3 KiB
Bash
Executable File
78 lines
2.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Plexum-minimax-provider installer (Phase v0.1).
|
|
#
|
|
# Builds + installs:
|
|
# ~/.plexum/plugins/plexum-minimax-provider/plexum-minimax-provider-plugin
|
|
# ~/.plexum/plugins/plexum-minimax-provider/manifest.json
|
|
#
|
|
# Operator then writes the per-profile config:
|
|
# ~/.plexum/plugins/plexum-minimax-provider/config.json
|
|
# {"api_key": "sk-cp-..."}
|
|
#
|
|
# Re-runnable. Profile data + config.json are never touched.
|
|
#
|
|
# Flags:
|
|
# --profile <p> Override profile root (default ~/.plexum)
|
|
set -euo pipefail
|
|
|
|
REPO="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
PROFILE_DIR="${HOME}/.plexum"
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--profile) PROFILE_DIR="$2"; shift 2 ;;
|
|
-h|--help) sed -n '2,/^set -euo/p' "$0" | sed -n '/^#/p' | sed 's/^# \{0,1\}//'; exit 0 ;;
|
|
*) echo "unknown flag: $1" >&2; exit 2 ;;
|
|
esac
|
|
done
|
|
|
|
log() { printf '\033[1;34m[minimax-install]\033[0m %s\n' "$*"; }
|
|
command -v go >/dev/null || { echo "go not found on PATH" >&2; exit 1; }
|
|
|
|
PLUGIN_DIR="${PROFILE_DIR}/plugins/plexum-minimax-provider"
|
|
mkdir -p "${PLUGIN_DIR}"
|
|
|
|
cd "${REPO}"
|
|
VERSION="$(git describe --tags --always 2>/dev/null || echo dev)"
|
|
LDFLAGS="-X main.Version=${VERSION}"
|
|
log "building plexum-minimax-provider-plugin (v=${VERSION})"
|
|
CGO_ENABLED=0 go build -ldflags="${LDFLAGS}" \
|
|
-o "${PLUGIN_DIR}/plexum-minimax-provider-plugin" \
|
|
./cmd/plexum-minimax-provider-plugin
|
|
|
|
cat > "${PLUGIN_DIR}/manifest.json" <<'EOF'
|
|
{
|
|
"name": "plexum-minimax-provider",
|
|
"version": "0.1.0",
|
|
"activation": "lazy",
|
|
"executable": "plexum-minimax-provider-plugin",
|
|
"contracts": {
|
|
"provider": {
|
|
"models": ["MiniMax-M2.7", "MiniMax-M2.7-highspeed"]
|
|
}
|
|
}
|
|
}
|
|
EOF
|
|
|
|
cat <<EOF
|
|
|
|
[minimax-install] done.
|
|
plugin binary: ${PLUGIN_DIR}/plexum-minimax-provider-plugin
|
|
manifest: ${PLUGIN_DIR}/manifest.json
|
|
models: MiniMax-M2.7 / MiniMax-M2.7-highspeed
|
|
endpoint: https://api.minimax.io/anthropic (default; CN via region:"cn")
|
|
|
|
Next steps:
|
|
1. Write API key:
|
|
cat > ${PLUGIN_DIR}/config.json <<JSON
|
|
{"api_key": "sk-cp-..."}
|
|
JSON
|
|
chmod 600 ${PLUGIN_DIR}/config.json
|
|
2. Allow plugin:
|
|
Add "plexum-minimax-provider" to ${PROFILE_DIR}/plexum.json's
|
|
.plugins.allow array
|
|
3. Point an agent at MiniMax:
|
|
plexum agent-add --model MiniMax-M2.7 <agent-id>
|
|
4. systemctl --user restart plexum
|
|
EOF
|