chore: generate
This commit is contained in:
@@ -7,7 +7,15 @@ import { asSchema, type ModelMessage, type Tool } from "ai"
|
||||
import { Cause, Effect, FiberSet, Queue } from "effect"
|
||||
import * as Stream from "effect/Stream"
|
||||
import { FetchHttpClient } from "effect/unstable/http"
|
||||
import { LLMRequest, Tool as NativeTool, ToolFailure, ToolRuntime, toDefinitions, type JsonSchema, type LLMEvent } from "@opencode-ai/llm"
|
||||
import {
|
||||
LLMRequest,
|
||||
Tool as NativeTool,
|
||||
ToolFailure,
|
||||
ToolRuntime,
|
||||
toDefinitions,
|
||||
type JsonSchema,
|
||||
type LLMEvent,
|
||||
} from "@opencode-ai/llm"
|
||||
import type { LLMClientShape } from "@opencode-ai/llm/route"
|
||||
import { LLMNative } from "./native-request"
|
||||
|
||||
@@ -80,17 +88,17 @@ export function stream(input: StreamInput): StreamResult {
|
||||
// translation belongs here, not split across both packages.
|
||||
const tools = nativeTools(input.tools, input)
|
||||
const request = LLMNative.request({
|
||||
model: input.model,
|
||||
apiKey: current.apiKey,
|
||||
baseURL: current.baseURL,
|
||||
messages: ProviderTransform.message(input.messages, input.model, input.providerOptions ?? {}),
|
||||
toolChoice: input.toolChoice,
|
||||
temperature: input.temperature,
|
||||
topP: input.topP,
|
||||
topK: input.topK,
|
||||
maxOutputTokens: input.maxOutputTokens,
|
||||
providerOptions: ProviderTransform.providerOptions(input.model, input.providerOptions ?? {}),
|
||||
headers: { ...providerHeaders(input.provider.options.headers), ...input.headers },
|
||||
model: input.model,
|
||||
apiKey: current.apiKey,
|
||||
baseURL: current.baseURL,
|
||||
messages: ProviderTransform.message(input.messages, input.model, input.providerOptions ?? {}),
|
||||
toolChoice: input.toolChoice,
|
||||
temperature: input.temperature,
|
||||
topP: input.topP,
|
||||
topK: input.topK,
|
||||
maxOutputTokens: input.maxOutputTokens,
|
||||
providerOptions: ProviderTransform.providerOptions(input.model, input.providerOptions ?? {}),
|
||||
headers: { ...providerHeaders(input.provider.options.headers), ...input.headers },
|
||||
})
|
||||
const stream = Stream.scoped(
|
||||
Stream.unwrap(
|
||||
|
||||
@@ -426,7 +426,9 @@ export const layer = Layer.effect(
|
||||
case "tool-input-delta":
|
||||
{
|
||||
const toolCall = yield* ensureToolCall(value)
|
||||
const assistantMessageID = flags.experimentalEventSystem ? yield* requireV2AssistantMessage(toolCall.call) : undefined
|
||||
const assistantMessageID = flags.experimentalEventSystem
|
||||
? yield* requireV2AssistantMessage(toolCall.call)
|
||||
: undefined
|
||||
if (assistantMessageID) {
|
||||
yield* events.publish(SessionEvent.Tool.Input.Delta, {
|
||||
sessionID: ctx.sessionID,
|
||||
@@ -589,12 +591,19 @@ export const layer = Layer.effect(
|
||||
const content = [
|
||||
ToolOutput.text({ type: "text", text: output.output }),
|
||||
...(output.attachments?.map((item: SessionV1.FilePart) =>
|
||||
ToolOutput.file({ type: "file", source: toolFileSourceFromUri(item.url), mime: item.mime, name: item.filename }),
|
||||
ToolOutput.file({
|
||||
type: "file",
|
||||
source: toolFileSourceFromUri(item.url),
|
||||
mime: item.mime,
|
||||
name: item.filename,
|
||||
}),
|
||||
) ?? []),
|
||||
]
|
||||
const unsupported = content.find((item) => item.type === "file" && item.source.type !== "data")
|
||||
if (unsupported?.type === "file") {
|
||||
const error = new Error(`Tool attachment source "${unsupported.source.type}" must be materialized before durable V2 settlement`)
|
||||
const error = new Error(
|
||||
`Tool attachment source "${unsupported.source.type}" must be materialized before durable V2 settlement`,
|
||||
)
|
||||
yield* events.publish(SessionEvent.Tool.Failed, {
|
||||
sessionID: ctx.sessionID,
|
||||
assistantMessageID,
|
||||
@@ -611,19 +620,20 @@ export const layer = Layer.effect(
|
||||
})
|
||||
yield* failToolCall(value.id, error)
|
||||
return
|
||||
} else yield* events.publish(SessionEvent.Tool.Success, {
|
||||
sessionID: ctx.sessionID,
|
||||
assistantMessageID,
|
||||
callID: value.id,
|
||||
structured: output.metadata,
|
||||
content,
|
||||
result: value.result,
|
||||
provider: {
|
||||
executed: value.providerExecuted === true || toolCall?.part.metadata?.providerExecuted === true,
|
||||
...(value.providerMetadata ? { metadata: value.providerMetadata } : {}),
|
||||
},
|
||||
timestamp: DateTime.makeUnsafe(Date.now()),
|
||||
})
|
||||
} else
|
||||
yield* events.publish(SessionEvent.Tool.Success, {
|
||||
sessionID: ctx.sessionID,
|
||||
assistantMessageID,
|
||||
callID: value.id,
|
||||
structured: output.metadata,
|
||||
content,
|
||||
result: value.result,
|
||||
provider: {
|
||||
executed: value.providerExecuted === true || toolCall?.part.metadata?.providerExecuted === true,
|
||||
...(value.providerMetadata ? { metadata: value.providerMetadata } : {}),
|
||||
},
|
||||
timestamp: DateTime.makeUnsafe(Date.now()),
|
||||
})
|
||||
}
|
||||
yield* completeToolCall(value.id, output)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user