@stonerzju/opencode 1.2.17 → 1.2.18
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/bin/opencode +29 -157
- package/package.json +29 -29
- package/src/acp/agent.ts +4 -4
- package/src/acp/session.ts +1 -1
- package/src/agent/agent.ts +3 -3
- package/src/bun/index.ts +2 -2
- package/src/cli/cmd/acp.ts +3 -3
- package/src/cli/cmd/debug/file.ts +1 -1
- package/src/cli/cmd/github.ts +2 -2
- package/src/cli/cmd/pr.ts +1 -1
- package/src/cli/cmd/tui/app.tsx +24 -24
- package/src/cli/cmd/tui/attach.ts +3 -3
- package/src/cli/cmd/tui/component/dialog-agent.tsx +3 -3
- package/src/cli/cmd/tui/component/dialog-command.tsx +3 -3
- package/src/cli/cmd/tui/component/dialog-mcp.tsx +5 -5
- package/src/cli/cmd/tui/component/dialog-model.tsx +4 -4
- package/src/cli/cmd/tui/component/dialog-provider.tsx +4 -4
- package/src/cli/cmd/tui/component/dialog-session-list.tsx +5 -5
- package/src/cli/cmd/tui/component/dialog-session-rename.tsx +3 -3
- package/src/cli/cmd/tui/component/dialog-skill.tsx +3 -3
- package/src/cli/cmd/tui/component/dialog-stash.tsx +3 -3
- package/src/cli/cmd/tui/component/dialog-status.tsx +2 -2
- package/src/cli/cmd/tui/component/dialog-tag.tsx +3 -3
- package/src/cli/cmd/tui/component/logo.tsx +2 -2
- package/src/cli/cmd/tui/component/prompt/autocomplete.tsx +6 -6
- package/src/cli/cmd/tui/component/prompt/frecency.tsx +2 -2
- package/src/cli/cmd/tui/component/prompt/history.tsx +2 -2
- package/src/cli/cmd/tui/component/prompt/index.tsx +14 -14
- package/src/cli/cmd/tui/component/prompt/stash.tsx +2 -2
- package/src/cli/cmd/tui/component/textarea-keybindings.ts +1 -1
- package/src/cli/cmd/tui/component/tips.tsx +1 -1
- package/src/cli/cmd/tui/context/directory.ts +1 -1
- package/src/cli/cmd/tui/context/exit.tsx +1 -1
- package/src/cli/cmd/tui/context/keybind.tsx +2 -2
- package/src/cli/cmd/tui/context/kv.tsx +2 -2
- package/src/cli/cmd/tui/context/local.tsx +6 -6
- package/src/cli/cmd/tui/context/sync.tsx +4 -4
- package/src/cli/cmd/tui/context/theme/opencode.json +245 -0
- package/src/cli/cmd/tui/context/theme.tsx +2 -2
- package/src/cli/cmd/tui/context/tui-config.tsx +1 -1
- package/src/cli/cmd/tui/event.ts +2 -2
- package/src/cli/cmd/tui/routes/home.tsx +6 -6
- package/src/cli/cmd/tui/routes/session/dialog-fork-from-timeline.tsx +6 -6
- package/src/cli/cmd/tui/routes/session/dialog-message.tsx +6 -6
- package/src/cli/cmd/tui/routes/session/dialog-subagent.tsx +2 -2
- package/src/cli/cmd/tui/routes/session/dialog-timeline.tsx +3 -3
- package/src/cli/cmd/tui/routes/session/header.tsx +5 -5
- package/src/cli/cmd/tui/routes/session/index.tsx +32 -32
- package/src/cli/cmd/tui/routes/session/permission.tsx +4 -4
- package/src/cli/cmd/tui/routes/session/sidebar.tsx +4 -4
- package/src/cli/cmd/tui/thread.ts +9 -9
- package/src/cli/cmd/tui/ui/dialog-confirm.tsx +1 -1
- package/src/cli/cmd/tui/ui/dialog-help.tsx +2 -2
- package/src/cli/cmd/tui/ui/dialog-select.tsx +5 -5
- package/src/cli/cmd/tui/ui/dialog.tsx +3 -3
- package/src/cli/cmd/tui/ui/toast.tsx +1 -1
- package/src/cli/cmd/tui/util/editor.ts +3 -3
- package/src/cli/cmd/tui/util/transcript.ts +1 -1
- package/src/cli/cmd/tui/worker.ts +10 -10
- package/src/cli/error.ts +1 -1
- package/src/cli/ui.ts +1 -1
- package/src/cli/upgrade.ts +4 -4
- package/src/command/index.ts +1 -1
- package/src/config/config.ts +10 -10
- package/src/config/markdown.ts +1 -1
- package/src/config/migrate-tui-config.ts +5 -5
- package/src/config/paths.ts +4 -4
- package/src/config/tui.ts +4 -4
- package/src/control/control.sql.ts +1 -1
- package/src/control/index.ts +1 -1
- package/src/control-plane/adaptors/worktree.ts +1 -1
- package/src/control-plane/session-proxy-middleware.ts +1 -1
- package/src/control-plane/workspace.sql.ts +1 -1
- package/src/control-plane/workspace.ts +7 -7
- package/src/file/index.ts +1 -1
- package/src/file/ripgrep.ts +2 -2
- package/src/file/watcher.ts +5 -5
- package/src/format/formatter.ts +1 -1
- package/src/ide/index.ts +3 -3
- package/src/index.ts +1 -1
- package/src/installation/index.ts +3 -3
- package/src/lsp/client.ts +3 -3
- package/src/lsp/index.ts +3 -3
- package/src/mcp/index.ts +4 -4
- package/src/permission/index.ts +2 -2
- package/src/permission/next.ts +10 -10
- package/src/plugin/codex.ts +1 -1
- package/src/plugin/copilot.ts +2 -2
- package/src/plugin/index.ts +1 -1
- package/src/project/bootstrap.ts +2 -2
- package/src/project/instance.ts +4 -4
- package/src/project/project.sql.ts +1 -1
- package/src/project/project.ts +5 -5
- package/src/project/state.ts +1 -1
- package/src/project/vcs.ts +4 -4
- package/src/provider/auth.ts +4 -4
- package/src/provider/error.ts +1 -1
- package/src/provider/models-snapshot.ts +2 -0
- package/src/provider/models.ts +1 -1
- package/src/provider/provider.ts +2 -2
- package/src/provider/transform.ts +2 -2
- package/src/pty/index.ts +5 -5
- package/src/question/index.ts +5 -5
- package/src/server/event.ts +1 -1
- package/src/server/mdns.ts +1 -1
- package/src/server/routes/global.ts +3 -3
- package/src/server/routes/permission.ts +1 -1
- package/src/server/routes/pty.ts +1 -1
- package/src/server/routes/session.ts +4 -4
- package/src/server/routes/tui.ts +1 -1
- package/src/server/server.ts +3 -3
- package/src/session/compaction.ts +7 -7
- package/src/session/index.ts +10 -10
- package/src/session/instruction.ts +1 -1
- package/src/session/llm.ts +11 -11
- package/src/session/message-v2.ts +10 -10
- package/src/session/message.ts +1 -1
- package/src/session/processor.ts +10 -10
- package/src/session/prompt.ts +8 -8
- package/src/session/retry.ts +2 -2
- package/src/session/revert.ts +1 -1
- package/src/session/session.sql.ts +3 -3
- package/src/session/status.ts +3 -3
- package/src/session/summary.ts +5 -5
- package/src/session/system.ts +1 -1
- package/src/session/todo.ts +2 -2
- package/src/share/share-next.ts +7 -7
- package/src/share/share.sql.ts +1 -1
- package/src/shell/shell.ts +3 -3
- package/src/skill/skill.ts +6 -6
- package/src/storage/db.ts +1 -1
- package/src/storage/storage.ts +1 -1
- package/src/tool/bash.ts +6 -6
- package/src/tool/edit.ts +1 -1
- package/src/tool/registry.ts +2 -2
- package/src/tool/skill.ts +1 -1
- package/src/tool/task.ts +3 -3
- package/src/util/array.ts +10 -0
- package/src/util/binary.ts +41 -0
- package/src/util/encode.ts +51 -0
- package/src/util/error.ts +54 -0
- package/src/util/identifier.ts +48 -0
- package/src/util/lazy.ts +4 -16
- package/src/util/path.ts +37 -0
- package/src/util/retry.ts +41 -0
- package/src/util/slug.ts +74 -0
- package/src/worktree/index.ts +3 -3
- package/AGENTS.md +0 -10
- package/BUN_SHELL_MIGRATION_PLAN.md +0 -136
- package/Dockerfile +0 -18
- package/README.md +0 -15
- package/bunfig.toml +0 -7
- package/drizzle.config.ts +0 -10
- package/script/build.ts +0 -224
- package/script/check-migrations.ts +0 -16
- package/script/postinstall.mjs +0 -131
- package/script/publish.ts +0 -181
- package/script/schema.ts +0 -63
- package/script/seed-e2e.ts +0 -50
- package/sst-env.d.ts +0 -10
- package/test/AGENTS.md +0 -81
- package/test/acp/agent-interface.test.ts +0 -51
- package/test/acp/event-subscription.test.ts +0 -683
- package/test/agent/agent.test.ts +0 -689
- package/test/bun.test.ts +0 -53
- package/test/cli/github-action.test.ts +0 -197
- package/test/cli/github-remote.test.ts +0 -80
- package/test/cli/import.test.ts +0 -38
- package/test/cli/plugin-auth-picker.test.ts +0 -120
- package/test/cli/tui/transcript.test.ts +0 -322
- package/test/config/agent-color.test.ts +0 -71
- package/test/config/config.test.ts +0 -1886
- package/test/config/fixtures/empty-frontmatter.md +0 -4
- package/test/config/fixtures/frontmatter.md +0 -28
- package/test/config/fixtures/markdown-header.md +0 -11
- package/test/config/fixtures/no-frontmatter.md +0 -1
- package/test/config/fixtures/weird-model-id.md +0 -13
- package/test/config/markdown.test.ts +0 -228
- package/test/config/tui.test.ts +0 -510
- package/test/control-plane/session-proxy-middleware.test.ts +0 -147
- package/test/control-plane/sse.test.ts +0 -56
- package/test/control-plane/workspace-server-sse.test.ts +0 -65
- package/test/control-plane/workspace-sync.test.ts +0 -97
- package/test/file/ignore.test.ts +0 -10
- package/test/file/index.test.ts +0 -394
- package/test/file/path-traversal.test.ts +0 -198
- package/test/file/ripgrep.test.ts +0 -39
- package/test/file/time.test.ts +0 -361
- package/test/fixture/db.ts +0 -11
- package/test/fixture/fixture.ts +0 -45
- package/test/fixture/lsp/fake-lsp-server.js +0 -77
- package/test/fixture/skills/agents-sdk/SKILL.md +0 -152
- package/test/fixture/skills/agents-sdk/references/callable.md +0 -92
- package/test/fixture/skills/cloudflare/SKILL.md +0 -211
- package/test/fixture/skills/index.json +0 -6
- package/test/ide/ide.test.ts +0 -82
- package/test/keybind.test.ts +0 -421
- package/test/lsp/client.test.ts +0 -95
- package/test/mcp/headers.test.ts +0 -153
- package/test/mcp/oauth-browser.test.ts +0 -249
- package/test/memory/abort-leak.test.ts +0 -136
- package/test/patch/patch.test.ts +0 -348
- package/test/permission/arity.test.ts +0 -33
- package/test/permission/next.test.ts +0 -689
- package/test/permission-task.test.ts +0 -319
- package/test/plugin/auth-override.test.ts +0 -44
- package/test/plugin/codex.test.ts +0 -123
- package/test/preload.ts +0 -80
- package/test/project/project.test.ts +0 -348
- package/test/project/worktree-remove.test.ts +0 -65
- package/test/provider/amazon-bedrock.test.ts +0 -446
- package/test/provider/copilot/convert-to-copilot-messages.test.ts +0 -523
- package/test/provider/copilot/copilot-chat-model.test.ts +0 -592
- package/test/provider/gitlab-duo.test.ts +0 -262
- package/test/provider/provider.test.ts +0 -2220
- package/test/provider/transform.test.ts +0 -2353
- package/test/pty/pty-output-isolation.test.ts +0 -140
- package/test/question/question.test.ts +0 -300
- package/test/scheduler.test.ts +0 -73
- package/test/server/global-session-list.test.ts +0 -89
- package/test/server/session-list.test.ts +0 -90
- package/test/server/session-select.test.ts +0 -78
- package/test/session/compaction.test.ts +0 -423
- package/test/session/instruction.test.ts +0 -170
- package/test/session/llm.test.ts +0 -667
- package/test/session/message-v2.test.ts +0 -924
- package/test/session/prompt.test.ts +0 -211
- package/test/session/retry.test.ts +0 -188
- package/test/session/revert-compact.test.ts +0 -285
- package/test/session/session.test.ts +0 -71
- package/test/session/structured-output-integration.test.ts +0 -233
- package/test/session/structured-output.test.ts +0 -385
- package/test/skill/discovery.test.ts +0 -110
- package/test/skill/skill.test.ts +0 -388
- package/test/snapshot/snapshot.test.ts +0 -1180
- package/test/storage/json-migration.test.ts +0 -846
- package/test/tool/__snapshots__/tool.test.ts.snap +0 -9
- package/test/tool/apply_patch.test.ts +0 -566
- package/test/tool/bash.test.ts +0 -402
- package/test/tool/edit.test.ts +0 -496
- package/test/tool/external-directory.test.ts +0 -127
- package/test/tool/fixtures/large-image.png +0 -0
- package/test/tool/fixtures/models-api.json +0 -38413
- package/test/tool/grep.test.ts +0 -110
- package/test/tool/question.test.ts +0 -107
- package/test/tool/read.test.ts +0 -504
- package/test/tool/registry.test.ts +0 -122
- package/test/tool/skill.test.ts +0 -112
- package/test/tool/truncation.test.ts +0 -160
- package/test/tool/webfetch.test.ts +0 -100
- package/test/tool/write.test.ts +0 -348
- package/test/util/filesystem.test.ts +0 -443
- package/test/util/format.test.ts +0 -59
- package/test/util/glob.test.ts +0 -164
- package/test/util/iife.test.ts +0 -36
- package/test/util/lazy.test.ts +0 -50
- package/test/util/lock.test.ts +0 -72
- package/test/util/process.test.ts +0 -59
- package/test/util/timeout.test.ts +0 -21
- package/test/util/wildcard.test.ts +0 -90
- package/tsconfig.json +0 -16
|
@@ -1,446 +0,0 @@
|
|
|
1
|
-
import { test, expect, describe } from "bun:test"
|
|
2
|
-
import path from "path"
|
|
3
|
-
import { unlink } from "fs/promises"
|
|
4
|
-
|
|
5
|
-
import { tmpdir } from "../fixture/fixture"
|
|
6
|
-
import { Instance } from "../../src/project/instance"
|
|
7
|
-
import { Provider } from "../../src/provider/provider"
|
|
8
|
-
import { Env } from "../../src/env"
|
|
9
|
-
import { Global } from "../../src/global"
|
|
10
|
-
import { Filesystem } from "../../src/util/filesystem"
|
|
11
|
-
|
|
12
|
-
test("Bedrock: config region takes precedence over AWS_REGION env var", async () => {
|
|
13
|
-
await using tmp = await tmpdir({
|
|
14
|
-
init: async (dir) => {
|
|
15
|
-
await Filesystem.write(
|
|
16
|
-
path.join(dir, "opencode.json"),
|
|
17
|
-
JSON.stringify({
|
|
18
|
-
$schema: "https://opencode.ai/config.json",
|
|
19
|
-
provider: {
|
|
20
|
-
"amazon-bedrock": {
|
|
21
|
-
options: {
|
|
22
|
-
region: "eu-west-1",
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
}),
|
|
27
|
-
)
|
|
28
|
-
},
|
|
29
|
-
})
|
|
30
|
-
await Instance.provide({
|
|
31
|
-
directory: tmp.path,
|
|
32
|
-
init: async () => {
|
|
33
|
-
Env.set("AWS_REGION", "us-east-1")
|
|
34
|
-
Env.set("AWS_PROFILE", "default")
|
|
35
|
-
},
|
|
36
|
-
fn: async () => {
|
|
37
|
-
const providers = await Provider.list()
|
|
38
|
-
expect(providers["amazon-bedrock"]).toBeDefined()
|
|
39
|
-
expect(providers["amazon-bedrock"].options?.region).toBe("eu-west-1")
|
|
40
|
-
},
|
|
41
|
-
})
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
test("Bedrock: falls back to AWS_REGION env var when no config region", async () => {
|
|
45
|
-
await using tmp = await tmpdir({
|
|
46
|
-
init: async (dir) => {
|
|
47
|
-
await Filesystem.write(
|
|
48
|
-
path.join(dir, "opencode.json"),
|
|
49
|
-
JSON.stringify({
|
|
50
|
-
$schema: "https://opencode.ai/config.json",
|
|
51
|
-
}),
|
|
52
|
-
)
|
|
53
|
-
},
|
|
54
|
-
})
|
|
55
|
-
await Instance.provide({
|
|
56
|
-
directory: tmp.path,
|
|
57
|
-
init: async () => {
|
|
58
|
-
Env.set("AWS_REGION", "eu-west-1")
|
|
59
|
-
Env.set("AWS_PROFILE", "default")
|
|
60
|
-
},
|
|
61
|
-
fn: async () => {
|
|
62
|
-
const providers = await Provider.list()
|
|
63
|
-
expect(providers["amazon-bedrock"]).toBeDefined()
|
|
64
|
-
expect(providers["amazon-bedrock"].options?.region).toBe("eu-west-1")
|
|
65
|
-
},
|
|
66
|
-
})
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
test("Bedrock: loads when bearer token from auth.json is present", async () => {
|
|
70
|
-
await using tmp = await tmpdir({
|
|
71
|
-
init: async (dir) => {
|
|
72
|
-
await Filesystem.write(
|
|
73
|
-
path.join(dir, "opencode.json"),
|
|
74
|
-
JSON.stringify({
|
|
75
|
-
$schema: "https://opencode.ai/config.json",
|
|
76
|
-
provider: {
|
|
77
|
-
"amazon-bedrock": {
|
|
78
|
-
options: {
|
|
79
|
-
region: "eu-west-1",
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
}),
|
|
84
|
-
)
|
|
85
|
-
},
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
const authPath = path.join(Global.Path.data, "auth.json")
|
|
89
|
-
|
|
90
|
-
// Save original auth.json if it exists
|
|
91
|
-
let originalAuth: string | undefined
|
|
92
|
-
try {
|
|
93
|
-
originalAuth = await Filesystem.readText(authPath)
|
|
94
|
-
} catch {
|
|
95
|
-
// File doesn't exist, that's fine
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
try {
|
|
99
|
-
// Write test auth.json
|
|
100
|
-
await Filesystem.write(
|
|
101
|
-
authPath,
|
|
102
|
-
JSON.stringify({
|
|
103
|
-
"amazon-bedrock": {
|
|
104
|
-
type: "api",
|
|
105
|
-
key: "test-bearer-token",
|
|
106
|
-
},
|
|
107
|
-
}),
|
|
108
|
-
)
|
|
109
|
-
|
|
110
|
-
await Instance.provide({
|
|
111
|
-
directory: tmp.path,
|
|
112
|
-
init: async () => {
|
|
113
|
-
Env.set("AWS_PROFILE", "")
|
|
114
|
-
Env.set("AWS_ACCESS_KEY_ID", "")
|
|
115
|
-
Env.set("AWS_BEARER_TOKEN_BEDROCK", "")
|
|
116
|
-
},
|
|
117
|
-
fn: async () => {
|
|
118
|
-
const providers = await Provider.list()
|
|
119
|
-
expect(providers["amazon-bedrock"]).toBeDefined()
|
|
120
|
-
expect(providers["amazon-bedrock"].options?.region).toBe("eu-west-1")
|
|
121
|
-
},
|
|
122
|
-
})
|
|
123
|
-
} finally {
|
|
124
|
-
// Restore original or delete
|
|
125
|
-
if (originalAuth !== undefined) {
|
|
126
|
-
await Filesystem.write(authPath, originalAuth)
|
|
127
|
-
} else {
|
|
128
|
-
try {
|
|
129
|
-
await unlink(authPath)
|
|
130
|
-
} catch {
|
|
131
|
-
// Ignore errors if file doesn't exist
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
test("Bedrock: config profile takes precedence over AWS_PROFILE env var", async () => {
|
|
138
|
-
await using tmp = await tmpdir({
|
|
139
|
-
init: async (dir) => {
|
|
140
|
-
await Filesystem.write(
|
|
141
|
-
path.join(dir, "opencode.json"),
|
|
142
|
-
JSON.stringify({
|
|
143
|
-
$schema: "https://opencode.ai/config.json",
|
|
144
|
-
provider: {
|
|
145
|
-
"amazon-bedrock": {
|
|
146
|
-
options: {
|
|
147
|
-
profile: "my-custom-profile",
|
|
148
|
-
region: "us-east-1",
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
}),
|
|
153
|
-
)
|
|
154
|
-
},
|
|
155
|
-
})
|
|
156
|
-
await Instance.provide({
|
|
157
|
-
directory: tmp.path,
|
|
158
|
-
init: async () => {
|
|
159
|
-
Env.set("AWS_PROFILE", "default")
|
|
160
|
-
Env.set("AWS_ACCESS_KEY_ID", "test-key-id")
|
|
161
|
-
},
|
|
162
|
-
fn: async () => {
|
|
163
|
-
const providers = await Provider.list()
|
|
164
|
-
expect(providers["amazon-bedrock"]).toBeDefined()
|
|
165
|
-
expect(providers["amazon-bedrock"].options?.region).toBe("us-east-1")
|
|
166
|
-
},
|
|
167
|
-
})
|
|
168
|
-
})
|
|
169
|
-
|
|
170
|
-
test("Bedrock: includes custom endpoint in options when specified", async () => {
|
|
171
|
-
await using tmp = await tmpdir({
|
|
172
|
-
init: async (dir) => {
|
|
173
|
-
await Filesystem.write(
|
|
174
|
-
path.join(dir, "opencode.json"),
|
|
175
|
-
JSON.stringify({
|
|
176
|
-
$schema: "https://opencode.ai/config.json",
|
|
177
|
-
provider: {
|
|
178
|
-
"amazon-bedrock": {
|
|
179
|
-
options: {
|
|
180
|
-
endpoint: "https://bedrock-runtime.us-east-1.vpce-xxxxx.amazonaws.com",
|
|
181
|
-
},
|
|
182
|
-
},
|
|
183
|
-
},
|
|
184
|
-
}),
|
|
185
|
-
)
|
|
186
|
-
},
|
|
187
|
-
})
|
|
188
|
-
await Instance.provide({
|
|
189
|
-
directory: tmp.path,
|
|
190
|
-
init: async () => {
|
|
191
|
-
Env.set("AWS_PROFILE", "default")
|
|
192
|
-
},
|
|
193
|
-
fn: async () => {
|
|
194
|
-
const providers = await Provider.list()
|
|
195
|
-
expect(providers["amazon-bedrock"]).toBeDefined()
|
|
196
|
-
expect(providers["amazon-bedrock"].options?.endpoint).toBe(
|
|
197
|
-
"https://bedrock-runtime.us-east-1.vpce-xxxxx.amazonaws.com",
|
|
198
|
-
)
|
|
199
|
-
},
|
|
200
|
-
})
|
|
201
|
-
})
|
|
202
|
-
|
|
203
|
-
test("Bedrock: autoloads when AWS_WEB_IDENTITY_TOKEN_FILE is present", async () => {
|
|
204
|
-
await using tmp = await tmpdir({
|
|
205
|
-
init: async (dir) => {
|
|
206
|
-
await Filesystem.write(
|
|
207
|
-
path.join(dir, "opencode.json"),
|
|
208
|
-
JSON.stringify({
|
|
209
|
-
$schema: "https://opencode.ai/config.json",
|
|
210
|
-
provider: {
|
|
211
|
-
"amazon-bedrock": {
|
|
212
|
-
options: {
|
|
213
|
-
region: "us-east-1",
|
|
214
|
-
},
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
}),
|
|
218
|
-
)
|
|
219
|
-
},
|
|
220
|
-
})
|
|
221
|
-
await Instance.provide({
|
|
222
|
-
directory: tmp.path,
|
|
223
|
-
init: async () => {
|
|
224
|
-
Env.set("AWS_WEB_IDENTITY_TOKEN_FILE", "/var/run/secrets/eks.amazonaws.com/serviceaccount/token")
|
|
225
|
-
Env.set("AWS_ROLE_ARN", "arn:aws:iam::123456789012:role/my-eks-role")
|
|
226
|
-
Env.set("AWS_PROFILE", "")
|
|
227
|
-
Env.set("AWS_ACCESS_KEY_ID", "")
|
|
228
|
-
},
|
|
229
|
-
fn: async () => {
|
|
230
|
-
const providers = await Provider.list()
|
|
231
|
-
expect(providers["amazon-bedrock"]).toBeDefined()
|
|
232
|
-
expect(providers["amazon-bedrock"].options?.region).toBe("us-east-1")
|
|
233
|
-
},
|
|
234
|
-
})
|
|
235
|
-
})
|
|
236
|
-
|
|
237
|
-
// Tests for cross-region inference profile prefix handling
|
|
238
|
-
// Models from models.dev may come with prefixes already (e.g., us., eu., global.)
|
|
239
|
-
// These should NOT be double-prefixed when passed to the SDK
|
|
240
|
-
|
|
241
|
-
test("Bedrock: model with us. prefix should not be double-prefixed", async () => {
|
|
242
|
-
await using tmp = await tmpdir({
|
|
243
|
-
init: async (dir) => {
|
|
244
|
-
await Filesystem.write(
|
|
245
|
-
path.join(dir, "opencode.json"),
|
|
246
|
-
JSON.stringify({
|
|
247
|
-
$schema: "https://opencode.ai/config.json",
|
|
248
|
-
provider: {
|
|
249
|
-
"amazon-bedrock": {
|
|
250
|
-
options: {
|
|
251
|
-
region: "us-east-1",
|
|
252
|
-
},
|
|
253
|
-
models: {
|
|
254
|
-
"us.anthropic.claude-opus-4-5-20251101-v1:0": {
|
|
255
|
-
name: "Claude Opus 4.5 (US)",
|
|
256
|
-
},
|
|
257
|
-
},
|
|
258
|
-
},
|
|
259
|
-
},
|
|
260
|
-
}),
|
|
261
|
-
)
|
|
262
|
-
},
|
|
263
|
-
})
|
|
264
|
-
await Instance.provide({
|
|
265
|
-
directory: tmp.path,
|
|
266
|
-
init: async () => {
|
|
267
|
-
Env.set("AWS_PROFILE", "default")
|
|
268
|
-
},
|
|
269
|
-
fn: async () => {
|
|
270
|
-
const providers = await Provider.list()
|
|
271
|
-
expect(providers["amazon-bedrock"]).toBeDefined()
|
|
272
|
-
// The model should exist with the us. prefix
|
|
273
|
-
expect(providers["amazon-bedrock"].models["us.anthropic.claude-opus-4-5-20251101-v1:0"]).toBeDefined()
|
|
274
|
-
},
|
|
275
|
-
})
|
|
276
|
-
})
|
|
277
|
-
|
|
278
|
-
test("Bedrock: model with global. prefix should not be prefixed", async () => {
|
|
279
|
-
await using tmp = await tmpdir({
|
|
280
|
-
init: async (dir) => {
|
|
281
|
-
await Filesystem.write(
|
|
282
|
-
path.join(dir, "opencode.json"),
|
|
283
|
-
JSON.stringify({
|
|
284
|
-
$schema: "https://opencode.ai/config.json",
|
|
285
|
-
provider: {
|
|
286
|
-
"amazon-bedrock": {
|
|
287
|
-
options: {
|
|
288
|
-
region: "us-east-1",
|
|
289
|
-
},
|
|
290
|
-
models: {
|
|
291
|
-
"global.anthropic.claude-opus-4-5-20251101-v1:0": {
|
|
292
|
-
name: "Claude Opus 4.5 (Global)",
|
|
293
|
-
},
|
|
294
|
-
},
|
|
295
|
-
},
|
|
296
|
-
},
|
|
297
|
-
}),
|
|
298
|
-
)
|
|
299
|
-
},
|
|
300
|
-
})
|
|
301
|
-
await Instance.provide({
|
|
302
|
-
directory: tmp.path,
|
|
303
|
-
init: async () => {
|
|
304
|
-
Env.set("AWS_PROFILE", "default")
|
|
305
|
-
},
|
|
306
|
-
fn: async () => {
|
|
307
|
-
const providers = await Provider.list()
|
|
308
|
-
expect(providers["amazon-bedrock"]).toBeDefined()
|
|
309
|
-
expect(providers["amazon-bedrock"].models["global.anthropic.claude-opus-4-5-20251101-v1:0"]).toBeDefined()
|
|
310
|
-
},
|
|
311
|
-
})
|
|
312
|
-
})
|
|
313
|
-
|
|
314
|
-
test("Bedrock: model with eu. prefix should not be double-prefixed", async () => {
|
|
315
|
-
await using tmp = await tmpdir({
|
|
316
|
-
init: async (dir) => {
|
|
317
|
-
await Filesystem.write(
|
|
318
|
-
path.join(dir, "opencode.json"),
|
|
319
|
-
JSON.stringify({
|
|
320
|
-
$schema: "https://opencode.ai/config.json",
|
|
321
|
-
provider: {
|
|
322
|
-
"amazon-bedrock": {
|
|
323
|
-
options: {
|
|
324
|
-
region: "eu-west-1",
|
|
325
|
-
},
|
|
326
|
-
models: {
|
|
327
|
-
"eu.anthropic.claude-opus-4-5-20251101-v1:0": {
|
|
328
|
-
name: "Claude Opus 4.5 (EU)",
|
|
329
|
-
},
|
|
330
|
-
},
|
|
331
|
-
},
|
|
332
|
-
},
|
|
333
|
-
}),
|
|
334
|
-
)
|
|
335
|
-
},
|
|
336
|
-
})
|
|
337
|
-
await Instance.provide({
|
|
338
|
-
directory: tmp.path,
|
|
339
|
-
init: async () => {
|
|
340
|
-
Env.set("AWS_PROFILE", "default")
|
|
341
|
-
},
|
|
342
|
-
fn: async () => {
|
|
343
|
-
const providers = await Provider.list()
|
|
344
|
-
expect(providers["amazon-bedrock"]).toBeDefined()
|
|
345
|
-
expect(providers["amazon-bedrock"].models["eu.anthropic.claude-opus-4-5-20251101-v1:0"]).toBeDefined()
|
|
346
|
-
},
|
|
347
|
-
})
|
|
348
|
-
})
|
|
349
|
-
|
|
350
|
-
test("Bedrock: model without prefix in US region should get us. prefix added", async () => {
|
|
351
|
-
await using tmp = await tmpdir({
|
|
352
|
-
init: async (dir) => {
|
|
353
|
-
await Filesystem.write(
|
|
354
|
-
path.join(dir, "opencode.json"),
|
|
355
|
-
JSON.stringify({
|
|
356
|
-
$schema: "https://opencode.ai/config.json",
|
|
357
|
-
provider: {
|
|
358
|
-
"amazon-bedrock": {
|
|
359
|
-
options: {
|
|
360
|
-
region: "us-east-1",
|
|
361
|
-
},
|
|
362
|
-
models: {
|
|
363
|
-
"anthropic.claude-opus-4-5-20251101-v1:0": {
|
|
364
|
-
name: "Claude Opus 4.5",
|
|
365
|
-
},
|
|
366
|
-
},
|
|
367
|
-
},
|
|
368
|
-
},
|
|
369
|
-
}),
|
|
370
|
-
)
|
|
371
|
-
},
|
|
372
|
-
})
|
|
373
|
-
await Instance.provide({
|
|
374
|
-
directory: tmp.path,
|
|
375
|
-
init: async () => {
|
|
376
|
-
Env.set("AWS_PROFILE", "default")
|
|
377
|
-
},
|
|
378
|
-
fn: async () => {
|
|
379
|
-
const providers = await Provider.list()
|
|
380
|
-
expect(providers["amazon-bedrock"]).toBeDefined()
|
|
381
|
-
// Non-prefixed model should still be registered
|
|
382
|
-
expect(providers["amazon-bedrock"].models["anthropic.claude-opus-4-5-20251101-v1:0"]).toBeDefined()
|
|
383
|
-
},
|
|
384
|
-
})
|
|
385
|
-
})
|
|
386
|
-
|
|
387
|
-
// Direct unit tests for cross-region inference profile prefix handling
|
|
388
|
-
// These test the prefix detection logic used in getModel
|
|
389
|
-
|
|
390
|
-
describe("Bedrock cross-region prefix detection", () => {
|
|
391
|
-
const crossRegionPrefixes = ["global.", "us.", "eu.", "jp.", "apac.", "au."]
|
|
392
|
-
|
|
393
|
-
test("should detect global. prefix", () => {
|
|
394
|
-
const modelID = "global.anthropic.claude-opus-4-5-20251101-v1:0"
|
|
395
|
-
const hasPrefix = crossRegionPrefixes.some((prefix) => modelID.startsWith(prefix))
|
|
396
|
-
expect(hasPrefix).toBe(true)
|
|
397
|
-
})
|
|
398
|
-
|
|
399
|
-
test("should detect us. prefix", () => {
|
|
400
|
-
const modelID = "us.anthropic.claude-opus-4-5-20251101-v1:0"
|
|
401
|
-
const hasPrefix = crossRegionPrefixes.some((prefix) => modelID.startsWith(prefix))
|
|
402
|
-
expect(hasPrefix).toBe(true)
|
|
403
|
-
})
|
|
404
|
-
|
|
405
|
-
test("should detect eu. prefix", () => {
|
|
406
|
-
const modelID = "eu.anthropic.claude-opus-4-5-20251101-v1:0"
|
|
407
|
-
const hasPrefix = crossRegionPrefixes.some((prefix) => modelID.startsWith(prefix))
|
|
408
|
-
expect(hasPrefix).toBe(true)
|
|
409
|
-
})
|
|
410
|
-
|
|
411
|
-
test("should detect jp. prefix", () => {
|
|
412
|
-
const modelID = "jp.anthropic.claude-sonnet-4-20250514-v1:0"
|
|
413
|
-
const hasPrefix = crossRegionPrefixes.some((prefix) => modelID.startsWith(prefix))
|
|
414
|
-
expect(hasPrefix).toBe(true)
|
|
415
|
-
})
|
|
416
|
-
|
|
417
|
-
test("should detect apac. prefix", () => {
|
|
418
|
-
const modelID = "apac.anthropic.claude-sonnet-4-20250514-v1:0"
|
|
419
|
-
const hasPrefix = crossRegionPrefixes.some((prefix) => modelID.startsWith(prefix))
|
|
420
|
-
expect(hasPrefix).toBe(true)
|
|
421
|
-
})
|
|
422
|
-
|
|
423
|
-
test("should detect au. prefix", () => {
|
|
424
|
-
const modelID = "au.anthropic.claude-sonnet-4-5-20250929-v1:0"
|
|
425
|
-
const hasPrefix = crossRegionPrefixes.some((prefix) => modelID.startsWith(prefix))
|
|
426
|
-
expect(hasPrefix).toBe(true)
|
|
427
|
-
})
|
|
428
|
-
|
|
429
|
-
test("should NOT detect prefix for non-prefixed model", () => {
|
|
430
|
-
const modelID = "anthropic.claude-opus-4-5-20251101-v1:0"
|
|
431
|
-
const hasPrefix = crossRegionPrefixes.some((prefix) => modelID.startsWith(prefix))
|
|
432
|
-
expect(hasPrefix).toBe(false)
|
|
433
|
-
})
|
|
434
|
-
|
|
435
|
-
test("should NOT detect prefix for amazon nova models", () => {
|
|
436
|
-
const modelID = "amazon.nova-pro-v1:0"
|
|
437
|
-
const hasPrefix = crossRegionPrefixes.some((prefix) => modelID.startsWith(prefix))
|
|
438
|
-
expect(hasPrefix).toBe(false)
|
|
439
|
-
})
|
|
440
|
-
|
|
441
|
-
test("should NOT detect prefix for cohere models", () => {
|
|
442
|
-
const modelID = "cohere.command-r-plus-v1:0"
|
|
443
|
-
const hasPrefix = crossRegionPrefixes.some((prefix) => modelID.startsWith(prefix))
|
|
444
|
-
expect(hasPrefix).toBe(false)
|
|
445
|
-
})
|
|
446
|
-
})
|