lunel-cli 0.1.26 → 0.1.27
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 +19 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1355,7 +1355,19 @@ async function handleAiPermissionReply(payload) {
|
|
|
1355
1355
|
async function subscribeToOpenCodeEvents(client) {
|
|
1356
1356
|
try {
|
|
1357
1357
|
const events = await client.event.subscribe();
|
|
1358
|
-
for await (const
|
|
1358
|
+
for await (const raw of events.stream) {
|
|
1359
|
+
// OpenCode SSE payload shapes vary across versions:
|
|
1360
|
+
// { type, properties, ... }
|
|
1361
|
+
// { payload: { type, properties, ... }, directory: "..." }
|
|
1362
|
+
const parsed = raw;
|
|
1363
|
+
const base = parsed?.payload && typeof parsed.payload === "object"
|
|
1364
|
+
? parsed.payload
|
|
1365
|
+
: parsed;
|
|
1366
|
+
if (!base || typeof base.type !== "string") {
|
|
1367
|
+
console.warn("[sse] Dropped malformed event:", JSON.stringify(parsed).substring(0, 200));
|
|
1368
|
+
continue;
|
|
1369
|
+
}
|
|
1370
|
+
console.log("[sse]", base.type);
|
|
1359
1371
|
if (dataChannel && dataChannel.readyState === WebSocket.OPEN) {
|
|
1360
1372
|
const msg = {
|
|
1361
1373
|
v: 1,
|
|
@@ -1363,16 +1375,19 @@ async function subscribeToOpenCodeEvents(client) {
|
|
|
1363
1375
|
ns: "ai",
|
|
1364
1376
|
action: "event",
|
|
1365
1377
|
payload: {
|
|
1366
|
-
type:
|
|
1367
|
-
properties:
|
|
1378
|
+
type: base.type,
|
|
1379
|
+
properties: base.properties || {},
|
|
1368
1380
|
},
|
|
1369
1381
|
};
|
|
1370
1382
|
dataChannel.send(JSON.stringify(msg));
|
|
1371
1383
|
}
|
|
1372
1384
|
}
|
|
1385
|
+
// Stream ended normally — reconnect
|
|
1386
|
+
console.log("[sse] Event stream ended, reconnecting...");
|
|
1387
|
+
setTimeout(() => subscribeToOpenCodeEvents(client), 1000);
|
|
1373
1388
|
}
|
|
1374
1389
|
catch (err) {
|
|
1375
|
-
console.error("
|
|
1390
|
+
console.error("[sse] Event stream error:", err.message);
|
|
1376
1391
|
setTimeout(() => subscribeToOpenCodeEvents(client), 3000);
|
|
1377
1392
|
}
|
|
1378
1393
|
}
|