@wipcomputer/wip-ldm-os 0.4.73-alpha.22 → 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.
@@ -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,
@@ -8,7 +8,7 @@ import {
8
8
  searchConversations,
9
9
  searchWorkspace,
10
10
  sendMessage
11
- } from "./chunk-24DJYS7Z.js";
11
+ } from "./chunk-6TOUTUOG.js";
12
12
  import "./chunk-3RG5ZIWI.js";
13
13
 
14
14
  // cli.ts
@@ -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 };
@@ -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,7 @@ import {
23
24
  sendLdmMessage,
24
25
  sendMessage,
25
26
  setSessionIdentity
26
- } from "./chunk-24DJYS7Z.js";
27
+ } from "./chunk-6TOUTUOG.js";
27
28
  import "./chunk-3RG5ZIWI.js";
28
29
  export {
29
30
  LDM_ROOT,
@@ -40,6 +41,7 @@ export {
40
41
  listActiveSessions,
41
42
  pushInbox,
42
43
  readWorkspaceFile,
44
+ refreshSessionIdentity,
43
45
  registerBridgeSession,
44
46
  resolveApiKey,
45
47
  resolveConfig,
@@ -15,7 +15,7 @@ import {
15
15
  sendLdmMessage,
16
16
  sendMessage,
17
17
  setSessionIdentity
18
- } from "./chunk-24DJYS7Z.js";
18
+ } from "./chunk-6TOUTUOG.js";
19
19
  import {
20
20
  __require
21
21
  } from "./chunk-3RG5ZIWI.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wipcomputer/wip-ldm-os",
3
- "version": "0.4.73-alpha.22",
3
+ "version": "0.4.73-alpha.23",
4
4
  "type": "module",
5
5
  "description": "LDM OS: identity, memory, and sovereignty infrastructure for AI agents",
6
6
  "engines": {
@@ -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