tring-chat 0.1.17 → 0.1.19

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.
package/README.md CHANGED
@@ -261,6 +261,7 @@ streams thumbnails, which is what keeps several projects cheap.
261
261
  | `Space` | back to the previous session |
262
262
  | `c` / `r` / `x` | new session / rename and colour / kill |
263
263
  | `m` | mark seen |
264
+ | `o` | orchestrator: every agent's questions in the centre |
264
265
  | `Esc` | close the picker |
265
266
 
266
267
  Browsers reserve `Ctrl+1`–`Ctrl+8` for tab switching, so `Shift+digit` is the
@@ -429,6 +430,34 @@ Two things are deliberate:
429
430
  Auto-executing whatever was there last time is how four dev servers end up fighting
430
431
  over a port.
431
432
 
433
+ ### Claude conversations come back too
434
+
435
+ A tile that was running Claude Code reopens the same conversation after a restart
436
+ of tring or of the machine: tring types `claude --resume <id>` into the tile's shell
437
+ once it has started. Claude waits for your next prompt, so nothing runs that was not
438
+ already running. Quitting Claude still leaves you in that shell.
439
+
440
+ tring learns which conversation each tile is running from Claude Code's
441
+ `SessionStart` and `SessionEnd` hooks, which `tring hooks install` adds (run it again
442
+ if you installed the hooks before this, then restart your `claude` sessions once).
443
+ Ending a conversation yourself (`/exit`, Ctrl+D, `/clear`) forgets it. Stopping tring
444
+ or shutting down does not, since that is the conversation you want back. A tile that
445
+ was resumed runs plain `claude --resume`, so flags you started it with (`--model`,
446
+ a permission mode) fall back to your settings.
447
+
448
+ To have tring itself running after a reboot:
449
+
450
+ ```sh
451
+ tring autostart on # flags after `on` are passed to the daemon, e.g. --allow-origin …
452
+ tring autostart status
453
+ tring autostart off
454
+ ```
455
+
456
+ This writes a systemd user unit on Linux, a LaunchAgent on macOS, or a `.cmd` in the
457
+ Startup folder on Windows, with the `PATH` you ran it from so the tiles find `claude`
458
+ and your tools. It is enabled for your next login, not started, since tring is usually
459
+ running already. A file at that path that tring did not write is left alone.
460
+
432
461
  ## Dropping files on a terminal
433
462
 
434
463
  Drag a screenshot, a spreadsheet or any other file onto the centre terminal and its path is typed into the prompt,
@@ -468,9 +497,54 @@ works in Chrome on Android and Safari on iOS, but not in Firefox, where the butt
468
497
  is not shown. Unlike paste, it has no fallback on plain http: browsers only give
469
498
  the microphone to an https page (or localhost).
470
499
 
500
+ ## Orchestrator
501
+
502
+ With many agents running, finding the one that is waiting means hunting through the
503
+ ring. The **Orchestrator** tab (or `Ctrl+Space`, then `o`) turns the centre into an
504
+ inbox of everything the agents are waiting on, from every session in every project:
505
+
506
+ - **permission prompts** — the command, the file and the edit, or the tool input, with
507
+ Allow, Deny (with an optional reason the agent sees) and *Answer in terminal*
508
+ - **questions** Claude asks with its AskUserQuestion tool — pick an option, or type
509
+ your own answer
510
+ - **finished turns** — the agent's last message and a box to reply in
511
+
512
+ Answer and the card goes; the next one moves up. The ring keeps running around it, and
513
+ *Open* takes you to that session's terminal. On a card, `a` allows, `d` denies, `t`
514
+ hands it back to the terminal, `o` opens it, `1`–`9` picks an option, and `↑`/`↓` move
515
+ between cards.
516
+
517
+ The prompt also stays live in the session's own terminal, and whichever you answer first
518
+ wins — answer it there and the card clears itself.
519
+
520
+ It reads what the agents ask through Claude Code hooks, never by scraping the screen:
521
+
522
+ ```
523
+ tring hooks install # or the Install button the inbox shows when they are missing
524
+ tring hooks status
525
+ tring hooks uninstall
526
+ ```
527
+
528
+ This adds a `tring-hook` entry per event to `~/.claude/settings.json` (keeping a backup
529
+ beside it, and leaving your own hooks alone). Outside a tring session `tring-hook` exits
530
+ at once and does nothing, so the same settings are safe for every `claude` you run.
531
+ Restart running `claude` sessions to pick the hooks up.
532
+
533
+ **AI approves routine prompts** (a switch in the inbox, off by default) has a small
534
+ Claude model (`claude -p --model haiku`, on your own Claude login) approve the prompts
535
+ that are plainly routine — tests, builds, edits inside the session's directory — so
536
+ only the rest reach you. It can only approve or leave a card for you; it never denies,
537
+ never answers a question and never replies for you. Some things always come to you
538
+ without the model being asked: `rm -r`/`-f`, `sudo`, `git push`/`reset --hard`,
539
+ publishing, deploys, `kubectl`/`terraform`, anything mentioning production, secrets and
540
+ `.env` files, paths outside the session's directory, MCP tools and plan approvals.
541
+ Every decision it makes is listed in the inbox with its reason.
542
+
471
543
  ## Claude Code
