vibe-coding-master 0.5.6 → 0.6.1

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.
@@ -9,16 +9,16 @@ export function registerTerminalWs(app, deps) {
9
9
  return;
10
10
  }
11
11
  wss.handleUpgrade(request, socket, head, (ws) => {
12
- bindTerminalSocket(ws, decodeURIComponent(match[1] ?? ""), deps.runtime);
12
+ bindTerminalSocket(ws, decodeURIComponent(match[1] ?? ""), deps);
13
13
  });
14
14
  });
15
15
  }
16
- function bindTerminalSocket(ws, sessionId, runtime) {
16
+ function bindTerminalSocket(ws, sessionId, deps) {
17
17
  let unsubscribe = () => { };
18
18
  let alive = true;
19
19
  let closed = false;
20
20
  try {
21
- unsubscribe = runtime.subscribe(sessionId, (event) => {
21
+ unsubscribe = deps.runtime.subscribe(sessionId, (event) => {
22
22
  if (event.type === "output") {
23
23
  send(ws, { type: "output", data: event.data ?? "" });
24
24
  }
@@ -59,11 +59,14 @@ function bindTerminalSocket(ws, sessionId, runtime) {
59
59
  try {
60
60
  const message = JSON.parse(raw.toString());
61
61
  if (message.type === "input") {
62
- runtime.write(sessionId, message.data);
62
+ deps.runtime.write(sessionId, message.data);
63
+ if (isManualInterruptInput(message.data)) {
64
+ void Promise.resolve(deps.onManualInterrupt?.(sessionId)).catch(() => undefined);
65
+ }
63
66
  }
64
67
  else if (message.type === "resize") {
65
68
  if (isSafeTerminalResize(message.cols, message.rows)) {
66
- runtime.resize(sessionId, message.cols, message.rows);
69
+ deps.runtime.resize(sessionId, message.cols, message.rows);
67
70
  }
68
71
  }
69
72
  }
@@ -91,6 +94,9 @@ export function isSafeTerminalResize(cols, rows) {
91
94
  cols <= MAX_TERMINAL_COLS &&
92
95
  rows <= MAX_TERMINAL_ROWS);
93
96
  }
97
+ export function isManualInterruptInput(data) {
98
+ return data.includes("\u0003");
99
+ }
94
100
  const MIN_TERMINAL_COLS = 20;
95
101
  const MIN_TERMINAL_ROWS = 5;
96
102
  const MAX_TERMINAL_COLS = 1000;