fix(tasks-hook): share task_system resolution
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
|
||||
import { REPLACEMENT_MESSAGE } from "./constants"
|
||||
import { createTasksTodowriteDisablerHook } from "./hook"
|
||||
|
||||
describe("createTasksTodowriteDisablerHook", () => {
|
||||
describe("#given experimental.task_system is omitted", () => {
|
||||
test("#when TodoWrite runs #then it is allowed by default", async () => {
|
||||
// given
|
||||
const hook = createTasksTodowriteDisablerHook({})
|
||||
|
||||
// when
|
||||
const result = hook["tool.execute.before"](
|
||||
{ tool: "TodoWrite", sessionID: "ses_123", callID: "call_123" },
|
||||
{ args: {} },
|
||||
)
|
||||
|
||||
// then
|
||||
await expect(result).resolves.toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe("#given experimental.task_system is enabled", () => {
|
||||
test("#when TodoWrite runs #then it is blocked", async () => {
|
||||
// given
|
||||
const hook = createTasksTodowriteDisablerHook({
|
||||
experimental: { task_system: true },
|
||||
})
|
||||
|
||||
// when
|
||||
const result = hook["tool.execute.before"](
|
||||
{ tool: "TodoWrite", sessionID: "ses_123", callID: "call_123" },
|
||||
{ args: {} },
|
||||
)
|
||||
|
||||
// then
|
||||
await expect(result).rejects.toThrow(REPLACEMENT_MESSAGE)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,3 +1,4 @@
|
||||
import { isTaskSystemEnabled } from "../../shared/task-system-enabled";
|
||||
import { BLOCKED_TOOLS, REPLACEMENT_MESSAGE } from "./constants";
|
||||
|
||||
export interface TasksTodowriteDisablerConfig {
|
||||
@@ -9,14 +10,14 @@ export interface TasksTodowriteDisablerConfig {
|
||||
export function createTasksTodowriteDisablerHook(
|
||||
config: TasksTodowriteDisablerConfig,
|
||||
) {
|
||||
const isTaskSystemEnabled = config.experimental?.task_system ?? true;
|
||||
const taskSystemEnabled = isTaskSystemEnabled(config);
|
||||
|
||||
return {
|
||||
"tool.execute.before": async (
|
||||
input: { tool: string; sessionID: string; callID: string },
|
||||
_output: { args: Record<string, unknown> },
|
||||
) => {
|
||||
if (!isTaskSystemEnabled) {
|
||||
if (!taskSystemEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user