Revert "Merge pull request #2607 from code-yeongyu/feat/openclaw-integration"
This reverts commit8213534e87, reversing changes made to84fb1113f1.
This commit is contained in:
@@ -1,70 +0,0 @@
|
||||
import { wakeOpenClaw } from "../../openclaw/client";
|
||||
import type { OpenClawConfig, OpenClawContext } from "../../openclaw/types";
|
||||
import { getMainSessionID } from "../../features/claude-code-session-state";
|
||||
import type { PluginContext } from "../../plugin/types";
|
||||
|
||||
export function createOpenClawSenderHook(
|
||||
ctx: PluginContext,
|
||||
config: OpenClawConfig
|
||||
) {
|
||||
return {
|
||||
event: async (input: {
|
||||
event: { type: string; properties?: Record<string, unknown> };
|
||||
}) => {
|
||||
const { type, properties } = input.event;
|
||||
const info = properties?.info as Record<string, unknown> | undefined;
|
||||
const context: OpenClawContext = {
|
||||
sessionId:
|
||||
(properties?.sessionID as string) ||
|
||||
(info?.id as string) ||
|
||||
getMainSessionID(),
|
||||
projectPath: ctx.directory,
|
||||
};
|
||||
|
||||
if (type === "session.created") {
|
||||
await wakeOpenClaw("session-start", context, config);
|
||||
} else if (type === "session.idle") {
|
||||
await wakeOpenClaw("session-idle", context, config);
|
||||
} else if (type === "session.deleted") {
|
||||
await wakeOpenClaw("session-end", context, config);
|
||||
}
|
||||
},
|
||||
|
||||
"tool.execute.before": async (
|
||||
input: { tool: string; sessionID: string },
|
||||
output: { args: Record<string, unknown> }
|
||||
) => {
|
||||
const toolName = input.tool.toLowerCase();
|
||||
const context: OpenClawContext = {
|
||||
sessionId: input.sessionID,
|
||||
projectPath: ctx.directory,
|
||||
};
|
||||
|
||||
if (
|
||||
toolName === "ask_user_question" ||
|
||||
toolName === "askuserquestion" ||
|
||||
toolName === "question"
|
||||
) {
|
||||
const question =
|
||||
typeof output.args.question === "string"
|
||||
? output.args.question
|
||||
: undefined;
|
||||
await wakeOpenClaw(
|
||||
"ask-user-question",
|
||||
{
|
||||
...context,
|
||||
question,
|
||||
},
|
||||
config
|
||||
);
|
||||
} else if (toolName === "skill") {
|
||||
const rawName =
|
||||
typeof output.args.name === "string" ? output.args.name : undefined;
|
||||
const command = rawName?.replace(/^\//, "").toLowerCase();
|
||||
if (command === "stop-continuation") {
|
||||
await wakeOpenClaw("stop", context, config);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user