@meetopenbot/claude-code 0.1.16 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +39 -3
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -86,10 +86,46 @@ var streamEventText = (event) => {
86
86
  if (delta?.type === "text_delta" && typeof delta.text === "string") return delta.text;
87
87
  return "";
88
88
  };
89
+ var parseToolUse = (block) => {
90
+ if (!block || typeof block !== "object" || !("type" in block)) return null;
91
+ const type = block.type;
92
+ if (type !== "tool_use" && type !== "mcp_tool_use" && type !== "server_tool_use") return null;
93
+ const { id, name, input, server_name } = block;
94
+ if (typeof id !== "string" || typeof name !== "string") return null;
95
+ const title = typeof server_name === "string" ? `${server_name}: ${name}` : name;
96
+ return { type: "tool_call", id, name: title, input };
97
+ };
98
+ var parseToolResult = (block) => {
99
+ if (!block || typeof block !== "object" || !("type" in block)) return null;
100
+ const type = block.type;
101
+ if (type !== "tool_result" && type !== "mcp_tool_result") return null;
102
+ const { tool_use_id, content, is_error } = block;
103
+ if (typeof tool_use_id !== "string") return null;
104
+ return { type: "tool_result", id: tool_use_id, output: content, error: is_error };
105
+ };
89
106
  var classifyClaudeEvent = (message) => {
90
107
  if (message.type === "assistant") {
91
- const text = extractText(message.message?.content);
92
- return text ? { type: "text", text } : { type: "skip" };
108
+ const content = message.message?.content;
109
+ const hints = [];
110
+ const text = extractText(content);
111
+ if (text) hints.push({ type: "text", text });
112
+ if (Array.isArray(content)) {
113
+ for (const block of content) {
114
+ const tool = parseToolUse(block);
115
+ if (tool) hints.push(tool);
116
+ }
117
+ }
118
+ return hints.length > 0 ? hints : { type: "skip" };
119
+ }
120
+ if (message.type === "user") {
121
+ const content = message.message?.content;
122
+ if (!Array.isArray(content)) return { type: "skip" };
123
+ const hints = [];
124
+ for (const block of content) {
125
+ const result = parseToolResult(block);
126
+ if (result) hints.push(result);
127
+ }
128
+ return hints.length > 0 ? hints : { type: "skip" };
93
129
  }
94
130
  if (message.type === "stream_event") {
95
131
  const text = streamEventText(message.event);
@@ -99,7 +135,7 @@ var classifyClaudeEvent = (message) => {
99
135
  };
100
136
  async function* runClaudeQuery(args) {
101
137
  const { prompt, sdkOptions, resumeId, state, storage } = args;
102
- const replies = createTextReplyBuffer();
138
+ const replies = createTextReplyBuffer({ groupId: "claude-code:tools" });
103
139
  let lastSessionId = resumeId;
104
140
  try {
105
141
  for await (const message of query({ prompt, options: sdkOptions })) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meetopenbot/claude-code",
3
- "version": "0.1.16",
3
+ "version": "1.0.0",
4
4
  "type": "module",
5
5
  "description": "Claude Code plugin for OpenBot",
6
6
  "main": "./dist/index.js",
@@ -19,7 +19,7 @@
19
19
  ],
20
20
  "dependencies": {
21
21
  "@anthropic-ai/claude-agent-sdk": "^0.2.138",
22
- "@meetopenbot/plugin-sdk": "^0.4.0"
22
+ "@meetopenbot/plugin-sdk": "^1.0.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/node": "^20.10.1",
@@ -28,8 +28,8 @@
28
28
  },
29
29
  "types": "./dist/index.d.ts",
30
30
  "scripts": {
31
- "build": "esbuild src/index.ts --bundle --platform=node --format=esm --outfile=dist/index.js --external:@meetopenbot/plugin-sdk --external:@anthropic-ai/claude-agent-sdk --external:melony --external:zod && node ../../scripts/write-plugin-declaration.mjs",
32
- "dev": "esbuild src/index.ts --bundle --platform=node --format=esm --outfile=dist/index.js --external:@meetopenbot/plugin-sdk --external:@anthropic-ai/claude-agent-sdk --external:melony --external:zod --watch",
31
+ "build": "esbuild src/index.ts --bundle --platform=node --format=esm --outfile=dist/index.js --external:@meetopenbot/plugin-sdk --external:@anthropic-ai/claude-agent-sdk --external:zod && node ../../scripts/write-plugin-declaration.mjs",
32
+ "dev": "esbuild src/index.ts --bundle --platform=node --format=esm --outfile=dist/index.js --external:@meetopenbot/plugin-sdk --external:@anthropic-ai/claude-agent-sdk --external:zod --watch",
33
33
  "typecheck": "tsc -p tsconfig.json --noEmit"
34
34
  }
35
35
  }