zjbar-opencode 1.1.8 → 1.1.9
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 +25 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -145,9 +145,14 @@ var ZjbarPlugin = async ({ directory, client }) => {
|
|
|
145
145
|
const paneId = process.env.ZELLIJ_PANE_ID;
|
|
146
146
|
if (!zellijSession || !paneId)
|
|
147
147
|
return {};
|
|
148
|
+
const GUARD_KEY = "ZJBAR_OPENCODE_ACTIVE";
|
|
149
|
+
if (process.env[GUARD_KEY])
|
|
150
|
+
return {};
|
|
151
|
+
process.env[GUARD_KEY] = "1";
|
|
148
152
|
const sessionId = crypto.randomUUID();
|
|
149
153
|
const termProgram = process.env.TERM_PROGRAM || null;
|
|
150
154
|
let activeSessionId = null;
|
|
155
|
+
let stopNotified = false;
|
|
151
156
|
let zellijBin = "zellij";
|
|
152
157
|
try {
|
|
153
158
|
const { execFileSync } = __require("node:child_process");
|
|
@@ -189,18 +194,30 @@ var ZjbarPlugin = async ({ directory, client }) => {
|
|
|
189
194
|
return {
|
|
190
195
|
event: async ({ event }) => {
|
|
191
196
|
const ev = event;
|
|
192
|
-
|
|
197
|
+
const eventType = ev.type;
|
|
198
|
+
switch (eventType) {
|
|
193
199
|
case "session.created":
|
|
194
|
-
activeSessionId = ev.properties?.
|
|
200
|
+
activeSessionId = ev.properties?.info?.id || null;
|
|
195
201
|
sendToZjbar("SessionStart");
|
|
196
202
|
break;
|
|
203
|
+
case "session.status": {
|
|
204
|
+
const status = ev.properties?.status?.type;
|
|
205
|
+
if (status === "busy") {
|
|
206
|
+
stopNotified = false;
|
|
207
|
+
sendToZjbar("UserPromptSubmit");
|
|
208
|
+
}
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
197
211
|
case "session.idle": {
|
|
198
212
|
sendToZjbar("Stop", null, null, true);
|
|
213
|
+
if (stopNotified)
|
|
214
|
+
break;
|
|
199
215
|
const sid = ev.properties?.sessionID || activeSessionId;
|
|
200
216
|
if (sid && client) {
|
|
201
217
|
try {
|
|
202
218
|
const summary = await getSessionSummary(client, sid);
|
|
203
219
|
if (summary && shouldNotify("Stop", paneId, termProgram)) {
|
|
220
|
+
stopNotified = true;
|
|
204
221
|
sendNotification("Stop", paneId, zellijSession, termProgram, summary);
|
|
205
222
|
}
|
|
206
223
|
} catch {}
|
|
@@ -216,10 +233,13 @@ var ZjbarPlugin = async ({ directory, client }) => {
|
|
|
216
233
|
sendToZjbar("PermissionRequest", null, permTitle);
|
|
217
234
|
break;
|
|
218
235
|
}
|
|
219
|
-
case "message.
|
|
220
|
-
|
|
221
|
-
|
|
236
|
+
case "message.updated": {
|
|
237
|
+
const msgInfo = ev.properties?.info;
|
|
238
|
+
if (msgInfo?.role === "user" && msgInfo?.sessionID) {
|
|
239
|
+
activeSessionId = msgInfo.sessionID;
|
|
240
|
+
}
|
|
222
241
|
break;
|
|
242
|
+
}
|
|
223
243
|
}
|
|
224
244
|
},
|
|
225
245
|
"tool.execute.before": async (input) => {
|