orchestrating 0.1.1 → 0.1.3

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 +17 -5
  2. package/package.json +1 -1
package/bin/orch CHANGED
@@ -90,7 +90,7 @@ async function handleLogin() {
90
90
  expires_at: expiresAt ? Number(expiresAt) : 0,
91
91
  });
92
92
  res.writeHead(200, { "Content-Type": "text/html" });
93
- res.end("<html><body><h2>Authenticated! You can close this tab.</h2><script>window.close()</script></body></html>");
93
+ res.end('<html><head><meta http-equiv="refresh" content="0;url=https://app.orchestrat.ing"></head><body><p>Redirecting to dashboard...</p></body></html>');
94
94
  console.log("\x1b[32mLogged in successfully.\x1b[0m");
95
95
  } else {
96
96
  res.writeHead(400, { "Content-Type": "text/html" });
@@ -98,8 +98,7 @@ async function handleLogin() {
98
98
  console.error("Authentication failed — no token received.");
99
99
  }
100
100
 
101
- server.close();
102
- resolve();
101
+ setTimeout(() => { server.close(); resolve(); }, 500);
103
102
  } else {
104
103
  res.writeHead(404);
105
104
  res.end();
@@ -231,6 +230,7 @@ const BUFFER_MAX = 50 * 1024; // 50KB reconnect buffer
231
230
  let ws = null;
232
231
  let wsReady = false;
233
232
  let reconnectTimer = null;
233
+ let authFailed = false;
234
234
  const sendBuffer = [];
235
235
  let bufferSize = 0;
236
236
 
@@ -276,7 +276,9 @@ function readPermissions() {
276
276
 
277
277
  function broadcastPermissions() {
278
278
  const perms = readPermissions();
279
- process.stderr.write(`${DIM}[perms] Broadcasting: ${perms.project.length} project${RESET}\n`);
279
+ if (process.env.DEBUG) {
280
+ process.stderr.write(`${DIM}[perms] Broadcasting: ${perms.project.length} project${RESET}\n`);
281
+ }
280
282
  sendToServer({ type: "agent_event", sessionId, event: { kind: "permission_state", ...perms } });
281
283
  }
282
284
 
@@ -796,6 +798,14 @@ function connectWs() {
796
798
  ws.on("message", (raw) => {
797
799
  try {
798
800
  const msg = JSON.parse(raw.toString());
801
+ if (msg.type === "error") {
802
+ process.stderr.write(`${RED}Server error: ${msg.error}${RESET}\n`);
803
+ if (/unauthorized|auth|token/i.test(msg.error || "")) {
804
+ process.stderr.write(`${RED}Run 'orch login' to authenticate.${RESET}\n`);
805
+ authFailed = true;
806
+ }
807
+ return;
808
+ }
799
809
  handleServerMessage(msg);
800
810
  } catch {}
801
811
  });
@@ -803,7 +813,9 @@ function connectWs() {
803
813
  ws.on("close", () => {
804
814
  wsReady = false;
805
815
  ws = null;
806
- reconnectTimer = setTimeout(connectWs, 2000);
816
+ if (!authFailed) {
817
+ reconnectTimer = setTimeout(connectWs, 2000);
818
+ }
807
819
  });
808
820
 
809
821
  ws.on("error", () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orchestrating",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Stream terminal sessions to the orchestrat.ing dashboard",
5
5
  "type": "module",
6
6
  "bin": {