GeezerVison is showing github.com — fix: provide EffectLogger.layer to bare Effect.runPromise/runFork cal… · ildella/opencode@5917ac2
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/bus/index.ts +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import z from "zod" | 2 | 2 | import { Effect, Exit, Layer, PubSub, Scope, ServiceMap, Stream } from "effect" | | 3 | +import { EffectLogger } from "@/effect/logger" | 3 | 4 | import { Log } from "../util/log" | 4 | 5 | import { BusEvent } from "./bus-event" | 5 | 6 | import { GlobalBus } from "./global" | @@ -146,7 +147,7 @@ export namespace Bus { | 146 | 147 |
| 147 | 148 | return () => { | 148 | 149 | log.info("unsubscribing", { type }) | 149 | | - Effect.runFork(Scope.close(scope, Exit.void)) | | 150 | + Effect.runFork(Scope.close(scope, Exit.void).pipe(Effect.provide(EffectLogger.layer))) | 150 | 151 | } | 151 | 152 | }) | 152 | 153 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/command/index.ts +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3,6 +3,7 @@ import { InstanceState } from "@/effect/instance-state" | 3 | 3 | import { makeRuntime } from "@/effect/run-service" | 4 | 4 | import { SessionID, MessageID } from "@/session/schema" | 5 | 5 | import { Effect, Layer, ServiceMap } from "effect" | | 6 | +import { EffectLogger } from "@/effect/logger" | 6 | 7 | import z from "zod" | 7 | 8 | import { Config } from "../config/config" | 8 | 9 | import { MCP } from "../mcp" | @@ -140,6 +141,7 @@ export namespace Command { | 140 | 141 | .map((message) => (message.content.type === "text" ? message.content.text : "")) | 141 | 142 | .join("\n") || "", | 142 | 143 | ), | | 144 | + Effect.provide(EffectLogger.layer), | 143 | 145 | ), | 144 | 146 | ) | 145 | 147 | }, | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/effect/instance-state.ts +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { Effect, Fiber, ScopedCache, Scope, ServiceMap } from "effect" | | 2 | +import { EffectLogger } from "@/effect/logger" | 2 | 3 | import { Instance, type InstanceContext } from "@/project/instance" | 3 | 4 | import { Context } from "@/util/context" | 4 | 5 | import { InstanceRef, WorkspaceRef } from "./instance-ref" | @@ -47,7 +48,7 @@ export namespace InstanceState { | 47 | 48 | }), | 48 | 49 | }) | 49 | 50 |
| 50 | | - const off = registerDisposer((directory) => Effect.runPromise(ScopedCache.invalidate(cache, directory))) | | 51 | + const off = registerDisposer((directory) => Effect.runPromise(ScopedCache.invalidate(cache, directory).pipe(Effect.provide(EffectLogger.layer)))) | 51 | 52 | yield* Effect.addFinalizer(() => Effect.sync(off)) | 52 | 53 |
| 53 | 54 | return { | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/mcp/index.ts +3-2Lines changed: 3 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -25,6 +25,7 @@ import { Bus } from "@/bus" | 25 | 25 | import { TuiEvent } from "@/cli/cmd/tui/event" | 26 | 26 | import open from "open" | 27 | 27 | import { Effect, Exit, Layer, Option, ServiceMap, Stream } from "effect" | | 28 | +import { EffectLogger } from "@/effect/logger" | 28 | 29 | import { InstanceState } from "@/effect/instance-state" | 29 | 30 | import { makeRuntime } from "@/effect/run-service" | 30 | 31 | import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process" | @@ -469,12 +470,12 @@ export namespace MCP { | 469 | 470 | log.info("tools list changed notification received", { server: name }) | 470 | 471 | if (s.clients[name] !== client || s.status[name]?.status !== "connected") return | 471 | 472 |
| 472 | | - const listed = await Effect.runPromise(defs(name, client, timeout)) | | 473 | + const listed = await Effect.runPromise(defs(name, client, timeout).pipe(Effect.provide(EffectLogger.layer))) | 473 | 474 | if (!listed) return | 474 | 475 | if (s.clients[name] !== client || s.status[name]?.status !== "connected") return | 475 | 476 |
| 476 | 477 | s.defs[name] = listed | 477 | | - await Effect.runPromise(bus.publish(ToolsChanged, { server: name }).pipe(Effect.ignore)) | | 478 | + await Effect.runPromise(bus.publish(ToolsChanged, { server: name }).pipe(Effect.ignore, Effect.provide(EffectLogger.layer))) | 478 | 479 | }) | 479 | 480 | } | 480 | 481 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/plugin/index.ts +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,6 +12,7 @@ import { gitlabAuthPlugin as GitlabAuthPlugin } from "opencode-gitlab-auth" | 12 | 12 | import { PoeAuthPlugin } from "opencode-poe-auth" | 13 | 13 | import { CloudflareAIGatewayAuthPlugin, CloudflareWorkersAuthPlugin } from "./cloudflare" | 14 | 14 | import { Effect, Layer, ServiceMap, Stream } from "effect" | | 15 | +import { EffectLogger } from "@/effect/logger" | 15 | 16 | import { InstanceState } from "@/effect/instance-state" | 16 | 17 | import { makeRuntime } from "@/effect/run-service" | 17 | 18 | import { errorMessage } from "@/util/error" | @@ -83,7 +84,7 @@ export namespace Plugin { | 83 | 84 | } | 84 | 85 |
| 85 | 86 | function publishPluginError(bus: Bus.Interface, message: string) { | 86 | | - Effect.runFork(bus.publish(Session.Event.Error, { error: new NamedError.Unknown({ message }).toObject() })) | | 87 | + Effect.runFork(bus.publish(Session.Event.Error, { error: new NamedError.Unknown({ message }).toObject() }).pipe(Effect.provide(EffectLogger.layer))) | 87 | 88 | } | 88 | 89 |
| 89 | 90 | async function applyPlugin(load: PluginLoader.Loaded, input: PluginInput, hooks: Hooks[]) { | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/provider/provider.ts +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -20,6 +20,7 @@ import { Global } from "../global" | 20 | 20 | import path from "path" | 21 | 21 | import { Filesystem } from "../util/filesystem" | 22 | 22 | import { Effect, Layer, ServiceMap } from "effect" | | 23 | +import { EffectLogger } from "@/effect/logger" | 23 | 24 | import { InstanceState } from "@/effect/instance-state" | 24 | 25 | import { makeRuntime } from "@/effect/run-service" | 25 | 26 |
| @@ -1215,7 +1216,7 @@ export namespace Provider { | 1215 | 1216 |
| 1216 | 1217 | const options = yield* Effect.promise(() => | 1217 | 1218 | plugin.auth!.loader!( | 1218 | | - () => Effect.runPromise(auth.get(providerID).pipe(Effect.orDie)) as any, | | 1219 | + () => Effect.runPromise(auth.get(providerID).pipe(Effect.orDie, Effect.provide(EffectLogger.layer))) as any, | 1219 | 1220 | database[plugin.auth!.provider], | 1220 | 1221 | ), | 1221 | 1222 | ) | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/pty/index.ts +3-2Lines changed: 3 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,6 +11,7 @@ import { Shell } from "@/shell/shell" | 11 | 11 | import { Plugin } from "@/plugin" | 12 | 12 | import { PtyID } from "./schema" | 13 | 13 | import { Effect, Layer, ServiceMap } from "effect" | | 14 | +import { EffectLogger } from "@/effect/logger" | 14 | 15 |
| 15 | 16 | export namespace Pty { | 16 | 17 | const log = Log.create({ service: "pty" }) | @@ -256,8 +257,8 @@ export namespace Pty { | 256 | 257 | if (session.info.status === "exited") return | 257 | 258 | log.info("session exited", { id, exitCode }) | 258 | 259 | session.info.status = "exited" | 259 | | - Effect.runFork(bus.publish(Event.Exited, { id, exitCode })) | 260 | | - Effect.runFork(remove(id)) | | 260 | + Effect.runFork(bus.publish(Event.Exited, { id, exitCode }).pipe(Effect.provide(EffectLogger.layer))) | | 261 | + Effect.runFork(remove(id).pipe(Effect.provide(EffectLogger.layer))) | 261 | 262 | }), | 262 | 263 | ) | 263 | 264 | yield* bus.publish(Event.Created, { info }) | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/session/message-v2.ts +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -15,6 +15,7 @@ import type { SystemError } from "bun" | 15 | 15 | import type { Provider } from "@/provider/provider" | 16 | 16 | import { ModelID, ProviderID } from "@/provider/schema" | 17 | 17 | import { Effect } from "effect" | | 18 | +import { EffectLogger } from "@/effect/logger" | 18 | 19 |
| 19 | 20 | /** Error shape thrown by Bun's fetch() when gzip/br decompression fails mid-stream */ | 20 | 21 | interface FetchDecompressionError extends Error { | @@ -839,7 +840,7 @@ export namespace MessageV2 { | 839 | 840 | model: Provider.Model, | 840 | 841 | options?: { stripMedia?: boolean }, | 841 | 842 | ): Promise<ModelMessage[]> { | 842 | | - return Effect.runPromise(toModelMessagesEffect(input, model, options)) | | 843 | + return Effect.runPromise(toModelMessagesEffect(input, model, options).pipe(Effect.provide(EffectLogger.layer))) | 843 | 844 | } | 844 | 845 |
| 845 | 846 | export function page(input: { sessionID: SessionID; limit: number; before?: string }) { | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/tool/external-directory.ts +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import path from "path" | 2 | 2 | import { Effect } from "effect" | | 3 | +import { EffectLogger } from "@/effect/logger" | 3 | 4 | import type { Tool } from "./tool" | 4 | 5 | import { Instance } from "../project/instance" | 5 | 6 | import { AppFileSystem } from "../filesystem" | @@ -42,5 +43,5 @@ export const assertExternalDirectoryEffect = Effect.fn("Tool.assertExternalDirec | 42 | 43 | }) | 43 | 44 |
| 44 | 45 | export async function assertExternalDirectory(ctx: Tool.Context, target?: string, options?: Options) { | 45 | | - return Effect.runPromise(assertExternalDirectoryEffect(ctx, target, options)) | | 46 | + return Effect.runPromise(assertExternalDirectoryEffect(ctx, target, options).pipe(Effect.provide(EffectLogger.layer))) | 46 | 47 | } |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/tool/registry.ts +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -30,6 +30,7 @@ import { Glob } from "../util/glob" | 30 | 30 | import path from "path" | 31 | 31 | import { pathToFileURL } from "url" | 32 | 32 | import { Effect, Layer, ServiceMap } from "effect" | | 33 | +import { EffectLogger } from "@/effect/logger" | 33 | 34 | import { FetchHttpClient, HttpClient } from "effect/unstable/http" | 34 | 35 | import { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner" | 35 | 36 | import * as CrossSpawnSpawner from "@/effect/cross-spawn-spawner" | @@ -136,7 +137,7 @@ export namespace ToolRegistry { | 136 | 137 | Effect.gen(function* () { | 137 | 138 | const pluginCtx: PluginToolContext = { | 138 | 139 | ...toolCtx, | 139 | | - ask: (req) => Effect.runPromise(toolCtx.ask(req)), | | 140 | + ask: (req) => Effect.runPromise(toolCtx.ask(req).pipe(Effect.provide(EffectLogger.layer))), | 140 | 141 | directory: ctx.directory, | 141 | 142 | worktree: ctx.worktree, | 142 | 143 | } | |
|