wispy-cli 2.7.10 → 2.7.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.
@@ -0,0 +1,101 @@
1
+ /**
2
+ * lib/jsonl-emitter.mjs — Structured JSONL event emitter for CI/pipeline integration
3
+ *
4
+ * When --json flag is used, all events are emitted as newline-delimited JSON
5
+ * to stdout. Event types: start, user_message, assistant_message,
6
+ * tool_call, tool_result, error, done.
7
+ */
8
+
9
+ export class JsonlEmitter {
10
+ /**
11
+ * Emit a raw event object as a JSON line to stdout.
12
+ * @param {object} event
13
+ */
14
+ emit(event) {
15
+ process.stdout.write(JSON.stringify(event) + "\n");
16
+ }
17
+
18
+ /**
19
+ * Emit a "start" event with session metadata.
20
+ * @param {{ model?: string, session_id?: string, [key: string]: any }} meta
21
+ */
22
+ start(meta) {
23
+ this.emit({ type: "start", ...meta, timestamp: new Date().toISOString() });
24
+ }
25
+
26
+ /**
27
+ * Emit a "tool_call" event.
28
+ * @param {string} name - Tool name
29
+ * @param {object} args - Tool arguments
30
+ */
31
+ toolCall(name, args) {
32
+ this.emit({ type: "tool_call", name, args, timestamp: new Date().toISOString() });
33
+ }
34
+
35
+ /**
36
+ * Emit a "tool_result" event.
37
+ * @param {string} name - Tool name
38
+ * @param {string|object} result - Tool result
39
+ * @param {number} durationMs - Duration in milliseconds
40
+ */
41
+ toolResult(name, result, durationMs) {
42
+ this.emit({
43
+ type: "tool_result",
44
+ name,
45
+ result: typeof result === "string" ? result.slice(0, 1000) : result,
46
+ duration_ms: durationMs,
47
+ });
48
+ }
49
+
50
+ /**
51
+ * Emit a user_message or assistant_message event.
52
+ * @param {"user"|"assistant"} role
53
+ * @param {string} content
54
+ */
55
+ message(role, content) {
56
+ this.emit({ type: `${role}_message`, content, timestamp: new Date().toISOString() });
57
+ }
58
+
59
+ /**
60
+ * Emit an "error" event.
61
+ * @param {Error|string} err
62
+ */
63
+ error(err) {
64
+ this.emit({
65
+ type: "error",
66
+ message: err?.message ?? String(err),
67
+ timestamp: new Date().toISOString(),
68
+ });
69
+ }
70
+
71
+ /**
72
+ * Emit a "done" event with final stats.
73
+ * @param {{ tokens?: { input: number, output: number }, duration_ms?: number, [key: string]: any }} stats
74
+ */
75
+ done(stats) {
76
+ this.emit({ type: "done", ...stats, timestamp: new Date().toISOString() });
77
+ }
78
+ }
79
+
80
+ /**
81
+ * A no-op emitter used when --json flag is not set.
82
+ * All methods are silent.
83
+ */
84
+ export class NullEmitter {
85
+ emit() {}
86
+ start() {}
87
+ toolCall() {}
88
+ toolResult() {}
89
+ message() {}
90
+ error() {}
91
+ done() {}
92
+ }
93
+
94
+ /**
95
+ * Create the appropriate emitter based on whether JSON mode is active.
96
+ * @param {boolean} jsonMode
97
+ * @returns {JsonlEmitter|NullEmitter}
98
+ */
99
+ export function createEmitter(jsonMode) {
100
+ return jsonMode ? new JsonlEmitter() : new NullEmitter();
101
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wispy-cli",
3
- "version": "2.7.10",
3
+ "version": "2.7.12",
4
4
  "description": "🌿 Wispy — AI workspace assistant with trustworthy execution (harness, receipts, approvals, diffs)",
5
5
  "license": "MIT",
6
6
  "author": "Minseo & Poropo",