47c8d85904
deploy-www / deploy (push) Has been cancelled
publish / version (push) Has been cancelled
publish / build-cli (push) Has been cancelled
publish / build-node-cli (map[host:blacksmith-4vcpu-ubuntu-2404 target:linux-x64]) (push) Has been cancelled
publish / build-node-cli (map[host:blacksmith-4vcpu-ubuntu-2404-arm target:linux-arm64]) (push) Has been cancelled
publish / build-node-cli (map[host:blacksmith-4vcpu-windows-2025 target:windows-arm64]) (push) Has been cancelled
publish / build-node-cli (map[host:blacksmith-4vcpu-windows-2025 target:windows-x64]) (push) Has been cancelled
publish / build-node-cli (map[host:macos-26 target:darwin-arm64]) (push) Has been cancelled
publish / sign-cli-windows (push) Has been cancelled
publish / build-electron (map[bun_install_flags:--os=darwin --cpu=arm64 host:macos-26 platform_flag:--mac --arm64 target:aarch64-apple-darwin]) (push) Has been cancelled
publish / build-electron (map[bun_install_flags:--os=darwin --cpu=x64 host:macos-26-intel platform_flag:--mac --x64 target:x86_64-apple-darwin]) (push) Has been cancelled
publish / build-electron (map[host:blacksmith-4vcpu-ubuntu-2404 platform_flag:--linux target:x86_64-unknown-linux-gnu]) (push) Has been cancelled
publish / build-electron (map[host:blacksmith-4vcpu-ubuntu-2404-arm platform_flag:--linux --arm64 target:aarch64-unknown-linux-gnu]) (push) Has been cancelled
publish / build-electron (map[host:blacksmith-4vcpu-windows-2025 platform_flag:--win target:x86_64-pc-windows-msvc]) (push) Has been cancelled
publish / build-electron (map[host:windows-2025 platform_flag:--win --arm64 target:aarch64-pc-windows-msvc]) (push) Has been cancelled
publish / publish (push) Has been cancelled
generate / generate (push) Has been cancelled
typecheck / typecheck (push) Has been cancelled
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
import { Tool } from "@opencode-ai/schema/tool"
|
|
import type { Agent } from "@opencode-ai/schema/agent"
|
|
import type { Session } from "@opencode-ai/schema/session"
|
|
import type { SessionMessage } from "@opencode-ai/schema/session-message"
|
|
import type { Hooks, Transform } from "./registration.js"
|
|
|
|
export interface ToolDraft {
|
|
add<Input extends Tool.ValueSchema<any>, Output extends Tool.ValueSchema<any> | undefined>(
|
|
tool: Tool.Info<Input, Output>,
|
|
): void
|
|
}
|
|
|
|
export interface ToolHooks {
|
|
readonly "execute.before": {
|
|
readonly tool: string
|
|
readonly sessionID: Session.ID
|
|
readonly agent: Agent.ID
|
|
readonly messageID: SessionMessage.ID
|
|
readonly id: Tool.CallID
|
|
input: unknown
|
|
}
|
|
readonly "execute.after": {
|
|
readonly tool: string
|
|
readonly sessionID: Session.ID
|
|
readonly agent: Agent.ID
|
|
readonly messageID: SessionMessage.ID
|
|
readonly id: Tool.CallID
|
|
readonly input: unknown
|
|
} & (
|
|
| {
|
|
readonly status: "completed"
|
|
result: Tool.Result
|
|
}
|
|
| {
|
|
readonly status: "error"
|
|
error: Tool.Error
|
|
}
|
|
)
|
|
}
|
|
|
|
// Only execute.before may fail: a Tool.Error rejects the call before the tool runs.
|
|
export interface ToolFailures extends Record<keyof ToolHooks, unknown> {
|
|
readonly "execute.before": Tool.Error
|
|
readonly "execute.after": never
|
|
}
|
|
|
|
export interface ToolDomain {
|
|
readonly transform: Transform<ToolDraft>
|
|
readonly hook: Hooks<ToolHooks, ToolFailures>
|
|
}
|