orchestrating 0.1.21 → 0.1.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.
Files changed (2) hide show
  1. package/bin/orch +24 -4
  2. package/package.json +1 -1
package/bin/orch CHANGED
@@ -256,6 +256,11 @@ let authToken = getAuthToken();
256
256
  const cwdFolder = path.basename(process.cwd());
257
257
  const effectiveLabel = label || cwdFolder || commandArgs.join(" ");
258
258
 
259
+ const DIM = "\x1b[2m";
260
+ const GREEN = "\x1b[32m";
261
+ const RED = "\x1b[31m";
262
+ const RESET = "\x1b[0m";
263
+
259
264
  // Refresh token on startup if expired or about to expire
260
265
  if (authToken && isTokenExpired()) {
261
266
  const refreshed = await refreshAuthToken();
@@ -276,6 +281,7 @@ if (!authToken && !serverUrl.includes("localhost") && !serverUrl.includes("127.0
276
281
  const BUFFER_MAX = 50 * 1024; // 50KB reconnect buffer
277
282
  const PING_INTERVAL_MS = 30_000; // 30s keepalive ping
278
283
  const PONG_TIMEOUT_MS = 10_000; // 10s to receive pong before assuming dead
284
+ const MAX_EVENT_HISTORY = 500; // max events to replay on reconnect
279
285
  let ws = null;
280
286
  let wsReady = false;
281
287
  let reconnectTimer = null;
@@ -284,8 +290,16 @@ let pongTimer = null;
284
290
  let authFailed = false;
285
291
  const sendBuffer = [];
286
292
  let bufferSize = 0;
293
+ const eventHistory = []; // all agent events for replay on reconnect
287
294
 
288
295
  function sendToServer(msg) {
296
+ // Track agent events for reconnect replay
297
+ if (msg.type === "agent_event" && msg.event) {
298
+ eventHistory.push(msg.event);
299
+ while (eventHistory.length > MAX_EVENT_HISTORY) {
300
+ eventHistory.shift();
301
+ }
302
+ }
289
303
  if (wsReady && ws && ws.readyState === WebSocket.OPEN) {
290
304
  ws.send(JSON.stringify(msg));
291
305
  } else {
@@ -301,10 +315,7 @@ function sendToServer(msg) {
301
315
 
302
316
  // --- Terminal colors ---
303
317
  const CYAN = "\x1b[36m";
304
- const DIM = "\x1b[2m";
305
- const GREEN = "\x1b[32m";
306
- const RED = "\x1b[31m";
307
- const RESET = "\x1b[0m";
318
+
308
319
  const BOLD = "\x1b[1m";
309
320
 
310
321
  // --- Permission mode ---
@@ -936,6 +947,15 @@ async function connectWs() {
936
947
  broadcastPermissions();
937
948
  }
938
949
 
950
+ // Replay event history so server can rebuild conversation after restarts
951
+ if (eventHistory.length > 0) {
952
+ ws.send(JSON.stringify({
953
+ type: "agent_history_replay",
954
+ sessionId,
955
+ events: eventHistory,
956
+ }));
957
+ }
958
+
939
959
  // Keepalive: send WebSocket ping frames every 30s to prevent idle disconnects
940
960
  if (pingTimer) clearInterval(pingTimer);
941
961
  if (pongTimer) clearTimeout(pongTimer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orchestrating",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
4
4
  "description": "Stream terminal sessions to the orchestrat.ing dashboard",
5
5
  "type": "module",
6
6
  "bin": {