mirror of
https://github.com/anomalyco/opencode.git
synced 2026-04-28 04:29:42 +00:00
chore: generate
This commit is contained in:
parent
3910a6e527
commit
3f8c659056
6 changed files with 42 additions and 16 deletions
|
|
@ -27,7 +27,10 @@ export const ApplyPatchTool = Tool.define(
|
|||
const format = yield* Format.Service
|
||||
const bus = yield* Bus.Service
|
||||
|
||||
const run = Effect.fn("ApplyPatchTool.execute")(function* (params: Schema.Schema.Type<typeof Parameters>, ctx: Tool.Context) {
|
||||
const run = Effect.fn("ApplyPatchTool.execute")(function* (
|
||||
params: Schema.Schema.Type<typeof Parameters>,
|
||||
ctx: Tool.Context,
|
||||
) {
|
||||
if (!params.patchText) {
|
||||
return yield* Effect.fail(new Error("patchText is required"))
|
||||
}
|
||||
|
|
@ -297,7 +300,8 @@ export const ApplyPatchTool = Tool.define(
|
|||
return {
|
||||
description: DESCRIPTION,
|
||||
parameters: Parameters,
|
||||
execute: (params: Schema.Schema.Type<typeof Parameters>, ctx: Tool.Context) => run(params, ctx).pipe(Effect.orDie),
|
||||
execute: (params: Schema.Schema.Type<typeof Parameters>, ctx: Tool.Context) =>
|
||||
run(params, ctx).pipe(Effect.orDie),
|
||||
}
|
||||
}),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -148,7 +148,10 @@ export const ReadTool = Tool.define(
|
|||
return nonPrintableCount / bytes.length > 0.3
|
||||
}
|
||||
|
||||
const run = Effect.fn("ReadTool.execute")(function* (params: Schema.Schema.Type<typeof Parameters>, ctx: Tool.Context) {
|
||||
const run = Effect.fn("ReadTool.execute")(function* (
|
||||
params: Schema.Schema.Type<typeof Parameters>,
|
||||
ctx: Tool.Context,
|
||||
) {
|
||||
if (params.offset !== undefined && params.offset < 1) {
|
||||
return yield* Effect.fail(new Error("offset must be greater than or equal to 1"))
|
||||
}
|
||||
|
|
@ -284,7 +287,8 @@ export const ReadTool = Tool.define(
|
|||
return {
|
||||
description: DESCRIPTION,
|
||||
parameters: Parameters,
|
||||
execute: (params: Schema.Schema.Type<typeof Parameters>, ctx: Tool.Context) => run(params, ctx).pipe(Effect.orDie),
|
||||
execute: (params: Schema.Schema.Type<typeof Parameters>, ctx: Tool.Context) =>
|
||||
run(params, ctx).pipe(Effect.orDie),
|
||||
}
|
||||
}),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,10 @@ export const TaskTool = Tool.define(
|
|||
const config = yield* Config.Service
|
||||
const sessions = yield* Session.Service
|
||||
|
||||
const run = Effect.fn("TaskTool.execute")(function* (params: Schema.Schema.Type<typeof Parameters>, ctx: Tool.Context) {
|
||||
const run = Effect.fn("TaskTool.execute")(function* (
|
||||
params: Schema.Schema.Type<typeof Parameters>,
|
||||
ctx: Tool.Context,
|
||||
) {
|
||||
const cfg = yield* config.get()
|
||||
|
||||
if (!ctx.extra?.bypassAgentCheck) {
|
||||
|
|
@ -166,7 +169,8 @@ export const TaskTool = Tool.define(
|
|||
return {
|
||||
description: DESCRIPTION,
|
||||
parameters: Parameters,
|
||||
execute: (params: Schema.Schema.Type<typeof Parameters>, ctx: Tool.Context) => run(params, ctx).pipe(Effect.orDie),
|
||||
execute: (params: Schema.Schema.Type<typeof Parameters>, ctx: Tool.Context) =>
|
||||
run(params, ctx).pipe(Effect.orDie),
|
||||
}
|
||||
}),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ import { Todo } from "../session/todo"
|
|||
// identical, and it removes the last zod dependency from this tool.
|
||||
const TodoItem = Schema.Struct({
|
||||
content: Schema.String.annotate({ description: "Brief description of the task" }),
|
||||
status: Schema.String.annotate({ description: "Current status of the task: pending, in_progress, completed, cancelled" }),
|
||||
status: Schema.String.annotate({
|
||||
description: "Current status of the task: pending, in_progress, completed, cancelled",
|
||||
}),
|
||||
priority: Schema.String.annotate({ description: "Priority level of the task: high, medium, low" }),
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -31,19 +31,25 @@ export interface ExecuteResult<M extends Metadata = Metadata> {
|
|||
attachments?: Omit<MessageV2.FilePart, "id" | "sessionID" | "messageID">[]
|
||||
}
|
||||
|
||||
export interface Def<Parameters extends Schema.Decoder<unknown> = Schema.Decoder<unknown>, M extends Metadata = Metadata> {
|
||||
export interface Def<
|
||||
Parameters extends Schema.Decoder<unknown> = Schema.Decoder<unknown>,
|
||||
M extends Metadata = Metadata,
|
||||
> {
|
||||
id: string
|
||||
description: string
|
||||
parameters: Parameters
|
||||
execute(args: Schema.Schema.Type<Parameters>, ctx: Context): Effect.Effect<ExecuteResult<M>>
|
||||
formatValidationError?(error: unknown): string
|
||||
}
|
||||
export type DefWithoutID<Parameters extends Schema.Decoder<unknown> = Schema.Decoder<unknown>, M extends Metadata = Metadata> = Omit<
|
||||
Def<Parameters, M>,
|
||||
"id"
|
||||
>
|
||||
export type DefWithoutID<
|
||||
Parameters extends Schema.Decoder<unknown> = Schema.Decoder<unknown>,
|
||||
M extends Metadata = Metadata,
|
||||
> = Omit<Def<Parameters, M>, "id">
|
||||
|
||||
export interface Info<Parameters extends Schema.Decoder<unknown> = Schema.Decoder<unknown>, M extends Metadata = Metadata> {
|
||||
export interface Info<
|
||||
Parameters extends Schema.Decoder<unknown> = Schema.Decoder<unknown>,
|
||||
M extends Metadata = Metadata,
|
||||
> {
|
||||
id: string
|
||||
init: () => Effect.Effect<DefWithoutID<Parameters, M>>
|
||||
}
|
||||
|
|
@ -121,7 +127,12 @@ function wrap<Parameters extends Schema.Decoder<unknown>, Result extends Metadat
|
|||
})
|
||||
}
|
||||
|
||||
export function define<Parameters extends Schema.Decoder<unknown>, Result extends Metadata, R, ID extends string = string>(
|
||||
export function define<
|
||||
Parameters extends Schema.Decoder<unknown>,
|
||||
Result extends Metadata,
|
||||
R,
|
||||
ID extends string = string,
|
||||
>(
|
||||
id: ID,
|
||||
init: Effect.Effect<Init<Parameters, Result>, never, R>,
|
||||
): Effect.Effect<Info<Parameters, Result>, never, R | Truncate.Service | Agent.Service> & { id: ID } {
|
||||
|
|
@ -136,7 +147,9 @@ export function define<Parameters extends Schema.Decoder<unknown>, Result extend
|
|||
)
|
||||
}
|
||||
|
||||
export function init<P extends Schema.Decoder<unknown>, M extends Metadata>(info: Info<P, M>): Effect.Effect<Def<P, M>> {
|
||||
export function init<P extends Schema.Decoder<unknown>, M extends Metadata>(
|
||||
info: Info<P, M>,
|
||||
): Effect.Effect<Def<P, M>> {
|
||||
return Effect.gen(function* () {
|
||||
const init = yield* info.init()
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -59,7 +59,6 @@ export function toJsonSchema<S extends Schema.Top>(schema: S) {
|
|||
return z.toJSONSchema(zod(schema), { io: "input" })
|
||||
}
|
||||
|
||||
|
||||
function walk(ast: SchemaAST.AST): z.ZodTypeAny {
|
||||
const cached = walkCache.get(ast)
|
||||
if (cached) return cached
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue