@openlap/openlap 1.1.7 → 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/channel.d.ts +1 -0
- package/dist/channel.js +3 -0
- package/dist/feed.js +1 -0
- package/dist/index.js +13 -0
- package/dist/proxy.js +13 -1
- package/package.json +1 -1
package/dist/channel.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export declare class ChannelManager {
|
|
|
35
35
|
private mySessionId;
|
|
36
36
|
constructor(baseUrl: string, onUpdate: UpdateCallback, getToken: () => string | undefined, onPresence?: PresenceCallback);
|
|
37
37
|
setSessionId(sessionId: string): void;
|
|
38
|
+
getSessionId(): string | undefined;
|
|
38
39
|
join(channel: string, name?: string): Promise<JoinResponse | null>;
|
|
39
40
|
leave(channel: string): Promise<void>;
|
|
40
41
|
mute(channel: string): boolean;
|
package/dist/channel.js
CHANGED
|
@@ -18,6 +18,9 @@ export class ChannelManager {
|
|
|
18
18
|
setSessionId(sessionId) {
|
|
19
19
|
this.mySessionId = sessionId;
|
|
20
20
|
}
|
|
21
|
+
getSessionId() {
|
|
22
|
+
return this.mySessionId;
|
|
23
|
+
}
|
|
21
24
|
// join calls the server API to register presence, then opens SSE.
|
|
22
25
|
async join(channel, name) {
|
|
23
26
|
if (this.channels.has(channel))
|
package/dist/feed.js
CHANGED
|
@@ -39,6 +39,7 @@ export class FeedManager {
|
|
|
39
39
|
.catch((err) => {
|
|
40
40
|
if (err.name === "AbortError")
|
|
41
41
|
return;
|
|
42
|
+
process.stderr.write(`[openlap] SSE ${tag} error: ${err.message}\n`);
|
|
42
43
|
// Reconnect after 5s
|
|
43
44
|
if (this.streams.has(tag)) {
|
|
44
45
|
setTimeout(() => this.connect(tag, controller), 5000);
|
package/dist/index.js
CHANGED
|
@@ -64,6 +64,19 @@ if (command === "help" || command === "--help" || command === "-h") {
|
|
|
64
64
|
process.exit(0);
|
|
65
65
|
}
|
|
66
66
|
// -- Default: run as MCP proxy server (called by Claude Code) ---------------
|
|
67
|
+
if (command === "--version" || command === "-v" || command === "version") {
|
|
68
|
+
try {
|
|
69
|
+
const { readFileSync } = await import("fs");
|
|
70
|
+
const { join, dirname } = await import("path");
|
|
71
|
+
const { fileURLToPath } = await import("url");
|
|
72
|
+
const ver = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), "..", "package.json"), "utf-8")).version;
|
|
73
|
+
console.log(ver);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
console.log("unknown");
|
|
77
|
+
}
|
|
78
|
+
process.exit(0);
|
|
79
|
+
}
|
|
67
80
|
if (command && command !== "serve") {
|
|
68
81
|
console.error(`Unknown command: ${command}`);
|
|
69
82
|
console.error("Run 'npx @openlap/openlap help' for usage.");
|
package/dist/proxy.js
CHANGED
|
@@ -102,6 +102,14 @@ export async function startProxy() {
|
|
|
102
102
|
});
|
|
103
103
|
// -- v1 compat: FeedManager for old track subscriptions -------------------
|
|
104
104
|
const feeds = new FeedManager(BASE_URL, (tag, update) => {
|
|
105
|
+
// Mute check: skip if channel is muted in ChannelManager
|
|
106
|
+
if (channels.isJoined(tag) && channels.isMuted(tag))
|
|
107
|
+
return;
|
|
108
|
+
// Echo suppression: skip own posts (session_id present in SSE JSON but not typed on TrackUpdate)
|
|
109
|
+
const sessionId = update.session_id;
|
|
110
|
+
const mySession = channels.getSessionId();
|
|
111
|
+
if (mySession && sessionId === mySession)
|
|
112
|
+
return;
|
|
105
113
|
const who = update.project_name || "unknown";
|
|
106
114
|
const health = update.health && update.health !== "on_track" ? ` [${update.health}]` : "";
|
|
107
115
|
const content = `[${who}]${health} ${update.body}`;
|
|
@@ -179,11 +187,15 @@ export async function startProxy() {
|
|
|
179
187
|
const channel = args.channel;
|
|
180
188
|
if (!channel)
|
|
181
189
|
return { content: [{ type: "text", text: "channel required" }], isError: true };
|
|
190
|
+
// Already joined -- return current state
|
|
191
|
+
if (channels.isJoined(channel)) {
|
|
192
|
+
return { content: [{ type: "text", text: `Already in ${channel}. Listening for updates.` }] };
|
|
193
|
+
}
|
|
182
194
|
const result = await channels.join(channel, args.name);
|
|
183
195
|
// Use v1 FeedManager for SSE delivery (proven working)
|
|
184
196
|
feeds.subscribe(channel);
|
|
185
197
|
if (!result)
|
|
186
|
-
return { content: [{ type: "text", text:
|
|
198
|
+
return { content: [{ type: "text", text: `Failed to join ${channel}. Check channel name and auth.` }], isError: true };
|
|
187
199
|
const r = result;
|
|
188
200
|
const lines = [`Joined ${channel}.`];
|
|
189
201
|
if (r.feed_url)
|