@openlap/openlap 1.1.4 → 1.1.6
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/channel.d.ts +0 -4
- package/dist/channel.js +7 -36
- package/dist/proxy.js +0 -4
- package/package.json +1 -1
package/dist/channel.d.ts
CHANGED
|
@@ -42,13 +42,9 @@ export declare class ChannelManager {
|
|
|
42
42
|
getFocusedChannel(): string | undefined;
|
|
43
43
|
isJoined(channel: string): boolean;
|
|
44
44
|
isMuted(channel: string): boolean;
|
|
45
|
-
hasChannels(): boolean;
|
|
46
|
-
heartbeat(): Promise<void>;
|
|
47
45
|
private connectSSE;
|
|
48
46
|
private readStream;
|
|
49
47
|
private handleSSEEvent;
|
|
50
|
-
private startHeartbeat;
|
|
51
|
-
private stopHeartbeat;
|
|
52
48
|
stop(): void;
|
|
53
49
|
}
|
|
54
50
|
export {};
|
package/dist/channel.js
CHANGED
|
@@ -46,10 +46,6 @@ export class ChannelManager {
|
|
|
46
46
|
const controller = new AbortController();
|
|
47
47
|
this.channels.set(channel, { controller, muted: false, focused: false });
|
|
48
48
|
this.connectSSE(channel, controller);
|
|
49
|
-
// Start heartbeat if first channel
|
|
50
|
-
if (this.channels.size === 1) {
|
|
51
|
-
this.startHeartbeat();
|
|
52
|
-
}
|
|
53
49
|
return data;
|
|
54
50
|
}
|
|
55
51
|
catch (err) {
|
|
@@ -64,10 +60,6 @@ export class ChannelManager {
|
|
|
64
60
|
return;
|
|
65
61
|
state.controller.abort();
|
|
66
62
|
this.channels.delete(channel);
|
|
67
|
-
// Stop heartbeat if no channels
|
|
68
|
-
if (this.channels.size === 0) {
|
|
69
|
-
this.stopHeartbeat();
|
|
70
|
-
}
|
|
71
63
|
const token = this.getToken();
|
|
72
64
|
const headers = {};
|
|
73
65
|
if (token)
|
|
@@ -121,24 +113,6 @@ export class ChannelManager {
|
|
|
121
113
|
isMuted(channel) {
|
|
122
114
|
return this.channels.get(channel)?.muted ?? false;
|
|
123
115
|
}
|
|
124
|
-
hasChannels() {
|
|
125
|
-
return this.channels.size > 0;
|
|
126
|
-
}
|
|
127
|
-
// Public heartbeat -- called by proxy on every tool invocation.
|
|
128
|
-
async heartbeat() {
|
|
129
|
-
const token = this.getToken();
|
|
130
|
-
if (!token)
|
|
131
|
-
return;
|
|
132
|
-
try {
|
|
133
|
-
await fetch(`${this.baseUrl}/api/presence/heartbeat`, {
|
|
134
|
-
method: "POST",
|
|
135
|
-
headers: { "Authorization": `Bearer ${token}` },
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
catch {
|
|
139
|
-
// not critical
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
116
|
// SSE connection for a channel
|
|
143
117
|
connectSSE(channel, controller) {
|
|
144
118
|
const url = `${this.baseUrl}/feed/${channel}/sse`;
|
|
@@ -146,15 +120,20 @@ export class ChannelManager {
|
|
|
146
120
|
const token = this.getToken();
|
|
147
121
|
if (token)
|
|
148
122
|
headers["Authorization"] = `Bearer ${token}`;
|
|
123
|
+
process.stderr.write(`[openlap] SSE connecting to ${channel}${token ? ' (with auth)' : ' (NO auth)'}\n`);
|
|
149
124
|
fetch(url, { headers, signal: controller.signal })
|
|
150
125
|
.then((res) => {
|
|
151
|
-
if (!res.ok || !res.body)
|
|
126
|
+
if (!res.ok || !res.body) {
|
|
127
|
+
process.stderr.write(`[openlap] SSE ${channel} failed: ${res.status}\n`);
|
|
152
128
|
throw new Error(`SSE connect failed: ${res.status}`);
|
|
129
|
+
}
|
|
130
|
+
process.stderr.write(`[openlap] SSE ${channel} connected\n`);
|
|
153
131
|
return this.readStream(channel, res.body, controller);
|
|
154
132
|
})
|
|
155
133
|
.catch((err) => {
|
|
156
134
|
if (err.name === "AbortError")
|
|
157
135
|
return;
|
|
136
|
+
process.stderr.write(`[openlap] SSE ${channel} error: ${err.message}\n`);
|
|
158
137
|
if (this.channels.has(channel)) {
|
|
159
138
|
setTimeout(() => this.connectSSE(channel, controller), 5000);
|
|
160
139
|
}
|
|
@@ -242,16 +221,8 @@ export class ChannelManager {
|
|
|
242
221
|
}
|
|
243
222
|
}
|
|
244
223
|
}
|
|
245
|
-
//
|
|
246
|
-
// (setInterval doesn't fire reliably in MCP stdio context).
|
|
247
|
-
startHeartbeat() {
|
|
248
|
-
this.heartbeat().catch(() => { });
|
|
249
|
-
}
|
|
250
|
-
stopHeartbeat() {
|
|
251
|
-
// No interval to clear -- heartbeats piggyback on tool calls
|
|
252
|
-
}
|
|
224
|
+
// No heartbeat needed. Presence persists until explicit leave or session expiry.
|
|
253
225
|
stop() {
|
|
254
|
-
this.stopHeartbeat();
|
|
255
226
|
for (const [, state] of this.channels) {
|
|
256
227
|
state.controller.abort();
|
|
257
228
|
}
|
package/dist/proxy.js
CHANGED
|
@@ -174,10 +174,6 @@ export async function startProxy() {
|
|
|
174
174
|
server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
175
175
|
const { name } = req.params;
|
|
176
176
|
const args = { ...(req.params.arguments ?? {}) };
|
|
177
|
-
// -- Heartbeat on every tool call (keeps presence alive) ----------------
|
|
178
|
-
if (channels.hasChannels()) {
|
|
179
|
-
channels.heartbeat().catch(() => { });
|
|
180
|
-
}
|
|
181
177
|
// -- v2 proxy-side channel tools (handled locally) ----------------------
|
|
182
178
|
if (name === "join_channel") {
|
|
183
179
|
const channel = args.channel;
|