@wipcomputer/wip-ldm-os 0.4.73-alpha.21 → 0.4.73-alpha.23
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/bridge/chunk-3RG5ZIWI.js +10 -0
- package/dist/bridge/{chunk-24DJYS7Z.js → chunk-6TOUTUOG.js} +31 -0
- package/dist/bridge/cli.js +2 -1
- package/dist/bridge/core.d.ts +12 -1
- package/dist/bridge/core.js +4 -1
- package/dist/bridge/mcp-server.js +24 -12
- package/dist/bridge/openclaw.js +2 -0
- package/package.json +1 -1
- package/src/bridge/core.ts +40 -0
- package/src/bridge/mcp-server.ts +29 -13
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
__require
|
|
10
|
+
};
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__require
|
|
3
|
+
} from "./chunk-3RG5ZIWI.js";
|
|
4
|
+
|
|
1
5
|
// core.ts
|
|
2
6
|
import { execSync, exec } from "child_process";
|
|
3
7
|
import { readdirSync, readFileSync, writeFileSync, existsSync, statSync, mkdirSync, renameSync, unlinkSync } from "fs";
|
|
@@ -115,6 +119,30 @@ function setSessionIdentity(agentId, sessionName) {
|
|
|
115
119
|
function getSessionIdentity() {
|
|
116
120
|
return { agentId: _sessionAgentId, sessionName: _sessionName };
|
|
117
121
|
}
|
|
122
|
+
function refreshSessionIdentity() {
|
|
123
|
+
try {
|
|
124
|
+
const sessionPath = join(
|
|
125
|
+
process.env.HOME || __require("os").homedir(),
|
|
126
|
+
".claude",
|
|
127
|
+
"sessions",
|
|
128
|
+
`${process.ppid}.json`
|
|
129
|
+
);
|
|
130
|
+
const data = JSON.parse(readFileSync(sessionPath, "utf-8"));
|
|
131
|
+
if (data.name && typeof data.name === "string" && data.name !== _sessionName) {
|
|
132
|
+
const oldName = _sessionName;
|
|
133
|
+
_sessionName = data.name;
|
|
134
|
+
try {
|
|
135
|
+
registerBridgeSession();
|
|
136
|
+
} catch {
|
|
137
|
+
}
|
|
138
|
+
if (oldName !== _sessionName) {
|
|
139
|
+
process.stderr.write(`wip-bridge: session name updated: ${oldName} -> ${_sessionName}
|
|
140
|
+
`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
} catch {
|
|
144
|
+
}
|
|
145
|
+
}
|
|
118
146
|
function parseTarget(to) {
|
|
119
147
|
if (to === "*") return { agent: "*", session: "*" };
|
|
120
148
|
const colonIdx = to.indexOf(":");
|
|
@@ -148,6 +176,7 @@ function pushInbox(msg) {
|
|
|
148
176
|
}
|
|
149
177
|
}
|
|
150
178
|
function drainInbox() {
|
|
179
|
+
refreshSessionIdentity();
|
|
151
180
|
try {
|
|
152
181
|
if (!existsSync(MESSAGES_DIR)) return [];
|
|
153
182
|
const files = readdirSync(MESSAGES_DIR).filter((f) => f.endsWith(".json"));
|
|
@@ -178,6 +207,7 @@ function drainInbox() {
|
|
|
178
207
|
}
|
|
179
208
|
}
|
|
180
209
|
function inboxCount() {
|
|
210
|
+
refreshSessionIdentity();
|
|
181
211
|
try {
|
|
182
212
|
if (!existsSync(MESSAGES_DIR)) return 0;
|
|
183
213
|
const files = readdirSync(MESSAGES_DIR).filter((f) => f.endsWith(".json"));
|
|
@@ -621,6 +651,7 @@ export {
|
|
|
621
651
|
resolveGatewayConfig,
|
|
622
652
|
setSessionIdentity,
|
|
623
653
|
getSessionIdentity,
|
|
654
|
+
refreshSessionIdentity,
|
|
624
655
|
pushInbox,
|
|
625
656
|
drainInbox,
|
|
626
657
|
inboxCount,
|
package/dist/bridge/cli.js
CHANGED
package/dist/bridge/core.d.ts
CHANGED
|
@@ -49,6 +49,17 @@ declare function getSessionIdentity(): {
|
|
|
49
49
|
agentId: string;
|
|
50
50
|
sessionName: string;
|
|
51
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* Re-read the session name from CC's session metadata file.
|
|
54
|
+
*
|
|
55
|
+
* CC writes the /rename label to ~/.claude/sessions/<pid>.json. The bridge
|
|
56
|
+
* reads this once on boot, but the name can change at any time via /rename
|
|
57
|
+
* or /resume. Calling this before each inbox check ensures the bridge
|
|
58
|
+
* always uses the current label for message targeting.
|
|
59
|
+
*
|
|
60
|
+
* Cheap: one file read per call. No network. No delay.
|
|
61
|
+
*/
|
|
62
|
+
declare function refreshSessionIdentity(): void;
|
|
52
63
|
/**
|
|
53
64
|
* Write a message to the file-based inbox.
|
|
54
65
|
* Creates a JSON file at ~/.ldm/messages/{uuid}.json.
|
|
@@ -133,4 +144,4 @@ declare function discoverSkills(openclawDir: string): SkillInfo[];
|
|
|
133
144
|
declare function executeSkillScript(skillDir: string, scripts: string[], scriptName: string | undefined, args: string): Promise<string>;
|
|
134
145
|
declare function readWorkspaceFile(workspaceDir: string, filePath: string): WorkspaceFileResult;
|
|
135
146
|
|
|
136
|
-
export { type BridgeConfig, type ConversationResult, type GatewayConfig, type InboxMessage, LDM_ROOT, type SessionInfo, type SkillInfo, type WorkspaceFileResult, type WorkspaceSearchResult, blobToEmbedding, cosineSimilarity, discoverSkills, drainInbox, executeSkillScript, findMarkdownFiles, getQueryEmbedding, getSessionIdentity, inboxCount, inboxCountBySession, listActiveSessions, pushInbox, readWorkspaceFile, registerBridgeSession, resolveApiKey, resolveConfig, resolveConfigMulti, resolveGatewayConfig, searchConversations, searchWorkspace, sendLdmMessage, sendMessage, setSessionIdentity };
|
|
147
|
+
export { type BridgeConfig, type ConversationResult, type GatewayConfig, type InboxMessage, LDM_ROOT, type SessionInfo, type SkillInfo, type WorkspaceFileResult, type WorkspaceSearchResult, blobToEmbedding, cosineSimilarity, discoverSkills, drainInbox, executeSkillScript, findMarkdownFiles, getQueryEmbedding, getSessionIdentity, inboxCount, inboxCountBySession, listActiveSessions, pushInbox, readWorkspaceFile, refreshSessionIdentity, registerBridgeSession, resolveApiKey, resolveConfig, resolveConfigMulti, resolveGatewayConfig, searchConversations, searchWorkspace, sendLdmMessage, sendMessage, setSessionIdentity };
|
package/dist/bridge/core.js
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
listActiveSessions,
|
|
14
14
|
pushInbox,
|
|
15
15
|
readWorkspaceFile,
|
|
16
|
+
refreshSessionIdentity,
|
|
16
17
|
registerBridgeSession,
|
|
17
18
|
resolveApiKey,
|
|
18
19
|
resolveConfig,
|
|
@@ -23,7 +24,8 @@ import {
|
|
|
23
24
|
sendLdmMessage,
|
|
24
25
|
sendMessage,
|
|
25
26
|
setSessionIdentity
|
|
26
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-6TOUTUOG.js";
|
|
28
|
+
import "./chunk-3RG5ZIWI.js";
|
|
27
29
|
export {
|
|
28
30
|
LDM_ROOT,
|
|
29
31
|
blobToEmbedding,
|
|
@@ -39,6 +41,7 @@ export {
|
|
|
39
41
|
listActiveSessions,
|
|
40
42
|
pushInbox,
|
|
41
43
|
readWorkspaceFile,
|
|
44
|
+
refreshSessionIdentity,
|
|
42
45
|
registerBridgeSession,
|
|
43
46
|
resolveApiKey,
|
|
44
47
|
resolveConfig,
|
|
@@ -15,7 +15,10 @@ import {
|
|
|
15
15
|
sendLdmMessage,
|
|
16
16
|
sendMessage,
|
|
17
17
|
setSessionIdentity
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-6TOUTUOG.js";
|
|
19
|
+
import {
|
|
20
|
+
__require
|
|
21
|
+
} from "./chunk-3RG5ZIWI.js";
|
|
19
22
|
|
|
20
23
|
// mcp-server.ts
|
|
21
24
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
@@ -323,18 +326,27 @@ ${lines.join("\n")}` }] };
|
|
|
323
326
|
console.error(`wip-bridge: registered ${executableSkills.length} skill tools + oc_skills_list (${skills.length} total skills)`);
|
|
324
327
|
}
|
|
325
328
|
function resolveSessionName() {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
"
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
329
|
+
const ccSessionDir = join(process.env.HOME || homedir(), ".claude", "sessions");
|
|
330
|
+
const ccSessionPath = join(ccSessionDir, `${process.ppid}.json`);
|
|
331
|
+
for (let attempt = 0; attempt < 3; attempt++) {
|
|
332
|
+
try {
|
|
333
|
+
const data = JSON.parse(readFileSync(ccSessionPath, "utf-8"));
|
|
334
|
+
if (data.name && typeof data.name === "string") {
|
|
335
|
+
return data.name;
|
|
336
|
+
}
|
|
337
|
+
if (attempt < 2) {
|
|
338
|
+
const { execSync } = __require("child_process");
|
|
339
|
+
execSync("sleep 0.5", { stdio: "ignore" });
|
|
340
|
+
}
|
|
341
|
+
} catch {
|
|
342
|
+
if (attempt < 2) {
|
|
343
|
+
try {
|
|
344
|
+
const { execSync } = __require("child_process");
|
|
345
|
+
execSync("sleep 0.5", { stdio: "ignore" });
|
|
346
|
+
} catch {
|
|
347
|
+
}
|
|
348
|
+
}
|
|
336
349
|
}
|
|
337
|
-
} catch {
|
|
338
350
|
}
|
|
339
351
|
if (process.env.LDM_SESSION_NAME) {
|
|
340
352
|
return process.env.LDM_SESSION_NAME;
|
package/dist/bridge/openclaw.js
CHANGED
package/package.json
CHANGED
package/src/bridge/core.ts
CHANGED
|
@@ -215,6 +215,41 @@ export function getSessionIdentity(): { agentId: string; sessionName: string } {
|
|
|
215
215
|
return { agentId: _sessionAgentId, sessionName: _sessionName };
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
+
/**
|
|
219
|
+
* Re-read the session name from CC's session metadata file.
|
|
220
|
+
*
|
|
221
|
+
* CC writes the /rename label to ~/.claude/sessions/<pid>.json. The bridge
|
|
222
|
+
* reads this once on boot, but the name can change at any time via /rename
|
|
223
|
+
* or /resume. Calling this before each inbox check ensures the bridge
|
|
224
|
+
* always uses the current label for message targeting.
|
|
225
|
+
*
|
|
226
|
+
* Cheap: one file read per call. No network. No delay.
|
|
227
|
+
*/
|
|
228
|
+
export function refreshSessionIdentity(): void {
|
|
229
|
+
try {
|
|
230
|
+
const sessionPath = join(
|
|
231
|
+
process.env.HOME || require("node:os").homedir(),
|
|
232
|
+
".claude",
|
|
233
|
+
"sessions",
|
|
234
|
+
`${process.ppid}.json`
|
|
235
|
+
);
|
|
236
|
+
const data = JSON.parse(readFileSync(sessionPath, "utf-8"));
|
|
237
|
+
if (data.name && typeof data.name === "string" && data.name !== _sessionName) {
|
|
238
|
+
const oldName = _sessionName;
|
|
239
|
+
_sessionName = data.name;
|
|
240
|
+
// Re-register with the new name so other agents can find us
|
|
241
|
+
try {
|
|
242
|
+
registerBridgeSession();
|
|
243
|
+
} catch {}
|
|
244
|
+
if (oldName !== _sessionName) {
|
|
245
|
+
process.stderr.write(`wip-bridge: session name updated: ${oldName} -> ${_sessionName}\n`);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
} catch {
|
|
249
|
+
// File doesn't exist or can't be read. Keep current name.
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
218
253
|
/**
|
|
219
254
|
* Parse a "to" field into agent and session parts.
|
|
220
255
|
* Formats: "cc-mini" (default session), "cc-mini:brainstorm" (named),
|
|
@@ -279,6 +314,10 @@ export function pushInbox(msg: { from: string; message?: string; body?: string;
|
|
|
279
314
|
* Moves processed messages to ~/.ldm/messages/_processed/.
|
|
280
315
|
*/
|
|
281
316
|
export function drainInbox(): InboxMessage[] {
|
|
317
|
+
// Re-read session name from CC metadata before filtering.
|
|
318
|
+
// Handles /rename and /resume happening after bridge boot.
|
|
319
|
+
refreshSessionIdentity();
|
|
320
|
+
|
|
282
321
|
try {
|
|
283
322
|
if (!existsSync(MESSAGES_DIR)) return [];
|
|
284
323
|
|
|
@@ -323,6 +362,7 @@ export function drainInbox(): InboxMessage[] {
|
|
|
323
362
|
* Count pending messages for this session without draining.
|
|
324
363
|
*/
|
|
325
364
|
export function inboxCount(): number {
|
|
365
|
+
refreshSessionIdentity();
|
|
326
366
|
try {
|
|
327
367
|
if (!existsSync(MESSAGES_DIR)) return 0;
|
|
328
368
|
|
package/src/bridge/mcp-server.ts
CHANGED
|
@@ -452,20 +452,36 @@ function registerSkillTools(skills: SkillInfo[]): void {
|
|
|
452
452
|
* Fallback chain: CC session file -> LDM_SESSION_NAME env -> "default"
|
|
453
453
|
*/
|
|
454
454
|
function resolveSessionName(): string {
|
|
455
|
-
// 1. Try CC session file for parent PID
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
455
|
+
// 1. Try CC session file for parent PID.
|
|
456
|
+
// CC and the bridge MCP server start concurrently. CC writes the session
|
|
457
|
+
// file after boot, but the bridge may read it before it exists or before
|
|
458
|
+
// the /rename label is written. Retry with a brief delay to handle the
|
|
459
|
+
// race. Three attempts, 500ms apart = up to 1s total wait. If it still
|
|
460
|
+
// fails, fall through to env var or default.
|
|
461
|
+
const ccSessionDir = join(process.env.HOME || homedir(), ".claude", "sessions");
|
|
462
|
+
const ccSessionPath = join(ccSessionDir, `${process.ppid}.json`);
|
|
463
|
+
|
|
464
|
+
for (let attempt = 0; attempt < 3; attempt++) {
|
|
465
|
+
try {
|
|
466
|
+
const data = JSON.parse(readFileSync(ccSessionPath, "utf-8"));
|
|
467
|
+
if (data.name && typeof data.name === "string") {
|
|
468
|
+
return data.name;
|
|
469
|
+
}
|
|
470
|
+
// File exists but no name yet. CC hasn't written /rename label.
|
|
471
|
+
// On the last attempt, break to fallback. Otherwise wait and retry.
|
|
472
|
+
if (attempt < 2) {
|
|
473
|
+
const { execSync } = require("node:child_process");
|
|
474
|
+
execSync("sleep 0.5", { stdio: "ignore" });
|
|
475
|
+
}
|
|
476
|
+
} catch {
|
|
477
|
+
// File doesn't exist yet. Wait and retry.
|
|
478
|
+
if (attempt < 2) {
|
|
479
|
+
try {
|
|
480
|
+
const { execSync } = require("node:child_process");
|
|
481
|
+
execSync("sleep 0.5", { stdio: "ignore" });
|
|
482
|
+
} catch {}
|
|
483
|
+
}
|
|
466
484
|
}
|
|
467
|
-
} catch {
|
|
468
|
-
// No session file for parent PID. Normal for non-CC harnesses.
|
|
469
485
|
}
|
|
470
486
|
|
|
471
487
|
// 2. Try env var (explicit override)
|