feat(main): wire up new tools, hooks and agents
Wire up in main plugin entry: - Import and create sisyphus_task tool - Import and wire taskResumeInfo, startWork, sisyphusOrchestrator hooks - Update tool restrictions from background_task to sisyphus_task - Pass userCategories to createSisyphusTask 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
parent
324ecd872e
commit
b9b8adc11c
45
src/index.ts
45
src/index.ts
@ -26,6 +26,9 @@ import {
|
|||||||
createRalphLoopHook,
|
createRalphLoopHook,
|
||||||
createAutoSlashCommandHook,
|
createAutoSlashCommandHook,
|
||||||
createEditErrorRecoveryHook,
|
createEditErrorRecoveryHook,
|
||||||
|
createTaskResumeInfoHook,
|
||||||
|
createStartWorkHook,
|
||||||
|
createSisyphusOrchestratorHook,
|
||||||
} from "./hooks";
|
} from "./hooks";
|
||||||
import {
|
import {
|
||||||
contextCollector,
|
contextCollector,
|
||||||
@ -49,12 +52,14 @@ import {
|
|||||||
import {
|
import {
|
||||||
builtinTools,
|
builtinTools,
|
||||||
createCallOmoAgent,
|
createCallOmoAgent,
|
||||||
|
createBackgroundTools,
|
||||||
createLookAt,
|
createLookAt,
|
||||||
createSkillTool,
|
createSkillTool,
|
||||||
createSkillMcpTool,
|
createSkillMcpTool,
|
||||||
createSlashcommandTool,
|
createSlashcommandTool,
|
||||||
discoverCommandsSync,
|
discoverCommandsSync,
|
||||||
sessionExists,
|
sessionExists,
|
||||||
|
createSisyphusTask,
|
||||||
interactive_bash,
|
interactive_bash,
|
||||||
startTmuxCheck,
|
startTmuxCheck,
|
||||||
} from "./tools";
|
} from "./tools";
|
||||||
@ -185,6 +190,16 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
|
|||||||
? createEditErrorRecoveryHook(ctx)
|
? createEditErrorRecoveryHook(ctx)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
|
const startWork = isHookEnabled("start-work")
|
||||||
|
? createStartWorkHook(ctx)
|
||||||
|
: null;
|
||||||
|
|
||||||
|
const sisyphusOrchestrator = isHookEnabled("sisyphus-orchestrator")
|
||||||
|
? createSisyphusOrchestratorHook(ctx)
|
||||||
|
: null;
|
||||||
|
|
||||||
|
const taskResumeInfo = createTaskResumeInfoHook();
|
||||||
|
|
||||||
const backgroundManager = new BackgroundManager(ctx);
|
const backgroundManager = new BackgroundManager(ctx);
|
||||||
|
|
||||||
const todoContinuationEnforcer = isHookEnabled("todo-continuation-enforcer")
|
const todoContinuationEnforcer = isHookEnabled("todo-continuation-enforcer")
|
||||||
@ -201,9 +216,15 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
|
|||||||
const backgroundNotificationHook = isHookEnabled("background-notification")
|
const backgroundNotificationHook = isHookEnabled("background-notification")
|
||||||
? createBackgroundNotificationHook(backgroundManager)
|
? createBackgroundNotificationHook(backgroundManager)
|
||||||
: null;
|
: null;
|
||||||
|
const backgroundTools = createBackgroundTools(backgroundManager, ctx.client);
|
||||||
|
|
||||||
const callOmoAgent = createCallOmoAgent(ctx, backgroundManager);
|
const callOmoAgent = createCallOmoAgent(ctx, backgroundManager);
|
||||||
const lookAt = createLookAt(ctx);
|
const lookAt = createLookAt(ctx);
|
||||||
|
const sisyphusTask = createSisyphusTask({
|
||||||
|
manager: backgroundManager,
|
||||||
|
client: ctx.client,
|
||||||
|
userCategories: pluginConfig.categories,
|
||||||
|
});
|
||||||
const disabledSkills = new Set(pluginConfig.disabled_skills ?? []);
|
const disabledSkills = new Set(pluginConfig.disabled_skills ?? []);
|
||||||
const systemMcpNames = getSystemMcpServerNames();
|
const systemMcpNames = getSystemMcpServerNames();
|
||||||
const builtinSkills = createBuiltinSkills().filter((skill) => {
|
const builtinSkills = createBuiltinSkills().filter((skill) => {
|
||||||
@ -268,8 +289,10 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
|
|||||||
|
|
||||||
tool: {
|
tool: {
|
||||||
...builtinTools,
|
...builtinTools,
|
||||||
|
...backgroundTools,
|
||||||
call_omo_agent: callOmoAgent,
|
call_omo_agent: callOmoAgent,
|
||||||
look_at: lookAt,
|
look_at: lookAt,
|
||||||
|
sisyphus_task: sisyphusTask,
|
||||||
skill: skillTool,
|
skill: skillTool,
|
||||||
skill_mcp: skillMcpTool,
|
skill_mcp: skillMcpTool,
|
||||||
slashcommand: slashcommandTool,
|
slashcommand: slashcommandTool,
|
||||||
@ -281,6 +304,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
|
|||||||
await keywordDetector?.["chat.message"]?.(input, output);
|
await keywordDetector?.["chat.message"]?.(input, output);
|
||||||
await contextInjector["chat.message"]?.(input, output);
|
await contextInjector["chat.message"]?.(input, output);
|
||||||
await autoSlashCommand?.["chat.message"]?.(input, output);
|
await autoSlashCommand?.["chat.message"]?.(input, output);
|
||||||
|
await startWork?.["chat.message"]?.(input, output);
|
||||||
|
|
||||||
if (ralphLoop) {
|
if (ralphLoop) {
|
||||||
const parts = (
|
const parts = (
|
||||||
@ -437,6 +461,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
|
|||||||
|
|
||||||
args.tools = {
|
args.tools = {
|
||||||
...(args.tools as Record<string, boolean> | undefined),
|
...(args.tools as Record<string, boolean> | undefined),
|
||||||
|
sisyphus_task: false,
|
||||||
...(isExploreOrLibrarian ? { call_omo_agent: false } : {}),
|
...(isExploreOrLibrarian ? { call_omo_agent: false } : {}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -484,24 +509,8 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
|
|||||||
await agentUsageReminder?.["tool.execute.after"](input, output);
|
await agentUsageReminder?.["tool.execute.after"](input, output);
|
||||||
await interactiveBashSession?.["tool.execute.after"](input, output);
|
await interactiveBashSession?.["tool.execute.after"](input, output);
|
||||||
await editErrorRecovery?.["tool.execute.after"](input, output);
|
await editErrorRecovery?.["tool.execute.after"](input, output);
|
||||||
|
await sisyphusOrchestrator?.["tool.execute.after"]?.(input, output);
|
||||||
if (input.tool === "sisyphus_task") {
|
await taskResumeInfo["tool.execute.after"](input, output);
|
||||||
const result = output.output;
|
|
||||||
if (result && typeof result === "string") {
|
|
||||||
const taskIdMatch = result.match(/task[_\s-]?id[:\s]+["']?([a-z0-9_-]+)["']?/i);
|
|
||||||
const sessionIdMatch = result.match(/session[_\s-]?id[:\s]+["']?([a-z0-9_-]+)["']?/i);
|
|
||||||
const descriptionMatch = result.match(/description[:\s]+["']?([^"'\n]+)["']?/i);
|
|
||||||
|
|
||||||
if (taskIdMatch?.[1] && sessionIdMatch?.[1]) {
|
|
||||||
backgroundManager.registerExternalTask({
|
|
||||||
taskId: taskIdMatch[1],
|
|
||||||
sessionID: sessionIdMatch[1],
|
|
||||||
parentSessionID: input.sessionID,
|
|
||||||
description: descriptionMatch?.[1] || "Background task",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user