refactor(hooks): replace direct output.args mutation with replaceToolArgs (question/webfetch/null-byte)
Replace Object.assign(output.args, truncatedArgs), output.args.url = resolution.url, and output.args.command = ... .replace(/\x00/g, "") with replaceToolArgs() calls in question-label-truncator, webfetch-redirect-guard, and plugin/tool-execute-before. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { replaceToolArgs } from "../../shared/replace-tool-args"
|
||||
|
||||
const MAX_LABEL_LENGTH = 30;
|
||||
|
||||
interface QuestionOption {
|
||||
@@ -56,7 +58,7 @@ export function createQuestionLabelTruncatorHook() {
|
||||
if (toolName === "askuserquestion" || toolName === "ask_user_question") {
|
||||
if (hasQuestions(output.args)) {
|
||||
const truncatedArgs = truncateQuestionLabels(output.args);
|
||||
Object.assign(output.args, truncatedArgs);
|
||||
replaceToolArgs(output, { questions: truncatedArgs.questions });
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { PluginInput } from "@opencode-ai/plugin"
|
||||
import { log } from "../../shared"
|
||||
import { log, replaceToolArgs } from "../../shared"
|
||||
import {
|
||||
MAX_WEBFETCH_REDIRECTS,
|
||||
WEBFETCH_REDIRECT_ERROR_PATTERNS,
|
||||
@@ -85,7 +85,7 @@ export function createWebFetchRedirectGuardHook(_ctx: PluginInput) {
|
||||
})
|
||||
|
||||
if (resolution.type === "resolved") {
|
||||
output.args.url = resolution.url
|
||||
replaceToolArgs(output, { url: resolution.url })
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { randomUUID } from "node:crypto"
|
||||
|
||||
import { getMainSessionID } from "../features/claude-code-session-state"
|
||||
import { clearBoulderState } from "../features/boulder-state"
|
||||
import { log } from "../shared"
|
||||
import { log, replaceToolArgs } from "../shared"
|
||||
import { stripInvisibleAgentCharacters } from "../shared/agent-display-names"
|
||||
import { resolveSessionAgent } from "./session-agent-resolver"
|
||||
import { parseRalphLoopArguments } from "../hooks/ralph-loop/command-arguments"
|
||||
@@ -54,7 +54,7 @@ export function createToolExecuteBeforeHandler(args: {
|
||||
return async (input, output): Promise<void> => {
|
||||
if (input.tool.toLowerCase() === "bash" && typeof output.args.command === "string") {
|
||||
if (output.args.command.includes("\x00")) {
|
||||
output.args.command = output.args.command.replace(/\x00/g, "")
|
||||
replaceToolArgs(output, { command: output.args.command.replace(/\x00/g, "") })
|
||||
log("[tool-execute-before] Stripped null bytes from bash command", {
|
||||
sessionID: input.sessionID,
|
||||
callID: input.callID,
|
||||
|
||||
Reference in New Issue
Block a user