mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-28 19:14:53 +00:00
68 lines
2.4 KiB
TypeScript
68 lines
2.4 KiB
TypeScript
export * as Agent from "./agent.js"
|
|
|
|
import { Schema } from "effect"
|
|
import { ephemeral, inventory } from "./event.js"
|
|
import { optional } from "./schema.js"
|
|
import { Model } from "./model.js"
|
|
import { Permission } from "./permission.js"
|
|
import { Provider } from "./provider.js"
|
|
import { PositiveInt, statics } from "./schema.js"
|
|
|
|
const Updated = ephemeral({ type: "agent.updated", schema: {} })
|
|
|
|
export const ID = Schema.String.pipe(Schema.brand("Agent.ID"), Schema.annotate({ identifier: "Agent.ID" }))
|
|
export type ID = typeof ID.Type
|
|
|
|
export const Name = Schema.String.pipe(Schema.brand("Agent.Name"))
|
|
export type Name = typeof Name.Type
|
|
|
|
export const Color = Schema.String.annotate({ identifier: "Agent.Color" })
|
|
export type Color = typeof Color.Type
|
|
|
|
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
|
export const Info = Schema.Struct({
|
|
id: ID,
|
|
name: Name,
|
|
model: Model.Ref.pipe(optional),
|
|
request: Provider.Request,
|
|
system: Schema.String.pipe(optional),
|
|
/**
|
|
* Added to the default prompt while the agent is selected, without replacing it like `system`. A string is
|
|
* introduced as this agent's instructions, and core tells the model when they stop applying. `{ selected, unselected }`
|
|
* sends both texts exactly as written: `selected` while the agent is selected, `unselected` once when the session
|
|
* switches away.
|
|
*/
|
|
instructions: Schema.Union([Schema.String, Schema.Struct({ selected: Schema.String, unselected: Schema.String })]).pipe(
|
|
optional,
|
|
),
|
|
description: Schema.String.pipe(optional),
|
|
mode: Schema.Literals(["subagent", "primary", "all"]),
|
|
hidden: Schema.Boolean,
|
|
color: Color.pipe(optional),
|
|
steps: PositiveInt.pipe(optional),
|
|
permissions: Permission.Ruleset,
|
|
})
|
|
.annotate({ identifier: "Agent.Info" })
|
|
.pipe(
|
|
statics(() => ({
|
|
default: (id: ID) =>
|
|
({
|
|
id,
|
|
name: Name.make(id),
|
|
request: { settings: {}, headers: {}, body: {} },
|
|
mode: "primary",
|
|
hidden: false,
|
|
permissions: [
|
|
{ action: "*", resource: "*", effect: "allow" },
|
|
{ action: "read", resource: "*.env", effect: "ask" },
|
|
{ action: "read", resource: "*.env.*", effect: "ask" },
|
|
{ action: "read", resource: "*.env.example", effect: "allow" },
|
|
],
|
|
}) satisfies Info,
|
|
})),
|
|
)
|
|
|
|
export const Event = {
|
|
Updated,
|
|
Definitions: inventory(Updated),
|
|
}
|