Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fe01fa7

Browse filesBrowse files
authored
remove makeRuntime facade from Env (anomalyco#22523)
1 parent 685d79e commit fe01fa7
Copy full SHA for fe01fa7

3 files changed

+85-96Lines changed: 85 additions & 96 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/opencode/src/env/index.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/src/env/index.ts
-19Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Context, Effect, Layer } from "effect"
22
import { InstanceState } from "@/effect/instance-state"
3-
import { makeRuntime } from "@/effect/run-service"
43

54
export namespace Env {
65
type State = Record<string, string | undefined>
@@ -35,22 +34,4 @@ export namespace Env {
3534
)
3635

3736
export const defaultLayer = layer
38-
39-
const rt = makeRuntime(Service, defaultLayer)
40-
41-
export function get(key: string) {
42-
return rt.runSync((svc) => svc.get(key))
43-
}
44-
45-
export function all() {
46-
return rt.runSync((svc) => svc.all())
47-
}
48-
49-
export function set(key: string, value: string) {
50-
return rt.runSync((svc) => svc.set(key, value))
51-
}
52-
53-
export function remove(key: string) {
54-
return rt.runSync((svc) => svc.remove(key))
55-
}
5637
}
Collapse file

‎packages/opencode/test/provider/amazon-bedrock.test.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/test/provider/amazon-bedrock.test.ts
+22-18Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import { Global } from "../../src/global"
1111
import { Filesystem } from "../../src/util/filesystem"
1212
import { Effect } from "effect"
1313
import { AppRuntime } from "../../src/effect/app-runtime"
14+
import { makeRuntime } from "../../src/effect/run-service"
15+
16+
const env = makeRuntime(Env.Service, Env.defaultLayer)
17+
const set = (k: string, v: string) => env.runSync((svc) => svc.set(k, v))
1418

1519
async function list() {
1620
return AppRuntime.runPromise(
@@ -42,8 +46,8 @@ test("Bedrock: config region takes precedence over AWS_REGION env var", async ()
4246
await Instance.provide({
4347
directory: tmp.path,
4448
init: async () => {
45-
Env.set("AWS_REGION", "us-east-1")
46-
Env.set("AWS_PROFILE", "default")
49+
set("AWS_REGION", "us-east-1")
50+
set("AWS_PROFILE", "default")
4751
},
4852
fn: async () => {
4953
const providers = await list()
@@ -67,8 +71,8 @@ test("Bedrock: falls back to AWS_REGION env var when no config region", async ()
6771
await Instance.provide({
6872
directory: tmp.path,
6973
init: async () => {
70-
Env.set("AWS_REGION", "eu-west-1")
71-
Env.set("AWS_PROFILE", "default")
74+
set("AWS_REGION", "eu-west-1")
75+
set("AWS_PROFILE", "default")
7276
},
7377
fn: async () => {
7478
const providers = await list()
@@ -122,9 +126,9 @@ test("Bedrock: loads when bearer token from auth.json is present", async () => {
122126
await Instance.provide({
123127
directory: tmp.path,
124128
init: async () => {
125-
Env.set("AWS_PROFILE", "")
126-
Env.set("AWS_ACCESS_KEY_ID", "")
127-
Env.set("AWS_BEARER_TOKEN_BEDROCK", "")
129+
set("AWS_PROFILE", "")
130+
set("AWS_ACCESS_KEY_ID", "")
131+
set("AWS_BEARER_TOKEN_BEDROCK", "")
128132
},
129133
fn: async () => {
130134
const providers = await list()
@@ -168,8 +172,8 @@ test("Bedrock: config profile takes precedence over AWS_PROFILE env var", async
168172
await Instance.provide({
169173
directory: tmp.path,
170174
init: async () => {
171-
Env.set("AWS_PROFILE", "default")
172-
Env.set("AWS_ACCESS_KEY_ID", "test-key-id")
175+
set("AWS_PROFILE", "default")
176+
set("AWS_ACCESS_KEY_ID", "test-key-id")
173177
},
174178
fn: async () => {
175179
const providers = await list()
@@ -200,7 +204,7 @@ test("Bedrock: includes custom endpoint in options when specified", async () =>
200204
await Instance.provide({
201205
directory: tmp.path,
202206
init: async () => {
203-
Env.set("AWS_PROFILE", "default")
207+
set("AWS_PROFILE", "default")
204208
},
205209
fn: async () => {
206210
const providers = await list()
@@ -233,10 +237,10 @@ test("Bedrock: autoloads when AWS_WEB_IDENTITY_TOKEN_FILE is present", async ()
233237
await Instance.provide({
234238
directory: tmp.path,
235239
init: async () => {
236-
Env.set("AWS_WEB_IDENTITY_TOKEN_FILE", "/var/run/secrets/eks.amazonaws.com/serviceaccount/token")
237-
Env.set("AWS_ROLE_ARN", "arn:aws:iam::123456789012:role/my-eks-role")
238-
Env.set("AWS_PROFILE", "")
239-
Env.set("AWS_ACCESS_KEY_ID", "")
240+
set("AWS_WEB_IDENTITY_TOKEN_FILE", "/var/run/secrets/eks.amazonaws.com/serviceaccount/token")
241+
set("AWS_ROLE_ARN", "arn:aws:iam::123456789012:role/my-eks-role")
242+
set("AWS_PROFILE", "")
243+
set("AWS_ACCESS_KEY_ID", "")
240244
},
241245
fn: async () => {
242246
const providers = await list()
@@ -276,7 +280,7 @@ test("Bedrock: model with us. prefix should not be double-prefixed", async () =>
276280
await Instance.provide({
277281
directory: tmp.path,
278282
init: async () => {
279-
Env.set("AWS_PROFILE", "default")
283+
set("AWS_PROFILE", "default")
280284
},
281285
fn: async () => {
282286
const providers = await list()
@@ -313,7 +317,7 @@ test("Bedrock: model with global. prefix should not be prefixed", async () => {
313317
await Instance.provide({
314318
directory: tmp.path,
315319
init: async () => {
316-
Env.set("AWS_PROFILE", "default")
320+
set("AWS_PROFILE", "default")
317321
},
318322
fn: async () => {
319323
const providers = await list()
@@ -349,7 +353,7 @@ test("Bedrock: model with eu. prefix should not be double-prefixed", async () =>
349353
await Instance.provide({
350354
directory: tmp.path,
351355
init: async () => {
352-
Env.set("AWS_PROFILE", "default")
356+
set("AWS_PROFILE", "default")
353357
},
354358
fn: async () => {
355359
const providers = await list()
@@ -385,7 +389,7 @@ test("Bedrock: model without prefix in US region should get us. prefix added", a
385389
await Instance.provide({
386390
directory: tmp.path,
387391
init: async () => {
388-
Env.set("AWS_PROFILE", "default")
392+
set("AWS_PROFILE", "default")
389393
},
390394
fn: async () => {
391395
const providers = await list()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.