@ax0l0tl/agent-governance-opencode 4.0.3 → 4.0.4
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/package.json +1 -1
- package/src/index.mjs +4 -29
package/package.json
CHANGED
package/src/index.mjs
CHANGED
|
@@ -178,35 +178,10 @@ function extractPromptFromEvent(event) {
|
|
|
178
178
|
if (!event || typeof event !== "object") {
|
|
179
179
|
return "";
|
|
180
180
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
// OpenCode emits chat.* events when the user sends a message. Different
|
|
186
|
-
// versions may key the prompt under different paths; check the common ones.
|
|
187
|
-
if (!/^(chat|message|prompt|user)\b/.test(type)) {
|
|
188
|
-
return "";
|
|
189
|
-
}
|
|
190
|
-
const props = event.properties ?? event.data ?? {};
|
|
191
|
-
const candidates = [
|
|
192
|
-
props.prompt,
|
|
193
|
-
props.message,
|
|
194
|
-
props.text,
|
|
195
|
-
props.content,
|
|
196
|
-
typeof props.message === "object" ? props.message?.content : undefined,
|
|
197
|
-
];
|
|
198
|
-
for (const candidate of candidates) {
|
|
199
|
-
if (typeof candidate === "string" && candidate.trim()) {
|
|
200
|
-
return candidate;
|
|
201
|
-
}
|
|
202
|
-
if (Array.isArray(candidate)) {
|
|
203
|
-
const joined = candidate
|
|
204
|
-
.map((part) => (typeof part === "string" ? part : part?.text ?? ""))
|
|
205
|
-
.filter(Boolean)
|
|
206
|
-
.join("\n");
|
|
207
|
-
if (joined.trim()) {
|
|
208
|
-
return joined;
|
|
209
|
-
}
|
|
181
|
+
if (event.type === "message.part.updated") {
|
|
182
|
+
const part = event.properties?.part;
|
|
183
|
+
if (part?.type === "text" && typeof part.text === "string") {
|
|
184
|
+
return part.text.trim();
|
|
210
185
|
}
|
|
211
186
|
}
|
|
212
187
|
return "";
|