6bffb2c40f
opencode >=1.14 freezes output.args via Immer before plugin hooks run. Direct property assignment or Object.assign on a frozen object throws TypeError. This helper replaces output.args with a shallow clone containing the patch, avoiding mutation of the frozen original. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
17 lines
660 B
TypeScript
17 lines
660 B
TypeScript
/**
|
|
* Safely replace tool arguments without mutating frozen objects.
|
|
*
|
|
* opencode >=1.14 may freeze `output.args` via Immer before plugin hooks run.
|
|
* Direct property assignment (`output.args.key = value`) or `Object.assign(output.args, patch)`
|
|
* throws `TypeError: Attempted to assign to readonly property` on a frozen object.
|
|
*
|
|
* This helper replaces `output.args` with a shallow clone containing the patch,
|
|
* which works regardless of whether the original args object is frozen.
|
|
*/
|
|
export function replaceToolArgs(
|
|
output: { args: Record<string, unknown> },
|
|
patch: Record<string, unknown>,
|
|
): void {
|
|
output.args = { ...output.args, ...patch }
|
|
}
|