fix: remove 8 more unnecessary as any casts in opencode core (#22877)
This commit is contained in:
@@ -178,7 +178,7 @@ export namespace ACP {
|
|||||||
})
|
})
|
||||||
for await (const event of events.stream) {
|
for await (const event of events.stream) {
|
||||||
if (this.eventAbort.signal.aborted) return
|
if (this.eventAbort.signal.aborted) return
|
||||||
const payload = (event as any)?.payload
|
const payload = event?.payload
|
||||||
if (!payload) continue
|
if (!payload) continue
|
||||||
await this.handleEvent(payload as Event).catch((error) => {
|
await this.handleEvent(payload as Event).catch((error) => {
|
||||||
log.error("failed to handle event", { error, type: payload.type })
|
log.error("failed to handle event", { error, type: payload.type })
|
||||||
|
|||||||
@@ -297,7 +297,9 @@ export const ProvidersLoginCommand = cmd({
|
|||||||
prompts.intro("Add credential")
|
prompts.intro("Add credential")
|
||||||
if (args.url) {
|
if (args.url) {
|
||||||
const url = args.url.replace(/\/+$/, "")
|
const url = args.url.replace(/\/+$/, "")
|
||||||
const wellknown = await fetch(`${url}/.well-known/opencode`).then((x) => x.json() as any)
|
const wellknown = (await fetch(`${url}/.well-known/opencode`).then((x) => x.json())) as {
|
||||||
|
auth: { command: string[]; env: string }
|
||||||
|
}
|
||||||
prompts.log.info(`Running \`${wellknown.auth.command.join(" ")}\``)
|
prompts.log.info(`Running \`${wellknown.auth.command.join(" ")}\``)
|
||||||
const proc = Process.spawn(wellknown.auth.command, {
|
const proc = Process.spawn(wellknown.auth.command, {
|
||||||
stdout: "pipe",
|
stdout: "pipe",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { dlopen, ptr } from "bun:ffi"
|
import { dlopen, ptr } from "bun:ffi"
|
||||||
|
import type { ReadStream } from "node:tty"
|
||||||
|
|
||||||
const STD_INPUT_HANDLE = -10
|
const STD_INPUT_HANDLE = -10
|
||||||
const ENABLE_PROCESSED_INPUT = 0x0001
|
const ENABLE_PROCESSED_INPUT = 0x0001
|
||||||
@@ -71,7 +72,7 @@ export function win32InstallCtrlCGuard() {
|
|||||||
if (!load()) return
|
if (!load()) return
|
||||||
if (unhook) return unhook
|
if (unhook) return unhook
|
||||||
|
|
||||||
const stdin = process.stdin as any
|
const stdin = process.stdin as ReadStream
|
||||||
const original = stdin.setRawMode
|
const original = stdin.setRawMode
|
||||||
|
|
||||||
const handle = k32!.symbols.GetStdHandle(STD_INPUT_HANDLE)
|
const handle = k32!.symbols.GetStdHandle(STD_INPUT_HANDLE)
|
||||||
@@ -93,7 +94,7 @@ export function win32InstallCtrlCGuard() {
|
|||||||
setImmediate(enforce)
|
setImmediate(enforce)
|
||||||
}
|
}
|
||||||
|
|
||||||
let wrapped: ((mode: boolean) => unknown) | undefined
|
let wrapped: ReadStream["setRawMode"] | undefined
|
||||||
|
|
||||||
if (typeof original === "function") {
|
if (typeof original === "function") {
|
||||||
wrapped = (mode: boolean) => {
|
wrapped = (mode: boolean) => {
|
||||||
|
|||||||
@@ -465,12 +465,12 @@ export const layer = Layer.effect(
|
|||||||
direction: "callHierarchy/incomingCalls" | "callHierarchy/outgoingCalls",
|
direction: "callHierarchy/incomingCalls" | "callHierarchy/outgoingCalls",
|
||||||
) {
|
) {
|
||||||
const results = yield* run(input.file, async (client) => {
|
const results = yield* run(input.file, async (client) => {
|
||||||
const items = (await client.connection
|
const items = await client.connection
|
||||||
.sendRequest("textDocument/prepareCallHierarchy", {
|
.sendRequest<unknown[] | null>("textDocument/prepareCallHierarchy", {
|
||||||
textDocument: { uri: pathToFileURL(input.file).href },
|
textDocument: { uri: pathToFileURL(input.file).href },
|
||||||
position: { line: input.line, character: input.character },
|
position: { line: input.line, character: input.character },
|
||||||
})
|
})
|
||||||
.catch(() => [])) as any[]
|
.catch(() => [] as unknown[])
|
||||||
if (!items?.length) return []
|
if (!items?.length) return []
|
||||||
return client.connection.sendRequest(direction, { item: items[0] }).catch(() => [])
|
return client.connection.sendRequest(direction, { item: items[0] }).catch(() => [])
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -531,7 +531,7 @@ export const layer = Layer.effect(
|
|||||||
Object.values(s.clients),
|
Object.values(s.clients),
|
||||||
(client) =>
|
(client) =>
|
||||||
Effect.gen(function* () {
|
Effect.gen(function* () {
|
||||||
const pid = (client.transport as any)?.pid
|
const pid = client.transport instanceof StdioClientTransport ? client.transport.pid : null
|
||||||
if (typeof pid === "number") {
|
if (typeof pid === "number") {
|
||||||
const pids = yield* descendants(pid)
|
const pids = yield* descendants(pid)
|
||||||
for (const dpid of pids) {
|
for (const dpid of pids) {
|
||||||
|
|||||||
+2
-2
@@ -354,7 +354,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
|
|||||||
details: "flex processing is only available for o3, o4-mini, and gpt-5 models",
|
details: "flex processing is only available for o3, o4-mini, and gpt-5 models",
|
||||||
})
|
})
|
||||||
// Remove from args if not supported
|
// Remove from args if not supported
|
||||||
delete (baseArgs as any).service_tier
|
baseArgs.service_tier = undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate priority processing support
|
// Validate priority processing support
|
||||||
@@ -366,7 +366,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
|
|||||||
"priority processing is only available for supported models (gpt-4, gpt-5, gpt-5-mini, o3, o4-mini) and requires Enterprise access. gpt-5-nano is not supported",
|
"priority processing is only available for supported models (gpt-4, gpt-5, gpt-5-mini, o3, o4-mini) and requires Enterprise access. gpt-5-nano is not supported",
|
||||||
})
|
})
|
||||||
// Remove from args if not supported
|
// Remove from args if not supported
|
||||||
delete (baseArgs as any).service_tier
|
baseArgs.service_tier = undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ function normalizeMessages(
|
|||||||
providerOptions: {
|
providerOptions: {
|
||||||
...msg.providerOptions,
|
...msg.providerOptions,
|
||||||
openaiCompatible: {
|
openaiCompatible: {
|
||||||
...(msg.providerOptions as any)?.openaiCompatible,
|
...msg.providerOptions?.openaiCompatible,
|
||||||
[field]: reasoningText,
|
[field]: reasoningText,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -77,8 +77,8 @@ function union(ast: SchemaAST.Union): z.ZodTypeAny {
|
|||||||
if (items.length === 1) return items[0]
|
if (items.length === 1) return items[0]
|
||||||
if (items.length < 2) return fail(ast)
|
if (items.length < 2) return fail(ast)
|
||||||
|
|
||||||
const discriminator = (ast as any).annotations?.discriminator
|
const discriminator = ast.annotations?.discriminator
|
||||||
if (discriminator) {
|
if (typeof discriminator === "string") {
|
||||||
return z.discriminatedUnion(discriminator, items as [z.ZodObject<any>, z.ZodObject<any>, ...z.ZodObject<any>[]])
|
return z.discriminatedUnion(discriminator, items as [z.ZodObject<any>, z.ZodObject<any>, ...z.ZodObject<any>[]])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user