472
544
 
473
- Optional. Add a `Stop` hook to `~/.claude/settings.json` so a tile turns green the
545
+ `tring hooks install` (see [Orchestrator](#orchestrator)) includes a Stop hook, so
546
+ a tile turns green the instant Claude ends its turn. To do only that by hand, add a
547
+ `Stop` hook to `~/.claude/settings.json` so a tile turns green the
474
548
  instant Claude ends its turn instead of after the idle timeout:
475
549
 
476
550
  ```json
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/hook-cli.ts
4
+ import { request as httpRequest } from "node:http";
5
+ import { request as httpsRequest } from "node:https";
6
+ var LOOPBACK = /* @__PURE__ */ new Set(["127.0.0.1", "localhost", "::1", "[::1]"]);
7
+ function readStdin() {
8
+ return new Promise((resolve) => {
9
+ if (process.stdin.isTTY) return resolve("");
10
+ const chunks = [];
11
+ process.stdin.on("data", (c) => chunks.push(c));
12
+ process.stdin.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")));
13
+ process.stdin.on("error", () => resolve(""));
14
+ });
15
+ }
16
+ function post(url, token, body) {
17
+ return new Promise((resolve) => {
18
+ const https = url.protocol === "https:";
19
+ const req = (https ? httpsRequest : httpRequest)(url, {
20
+ method: "POST",
21
+ headers: {
22
+ "content-type": "application/json",
23
+ "content-length": Buffer.byteLength(body),
24
+ ...token ? { authorization: `Bearer ${token}` } : {}
25
+ },
26
+ // A daemon on this machine with a self-signed --tls-cert is still the
27
+ // daemon that spawned us; anywhere else the certificate must check out.
28
+ ...https && LOOPBACK.has(url.hostname) ? { rejectUnauthorized: false } : {}
29
+ }, (res) => {
30
+ const chunks = [];
31
+ res.on("data", (c) => chunks.push(c));
32
+ res.on("end", () => resolve(res.statusCode === 200 ? Buffer.concat(chunks).toString("utf8") : null));
33
+ res.on("error", () => resolve(null));
34
+ });
35
+ req.on("error", () => resolve(null));
36
+ req.end(body);
37
+ });
38
+ }
39
+ async function main() {
40
+ const event = process.argv[2];
41
+ const id = process.env["TRING_SESSION_ID"];
42
+ const base = process.env["TRING_URL"];
43
+ if (!event || !id || !base) return;
44
+ const raw = await readStdin();
45
+ let payload = {};
46
+ try {
47
+ payload = raw.trim() ? JSON.parse(raw) : {};
48
+ } catch {
49
+ return;
50
+ }
51
+ let url;
52
+ try {
53
+ url = new URL(`/api/sessions/${encodeURIComponent(id)}/hook`, base);
54
+ } catch {
55
+ return;
56
+ }
57
+ const reply = await post(url, process.env["TRING_TOKEN"], JSON.stringify({ event, payload }));
58
+ if (!reply) return;
59
+ try {
60
+ const { output } = JSON.parse(reply);
61
+ if (output && typeof output === "object") process.stdout.write(JSON.stringify(output) + "\n");
62
+ } catch {
63
+ }
64
+ }
65
+ main().then(() => process.exit(0), () => process.exit(0));