opencode-browser-annotation-plugin 0.1.1 → 0.1.3
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/plugin.js +8 -8
- package/package.json +4 -1
package/dist/plugin.js
CHANGED
|
@@ -174,19 +174,22 @@ export const BrowserAnnotationPlugin = async ({ client, directory }) => {
|
|
|
174
174
|
sendJson(res, 404, { ok: false, error: "Not found" });
|
|
175
175
|
}
|
|
176
176
|
function start() {
|
|
177
|
+
if (server)
|
|
178
|
+
return; // never double-listen (the plugin may init more than once)
|
|
177
179
|
const s = createServer(handle);
|
|
180
|
+
server = s; // claim synchronously so a re-entrant start() is a no-op
|
|
178
181
|
s.on("error", (error) => {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
182
|
+
// Another instance already owns the port. Drop this half-open server so we
|
|
183
|
+
// don't leave a listener that resets connections without responding.
|
|
184
|
+
server = null;
|
|
185
|
+
s.close();
|
|
186
|
+
if (error.code !== "EADDRINUSE") {
|
|
183
187
|
log("error", `Annotation server error: ${error.message}`);
|
|
184
188
|
}
|
|
185
189
|
});
|
|
186
190
|
s.listen(port, host, () => {
|
|
187
191
|
log("info", `Browser annotation server listening on http://${host}:${port}`);
|
|
188
192
|
});
|
|
189
|
-
server = s;
|
|
190
193
|
}
|
|
191
194
|
start();
|
|
192
195
|
return {
|
|
@@ -199,9 +202,6 @@ export const BrowserAnnotationPlugin = async ({ client, directory }) => {
|
|
|
199
202
|
if (event.properties.info.id === activeSessionID)
|
|
200
203
|
activeSessionID = null;
|
|
201
204
|
}
|
|
202
|
-
else if (event.type === "server.connected" && !server) {
|
|
203
|
-
start();
|
|
204
|
-
}
|
|
205
205
|
},
|
|
206
206
|
};
|
|
207
207
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-browser-annotation-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Select an element in your browser, type an instruction, and send it to your OpenCode agent over a loopback + SSH tunnel. Text and element metadata only (no screenshots).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"opencode",
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
"url": "git+https://github.com/caoool/opencode-browser-annotation-plugin.git"
|
|
17
17
|
},
|
|
18
18
|
"type": "module",
|
|
19
|
+
"main": "./dist/plugin.js",
|
|
20
|
+
"module": "./dist/plugin.js",
|
|
21
|
+
"types": "./dist/plugin.d.ts",
|
|
19
22
|
"exports": {
|
|
20
23
|
".": {
|
|
21
24
|
"types": "./dist/plugin.d.ts",
|