@co0ontty/wand 1.9.0 → 1.14.2

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.
@@ -11,12 +11,9 @@ function escapeHtml(value) {
11
11
  }
12
12
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
13
13
  // Cache the script content
14
- let _scriptCache = null;
15
14
  export function getScriptContent(configPath) {
16
- if (!_scriptCache) {
17
- const scriptPath = path.join(__dirname, "content", "scripts.js");
18
- _scriptCache = fs.readFileSync(scriptPath, "utf-8");
19
- }
15
+ const scriptPath = path.join(__dirname, "content", "scripts.js");
16
+ const scriptContent = fs.readFileSync(scriptPath, "utf-8");
20
17
  // Inject the config path
21
- return _scriptCache.replace("${escapeHtml(configPath)}", escapeHtml(configPath));
18
+ return scriptContent.replace("${escapeHtml(configPath)}", escapeHtml(configPath));
22
19
  }
@@ -3,14 +3,15 @@
3
3
  * Handles debounced output events, backpressure control, and client subscriptions.
4
4
  */
5
5
  import { WebSocketServer } from "ws";
6
- import type { SessionSnapshot, ProcessEvent } from "./types.js";
6
+ import type { CardExpandDefaults, SessionSnapshot, ProcessEvent } from "./types.js";
7
7
  export type { ProcessEvent } from "./types.js";
8
8
  export declare class WsBroadcastManager {
9
9
  private wss;
10
10
  private clients;
11
11
  private outputDebounceCache;
12
12
  private eventEmitter;
13
- constructor(wss: WebSocketServer);
13
+ private getCardDefaults;
14
+ constructor(wss: WebSocketServer, getCardDefaults?: () => CardExpandDefaults);
14
15
  /** Set up connection handling. Should be called once during server startup. */
15
16
  setup(getSession: (id: string) => SessionSnapshot | null): void;
16
17
  /** Emit a process event to all subscribed WebSocket clients. */
@@ -5,6 +5,7 @@
5
5
  import { WebSocket } from "ws";
6
6
  import { EventEmitter } from "node:events";
7
7
  import { validateSession } from "./auth.js";
8
+ import { truncateMessagesForTransport } from "./message-truncator.js";
8
9
  // ── Constants ──
9
10
  const MAX_QUEUE_SIZE = 500;
10
11
  const OUTPUT_DEBOUNCE_MS = 16;
@@ -14,8 +15,10 @@ export class WsBroadcastManager {
14
15
  clients = new Set();
15
16
  outputDebounceCache = new Map();
16
17
  eventEmitter = new EventEmitter();
17
- constructor(wss) {
18
+ getCardDefaults;
19
+ constructor(wss, getCardDefaults) {
18
20
  this.wss = wss;
21
+ this.getCardDefaults = getCardDefaults ?? (() => ({}));
19
22
  }
20
23
  /** Set up connection handling. Should be called once during server startup. */
21
24
  setup(getSession) {
@@ -45,10 +48,13 @@ export class WsBroadcastManager {
45
48
  if (msg.type === "subscribe" && msg.sessionId) {
46
49
  const snapshot = getSession(msg.sessionId);
47
50
  if (snapshot) {
51
+ const truncatedMessages = snapshot.messages
52
+ ? truncateMessagesForTransport(snapshot.messages, this.getCardDefaults())
53
+ : undefined;
48
54
  ws.send(JSON.stringify({
49
55
  type: "init",
50
56
  sessionId: msg.sessionId,
51
- data: { ...snapshot, messages: snapshot.messages, output: snapshot.output },
57
+ data: { ...snapshot, messages: truncatedMessages, output: snapshot.output },
52
58
  }));
53
59
  }
54
60
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@co0ontty/wand",
3
- "version": "1.9.0",
3
+ "version": "1.14.2",
4
4
  "description": "A web terminal for local CLI tools like Claude.",
5
5
  "type": "module",
6
6
  "bin": {