fix(tools/call-omo-agent): replace as any with SDKMessage interface
Add SDKMessage local interface for message type safety Replace any lambda params and message casts with SDKMessage Remove eslint-disable comments for no-explicit-any Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
parent
07113ebe94
commit
ff0e9ac557
@ -2,6 +2,11 @@ import type { PluginInput } from "@opencode-ai/plugin"
|
|||||||
import { log } from "../../shared"
|
import { log } from "../../shared"
|
||||||
import { consumeNewMessages } from "../../shared/session-cursor"
|
import { consumeNewMessages } from "../../shared/session-cursor"
|
||||||
|
|
||||||
|
interface SDKMessage {
|
||||||
|
info?: { role?: string; time?: { created?: number } }
|
||||||
|
parts?: Array<{ type: string; text?: string; content?: string | Array<{ type: string; text?: string }> }>
|
||||||
|
}
|
||||||
|
|
||||||
export async function processMessages(
|
export async function processMessages(
|
||||||
sessionID: string,
|
sessionID: string,
|
||||||
ctx: PluginInput
|
ctx: PluginInput
|
||||||
@ -20,9 +25,8 @@ export async function processMessages(
|
|||||||
|
|
||||||
// Include both assistant messages AND tool messages
|
// Include both assistant messages AND tool messages
|
||||||
// Tool results (grep, glob, bash output) come from role "tool"
|
// Tool results (grep, glob, bash output) come from role "tool"
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
const relevantMessages = messages.filter(
|
const relevantMessages = messages.filter(
|
||||||
(m: any) => m.info?.role === "assistant" || m.info?.role === "tool"
|
(m: SDKMessage) => m.info?.role === "assistant" || m.info?.role === "tool"
|
||||||
)
|
)
|
||||||
|
|
||||||
if (relevantMessages.length === 0) {
|
if (relevantMessages.length === 0) {
|
||||||
@ -34,8 +38,7 @@ export async function processMessages(
|
|||||||
log(`[call_omo_agent] Found ${relevantMessages.length} relevant messages`)
|
log(`[call_omo_agent] Found ${relevantMessages.length} relevant messages`)
|
||||||
|
|
||||||
// Sort by time ascending (oldest first) to process messages in order
|
// Sort by time ascending (oldest first) to process messages in order
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
const sortedMessages = [...relevantMessages].sort((a: SDKMessage, b: SDKMessage) => {
|
||||||
const sortedMessages = [...relevantMessages].sort((a: any, b: any) => {
|
|
||||||
const timeA = a.info?.time?.created ?? 0
|
const timeA = a.info?.time?.created ?? 0
|
||||||
const timeB = b.info?.time?.created ?? 0
|
const timeB = b.info?.time?.created ?? 0
|
||||||
return timeA - timeB
|
return timeA - timeB
|
||||||
@ -52,12 +55,11 @@ export async function processMessages(
|
|||||||
const extractedContent: string[] = []
|
const extractedContent: string[] = []
|
||||||
|
|
||||||
for (const message of newMessages) {
|
for (const message of newMessages) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
for (const part of message.parts ?? []) {
|
||||||
for (const part of (message as any).parts ?? []) {
|
|
||||||
// Handle both "text" and "reasoning" parts (thinking models use "reasoning")
|
// Handle both "text" and "reasoning" parts (thinking models use "reasoning")
|
||||||
if ((part.type === "text" || part.type === "reasoning") && part.text) {
|
if ((part.type === "text" || part.type === "reasoning") && part.text) {
|
||||||
extractedContent.push(part.text)
|
extractedContent.push(part.text)
|
||||||
} else if (part.type === "tool_result") {
|
} else if ((part.type as string) === "tool_result") {
|
||||||
// Tool results contain the actual output from tool calls
|
// Tool results contain the actual output from tool calls
|
||||||
const toolResult = part as { content?: string | Array<{ type: string; text?: string }> }
|
const toolResult = part as { content?: string | Array<{ type: string; text?: string }> }
|
||||||
if (typeof toolResult.content === "string" && toolResult.content) {
|
if (typeof toolResult.content === "string" && toolResult.content) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user