mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-15 12:41:37 +03:00
refactor(core): validate codemode fetch display args and drop unused catalog schema (#57959)
This commit is contained in:
committed by
GitHub
Unverified
parent
d26b612066
commit
248bfbe111
@@ -2,14 +2,13 @@ export * as CodeModeCatalog from "./catalog.js"
|
||||
|
||||
import { Schema } from "effect"
|
||||
|
||||
export const Tool = Schema.Struct({
|
||||
type: Schema.Literal("tool"),
|
||||
name: Schema.String,
|
||||
description: Schema.String,
|
||||
signature: Schema.String,
|
||||
pinned: Schema.optionalKey(Schema.Boolean),
|
||||
})
|
||||
export type Tool = typeof Tool.Type
|
||||
export type Tool = {
|
||||
readonly type: "tool"
|
||||
readonly name: string
|
||||
readonly description: string
|
||||
readonly signature: string
|
||||
readonly pinned?: boolean
|
||||
}
|
||||
|
||||
export type Namespace = {
|
||||
readonly type: "namespace"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
export * as CodeModeWeb from "./web.js"
|
||||
|
||||
import { Extension } from "@opencode/codemode"
|
||||
import { isRecord } from "@opencode/ai/utils/record"
|
||||
|
||||
const TIMEOUT_MS = 30_000
|
||||
|
||||
@@ -43,6 +44,7 @@ export const extension = Extension.make({ name: "web", globals: { fetch } })
|
||||
|
||||
/** What to show for a fetch call: its method and URL. */
|
||||
export const display = (args: ReadonlyArray<unknown>) => {
|
||||
const [input, init] = args as [string | URL, Init | undefined]
|
||||
return { method: init?.method?.toUpperCase() ?? "GET", url: String(input) }
|
||||
const [input, init] = args
|
||||
const method = isRecord(init) && typeof init.method === "string" ? init.method.toUpperCase() : "GET"
|
||||
return { method, url: String(input) }
|
||||
}
|
||||
|
||||
@@ -93,19 +93,10 @@ export const Info = Schema.Struct({
|
||||
setCacheKey: Schema.optional(Schema.Boolean).annotate({
|
||||
description: "Enable promptCacheKey for this provider (default false)",
|
||||
}),
|
||||
timeout: Schema.optional(
|
||||
Schema.Union([PositiveInt, Schema.Literal(false)]).annotate({
|
||||
description: "Timeout in milliseconds for full requests to this provider. Set to false to disable timeout.",
|
||||
}),
|
||||
).annotate({
|
||||
timeout: Schema.optional(Schema.Union([PositiveInt, Schema.Literal(false)])).annotate({
|
||||
description: "Timeout in milliseconds for full requests to this provider. Set to false to disable timeout.",
|
||||
}),
|
||||
headerTimeout: Schema.optional(
|
||||
Schema.Union([PositiveInt, Schema.Literal(false)]).annotate({
|
||||
description:
|
||||
"Timeout in milliseconds to wait for response headers. Provider integrations may set defaults. Set to false to disable timeout.",
|
||||
}),
|
||||
).annotate({
|
||||
headerTimeout: Schema.optional(Schema.Union([PositiveInt, Schema.Literal(false)])).annotate({
|
||||
description:
|
||||
"Timeout in milliseconds to wait for response headers. Provider integrations may set defaults. Set to false to disable timeout.",
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user