bugxhunter 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +23 -0
- package/README.md +97 -0
- package/docker-compose.yml +20 -0
- package/package.json +4 -1
- package/server/dist/bedrock.js +288 -0
- package/server/dist/index.js +15 -5
- package/server/dist/opencode.js +4 -3
- package/server/dist/providers.js +136 -9
- package/server/dist/recon.js +1 -1
- package/server/dist/scx.js +24 -15
- package/server/dist/vault.js +7 -0
- package/web/dist/assets/index-BSAL7ncz.js +303 -0
- package/web/dist/index.html +1 -1
- package/web/dist/assets/index-CBhVvqRv.js +0 -299
package/.env.example
CHANGED
|
@@ -24,6 +24,29 @@
|
|
|
24
24
|
# has access (it may not appear in the Playground's live list even when it does).
|
|
25
25
|
# ANTHROPIC_MODELS=claude-opus-5-5,claude-sonnet-5-5,claude-haiku-5-5,claude-mythos-5-2
|
|
26
26
|
|
|
27
|
+
# Optional: models on Amazon Bedrock in your own AWS account (GLM 5.3 by
|
|
28
|
+
# default), called directly. See "GLM 5.3 on Amazon Bedrock" in the README.
|
|
29
|
+
# BEDROCK_REGION=ap-southeast-2
|
|
30
|
+
# Ids the agent may use (the Playground lists them once a sign-in is set up).
|
|
31
|
+
# GLM 5.3 is global.zai.glm-5.3 from most regions, us.zai.glm-5.3 from US ones.
|
|
32
|
+
# BEDROCK_MODELS=global.zai.glm-5.3
|
|
33
|
+
# How hard Bedrock's reasoning models think when a call does not say: low,
|
|
34
|
+
# medium, high, xhigh or max. Unset = the model's default (max for GLM 5.3),
|
|
35
|
+
# which can spend a short output limit before any answer is written.
|
|
36
|
+
# BEDROCK_REASONING_EFFORT=medium
|
|
37
|
+
# Sign in with ONE of:
|
|
38
|
+
# - an AWS profile (IAM Identity Center / SSO, or an assumed role). In Docker,
|
|
39
|
+
# also uncomment the ~/.aws volume on the runner in docker-compose.yml.
|
|
40
|
+
# BEDROCK_AWS_PROFILE=my-sso-profile
|
|
41
|
+
# - an OIDC role (GitHub Actions, Kubernetes): the role, and the token's file.
|
|
42
|
+
# AWS_ROLE_ARN=arn:aws:iam::111122223333:role/bugxhunter-bedrock
|
|
43
|
+
# AWS_WEB_IDENTITY_TOKEN_FILE=/var/run/secrets/tokens/aws
|
|
44
|
+
# - the compute's own role (EC2 instance profile; ECS needs nothing set).
|
|
45
|
+
# BEDROCK_AUTH=aws
|
|
46
|
+
# - a Bedrock API key: put it in the vault as AWS_BEARER_TOKEN_BEDROCK (keys
|
|
47
|
+
# dialog) rather than here.
|
|
48
|
+
# AWS_BEARER_TOKEN_BEDROCK=
|
|
49
|
+
|
|
27
50
|
# GitHub needs nothing here: "Connect GitHub" in the sidebar signs in to the
|
|
28
51
|
# public BugXHunter GitHub App (read-only). A fork that registers its own app
|
|
29
52
|
# sets its Client ID and slug:
|
package/README.md
CHANGED
|
@@ -215,6 +215,92 @@ The agent never holds the key: its calls go to the runner's `/openrouter/v1` pro
|
|
|
215
215
|
token, exactly like SCX, in both local and Docker modes. Pricing is OpenRouter's; the Playground
|
|
216
216
|
shows each model's per-token rates.
|
|
217
217
|
|
|
218
|
+
## GLM 5.3 on Amazon Bedrock
|
|
219
|
+
|
|
220
|
+
The runner can call models on [Amazon Bedrock](https://aws.amazon.com/bedrock/) directly, in your
|
|
221
|
+
own AWS account: GLM 5.3 by default, through Bedrock's OpenAI-compatible endpoint
|
|
222
|
+
(`bedrock-runtime.<region>.amazonaws.com/openai/v1`). The **Playground** lists them under an
|
|
223
|
+
**Amazon Bedrock** heading as `bedrock/<id>`; the **agent** gets them as `bedrock/<id>` too.
|
|
224
|
+
|
|
225
|
+
Set the region with `BEDROCK_REGION` (else `AWS_REGION`), then sign in one of these ways. The first
|
|
226
|
+
that is set up is used, and a Bedrock API key wins over all of them:
|
|
227
|
+
|
|
228
|
+
| Sign-in | Set | Use it when |
|
|
229
|
+
|---|---|---|
|
|
230
|
+
| **OIDC role** (web identity) | `AWS_ROLE_ARN` and `AWS_WEB_IDENTITY_TOKEN_FILE` | The runner runs where an identity provider issues it a token: GitHub Actions, Kubernetes (EKS IRSA), another OIDC issuer the role trusts. Nothing long-lived exists: the runner trades the token for role credentials through STS and renews them itself |
|
|
231
|
+
| **AWS profile** | `BEDROCK_AWS_PROFILE` (else `AWS_PROFILE`) | The runner is on your own machine. An IAM Identity Center (SSO) profile gives short-lived credentials that `aws sso login` renews; a profile with `role_arn` narrows them to a role that may only invoke the model |
|
|
232
|
+
| **The compute's role** | nothing on ECS; `BEDROCK_AUTH=aws` on EC2 or with a default profile | The runner is deployed in AWS: a task role, pod identity or instance profile |
|
|
233
|
+
| **Access keys** | `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` (and `AWS_SESSION_TOKEN`) | Temporary keys pasted for a session. Avoid an IAM user's long-lived keys |
|
|
234
|
+
| **Bedrock API key** | vault item `AWS_BEARER_TOKEN_BEDROCK` (keys dialog), or `AWS_BEARER_TOKEN_BEDROCK_FILE` | You cannot give the runner an AWS identity. Sealed in the vault like the other keys. Short-term keys last 12 hours at most; a long-term key is an IAM user's standing credential, which AWS recommends for exploration only |
|
|
235
|
+
|
|
236
|
+
**Which to choose:** a role the runner is given beats anything it has to hold. Deployed in AWS, use
|
|
237
|
+
the compute's role; in CI or Kubernetes, the OIDC role; on your own machine, an SSO profile. Keep
|
|
238
|
+
the API key and access keys for when none of those is possible.
|
|
239
|
+
|
|
240
|
+
In Docker the profile needs your AWS config: uncomment the `~/.aws` volume on the `runner` service
|
|
241
|
+
in `docker-compose.yml` (read-only, and only the runner gets it), set `BEDROCK_AWS_PROFILE` and
|
|
242
|
+
`BEDROCK_REGION` in `.env`, and set `BEDROCK_MODELS=global.zai.glm-5.3` so the agent's picker shows
|
|
243
|
+
the model. When the SSO session lapses, model calls answer with a 503 that says so: run
|
|
244
|
+
`aws sso login` on the host and carry on, no restart needed. On Linux the files under `~/.aws` must
|
|
245
|
+
be readable by the container's user (uid 1000).
|
|
246
|
+
|
|
247
|
+
As with every provider, the agent holds nothing: its calls go to the runner's `/bedrock/v1` proxy
|
|
248
|
+
with the proxy token, and the runner signs them (SigV4) or adds the key. AWS credentials are
|
|
249
|
+
removed from the runner's environment at start-up, so the agent's shell does not inherit them in
|
|
250
|
+
local mode either.
|
|
251
|
+
|
|
252
|
+
Things to know:
|
|
253
|
+
|
|
254
|
+
- **Locking the vault stops Bedrock too.** AWS credentials are not vault items, so once a vault
|
|
255
|
+
exists the runner refuses to sign while it is sealed (model calls answer 503) and drops the
|
|
256
|
+
credentials it holds in memory. The first call after an unlock loads them afresh from the
|
|
257
|
+
profile or role. This is a gate in the runner, not encryption: a mounted `~/.aws` stays readable
|
|
258
|
+
to the runner's container, so give it a profile that can do no more than invoke the model.
|
|
259
|
+
- **Reasoning effort.** GLM 5.3 on Bedrock reasons at `max` effort unless told otherwise, and
|
|
260
|
+
reasoning counts against the output limit: at a 4,096-token limit a request can spend all of it
|
|
261
|
+
thinking and write nothing (the chat says so when that happens). The Playground's **Reasoning
|
|
262
|
+
effort** setting picks `low`, `medium`, `high`, `xhigh` or `max` per chat.
|
|
263
|
+
`BEDROCK_REASONING_EFFORT` sets the runner's default for every Bedrock call that names none,
|
|
264
|
+
the agent's included.
|
|
265
|
+
- **OpenAI's GPT models.** `global.openai.gpt-6.2-astra` and `global.openai.gpt-6-astra` are known
|
|
266
|
+
to the runner: add one to `BEDROCK_MODELS` to use it. They read images, so the threat-model
|
|
267
|
+
canvas can build from a screenshot. They take the output limit as `max_completion_tokens` and
|
|
268
|
+
refuse `stop` and any temperature or top-p but the default, so the runner renames the one and
|
|
269
|
+
drops the others. **They are for the Playground only**: Bedrock's Chat Completions route
|
|
270
|
+
refuses function tools for them (its Responses route takes them, which the runner does not
|
|
271
|
+
speak), so they are left out of the agent's model picker and the Playground sends them no tools.
|
|
272
|
+
They are not open-weight, and cost far more per token than GLM 5.3.
|
|
273
|
+
- **Only the models you list.** The agent can call a Bedrock model only if it is in
|
|
274
|
+
`BEDROCK_MODELS`; the proxy answers 403 for any other. The runner's AWS identity can usually
|
|
275
|
+
invoke more than that, and the agent runs untrusted input.
|
|
276
|
+
- **GLM 5.3 has no single-region form.** It is called through a cross-region inference profile:
|
|
277
|
+
`global.zai.glm-5.3` from most regions (inference may then run in any commercial AWS region), or
|
|
278
|
+
`us.zai.glm-5.3` from US regions only. Prompts, code and tool output go where the profile sends
|
|
279
|
+
them, so check that against where your engagement's data may be processed.
|
|
280
|
+
- **Access is per account.** AWS offers GLM 5.3 to eligible accounts only; one without it answers
|
|
281
|
+
`403 … is not available for this account` even though the model is listed.
|
|
282
|
+
- **Other ids.** `BEDROCK_MODELS` takes any model or inference-profile id the endpoint serves,
|
|
283
|
+
including the ARN of your own application inference profile (which puts the spend under that
|
|
284
|
+
profile's cost-allocation tags). Ids the runner has no metadata for get conservative limits.
|
|
285
|
+
- **Permissions.** The role needs `bedrock:InvokeModel` and `bedrock:InvokeModelWithResponseStream`
|
|
286
|
+
on the inference profile and on the model behind it, and nothing else. A starting point:
|
|
287
|
+
|
|
288
|
+
```json
|
|
289
|
+
{
|
|
290
|
+
"Version": "2012-10-17",
|
|
291
|
+
"Statement": [{
|
|
292
|
+
"Effect": "Allow",
|
|
293
|
+
"Action": ["bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream"],
|
|
294
|
+
"Resource": [
|
|
295
|
+
"arn:aws:bedrock:ap-southeast-2:111122223333:inference-profile/global.zai.glm-5.3",
|
|
296
|
+
"arn:aws:bedrock:*::foundation-model/zai.glm-5.3"
|
|
297
|
+
]
|
|
298
|
+
}]
|
|
299
|
+
}
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
An API key also needs `bedrock:CallWithBearerToken`, which some organisations deny by policy.
|
|
303
|
+
|
|
218
304
|
## Claude via the Anthropic API
|
|
219
305
|
|
|
220
306
|
1. Add your Anthropic key to the vault as `ANTHROPIC_API_KEY` (keys dialog). The **Playground**
|
|
@@ -371,6 +457,15 @@ nobody is there to unlock.
|
|
|
371
457
|
| `ANTHROPIC_API_KEY` | the vault, else unset | Anthropic key in the clear; prefer the vault item of the same name |
|
|
372
458
|
| `ANTHROPIC_MODELS` | `claude-opus-5-5,claude-sonnet-5-5,claude-haiku-5-5` | Claude model ids in the agent's picker (local mode; Docker: `docker/opencode.json`) |
|
|
373
459
|
| `ANTHROPIC_BASE_URL` | `https://api.anthropic.com/v1` | Anthropic endpoint |
|
|
460
|
+
| `BEDROCK_REGION` | `AWS_REGION`, else `us-east-1` | AWS region whose Bedrock endpoint is called |
|
|
461
|
+
| `BEDROCK_MODELS` | `global.zai.glm-5.3` | Comma list of Bedrock model or inference-profile ids (Docker: set it to show them in the agent's picker) |
|
|
462
|
+
| `BEDROCK_REASONING_EFFORT` | unset (the model's default, `max` for GLM 5.3) | `low`, `medium`, `high`, `xhigh` or `max`: the effort for Bedrock calls that name none, from the Playground and the agent |
|
|
463
|
+
| `BEDROCK_AWS_PROFILE` | `AWS_PROFILE`, else unset | AWS profile (SSO, assumed role) the runner signs Bedrock calls with |
|
|
464
|
+
| `AWS_ROLE_ARN`, `AWS_WEB_IDENTITY_TOKEN_FILE` | unset | An OIDC role and the file holding the identity token; `AWS_ROLE_SESSION_NAME` names the session |
|
|
465
|
+
| `BEDROCK_AUTH` | unset | `aws` uses the compute's own role or the default profile (automatic on ECS) |
|
|
466
|
+
| `AWS_BEARER_TOKEN_BEDROCK_FILE` | unset | A file holding a Bedrock API key, as `SCX_API_FILE` |
|
|
467
|
+
| `AWS_BEARER_TOKEN_BEDROCK` | the vault, else unset | Bedrock API key in the clear; prefer the vault item of the same name. Wins over AWS credentials |
|
|
468
|
+
| `BEDROCK_BASE_URL` | the region's `bedrock-runtime` endpoint | Bedrock's OpenAI-compatible endpoint (for a VPC endpoint) |
|
|
374
469
|
| `GITHUB_CLIENT_ID` | the BugXHunter app | A fork's own GitHub App (device flow); `GITHUB_APP_SLUG` names its install page |
|
|
375
470
|
| `OPEN_RUNNER_VAULT_FILE` | `~/.config/bugxhunter/vault.json` | The sealed vault (Docker: `/data/vault.json` on the `runner-data` volume) |
|
|
376
471
|
| `OPEN_RUNNER_VAULT_IDLE_MINUTES` | `120` | Auto-lock after this long without a model call or API write; `0` = never |
|
|
@@ -403,6 +498,7 @@ GHCR images by digest) and the signed `checksums.txt` that covers them all.
|
|
|
403
498
|
<!-- releases:start -->
|
|
404
499
|
| Release | Published | Checksums | Signature | Signature check | Build |
|
|
405
500
|
| --- | --- | --- | --- | --- | --- |
|
|
501
|
+
| [v0.10.0](https://github.com/cintelis/bugxhunter-runner/releases/tag/v0.10.0) | 2026-11-21 | [checksums.txt](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.10.0/checksums.txt) | [checksums.txt.sig](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.10.0/checksums.txt.sig) | ✅ release key | [workflow run](https://github.com/cintelis/bugxhunter-runner/actions/runs/44896163152) |
|
|
406
502
|
| [v0.9.7](https://github.com/cintelis/bugxhunter-runner/releases/tag/v0.9.7) | 2026-11-19 | [checksums.txt](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.9.7/checksums.txt) | [checksums.txt.sig](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.9.7/checksums.txt.sig) | ✅ release key | [workflow run](https://github.com/cintelis/bugxhunter-runner/actions/runs/44437259098) |
|
|
407
503
|
| [v0.9.6](https://github.com/cintelis/bugxhunter-runner/releases/tag/v0.9.6) | 2026-11-18 | [checksums.txt](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.9.6/checksums.txt) | [checksums.txt.sig](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.9.6/checksums.txt.sig) | ✅ release key | [workflow run](https://github.com/cintelis/bugxhunter-runner/actions/runs/44381703840) |
|
|
408
504
|
| [v0.9.5](https://github.com/cintelis/bugxhunter-runner/releases/tag/v0.9.5) | 2026-10-29 | [checksums.txt](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.9.5/checksums.txt) | [checksums.txt.sig](https://github.com/cintelis/bugxhunter-runner/releases/download/v0.9.5/checksums.txt.sig) | ✅ release key | [workflow run](https://github.com/cintelis/bugxhunter-runner/actions/runs/40882124130) |
|
|
@@ -491,6 +587,7 @@ publisher** on npmjs.com set to this repository and `release.yml`, once; no npm
|
|
|
491
587
|
| `server/src/recon.ts`, `recon-driver.ts`, `recon-run.ts` | Supervised recon: the model router and approval gate, the driver loop, and the OpenCode side of a turn (`web/src/ReconPanel.tsx` is its UI) |
|
|
492
588
|
| `server/src/scx.ts`, `rag.ts` | SCX client and in-memory knowledge base (Playground) |
|
|
493
589
|
| `server/src/providers.ts`, `anthropic.ts`, `nvidia-health.ts` | Anthropic / NVIDIA / OpenRouter providers (Claude via the official SDK); hides NVIDIA models whose endpoints are retired |
|
|
590
|
+
| `server/src/bedrock.ts` | Amazon Bedrock: which AWS credentials the runner uses (OIDC role, profile, compute role) and the SigV4 signing of each call |
|
|
494
591
|
| `server/src/playground-store.ts` | Saved Playground sessions, sealed with the vault key |
|
|
495
592
|
| `server/src/render.ts`, `docker/render-server.py`, `docker/drawio_outline.py` | The render service (diagrams, `.drawio` outlines) and the runner's client for it |
|
|
496
593
|
| `web/src/Canvas.tsx`, `web/src/canvas/` | The threat-model canvas |
|
package/docker-compose.yml
CHANGED
|
@@ -43,6 +43,22 @@ services:
|
|
|
43
43
|
# (ANTHROPIC_API_KEY) or here; ANTHROPIC_MODELS lists the ids the agent's picker shows.
|
|
44
44
|
ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY:-}
|
|
45
45
|
ANTHROPIC_MODELS: ${ANTHROPIC_MODELS:-}
|
|
46
|
+
# Optional: models on Amazon Bedrock, called directly (GLM 5.3 by default). Sign in
|
|
47
|
+
# with ONE of these (see "Amazon Bedrock" in the README):
|
|
48
|
+
# - an AWS profile: mount your ~/.aws read-only (the volume below) and name the
|
|
49
|
+
# profile in BEDROCK_AWS_PROFILE. For an IAM Identity Center (SSO) profile,
|
|
50
|
+
# `aws sso login` on the host renews it; nothing long-lived is stored.
|
|
51
|
+
# - an OIDC role: AWS_ROLE_ARN plus AWS_WEB_IDENTITY_TOKEN_FILE (mount the token file).
|
|
52
|
+
# - a Bedrock API key: in the vault as AWS_BEARER_TOKEN_BEDROCK (keys dialog), or here.
|
|
53
|
+
# BEDROCK_MODELS lists the ids the agent may use (set it to show them in the Runner).
|
|
54
|
+
BEDROCK_REGION: ${BEDROCK_REGION:-}
|
|
55
|
+
BEDROCK_MODELS: ${BEDROCK_MODELS:-}
|
|
56
|
+
BEDROCK_REASONING_EFFORT: ${BEDROCK_REASONING_EFFORT:-} # low|medium|high|xhigh|max; unset = the model's default
|
|
57
|
+
BEDROCK_AWS_PROFILE: ${BEDROCK_AWS_PROFILE:-}
|
|
58
|
+
BEDROCK_AUTH: ${BEDROCK_AUTH:-}
|
|
59
|
+
AWS_ROLE_ARN: ${AWS_ROLE_ARN:-}
|
|
60
|
+
AWS_WEB_IDENTITY_TOKEN_FILE: ${AWS_WEB_IDENTITY_TOKEN_FILE:-}
|
|
61
|
+
AWS_BEARER_TOKEN_BEDROCK: ${AWS_BEARER_TOKEN_BEDROCK:-}
|
|
46
62
|
# Supervised recon: the model profile (recon-open | recon-balanced | recon-quality;
|
|
47
63
|
# default recon-balanced with an Anthropic key, recon-open without) and optional
|
|
48
64
|
# per-role models. The agent gets the same per-role values (below).
|
|
@@ -63,6 +79,9 @@ services:
|
|
|
63
79
|
- workspace:/workspace # same volume as the agent: attachments
|
|
64
80
|
- logs:/logs # audit + egress logs; NOT mounted in the agent, so it can't edit them
|
|
65
81
|
- runner-data:/data # the sealed key vault (ciphertext only; see SECURITY.md)
|
|
82
|
+
# Amazon Bedrock with an AWS profile (BEDROCK_AWS_PROFILE): uncomment to give the
|
|
83
|
+
# runner, and only the runner, your AWS config and SSO session, read-only.
|
|
84
|
+
# - ${HOME}/.aws:/home/node/.aws:ro
|
|
66
85
|
ports:
|
|
67
86
|
- "127.0.0.1:${OPEN_RUNNER_PORT:-8790}:8790" # localhost only; put TLS in front before exposing
|
|
68
87
|
networks: [net, render]
|
|
@@ -87,6 +106,7 @@ services:
|
|
|
87
106
|
SCX_PROXY_TOKEN: ${SCX_PROXY_TOKEN:?run docker/setup.ps1 first}
|
|
88
107
|
OPENCODE_ENABLE_EXA: "1" # turns on OpenCode's websearch tool (Exa)
|
|
89
108
|
OPENROUTER_MODELS: ${OPENROUTER_MODELS:-} # same list as runner: becomes an OpenCode provider via runner's proxy
|
|
109
|
+
BEDROCK_MODELS: ${BEDROCK_MODELS:-} # same list as runner; the AWS sign-in stays in the runner
|
|
90
110
|
# Recon subagents run on open-weight models unless a role is set here (see docker/agent-entrypoint.sh).
|
|
91
111
|
RECON_EXECUTOR_MODEL: ${RECON_EXECUTOR_MODEL:-}
|
|
92
112
|
RECON_TRIAGE_MODEL: ${RECON_TRIAGE_MODEL:-}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bugxhunter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "BugXHunter: an AI security-testing agent with a sandboxed runner, a passkey-sealed key vault and read-only GitHub access. `npx bugxhunter` runs it on your machine.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://bugxhunter.com",
|
|
@@ -29,7 +29,10 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@anthropic-ai/sdk": "^1.3.0",
|
|
32
|
+
"@aws-sdk/credential-providers": "^3.1177.0",
|
|
32
33
|
"@opencode-ai/sdk": "^1.17.11",
|
|
34
|
+
"@smithy/hash-node": "^4.5.2",
|
|
35
|
+
"@smithy/signature-v4": "^5.7.5",
|
|
33
36
|
"dotenv": "^18.0.6",
|
|
34
37
|
"express": "^5.2.1",
|
|
35
38
|
"express-rate-limit": "^8.7.1",
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Amazon Bedrock, called directly: open-weight models (GLM 5.3 by default) on
|
|
3
|
+
* Bedrock's OpenAI-compatible Chat Completions API,
|
|
4
|
+
* `https://bedrock-runtime.<region>.amazonaws.com/openai/v1`.
|
|
5
|
+
*
|
|
6
|
+
* Two ways to authenticate, both held by the runner and never by the agent:
|
|
7
|
+
*
|
|
8
|
+
* - AWS credentials, signing each call with SigV4. Where they come from, first
|
|
9
|
+
* match wins:
|
|
10
|
+
* 1. an OIDC web identity (AWS_ROLE_ARN + AWS_WEB_IDENTITY_TOKEN_FILE): the
|
|
11
|
+
* runner exchanges the token for short-lived role credentials through
|
|
12
|
+
* STS, and again whenever they are about to expire;
|
|
13
|
+
* 2. a shared profile (BEDROCK_AWS_PROFILE, else AWS_PROFILE) from
|
|
14
|
+
* ~/.aws/config: IAM Identity Center (SSO), an assumed role, or a
|
|
15
|
+
* credential process;
|
|
16
|
+
* 3. access keys in the environment (AWS_ACCESS_KEY_ID, ...);
|
|
17
|
+
* 4. the compute's own role (an ECS task role, EKS pod identity, an EC2
|
|
18
|
+
* instance profile): on ECS this is found by itself, elsewhere set
|
|
19
|
+
* BEDROCK_AUTH=aws.
|
|
20
|
+
* - A Bedrock API key (AWS_BEARER_TOKEN_BEDROCK), sent as a bearer token like
|
|
21
|
+
* every other provider's key. providers.ts reads it from the vault, a key
|
|
22
|
+
* file or the environment, and it wins over AWS credentials when both exist.
|
|
23
|
+
*
|
|
24
|
+
* AWS credentials are not vault items, so providers.ts gates them on the vault
|
|
25
|
+
* instead: once a vault exists nothing is signed while it is sealed, and
|
|
26
|
+
* sealing it drops the credentials held in memory here.
|
|
27
|
+
*
|
|
28
|
+
* Everything read from the environment here is removed from it, for the reason
|
|
29
|
+
* given in providers.ts: the OpenCode server is spawned with a copy of our
|
|
30
|
+
* environment, and the agent's shell inherits that.
|
|
31
|
+
*/
|
|
32
|
+
import { fromIni, fromNodeProviderChain, fromTokenFile } from "@aws-sdk/credential-providers";
|
|
33
|
+
import { Hash } from "@smithy/hash-node";
|
|
34
|
+
import { SignatureV4 } from "@smithy/signature-v4";
|
|
35
|
+
import { httpError } from "./errors.js";
|
|
36
|
+
/** A region name, as it goes into the endpoint's host name. */
|
|
37
|
+
const REGION = /^[a-z]{2}(-[a-z]+)+-\d{1,2}$/;
|
|
38
|
+
function take(env, name) {
|
|
39
|
+
const value = env[name]?.trim();
|
|
40
|
+
delete env[name];
|
|
41
|
+
return value || undefined;
|
|
42
|
+
}
|
|
43
|
+
/** Read the Bedrock settings from `env`, removing the credential variables from it. */
|
|
44
|
+
export function readSettings(env = process.env) {
|
|
45
|
+
const named = env.BEDROCK_REGION?.trim() || env.AWS_REGION?.trim() || env.AWS_DEFAULT_REGION?.trim() || "us-east-1";
|
|
46
|
+
if (!REGION.test(named))
|
|
47
|
+
throw new Error(`BEDROCK_REGION: "${named}" is not an AWS region name (for example ap-southeast-2).`);
|
|
48
|
+
const region = named;
|
|
49
|
+
const baseUrl = (env.BEDROCK_BASE_URL?.trim() || `https://bedrock-runtime.${region}.amazonaws.com/openai/v1`).replace(/\/$/, "");
|
|
50
|
+
const accessKeyId = take(env, "AWS_ACCESS_KEY_ID");
|
|
51
|
+
const secretAccessKey = take(env, "AWS_SECRET_ACCESS_KEY");
|
|
52
|
+
const sessionToken = take(env, "AWS_SESSION_TOKEN");
|
|
53
|
+
const roleArn = take(env, "AWS_ROLE_ARN");
|
|
54
|
+
const tokenFile = take(env, "AWS_WEB_IDENTITY_TOKEN_FILE");
|
|
55
|
+
const sessionName = take(env, "AWS_ROLE_SESSION_NAME");
|
|
56
|
+
const ownProfile = take(env, "BEDROCK_AWS_PROFILE");
|
|
57
|
+
const profile = ownProfile ?? take(env, "AWS_PROFILE");
|
|
58
|
+
delete env.AWS_PROFILE;
|
|
59
|
+
const explicit = env.BEDROCK_AUTH?.trim().toLowerCase() === "aws";
|
|
60
|
+
const onEcs = Boolean(env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI || env.AWS_CONTAINER_CREDENTIALS_FULL_URI);
|
|
61
|
+
const base = { region, baseUrl };
|
|
62
|
+
if (roleArn && tokenFile) {
|
|
63
|
+
return {
|
|
64
|
+
...base, mode: "web-identity", describe: `OIDC web identity, role ${roleArn}`,
|
|
65
|
+
credentials: fromTokenFile({
|
|
66
|
+
roleArn, webIdentityTokenFile: tokenFile, roleSessionName: sessionName ?? "bugxhunter-runner",
|
|
67
|
+
clientConfig: { region },
|
|
68
|
+
}),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
if (profile) {
|
|
72
|
+
return {
|
|
73
|
+
...base, mode: "profile", describe: `AWS profile "${profile}"`,
|
|
74
|
+
credentials: fromIni({ profile, clientConfig: { region } }),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if (accessKeyId && secretAccessKey) {
|
|
78
|
+
const fixed = { accessKeyId, secretAccessKey, ...(sessionToken ? { sessionToken } : {}) };
|
|
79
|
+
return {
|
|
80
|
+
...base, mode: "static",
|
|
81
|
+
describe: sessionToken ? "temporary access keys in the environment" : "long-lived access keys in the environment",
|
|
82
|
+
credentials: async () => fixed,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
if (explicit || onEcs) {
|
|
86
|
+
return {
|
|
87
|
+
...base, mode: "chain", describe: "the compute's own AWS role",
|
|
88
|
+
credentials: fromNodeProviderChain({ clientConfig: { region } }),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return { ...base, mode: "none", describe: "none" };
|
|
92
|
+
}
|
|
93
|
+
/** Temporary credentials are replaced this long before they expire. */
|
|
94
|
+
const REFRESH_BEFORE_MS = 5 * 60_000;
|
|
95
|
+
/** Credentials without an expiry (a profile's static keys) are re-read this often, so a rotated file is noticed. */
|
|
96
|
+
const REREAD_MS = 5 * 60_000;
|
|
97
|
+
/**
|
|
98
|
+
* Cache a credential source: one lookup for concurrent callers, and a fresh one near expiry.
|
|
99
|
+
* `forget()` drops what is held, and the result of a lookup still in flight.
|
|
100
|
+
*/
|
|
101
|
+
export function cached(source, now = Date.now) {
|
|
102
|
+
let held;
|
|
103
|
+
let pending;
|
|
104
|
+
let generation = 0;
|
|
105
|
+
const get = async () => {
|
|
106
|
+
if (held && now() < held.until)
|
|
107
|
+
return held.value;
|
|
108
|
+
if (pending)
|
|
109
|
+
return pending;
|
|
110
|
+
const mine = generation;
|
|
111
|
+
const lookup = source().then((value) => {
|
|
112
|
+
if (mine === generation) {
|
|
113
|
+
const expires = value.expiration?.getTime();
|
|
114
|
+
held = { value, until: expires ? expires - REFRESH_BEFORE_MS : now() + REREAD_MS };
|
|
115
|
+
}
|
|
116
|
+
return value;
|
|
117
|
+
}).finally(() => { if (pending === lookup)
|
|
118
|
+
pending = undefined; });
|
|
119
|
+
pending = lookup;
|
|
120
|
+
return lookup;
|
|
121
|
+
};
|
|
122
|
+
return Object.assign(get, {
|
|
123
|
+
forget() {
|
|
124
|
+
generation += 1;
|
|
125
|
+
held = undefined;
|
|
126
|
+
pending = undefined;
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/** `request`'s headers with a SigV4 signature for Bedrock added (authorization, x-amz-date, and the session token if any). */
|
|
131
|
+
export async function signRequest(request, region, credentials, signingDate) {
|
|
132
|
+
const url = new URL(request.url);
|
|
133
|
+
const query = {};
|
|
134
|
+
for (const [k, v] of url.searchParams)
|
|
135
|
+
query[k] = v;
|
|
136
|
+
const signer = new SignatureV4({ service: "bedrock", region, credentials, sha256: Hash.bind(null, "sha256") });
|
|
137
|
+
const signed = await signer.sign({
|
|
138
|
+
method: request.method.toUpperCase(),
|
|
139
|
+
protocol: url.protocol,
|
|
140
|
+
hostname: url.hostname,
|
|
141
|
+
...(url.port ? { port: Number(url.port) } : {}),
|
|
142
|
+
path: url.pathname,
|
|
143
|
+
query,
|
|
144
|
+
headers: { ...request.headers, host: url.host },
|
|
145
|
+
body: request.body,
|
|
146
|
+
}, signingDate ? { signingDate } : undefined);
|
|
147
|
+
const { host: _host, ...headers } = signed.headers;
|
|
148
|
+
return headers; // fetch sets Host itself, from the same URL
|
|
149
|
+
}
|
|
150
|
+
const oneLine = (e) => String(e?.message ?? e).replace(/\s+/g, " ").slice(0, 300);
|
|
151
|
+
export const settings = readSettings();
|
|
152
|
+
const source = settings.credentials ? cached(settings.credentials) : undefined;
|
|
153
|
+
/** Drop the AWS credentials held in memory (the vault was locked). The next call loads them afresh. */
|
|
154
|
+
export const forget = () => source?.forget();
|
|
155
|
+
/** Whether AWS credentials are set up for Bedrock (they may still fail to load: an SSO session can lapse). */
|
|
156
|
+
export const awsConfigured = () => settings.mode !== "none";
|
|
157
|
+
/** Sign one call to Bedrock with the runner's AWS credentials. Throws a 503 the client can explain. */
|
|
158
|
+
export async function sign(request) {
|
|
159
|
+
if (!source)
|
|
160
|
+
throw httpError(503, "No AWS credentials for Bedrock. Set BEDROCK_AWS_PROFILE, an OIDC role, or add AWS_BEARER_TOKEN_BEDROCK to the vault.");
|
|
161
|
+
let credentials;
|
|
162
|
+
try {
|
|
163
|
+
credentials = await source();
|
|
164
|
+
}
|
|
165
|
+
catch (e) {
|
|
166
|
+
const hint = settings.mode === "profile" ? " If it is an SSO profile, sign in again with `aws sso login`." : "";
|
|
167
|
+
throw httpError(503, `Could not load AWS credentials for Bedrock (${settings.describe}): ${oneLine(e)}.${hint}`);
|
|
168
|
+
}
|
|
169
|
+
return signRequest(request, settings.region, credentials);
|
|
170
|
+
}
|
|
171
|
+
const GLM_53 = { context: 1_000_000, output: 128_000, features: ["tools", "reasoning"] };
|
|
172
|
+
/**
|
|
173
|
+
* OpenAI's GPT models on Bedrock. Limits as OpenAI publishes them for the same models; they read
|
|
174
|
+
* images. Bedrock's Chat Completions route refuses function tools for them (its Responses route
|
|
175
|
+
* takes them, which the runner does not speak), so they are for the Playground, not the agent.
|
|
176
|
+
*/
|
|
177
|
+
const GPT_ASTRA = { context: 1_050_000, output: 128_000, features: ["reasoning", "json_mode"], image: true, chatOnly: true };
|
|
178
|
+
/**
|
|
179
|
+
* Bedrock's OpenAI-compatible route has no model list, so the ids are named in
|
|
180
|
+
* BEDROCK_MODELS and the ones we know carry their limits here. GLM 5.3 has no
|
|
181
|
+
* single-region form: it is called through a cross-region inference profile,
|
|
182
|
+
* `global.` from most regions and `us.` from the US ones.
|
|
183
|
+
*/
|
|
184
|
+
export const BEDROCK_CATALOGUE = {
|
|
185
|
+
"global.zai.glm-5.3": { ...GLM_53, name: "GLM 5.3 (Bedrock)", description: "Z.ai GLM 5.3 on Amazon Bedrock, through the global cross-region profile: inference may run in any commercial AWS region." },
|
|
186
|
+
"us.zai.glm-5.3": { ...GLM_53, name: "GLM 5.3 (Bedrock, US)", description: "Z.ai GLM 5.3 on Amazon Bedrock, kept to US regions. Callable from US regions only." },
|
|
187
|
+
"global.openai.gpt-6.2-astra": { ...GPT_ASTRA, name: "GPT-6.2 Astra (Bedrock)", description: "OpenAI GPT-6.2 Astra on Amazon Bedrock, through the global cross-region profile. Reads images. Not open-weight; sampling settings are fixed." },
|
|
188
|
+
"global.openai.gpt-6-astra": { ...GPT_ASTRA, name: "GPT-6 Astra (Bedrock)", description: "OpenAI GPT-6 Astra on Amazon Bedrock, through the global cross-region profile. Reads images. Not open-weight; sampling settings are fixed." },
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* OpenAI's hosted GPT models on Bedrock (not the open-weight gpt-oss ones), by id or by an
|
|
192
|
+
* inference profile of one. They take the output limit as `max_completion_tokens`, and refuse
|
|
193
|
+
* `stop` and any `temperature` or `top_p` but the default.
|
|
194
|
+
*/
|
|
195
|
+
export const isOpenAiGpt = (model) => /(^|\.)openai\.gpt-(?!oss)/.test(model);
|
|
196
|
+
/** Chat parameters the hosted GPT models refuse outright or accept only at their default. */
|
|
197
|
+
const GPT_REFUSED = ["temperature", "top_p", "stop", "frequency_penalty", "presence_penalty"];
|
|
198
|
+
/**
|
|
199
|
+
* A chat-completions request as the Bedrock model named in it accepts it. Returns the same
|
|
200
|
+
* object when there is nothing to change, so a caller can tell.
|
|
201
|
+
*/
|
|
202
|
+
export function prepareRequest(params, effort = REASONING_EFFORT) {
|
|
203
|
+
let out = params;
|
|
204
|
+
const change = (next) => { out = next; };
|
|
205
|
+
if (effort && out.reasoning_effort === undefined)
|
|
206
|
+
change({ ...out, reasoning_effort: effort });
|
|
207
|
+
if (typeof out.model === "string" && isOpenAiGpt(out.model)) {
|
|
208
|
+
if (GPT_REFUSED.some((k) => out[k] !== undefined)) {
|
|
209
|
+
const kept = { ...out };
|
|
210
|
+
for (const k of GPT_REFUSED)
|
|
211
|
+
delete kept[k];
|
|
212
|
+
change(kept);
|
|
213
|
+
}
|
|
214
|
+
if (out.max_tokens !== undefined) {
|
|
215
|
+
const { max_tokens, ...rest } = out;
|
|
216
|
+
change({ ...rest, ...(rest.max_completion_tokens === undefined ? { max_completion_tokens: max_tokens } : {}) });
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return out;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* A Playground request without the tools a hosted GPT model would refuse the whole call over.
|
|
223
|
+
* The Playground sends whatever tools the chat has configured; the sidebar already shows such a
|
|
224
|
+
* model as having no tool support. The agent's calls are not touched: there the refusal must show.
|
|
225
|
+
*/
|
|
226
|
+
export function withoutRefusedTools(params) {
|
|
227
|
+
if (typeof params.model !== "string" || !isOpenAiGpt(params.model))
|
|
228
|
+
return params;
|
|
229
|
+
if (params.tools === undefined && params.tool_choice === undefined)
|
|
230
|
+
return params;
|
|
231
|
+
const { tools: _tools, tool_choice: _choice, ...rest } = params;
|
|
232
|
+
return rest;
|
|
233
|
+
}
|
|
234
|
+
/** The models the agent may be offered: those in BEDROCK_MODELS that can call tools on this route. */
|
|
235
|
+
export const agentModels = () => BEDROCK_MODELS.filter((id) => !(BEDROCK_CATALOGUE[id]?.chatOnly ?? isOpenAiGpt(id)));
|
|
236
|
+
/** Whether the proxy may forward a call for this model: only the ids in BEDROCK_MODELS. */
|
|
237
|
+
export const allowsModel = (model) => typeof model === "string" && BEDROCK_MODELS.includes(model);
|
|
238
|
+
/** Model or inference-profile ids the Playground and agent may use (BEDROCK_MODELS, comma list). */
|
|
239
|
+
export const BEDROCK_MODELS = (process.env.BEDROCK_MODELS?.trim() || "global.zai.glm-5.3")
|
|
240
|
+
.split(",").map((s) => s.trim()).filter(Boolean);
|
|
241
|
+
/** Playground ids for Bedrock models: `bedrock/<model or inference-profile id>`. */
|
|
242
|
+
export const BEDROCK_PREFIX = "bedrock/";
|
|
243
|
+
// --- Reasoning effort -----------------------------------------------------------
|
|
244
|
+
/** The efforts Bedrock's Chat Completions route takes for GLM 5.3 (`none` and `minimal` are refused). */
|
|
245
|
+
export const REASONING_EFFORTS = ["low", "medium", "high", "xhigh", "max"];
|
|
246
|
+
/** BEDROCK_REASONING_EFFORT as an effort, or undefined when it is not set. Throws on anything else. */
|
|
247
|
+
export function readReasoningEffort(value) {
|
|
248
|
+
const v = value?.trim().toLowerCase();
|
|
249
|
+
if (!v)
|
|
250
|
+
return undefined;
|
|
251
|
+
if (!REASONING_EFFORTS.includes(v)) {
|
|
252
|
+
throw new Error(`BEDROCK_REASONING_EFFORT: "${value}" is not one of ${REASONING_EFFORTS.join(", ")}.`);
|
|
253
|
+
}
|
|
254
|
+
return v;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* The effort a Bedrock call gets when it names none (BEDROCK_REASONING_EFFORT). Unset, the
|
|
258
|
+
* model's own default stands, which for GLM 5.3 is `max`: thorough, but reasoning counts
|
|
259
|
+
* against the output limit, so a short limit can be spent before any answer is written.
|
|
260
|
+
*/
|
|
261
|
+
export const REASONING_EFFORT = readReasoningEffort(process.env.BEDROCK_REASONING_EFFORT);
|
|
262
|
+
/** A chat-completions body as a JSON object, or undefined when it is not one. */
|
|
263
|
+
function bodyObject(body) {
|
|
264
|
+
if (!body.length)
|
|
265
|
+
return undefined;
|
|
266
|
+
try {
|
|
267
|
+
const parsed = JSON.parse(body.toString("utf8"));
|
|
268
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : undefined;
|
|
269
|
+
}
|
|
270
|
+
catch {
|
|
271
|
+
return undefined;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* An agent's chat-completions body, as it arrives through the proxy, prepared for the model
|
|
276
|
+
* it names (see prepareRequest). Anything that is not a JSON object, or needs no change, is
|
|
277
|
+
* passed on byte for byte.
|
|
278
|
+
*/
|
|
279
|
+
export function prepareBody(body, effort = REASONING_EFFORT) {
|
|
280
|
+
const parsed = bodyObject(body);
|
|
281
|
+
if (!parsed)
|
|
282
|
+
return body;
|
|
283
|
+
const prepared = prepareRequest(parsed, effort);
|
|
284
|
+
return prepared === parsed ? body : Buffer.from(JSON.stringify(prepared));
|
|
285
|
+
}
|
|
286
|
+
/** The model a proxied body names, if it is a JSON object that names one. */
|
|
287
|
+
export const bodyModel = (body) => bodyObject(body)?.model;
|
|
288
|
+
//# sourceMappingURL=bedrock.js.map
|
package/server/dist/index.js
CHANGED
|
@@ -11,7 +11,8 @@ import express from "express";
|
|
|
11
11
|
import fs from "node:fs";
|
|
12
12
|
import path from "node:path";
|
|
13
13
|
import { SCXError } from "./scx.js";
|
|
14
|
-
import { PROVIDERS, PROXY_TOKEN, PORT, OPENROUTER_MODELS,
|
|
14
|
+
import { PROVIDERS, PROXY_TOKEN, PORT, OPENROUTER_MODELS, clients, clientFor, configured, isRetiredStatus, keySource, listModels, proxyBody, proxyHeaders, proxyPaths, proxyRefusal, proxyTokenOk, } from "./providers.js";
|
|
15
|
+
import { REASONING_EFFORT as bedrockEffort, settings as bedrockSettings } from "./bedrock.js";
|
|
15
16
|
import { KnowledgeBase, buildContextBlock } from "./rag.js";
|
|
16
17
|
import { getClient, serverUrl, resolveDirectory, projectFile, listAgentModels, toUiEvent, toUiMessages, parseModelId, oc, query, httpError, SessionFamily, childSessions, markInterrupted, DEFAULT_DIRECTORY, DEFAULT_MODEL, REMOTE_URL, REPO_ROOT, ALLOWED_ROOTS, } from "./opencode.js";
|
|
17
18
|
import { mountAuth, authRequired, issueSession } from "./auth.js";
|
|
@@ -63,10 +64,16 @@ for (const p of Object.values(PROVIDERS)) {
|
|
|
63
64
|
chunks.push(c);
|
|
64
65
|
const ctrl = new AbortController();
|
|
65
66
|
res.on("close", () => ctrl.abort());
|
|
66
|
-
const
|
|
67
|
+
const url = p.baseUrl + sub + (req.url.includes("?") ? req.url.slice(req.url.indexOf("?")) : "");
|
|
68
|
+
const received = Buffer.concat(chunks);
|
|
69
|
+
const refusal = req.method === "POST" ? proxyRefusal(p, received) : null;
|
|
70
|
+
if (refusal)
|
|
71
|
+
return res.status(403).json({ error: { message: refusal, type: "model_not_offered" } });
|
|
72
|
+
const body = req.method === "GET" || req.method === "HEAD" ? undefined : proxyBody(p, received);
|
|
73
|
+
const upstream = await fetch(url, {
|
|
67
74
|
method: req.method,
|
|
68
|
-
headers:
|
|
69
|
-
body
|
|
75
|
+
headers: await proxyHeaders(p, req.headers, { method: req.method, url, body }),
|
|
76
|
+
body,
|
|
70
77
|
signal: ctrl.signal,
|
|
71
78
|
});
|
|
72
79
|
res.status(upstream.status);
|
|
@@ -1015,13 +1022,16 @@ const server = app.listen(PORT, process.env.HOST ?? "127.0.0.1", () => {
|
|
|
1015
1022
|
vault: "vault",
|
|
1016
1023
|
file: "a key file (not in the clear in the environment)",
|
|
1017
1024
|
env: ".env — consider moving it into the vault",
|
|
1025
|
+
aws: `AWS credentials (${bedrockSettings.describe}), region ${bedrockSettings.region}`,
|
|
1018
1026
|
"opencode-auth": "OpenCode's auth.json — consider moving it into the vault",
|
|
1019
1027
|
none: p.id === "scx" ? "none yet — set up the vault in the sidebar" : "not configured (optional)",
|
|
1020
1028
|
}[src];
|
|
1021
|
-
console.log(` ${p.name} key: ${where}`);
|
|
1029
|
+
console.log(` ${p.name} ${src === "aws" ? "sign-in" : "key"}: ${where}`);
|
|
1022
1030
|
}
|
|
1023
1031
|
if (vault.isInitialised())
|
|
1024
1032
|
console.log(` vault: ${vault.VAULT_FILE} (${vault.isUnsealed() ? "unsealed" : "sealed — unlock it in the UI"})`);
|
|
1033
|
+
if (bedrockEffort && keySource("bedrock") !== "none")
|
|
1034
|
+
console.log(` Amazon Bedrock reasoning effort: ${bedrockEffort} (unless a call sets its own)`);
|
|
1025
1035
|
if (OPENROUTER_MODELS.length)
|
|
1026
1036
|
console.log(` OpenRouter models for the agent: ${OPENROUTER_MODELS.join(", ")}`);
|
|
1027
1037
|
console.log(` agent: ${REMOTE_URL ? `remote OpenCode at ${REMOTE_URL}` : "local OpenCode"}`);
|
package/server/dist/opencode.js
CHANGED
|
@@ -20,7 +20,7 @@ import { execFileSync } from "node:child_process";
|
|
|
20
20
|
import { fileURLToPath } from "node:url";
|
|
21
21
|
import { createOpencodeServer, createOpencodeClient } from "@opencode-ai/sdk";
|
|
22
22
|
import { httpError } from "./errors.js";
|
|
23
|
-
import { anthropicOpencodeProvider, openrouterOpencodeProvider, nvidiaOpencodeProvider, ANTHROPIC_MODELS, OPENROUTER_MODELS, PORT } from "./providers.js";
|
|
23
|
+
import { anthropicOpencodeProvider, bedrockOpencodeProvider, openrouterOpencodeProvider, nvidiaOpencodeProvider, ANTHROPIC_MODELS, OPENROUTER_MODELS, PORT } from "./providers.js";
|
|
24
24
|
import { reconAgents, setAnthropicAvailable, tierOrder, withScrubbedEnv } from "./recon.js";
|
|
25
25
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
26
26
|
/** BugXHunter's own folder: the default project when none is chosen. */
|
|
@@ -50,7 +50,7 @@ export const VISION_AGENT = {
|
|
|
50
50
|
/**
|
|
51
51
|
* Config layered on the user's own OpenCode setup. With OPENROUTER_MODELS set,
|
|
52
52
|
* it adds an `openrouter` provider that calls back through this server's
|
|
53
|
-
* key-injecting proxy, so the OpenRouter key stays in the vault. NVIDIA and
|
|
53
|
+
* key-injecting proxy, so the OpenRouter key stays in the vault. NVIDIA, Bedrock and
|
|
54
54
|
* Anthropic work the same way when their keys are configured (Claude through
|
|
55
55
|
* OpenCode's native Anthropic client, the ids in ANTHROPIC_MODELS).
|
|
56
56
|
*/
|
|
@@ -74,7 +74,8 @@ async function inlineConfig() {
|
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
const
|
|
77
|
+
const bedrock = bedrockOpencodeProvider(`http://127.0.0.1:${PORT}/bedrock/v1`);
|
|
78
|
+
const provider = { ...(openrouter ? { openrouter } : {}), ...(nvidia ? { nvidia } : {}), ...(anthropic ? { anthropic } : {}), ...(bedrock ? { bedrock } : {}) };
|
|
78
79
|
return {
|
|
79
80
|
model: DEFAULT_MODEL,
|
|
80
81
|
agent: {
|