coderemote 0.3.4 → 0.3.5

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/dist/coderemote.js +35 -3
  2. package/package.json +1 -1
@@ -66,6 +66,8 @@ var Routes = Object.freeze({
66
66
  agentsSetup: "GET /api/agents/setup",
67
67
  agentsPrompt: "POST /api/agents/prompt",
68
68
  agentsKeys: "POST /api/agents/keys",
69
+ agentsStop: "POST /api/agents/stop",
70
+ agentsForget: "POST /api/agents/forget",
69
71
  agentsUpload: "POST /api/agents/uploads",
70
72
  pushDeviceSet: "PUT /api/push/device",
71
73
  pushDeviceDelete: "DELETE /api/push/device",
@@ -633,6 +635,17 @@ var AgentHub = class extends EventEmitter {
633
635
  }
634
636
  }
635
637
  }
638
+ /**
639
+ * Drops a session from the list, withdrawing its requests. One still running elsewhere comes
640
+ * back with its next hook event.
641
+ */
642
+ forget(id) {
643
+ const s = this.#sessions.get(id);
644
+ if (!s) throw new HttpError(404, "no such session");
645
+ if (s.state !== "ended") this.#end(s);
646
+ this.#sessions.delete(id);
647
+ this.emit("message", { type: "session_removed", session: id, replacedBy: null });
648
+ }
636
649
  /** Forgets sessions that ended more than a day ago. */
637
650
  sweep() {
638
651
  const cutoff = this.#now() - ENDED_TTL;
@@ -1630,8 +1643,8 @@ var TerminalSession = class {
1630
1643
  this.pty.resize(cols, rows);
1631
1644
  }
1632
1645
  }
1633
- kill() {
1634
- this.pty.kill();
1646
+ kill(signal) {
1647
+ this.pty.kill(signal);
1635
1648
  }
1636
1649
  /** Types into the session, as a client's keyboard would. */
1637
1650
  write(data) {
@@ -2288,6 +2301,25 @@ function createAgentServer({
2288
2301
  }
2289
2302
  return {};
2290
2303
  },
2304
+ [Routes.agentsStop]: async (url, req) => {
2305
+ const { session: id } = await readJson(req);
2306
+ const { term } = typingTarget(id, { whileWaiting: true });
2307
+ term.kill();
2308
+ setTimeout(() => {
2309
+ if (term.exitCode === null) term.kill("SIGKILL");
2310
+ }, 3e3).unref();
2311
+ return {};
2312
+ },
2313
+ [Routes.agentsForget]: async (url, req) => {
2314
+ const { session: id } = await readJson(req);
2315
+ const session = typeof id === "string" ? agents.session(id) : null;
2316
+ if (!session) throw new HttpError(404, "no such session");
2317
+ if (session.state !== "ended" && session.terminal && sessions.get(session.terminal)) {
2318
+ throw new HttpError(409, "this session still runs here; stop it first");
2319
+ }
2320
+ agents.forget(id);
2321
+ return {};
2322
+ },
2291
2323
  [Routes.agentsAnswer]: async (url, req) => {
2292
2324
  agents.answer(await readJson(req));
2293
2325
  return {};
@@ -3016,7 +3048,7 @@ function installCommand(installedAt) {
3016
3048
  // package.json
3017
3049
  var package_default = {
3018
3050
  name: "coderemote",
3019
- version: "0.3.4",
3051
+ version: "0.3.5",
3020
3052
  description: "Use your computer from your iPhone: files, git and a real terminal over a secure Microsoft Dev Tunnel. No SSH, no port forwarding, no VPN.",
3021
3053
  keywords: [
3022
3054
  "remote",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coderemote",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "Use your computer from your iPhone: files, git and a real terminal over a secure Microsoft Dev Tunnel. No SSH, no port forwarding, no VPN.",
5
5
  "keywords": [
6
6
  "remote",