refactor: unwrap Agent namespace + self-reexport (#22935)
This commit is contained in:
@@ -24,8 +24,7 @@ import { InstanceState } from "@/effect"
|
|||||||
import * as Option from "effect/Option"
|
import * as Option from "effect/Option"
|
||||||
import * as OtelTracer from "@effect/opentelemetry/Tracer"
|
import * as OtelTracer from "@effect/opentelemetry/Tracer"
|
||||||
|
|
||||||
export namespace Agent {
|
export const Info = z
|
||||||
export const Info = z
|
|
||||||
.object({
|
.object({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
description: z.string().optional(),
|
description: z.string().optional(),
|
||||||
@@ -50,11 +49,11 @@ export namespace Agent {
|
|||||||
.meta({
|
.meta({
|
||||||
ref: "Agent",
|
ref: "Agent",
|
||||||
})
|
})
|
||||||
export type Info = z.infer<typeof Info>
|
export type Info = z.infer<typeof Info>
|
||||||
|
|
||||||
export interface Interface {
|
export interface Interface {
|
||||||
readonly get: (agent: string) => Effect.Effect<Agent.Info>
|
readonly get: (agent: string) => Effect.Effect<Info>
|
||||||
readonly list: () => Effect.Effect<Agent.Info[]>
|
readonly list: () => Effect.Effect<Info[]>
|
||||||
readonly defaultAgent: () => Effect.Effect<string>
|
readonly defaultAgent: () => Effect.Effect<string>
|
||||||
readonly generate: (input: {
|
readonly generate: (input: {
|
||||||
description: string
|
description: string
|
||||||
@@ -64,13 +63,13 @@ export namespace Agent {
|
|||||||
whenToUse: string
|
whenToUse: string
|
||||||
systemPrompt: string
|
systemPrompt: string
|
||||||
}>
|
}>
|
||||||
}
|
}
|
||||||
|
|
||||||
type State = Omit<Interface, "generate">
|
type State = Omit<Interface, "generate">
|
||||||
|
|
||||||
export class Service extends Context.Service<Service, Interface>()("@opencode/Agent") {}
|
export class Service extends Context.Service<Service, Interface>()("@opencode/Agent") {}
|
||||||
|
|
||||||
export const layer = Layer.effect(
|
export const layer = Layer.effect(
|
||||||
Service,
|
Service,
|
||||||
Effect.gen(function* () {
|
Effect.gen(function* () {
|
||||||
const config = yield* Config.Service
|
const config = yield* Config.Service
|
||||||
@@ -400,13 +399,14 @@ export namespace Agent {
|
|||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
export const defaultLayer = layer.pipe(
|
export const defaultLayer = layer.pipe(
|
||||||
Layer.provide(Plugin.defaultLayer),
|
Layer.provide(Plugin.defaultLayer),
|
||||||
Layer.provide(Provider.defaultLayer),
|
Layer.provide(Provider.defaultLayer),
|
||||||
Layer.provide(Auth.defaultLayer),
|
Layer.provide(Auth.defaultLayer),
|
||||||
Layer.provide(Config.defaultLayer),
|
Layer.provide(Config.defaultLayer),
|
||||||
Layer.provide(Skill.defaultLayer),
|
Layer.provide(Skill.defaultLayer),
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
export * as Agent from "./agent"
|
||||||
|
|||||||
Reference in New Issue
Block a user