mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-20 18:57:17 +03:00
feat(core): use freeform tool input on models that support it (#61703)
This commit is contained in:
committed by
GitHub
Unverified
parent
64bd35afa9
commit
53f2d631df
@@ -86,6 +86,7 @@ class ModelConfig extends Schema.Class<ModelConfig>("Config.Model")({
|
||||
// Partial: unset fields fall back to the base model's capabilities, then the defaults.
|
||||
capabilities: Capabilities.mapFields((fields) => ({
|
||||
tools: optional(fields.tools),
|
||||
freeform: fields.freeform,
|
||||
input: optional(fields.input),
|
||||
output: optional(fields.output),
|
||||
temperature: fields.temperature,
|
||||
|
||||
@@ -5,6 +5,7 @@ import { optional, statics } from "./schema.js"
|
||||
import { Provider } from "./provider.js"
|
||||
import { Compatibility, MaxTokensField, MediaInput, ReasoningField } from "./model-compatibility.js"
|
||||
import { Money } from "./money.js"
|
||||
import { FreeformFormat } from "./tool.js"
|
||||
import { ephemeral, inventory } from "./event.js"
|
||||
|
||||
export const ID = Schema.String.pipe(Schema.brand("Model.ID"))
|
||||
@@ -77,6 +78,8 @@ export const Overlays = {
|
||||
export interface Capabilities extends Schema.Schema.Type<typeof Capabilities> {}
|
||||
export const Capabilities = Schema.Struct({
|
||||
tools: Schema.Boolean,
|
||||
/** Freeform tool input formats advertised by the selected API. Absent or empty means JSON tools only. */
|
||||
freeform: Schema.Array(FreeformFormat).pipe(optional),
|
||||
input: Schema.Array(Schema.String),
|
||||
output: Schema.Array(Schema.String),
|
||||
/** Whether the model accepts a sampling temperature. Unknown when unset. */
|
||||
|
||||
@@ -8,6 +8,18 @@ import type { SessionMessage } from "./session-message.js"
|
||||
|
||||
export type Metadata = Readonly<Record<string, any>>
|
||||
|
||||
/** Optional wire encoding of a tool's single required string field. Execution still receives the object. */
|
||||
export const Freeform = Schema.Union([
|
||||
Schema.Struct({ type: Schema.Literal("text") }),
|
||||
Schema.Struct({ type: Schema.Literal("regex"), pattern: Schema.String }),
|
||||
Schema.Struct({ type: Schema.Literal("lark"), grammar: Schema.String }),
|
||||
]).annotate({ identifier: "Tool.Freeform" })
|
||||
export type Freeform = typeof Freeform.Type
|
||||
|
||||
export const FreeformFormat = Schema.Literals(Freeform.members.map((member) => member.fields.type.literal)).annotate({
|
||||
identifier: "Tool.FreeformFormat",
|
||||
})
|
||||
|
||||
export const CallID = Schema.String.pipe(Schema.brand("Tool.CallID"))
|
||||
export type CallID = typeof CallID.Type
|
||||
|
||||
@@ -100,6 +112,7 @@ export type Info<
|
||||
> = {
|
||||
readonly name: string
|
||||
readonly input: Input
|
||||
readonly freeform?: Freeform
|
||||
readonly description: string
|
||||
readonly execute: (input: InputValue<Input>, context: Context) => Effect.Effect<Result<Output>, Error>
|
||||
readonly output?: Output
|
||||
|
||||
Reference in New Issue
Block a user