mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-09-30 06:53:14 +00:00
Some checks failed
CI / Lint (push) Waiting to run
CI / Format check (push) Waiting to run
CI / Unit tests (push) Waiting to run
CI / Playwright E2E (push) Waiting to run
Build & publish app artifacts / Publish + deploy (dev) (push) Has been cancelled
Build & publish app artifacts / Publish + deploy (prod) (push) Has been cancelled
Infra CD / Infra CI (pre-deploy) (push) Has been cancelled
Infra CD / Deploy open-swe-dev (push) Has been cancelled
Infra CD / Deploy open-swe-prod (push) Has been cancelled
* feat: switch model providers to AWS Bedrock (Claude) and Fireworks (non-Claude)
Migrate off direct provider APIs: AWS Bedrock for Anthropic/Claude via the
cross-region inference profile us.anthropic.claude-opus-4-8, Fireworks AI for
all non-Claude models. Drop OpenAI (gpt-5.5) and Google (gemini-3.5-flash)
entirely. DEFAULT_MODEL_ID is now Bedrock Claude; all Fireworks models stay
freely selectable for the agent and reviewer graphs and via team/profile
defaults.
- pyproject: add langchain-aws (ChatBedrockConverse + boto3)
- options.py: Bedrock Claude entry + default; remove openai/google entries
- model.py: bedrock_converse provider_model_kwargs (effort -> thinking budget),
region pin in make_model, bedrock<->fireworks fallback pairing, AWS_REGION/
FIREWORKS_API_KEY local-dev validation
- server.py: provider-aware fallback kwargs build
- sanitize_thinking_blocks: also sanitize ChatBedrockConverse thinking blocks
- model_fallback: treat transient botocore ClientError codes as fallback-worthy
- eval_jobs: repoint hardcoded eval model id to Bedrock Claude
- tests: repoint dropped model ids; drop obsolete google test module
* fix(bedrock): use adaptive thinking + output_config.effort for Opus 4.8
The handoff spec wired Bedrock Converse thinking as
{type: enabled, budget_tokens: N}, but Opus 4.7+ rejects that with a
ValidationException: thinking.type "enabled" is not supported; it requires
thinking.type "adaptive" plus output_config.effort. Verified by live invoke
against us.anthropic.claude-opus-4-8 (account 328440206208, us-east-1):
the enabled+budget shape 400s, adaptive+effort returns normally.
Map profile effort to additional_model_request_fields:
{thinking: {type: adaptive, display: summarized},
output_config: {effort: <low|medium|high|xhigh|max>}}
reusing anthropic_thinking_for/anthropic_effort_for. Update the two
subagent-model tests asserting the old shape.
* fix(deploy): seed Bedrock/Fireworks models, not the dropped anthropic:/openai: ids
Model selection is store-driven, so seed_store.sh's team_settings/default seed is
what runs in prod. It still seeded the removed providers, which would fail at runtime
after the migration:
- agent/builder: anthropic:claude-opus-4-8 -> bedrock_converse:us.anthropic.claude-opus-4-8
- reviewer: openai:gpt-5.5 (dropped) -> bedrock_converse:us.anthropic.claude-opus-4-8
(set SEED_REVIEWER_MODEL to a Fireworks model for a cross-family reviewer)
- fetch-config REQUIRED_PROVIDER_KEYS default ANTHROPIC_API_KEY,OPENAI_API_KEY ->
FIREWORKS_API_KEY (Bedrock auths via host IAM role; dropping the old keys would
otherwise fail-fast at boot)
- docs (DEPLOYMENT/ROTATION/put-config) updated to match.
Surfaced by the cross-family review + verified against deploy/.
* fix(bedrock): security-review NITs — region resolution, error sanitization, reasoning-block strip
From /sh-security-review (all confirmed-low):
- model.py: resolve region from AWS_REGION OR AWS_DEFAULT_REGION (matches
validate_local_dev_llm_config) so the validated region is the one actually used.
- model_fallback.py: sanitize Bedrock AccessDenied/ResourceNotFound errors to the
error code only, so the role ARN + account id in the raw botocore message never
reach logs or the user channel (CWE-209).
- sanitize_thinking_blocks.py: also strip empty Bedrock reasoning_content blocks
(Converse emits reasoning_content, not thinking) so the middleware is not a no-op
on Bedrock; + unit tests. (Empty blocks replay fine today; defensive.)
* deploy(bedrock): grant instance-role Bedrock invoke + repoint LLM_MODEL_ID / eval model ids
Deployment-readiness for the Bedrock migration (PR #62):
- instance-role.ts: least-privilege bedrock:InvokeModel[WithResponseStream] on the
us.anthropic.claude-opus-4-8 inference-profile ARN + the foundation-model ARN in
each routed region (us-east-1/2, us-west-2). The model runs in the server process
on the box, so the EC2 instance role is the principal. Simulator-verified (allowed
for opus-4-8, implicitDeny for other models) and synth-verified. Passed the
mandatory GPT-4.1 IAM cross-review (no blockers, least-privilege confirmed).
- config-store.ts: IaC SSM LLM_MODEL_ID anthropic:claude-opus-4-8 ->
bedrock_converse:us.anthropic.claude-opus-4-8. This SSM value overrides
seed_store.sh's default via pick precedence, so the seed-script fix alone was
insufficient — both sources now point at the supported Bedrock id.
- infra/README.md + evals/reviewer/config.toml: repoint stale anthropic:/google_genai:
ids to the Bedrock id (config.toml's model_id was an active, now-broken value).
AWS_REGION is already wired via user-data.sh (IMDS -> boot.env), so no change needed there.
* chore(secrets): drop OPENAI/GOOGLE/GROQ key shells (revoked, providers removed)
Those three providers were dropped in the Bedrock/Fireworks migration and their keys
revoked; the live Secrets Manager objects (open-swe-{dev,prod}/{OPENAI,GOOGLE,GROQ}_API_KEY)
were deleted (7-day recovery). Remove them from the IaC so a future cdk deploy does not
recreate the shells, and from fetch-config's mirror array so boot stops requesting them:
- config-store.ts SECRET_VARS + descriptions (28 -> 25 shells)
- fetch-config.sh SECRET_VARS array (kept in lockstep)
- put-config.sh: drop the put_secret lines; ANTHROPIC_API_KEY re-labelled optional
(eval judge only — Bedrock builder/reviewer auth via the host IAM role).
REQUIRED_PROVIDER_KEYS is not set in SSM, so it uses the FIREWORKS_API_KEY default.
152 lines
8.2 KiB
Bash
Executable file
152 lines
8.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# put-config.sh — out-of-band populator for the open-swe config store.
|
|
#
|
|
# T11 (CDK) creates the RESOURCE SHELLS:
|
|
# - 28 Secrets Manager secrets open-swe-<env>/<VAR> (value-LESS shells)
|
|
# - the IaC-managed SSM params /open-swe-<env>/<VAR> (real values, owned in CDK)
|
|
# This script sets the values that CANNOT live in IaC — every secret value, plus
|
|
# the out-of-band SSM params (operationally-variable / env-specific-unknown). Run
|
|
# it AFTER `cdk deploy open-swe-<env>` and BEFORE the EC2/T12 box first boots, so
|
|
# fetch-config.sh finds every REQUIRED var populated and never writes a partial .env.
|
|
#
|
|
# The secret list below mirrors config-store.ts SECRET_VARS (28 names — the
|
|
# inventory's "29" double-counted JUDGE_ANTHROPIC_BASE_URL, which is config
|
|
# (SSM), not a secret). Keep the two lists in lockstep.
|
|
#
|
|
# SAFETY:
|
|
# - NO real secret values live in this file — every secret is a <FILL> placeholder.
|
|
# Replace <FILL...> inline at run time, pipe from a vault, or export the
|
|
# matching OPENSWE_PUT_<VAR> env var; NEVER commit real values.
|
|
# - It does NOT touch the IaC-managed SSM params (SANDBOX_TYPE, DEFAULT_REPO_OWNER,
|
|
# ALLOWED_GITHUB_ORGS, DEFAULT_REPO_NAME, DASHBOARD_*_URL/ORIGINS, LLM_MODEL_ID)
|
|
# — CDK owns those; setting them here would cause drift.
|
|
# - Secrets go to Secrets Manager; the box's instance role grants read on
|
|
# open-swe-<env>/* and /open-swe-<env>/* (no kms:Decrypt — AWS-managed keys).
|
|
#
|
|
# Idempotent: put-secret-value adds a new AWSCURRENT version; put-parameter
|
|
# --overwrite updates in place.
|
|
|
|
set -euo pipefail
|
|
|
|
ENV="${1:-}"
|
|
case "$ENV" in
|
|
dev | prod) ;;
|
|
*)
|
|
echo "usage: put-config.sh <dev|prod>" >&2
|
|
exit 2
|
|
;;
|
|
esac
|
|
|
|
REGION="${AWS_REGION:-${AWS_DEFAULT_REGION:-us-east-1}}"
|
|
SECRET_PREFIX="open-swe-${ENV}/"
|
|
SSM_PREFIX="/open-swe-${ENV}/"
|
|
|
|
command -v aws >/dev/null 2>&1 || { echo "put-config: 'aws' not found on PATH" >&2; exit 3; }
|
|
|
|
# --- helpers -----------------------------------------------------------------
|
|
# put_secret VAR : set the value of an EXISTING secret shell open-swe-<env>/VAR.
|
|
# Resolution order for the value: $OPENSWE_PUT_<VAR> env var, else the literal
|
|
# <FILL> placeholder (which aborts so an unset secret is never silently shipped).
|
|
put_secret() {
|
|
local var="$1"
|
|
local override_name="OPENSWE_PUT_${var}"
|
|
local value="${!override_name:-<FILL>}"
|
|
if [ "$value" = "<FILL>" ]; then
|
|
echo "put-config[$ENV]: SKIP secret ${var} (no value; set ${override_name} or edit inline)" >&2
|
|
return 0
|
|
fi
|
|
aws secretsmanager put-secret-value \
|
|
--secret-id "${SECRET_PREFIX}${var}" \
|
|
--secret-string "$value" \
|
|
--region "$REGION" \
|
|
--no-cli-pager >/dev/null
|
|
echo "put-config[$ENV]: set secret ${var}"
|
|
}
|
|
|
|
# put_param VAR [TYPE] : create/update an out-of-band SSM param /open-swe-<env>/VAR.
|
|
# TYPE defaults to String; pass SecureString for anything sensitive-but-not-a-secret.
|
|
put_param() {
|
|
local var="$1" type="${2:-String}"
|
|
local override_name="OPENSWE_PUT_${var}"
|
|
local value="${!override_name:-<FILL>}"
|
|
if [ "$value" = "<FILL>" ]; then
|
|
echo "put-config[$ENV]: SKIP param ${var} (no value; set ${override_name} or edit inline)" >&2
|
|
return 0
|
|
fi
|
|
aws ssm put-parameter \
|
|
--name "${SSM_PREFIX}${var}" \
|
|
--value "$value" \
|
|
--type "$type" \
|
|
--overwrite \
|
|
--region "$REGION" \
|
|
--no-cli-pager >/dev/null
|
|
echo "put-config[$ENV]: set param ${var} (${type})"
|
|
}
|
|
|
|
# --- 1) Secrets (open-swe-<env>/<VAR>) — 28 shells from config-store.ts -------
|
|
# REQUIRED at boot (fetch-config fail-fast): DASHBOARD_JWT_SECRET,
|
|
# TOKEN_ENCRYPTION_KEY, GITHUB_APP_PRIVATE_KEY/CLIENT_SECRET, the active provider
|
|
# key(s) (ANTHROPIC_API_KEY + OPENAI_API_KEY by default), LANGSMITH_API_KEY_PROD,
|
|
# and (prod) GITHUB_WEBHOOK_SECRET + SLACK_SIGNING_SECRET.
|
|
put_secret ANTHROPIC_API_KEY # optional — eval judge only (JUDGE_ANTHROPIC_API_KEY fallback); Bedrock builder/reviewer use the host IAM role
|
|
put_secret DASHBOARD_JWT_SECRET # REQUIRED — dashboard session JWT signing
|
|
put_secret TOKEN_ENCRYPTION_KEY # REQUIRED — Fernet key(s) for GH-token crypto
|
|
put_secret GITHUB_APP_PRIVATE_KEY # REQUIRED — GitHub App PEM (multiline; quote it)
|
|
put_secret GITHUB_APP_CLIENT_SECRET # REQUIRED — dashboard OAuth login
|
|
put_secret LANGSMITH_API_KEY_PROD # REQUIRED (langsmith sandbox) — prod key
|
|
put_secret GITHUB_WEBHOOK_SECRET # prod-REQUIRED — GitHub webhook signature
|
|
put_secret SLACK_SIGNING_SECRET # prod-REQUIRED — Slack webhook signature
|
|
put_secret LINEAR_WEBHOOK_SECRET # required only when Linear is wired
|
|
# Optional / conditional secrets — set the ones this deployment actually uses.
|
|
put_secret CORRIDOR_API_TOKEN # optional — Corridor MCP
|
|
put_secret CORRIDOR_MCP_TOKEN # optional — Corridor MCP (alt name)
|
|
put_secret CORRIDOR_TOKEN # optional — Corridor MCP (alt name)
|
|
put_secret DAYTONA_API_KEY # only if SANDBOX_TYPE=daytona
|
|
put_secret EXA_API_KEY # optional — Exa web search
|
|
put_secret FIREWORKS_API_KEY # active non-Claude key (fallback/subagents); Bedrock uses the host IAM role
|
|
put_secret GITHUB_PAT # optional — PAT fallback
|
|
put_secret JUDGE_ANTHROPIC_API_KEY # optional — eval judge (falls back to ANTHROPIC)
|
|
put_secret LANGSMITH_API_KEY # optional — LangSmith (dev)
|
|
put_secret LANGCHAIN_API_KEY # optional — LangSmith alt name
|
|
put_secret LINEAR_API_KEY # optional — Linear API
|
|
put_secret RUNLOOP_API_KEY # only if SANDBOX_TYPE=runloop
|
|
put_secret SLACK_BOT_TOKEN # optional — Slack bot token
|
|
put_secret SLACK_CLIENT_SECRET # optional — Slack OAuth
|
|
put_secret USER_ID_API_KEY_MAP # optional — JSON map user id -> API key (per-user auth)
|
|
put_secret X_SERVICE_AUTH_JWT_SECRET # optional — service-auth JWT
|
|
|
|
# --- 2) Out-of-band SSM params (/open-swe-<env>/<VAR>) ------------------------
|
|
# These are NOT created by CDK (operationally-variable / env-specific-unknown).
|
|
# put_param creates them on first run.
|
|
put_param DEFAULT_SANDBOX_SNAPSHOT_ID # REQUIRED (langsmith) — changes every rebuild
|
|
put_param GITHUB_APP_ID # REQUIRED — GitHub App numeric id
|
|
put_param GITHUB_APP_INSTALLATION_ID # REQUIRED — GitHub App installation id
|
|
put_param GITHUB_APP_CLIENT_ID # REQUIRED — dashboard OAuth client id
|
|
put_param GITHUB_OAUTH_PROVIDER_ID # GitHub OAuth provider id
|
|
put_param LANGSMITH_TENANT_ID_PROD # LangSmith prod tenant id
|
|
put_param LANGSMITH_URL_PROD # LangSmith prod URL
|
|
put_param LANGSMITH_ENDPOINT # LangSmith API endpoint
|
|
put_param LANGSMITH_ENDPOINT_PROD # LangSmith prod API endpoint
|
|
put_param LANGSMITH_HOST_API_URL # LangSmith host API URL
|
|
put_param LANGGRAPH_URL # LangGraph server URL
|
|
put_param LANGGRAPH_URL_PROD # LangGraph server URL (prod)
|
|
put_param LANGCHAIN_REVISION_ID # LangChain revision id
|
|
put_param SLACK_CLIENT_ID # Slack OAuth client id
|
|
put_param SLACK_TEAM_ID # Slack workspace/team id
|
|
put_param SLACK_BOT_USER_ID # Slack bot user id
|
|
put_param SLACK_BOT_USERNAME # Slack bot username
|
|
put_param SLACK_REPO_OWNER # Slack default repo owner
|
|
put_param SLACK_REPO_NAME # Slack default repo name
|
|
put_param CONFIGURED_ADMINS # dashboard admin GitHub logins (comma list)
|
|
put_param OBSERVABILITY_AUTHORIZED_EMAILS # observability allowlist (comma list)
|
|
put_param PUBLIC_REPO_ORG_GATE # public-repo trigger gate (org name; empty=off)
|
|
put_param ALLOWED_GITHUB_REPOS # extra repo allowlist (comma list)
|
|
put_param LLM_FALLBACK_MODEL_ID # optional — model fallback id
|
|
put_param DATADOG_MCP_TOOLSETS # optional — Datadog MCP toolsets
|
|
put_param NOTION_MCP_CLIENT_NAME # optional — Notion MCP client name
|
|
put_param API_STANDARDS_SKILL_HANDLE # optional — API standards skill handle
|
|
put_param REPO_SNAPSHOT_BASE_IMAGE # optional — repo snapshot base image
|
|
put_param REPO_SNAPSHOT_BUILD_TIMEOUT_SECONDS # optional — snapshot build timeout
|
|
put_param REPO_SNAPSHOT_STALE_BUILD_SECONDS # optional — snapshot stale threshold
|
|
|
|
echo "put-config[$ENV]: done. Verify with fetch-config.sh ${ENV} before first boot."
|