refactor(tools): migrate producers to shared metadata bridge

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-04-16 13:52:20 +09:00
parent 4da3005797
commit c6a407c486
10 changed files with 17 additions and 123 deletions
@@ -1,6 +1,6 @@
import { tool, type ToolDefinition } from "@opencode-ai/plugin"
import type { BackgroundTask } from "../../features/background-agent"
import { storeToolMetadata } from "../../features/tool-metadata-store"
import { publishToolMetadata } from "../../features/tool-metadata-store"
import type { BackgroundOutputArgs } from "./types"
import type { BackgroundOutputClient, BackgroundOutputManager } from "./clients"
import { BACKGROUND_OUTPUT_DESCRIPTION } from "./constants"
@@ -23,13 +23,6 @@ type ToolContextWithMetadata = {
call_id?: string
}
function resolveToolCallID(ctx: ToolContextWithMetadata): string | undefined {
if (typeof ctx.callID === "string" && ctx.callID.trim() !== "") return ctx.callID
if (typeof ctx.callId === "string" && ctx.callId.trim() !== "") return ctx.callId
if (typeof ctx.call_id === "string" && ctx.call_id.trim() !== "") return ctx.call_id
return undefined
}
function formatResolvedTitle(task: BackgroundTask): string {
const label = task.agent === SISYPHUS_JUNIOR_AGENT && task.category ? task.category : task.agent
return `${label} - ${task.description}`
@@ -80,12 +73,7 @@ export function createBackgroundOutput(manager: BackgroundOutputManager, client:
...(task.sessionID ? { sessionId: task.sessionID } : {}),
} as Record<string, unknown>,
}
ctx.metadata?.(meta)
const callID = resolveToolCallID(ctx)
if (callID) {
storeToolMetadata(ctx.sessionID, callID, meta)
}
await publishToolMetadata(ctx, meta)
const shouldBlock = args.block === true
const timeoutMs = Math.min(args.timeout ?? 60000, 600000)
@@ -4,7 +4,7 @@ import type { BackgroundTaskArgs } from "./types"
import { BACKGROUND_TASK_DESCRIPTION } from "./constants"
import { resolveMessageContext } from "../../features/hook-message-injector"
import { getSessionAgent } from "../../features/claude-code-session-state"
import { storeToolMetadata } from "../../features/tool-metadata-store"
import { publishToolMetadata } from "../../features/tool-metadata-store"
import { log } from "../../shared/logger"
import { delay } from "./delay"
import { getMessageDir } from "./message-dir"
@@ -100,11 +100,7 @@ export function createBackgroundTask(
...(sessionId ? { sessionId } : {}),
},
}
ctx.metadata?.(bgMeta)
if (ctx.callID) {
storeToolMetadata(ctx.sessionID, ctx.callID, bgMeta)
}
await publishToolMetadata(ctx, bgMeta)
return `Background task launched successfully.