@blueplane/opencode-capture 0.2.1 → 0.2.2
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/plugin.ts +4 -2
- package/writer.ts +9 -0
package/package.json
CHANGED
package/plugin.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import type { Plugin } from "@opencode-ai/plugin";
|
|
6
6
|
import * as path from "path";
|
|
7
7
|
import * as os from "os";
|
|
8
|
-
import { writeEvent, isEventBusType, type WriterConfig } from "./writer";
|
|
8
|
+
import { writeEvent, isEventBusType, isStreamingEvent, type WriterConfig } from "./writer";
|
|
9
9
|
|
|
10
10
|
// ---------------------------------------------------------------------------
|
|
11
11
|
// Plugin export
|
|
@@ -25,7 +25,9 @@ const plugin: Plugin = async (_input) => {
|
|
|
25
25
|
try {
|
|
26
26
|
const hookType = event.type;
|
|
27
27
|
if (!isEventBusType(hookType)) return;
|
|
28
|
-
|
|
28
|
+
const props = (event as any).properties;
|
|
29
|
+
if (isStreamingEvent(hookType, props)) return;
|
|
30
|
+
writeEvent(hookType, props, cfg);
|
|
29
31
|
} catch {
|
|
30
32
|
/* fire-and-forget */
|
|
31
33
|
}
|
package/writer.ts
CHANGED
|
@@ -37,6 +37,8 @@ const ALLOWED_EVENT_BUS_TYPES = new Set([
|
|
|
37
37
|
"file.edited",
|
|
38
38
|
"message.removed",
|
|
39
39
|
"message.updated",
|
|
40
|
+
"message.part.updated",
|
|
41
|
+
"message.part.removed",
|
|
40
42
|
"permission.asked",
|
|
41
43
|
"permission.replied",
|
|
42
44
|
"todo.updated",
|
|
@@ -74,6 +76,13 @@ export function isEventBusType(hookType: string): boolean {
|
|
|
74
76
|
return ALLOWED_EVENT_BUS_TYPES.has(hookType);
|
|
75
77
|
}
|
|
76
78
|
|
|
79
|
+
export function isStreamingEvent(hookType: string, properties: Record<string, any> | undefined): boolean {
|
|
80
|
+
if (!properties) return false;
|
|
81
|
+
if (hookType === "message.part.updated" && properties.delta != null) return true;
|
|
82
|
+
if (hookType === "message.updated" && properties.info?.role === "assistant" && !properties.info?.finish) return true;
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
|
|
77
86
|
// ---------------------------------------------------------------------------
|
|
78
87
|
// Spinlock
|
|
79
88
|
// ---------------------------------------------------------------------------
|