refactor(ai): name provider turn operations

This commit is contained in:
Shoubhit Dash 2026-07-24 23:42:46 +05:30
commit 16df2467fd
11 changed files with 30 additions and 26 deletions

View file

@ -23,6 +23,10 @@ import * as AnthropicMessages from "@opencode-ai/ai/protocols/anthropic-messages
describe("public exports", () => {
test("root exposes app-facing runtime APIs", () => {
expect(LLM.request).toBeFunction()
expect(LLM.generateTurn).toBeFunction()
expect(LLM.streamTurn).toBeFunction()
expect(LLM).not.toHaveProperty("generate")
expect(LLM).not.toHaveProperty("stream")
expect(LLMClient.Service).toBeFunction()
expect(LLMClient.layer).toBeDefined()
expect(ImageInput.bytes).toBeFunction()

View file

@ -47,7 +47,7 @@ describe("Cloudflare", () => {
it.effect("posts to the derived gateway endpoint with bearer auth", () =>
Effect.gen(function* () {
const response = yield* LLM.generate(
const response = yield* LLM.generateTurn(
LLM.request({
model: CloudflareAIGateway.configure({
accountId: "test-account",
@ -104,7 +104,7 @@ describe("Cloudflare", () => {
index: 0,
},
]
const response = yield* LLM.generate(LLM.request({ model, prompt: "Say hello." })).pipe(
const response = yield* LLM.generateTurn(LLM.request({ model, prompt: "Say hello." })).pipe(
Effect.provide(
dynamicResponse((input) =>
Effect.succeed(
@ -150,7 +150,7 @@ describe("Cloudflare", () => {
it.effect("supports authenticated AI Gateway plus upstream provider auth", () =>
Effect.gen(function* () {
yield* LLM.generate(
yield* LLM.generateTurn(
LLM.request({
model: CloudflareAIGateway.configure({
accountId: "test-account",
@ -221,7 +221,7 @@ describe("Cloudflare", () => {
it.effect("posts direct Workers AI requests to the account endpoint with bearer auth", () =>
Effect.gen(function* () {
const response = yield* LLM.generate(
const response = yield* LLM.generateTurn(
LLM.request({
model: CloudflareWorkersAI.configure({
accountId: "test-account",
@ -256,7 +256,7 @@ describe("Cloudflare", () => {
it.effect("supports direct Workers AI token aliases through auth config", () =>
Effect.gen(function* () {
yield* LLM.generate(
yield* LLM.generateTurn(
LLM.request({
model: CloudflareWorkersAI.configure({
accountId: "test-account",

View file

@ -29,7 +29,7 @@ describe("OpenAI Responses image generation recorded", () => {
partialImages: 0,
}),
]
const response = yield* LLM.generate(
const response = yield* LLM.generateTurn(
LLM.request({
model: openai.responses("gpt-5-mini"),
messages: [initial],
@ -49,7 +49,7 @@ describe("OpenAI Responses image generation recorded", () => {
expect(result.result.value[0].mime).toBe("image/jpeg")
expect(result.result.value[0].uri.startsWith("data:image/jpeg;base64,")).toBe(true)
const edited = yield* LLM.generate(
const edited = yield* LLM.generateTurn(
LLM.request({
model: openai.responses("gpt-5-mini"),
messages: [initial, response.message, Message.user("Now make the triangle blue.")],

View file

@ -32,9 +32,9 @@ Tool.make({
],
})
LLM.stream(request)
LLM.generate(LLMRequest.update(request, { tools: toDefinitions({ schemaOnly }) }))
LLM.streamTurn(request)
LLM.generateTurn(LLMRequest.update(request, { tools: toDefinitions({ schemaOnly }) }))
ToolRuntime.dispatch({ executable }, { type: "tool-call", id: "call_1", name: "executable", input: { city: "Paris" } })
// @ts-expect-error High-level tool orchestration overloads are intentionally not supported.
LLM.stream({ request, tools: { schemaOnly } })
LLM.streamTurn({ request, tools: { schemaOnly } })