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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user