@wipcomputer/wip-ldm-os 0.4.73-alpha.20 → 0.4.73-alpha.22
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.
|
@@ -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
|
+
};
|
package/dist/bridge/cli.js
CHANGED
package/dist/bridge/core.js
CHANGED
|
@@ -16,12 +16,15 @@ import {
|
|
|
16
16
|
sendMessage,
|
|
17
17
|
setSessionIdentity
|
|
18
18
|
} from "./chunk-24DJYS7Z.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";
|
|
22
25
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
23
26
|
import { createServer } from "http";
|
|
24
|
-
import { appendFileSync, mkdirSync } from "fs";
|
|
27
|
+
import { appendFileSync, mkdirSync, readFileSync } from "fs";
|
|
25
28
|
import { join } from "path";
|
|
26
29
|
import { homedir } from "os";
|
|
27
30
|
import { z } from "zod";
|
|
@@ -322,11 +325,39 @@ ${lines.join("\n")}` }] };
|
|
|
322
325
|
);
|
|
323
326
|
console.error(`wip-bridge: registered ${executableSkills.length} skill tools + oc_skills_list (${skills.length} total skills)`);
|
|
324
327
|
}
|
|
328
|
+
function resolveSessionName() {
|
|
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
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (process.env.LDM_SESSION_NAME) {
|
|
352
|
+
return process.env.LDM_SESSION_NAME;
|
|
353
|
+
}
|
|
354
|
+
return "default";
|
|
355
|
+
}
|
|
325
356
|
async function main() {
|
|
326
357
|
const agentId = process.env.LDM_AGENT_ID || "cc-mini";
|
|
327
|
-
const sessionName =
|
|
358
|
+
const sessionName = resolveSessionName();
|
|
328
359
|
setSessionIdentity(agentId, sessionName);
|
|
329
|
-
console.error(`wip-bridge: session identity: ${agentId}:${sessionName}`);
|
|
360
|
+
console.error(`wip-bridge: session identity: ${agentId}:${sessionName} (resolved from ${sessionName !== "default" ? "CC session file or env" : "default"})`);
|
|
330
361
|
const session = registerBridgeSession();
|
|
331
362
|
if (session) {
|
|
332
363
|
console.error(`wip-bridge: registered session ${agentId}--${sessionName} (pid ${session.pid})`);
|
package/dist/bridge/openclaw.js
CHANGED
package/package.json
CHANGED
package/src/bridge/mcp-server.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
5
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
6
|
import { createServer, IncomingMessage, ServerResponse } from "node:http";
|
|
7
|
-
import { appendFileSync, mkdirSync } from "node:fs";
|
|
7
|
+
import { appendFileSync, mkdirSync, readFileSync } from "node:fs";
|
|
8
8
|
import { join } from "node:path";
|
|
9
9
|
import { homedir } from "node:os";
|
|
10
10
|
import { z } from "zod";
|
|
@@ -441,12 +441,66 @@ function registerSkillTools(skills: SkillInfo[]): void {
|
|
|
441
441
|
|
|
442
442
|
// ── Start ────────────────────────────────────────────────────────────
|
|
443
443
|
|
|
444
|
+
/**
|
|
445
|
+
* Resolve session name from Claude Code's session metadata.
|
|
446
|
+
*
|
|
447
|
+
* CC writes session files to ~/.claude/sessions/<pid>.json with the
|
|
448
|
+
* /rename label as the "name" field. The bridge MCP server is a child
|
|
449
|
+
* process of CC, so process.ppid gives the CC PID. Reading the parent's
|
|
450
|
+
* session file gives us the label automatically, no env var needed.
|
|
451
|
+
*
|
|
452
|
+
* Fallback chain: CC session file -> LDM_SESSION_NAME env -> "default"
|
|
453
|
+
*/
|
|
454
|
+
function resolveSessionName(): string {
|
|
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
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
// 2. Try env var (explicit override)
|
|
488
|
+
if (process.env.LDM_SESSION_NAME) {
|
|
489
|
+
return process.env.LDM_SESSION_NAME;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// 3. Default
|
|
493
|
+
return "default";
|
|
494
|
+
}
|
|
495
|
+
|
|
444
496
|
async function main() {
|
|
445
|
-
//
|
|
497
|
+
// Set session identity: auto-detect from CC session metadata, env, or default
|
|
446
498
|
const agentId = process.env.LDM_AGENT_ID || "cc-mini";
|
|
447
|
-
const sessionName =
|
|
499
|
+
const sessionName = resolveSessionName();
|
|
448
500
|
setSessionIdentity(agentId, sessionName);
|
|
449
|
-
console.error(`wip-bridge: session identity: ${agentId}:${sessionName}
|
|
501
|
+
console.error(`wip-bridge: session identity: ${agentId}:${sessionName} (resolved from ${
|
|
502
|
+
sessionName !== "default" ? "CC session file or env" : "default"
|
|
503
|
+
})`);
|
|
450
504
|
|
|
451
505
|
// Phase 2: Register session in ~/.ldm/sessions/
|
|
452
506
|
const session = registerBridgeSession();
|