fix(core): clean up Effect audit patterns (#35174)

This commit is contained in:
Kit Langton 2026-07-03 13:54:13 -04:00 committed by GitHub
commit 1b88ff8d53
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 118 additions and 62 deletions

View file

@ -438,7 +438,7 @@ function insertMessage(db: DatabaseService, event: SessionEvent.DurableEvent, me
const layer = Layer.effectDiscard(
Effect.gen(function* () {
const events = yield* EventV2.Service
const { db } = yield* Database.Service
const db = (yield* Database.Service).db
yield* events.project(SessionV1.Event.Created, (event) =>
Effect.gen(function* () {
const stored = yield* db

View file

@ -7,6 +7,7 @@ import {
type Model,
type ProviderMetadata,
} from "@opencode-ai/llm"
import { Option, Schema } from "effect"
import { SessionMessage } from "../message"
import type { FileAttachment } from "../prompt"
@ -18,14 +19,12 @@ const media = (file: FileAttachment): ContentPart => ({
metadata: file.description === undefined ? undefined : { description: file.description },
})
const toolInput = (tool: SessionMessage.AssistantTool) => {
if (tool.state.status !== "pending") return tool.state.input
try {
return JSON.parse(tool.state.input) as unknown
} catch {
return tool.state.input
}
}
const decodeToolInput = Schema.decodeUnknownOption(Schema.UnknownFromJsonString)
const toolInput = (tool: SessionMessage.AssistantTool) =>
tool.state.status === "pending"
? Option.getOrElse(decodeToolInput(tool.state.input), () => tool.state.input)
: tool.state.input
const toolCall = (tool: SessionMessage.AssistantTool, providerMetadata: ProviderMetadata | undefined): ContentPart =>
ToolCallPart.make({