@meetopenbot/codex 1.0.11 → 1.0.12
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.
- package/dist/index.js +68 -21
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import {
|
|
3
3
|
definePlugin,
|
|
4
4
|
shouldHandleInvoke,
|
|
5
|
-
agentOutput
|
|
5
|
+
agentOutput,
|
|
6
|
+
uiWidget
|
|
6
7
|
} from "@meetopenbot/plugin-sdk";
|
|
7
8
|
import {
|
|
8
9
|
Codex
|
|
@@ -97,30 +98,76 @@ var codex_default = definePlugin({
|
|
|
97
98
|
const turn = await getThread(ctx?.state, event.meta).runStreamed(content);
|
|
98
99
|
for await (const chunk of turn.events) {
|
|
99
100
|
if (chunk.type === "item.completed") {
|
|
100
|
-
|
|
101
|
-
if (
|
|
102
|
-
outputContent = chunk.item.text;
|
|
103
|
-
} else if (chunk.item.type === "reasoning") {
|
|
104
|
-
outputContent = chunk.item.text;
|
|
105
|
-
} else if (chunk.item.type === "command_execution") {
|
|
106
|
-
outputContent = `Executing: ${chunk.item.command}`;
|
|
107
|
-
} else if (chunk.item.type === "file_change") {
|
|
108
|
-
outputContent = chunk.item.changes.map((change) => `${change.path}: ${change.action}`).join("\n");
|
|
109
|
-
} else if (chunk.item.type === "error") {
|
|
110
|
-
outputContent = `Error: ${chunk.item.message}`;
|
|
111
|
-
} else if (chunk.item.type === "todo_list") {
|
|
112
|
-
outputContent = chunk.item.items.map(
|
|
113
|
-
(item) => `- ${item.text} (${item.completed ? "completed" : "pending"})`
|
|
114
|
-
).join("\n");
|
|
115
|
-
} else if (chunk.item.type === "web_search") {
|
|
116
|
-
outputContent = `Searching: ${chunk.item.query}`;
|
|
117
|
-
}
|
|
118
|
-
if (outputContent) {
|
|
101
|
+
const { item } = chunk;
|
|
102
|
+
if (item.type === "agent_message") {
|
|
119
103
|
yield agentOutput({
|
|
120
104
|
agentId: context.agentId,
|
|
121
|
-
content:
|
|
105
|
+
content: item.text,
|
|
122
106
|
threadId: event.meta?.threadId
|
|
123
107
|
});
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
let title = "";
|
|
111
|
+
let body = "";
|
|
112
|
+
switch (item.type) {
|
|
113
|
+
case "reasoning":
|
|
114
|
+
title = "Reasoning";
|
|
115
|
+
body = item.text;
|
|
116
|
+
break;
|
|
117
|
+
case "command_execution":
|
|
118
|
+
title = "Command Execution";
|
|
119
|
+
body = `Executing: ${item.command}`;
|
|
120
|
+
break;
|
|
121
|
+
case "file_change":
|
|
122
|
+
title = "File Change";
|
|
123
|
+
body = item.changes.map((change) => `${change.path}: ${change.kind || change.action}`).join("\n");
|
|
124
|
+
break;
|
|
125
|
+
case "mcp_tool_call":
|
|
126
|
+
title = `Tool: ${item.tool}`;
|
|
127
|
+
body = `Arguments: ${JSON.stringify(item.arguments, null, 2)}`;
|
|
128
|
+
if (item.result) {
|
|
129
|
+
body += `
|
|
130
|
+
|
|
131
|
+
Result: ${JSON.stringify(
|
|
132
|
+
item.result.structured_content || item.result.content,
|
|
133
|
+
null,
|
|
134
|
+
2
|
|
135
|
+
)}`;
|
|
136
|
+
}
|
|
137
|
+
if (item.error) {
|
|
138
|
+
body += `
|
|
139
|
+
|
|
140
|
+
Error: ${item.error.message}`;
|
|
141
|
+
}
|
|
142
|
+
break;
|
|
143
|
+
case "web_search":
|
|
144
|
+
title = "Web Search";
|
|
145
|
+
body = `Searching: ${item.query}`;
|
|
146
|
+
break;
|
|
147
|
+
case "todo_list":
|
|
148
|
+
title = "Todo List";
|
|
149
|
+
body = item.items.map(
|
|
150
|
+
(todo) => `- ${todo.text} (${todo.completed ? "completed" : "pending"})`
|
|
151
|
+
).join("\n");
|
|
152
|
+
break;
|
|
153
|
+
case "error":
|
|
154
|
+
title = "Error";
|
|
155
|
+
body = item.message;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
if (title && body) {
|
|
159
|
+
yield uiWidget({
|
|
160
|
+
agentId: context.agentId,
|
|
161
|
+
threadId: event.meta?.threadId,
|
|
162
|
+
widget: {
|
|
163
|
+
kind: "message",
|
|
164
|
+
title,
|
|
165
|
+
body,
|
|
166
|
+
// @ts-ignore
|
|
167
|
+
variant: "basic",
|
|
168
|
+
display: "collapsed"
|
|
169
|
+
}
|
|
170
|
+
});
|
|
124
171
|
}
|
|
125
172
|
}
|
|
126
173
|
}
|