@xqli02/mneme 0.1.11 → 0.1.13
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/src/commands/auto.mjs +1155 -209
- package/src/opencode-client.mjs +9 -5
package/src/opencode-client.mjs
CHANGED
|
@@ -37,12 +37,16 @@ export function createClient(baseUrl) {
|
|
|
37
37
|
/**
|
|
38
38
|
* Subscribe to SSE event stream.
|
|
39
39
|
* Returns an async iterator of parsed events: { type, properties }.
|
|
40
|
+
* @param {string} path
|
|
41
|
+
* @param {{ signal?: AbortSignal }} [opts]
|
|
40
42
|
*/
|
|
41
|
-
async function* subscribeEvents(path = "/event") {
|
|
43
|
+
async function* subscribeEvents(path = "/event", opts = {}) {
|
|
42
44
|
const url = `${base}${path}`;
|
|
43
|
-
const
|
|
45
|
+
const fetchOpts = {
|
|
44
46
|
headers: { Accept: "text/event-stream" },
|
|
45
|
-
}
|
|
47
|
+
};
|
|
48
|
+
if (opts.signal) fetchOpts.signal = opts.signal;
|
|
49
|
+
const res = await fetch(url, fetchOpts);
|
|
46
50
|
if (!res.ok) {
|
|
47
51
|
throw new Error(`SSE connect failed: ${res.status}`);
|
|
48
52
|
}
|
|
@@ -126,8 +130,8 @@ export function createClient(baseUrl) {
|
|
|
126
130
|
|
|
127
131
|
/** Events */
|
|
128
132
|
events: {
|
|
129
|
-
subscribe: () => subscribeEvents("/event"),
|
|
130
|
-
subscribeGlobal: () => subscribeEvents("/global/event"),
|
|
133
|
+
subscribe: (opts) => subscribeEvents("/event", opts),
|
|
134
|
+
subscribeGlobal: (opts) => subscribeEvents("/global/event", opts),
|
|
131
135
|
},
|
|
132
136
|
|
|
133
137
|
/** Raw request for anything else */
|