@rarog/server 1.1.2-beta.1 → 1.1.2-beta.2

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 (124) hide show
  1. package/node_modules/@rarog/shared/package.json +1 -1
  2. package/node_modules/@rarog/shared/src/decode.js +43 -1
  3. package/node_modules/@rarog/shared/src/notify-copy.js +1 -0
  4. package/node_modules/@rarog/shared/src/protocol/context.js +57 -0
  5. package/node_modules/@rarog/shared/src/protocol/coordination.js +42 -0
  6. package/node_modules/@rarog/shared/src/protocol/dialog-live.js +117 -0
  7. package/node_modules/@rarog/shared/src/protocol/files.js +1 -1
  8. package/node_modules/@rarog/shared/src/protocol/inbox.js +6 -0
  9. package/node_modules/@rarog/shared/src/protocol/presence.js +47 -0
  10. package/node_modules/@rarog/shared/src/protocol.js +14 -146
  11. package/node_modules/@rarog/shared/src/rest.js +16 -1
  12. package/node_modules/@rarog/shared/src/sentences/push.js +6 -0
  13. package/node_modules/@rarog/shared/src/sentences/rest.js +9 -0
  14. package/node_modules/@rarog/shared/src/sentences/restart.js +1 -0
  15. package/node_modules/@rarog/shared/src/sentences/session.js +24 -0
  16. package/package.json +2 -2
  17. package/plugin/rarog/.claude-plugin/plugin.json +4 -0
  18. package/plugin/rarog/bin/rarog-coordinator +7 -0
  19. package/plugin/rarog/hooks/hooks.json +18 -0
  20. package/plugin/rarog/hooks/recipient.mjs +95 -0
  21. package/plugin/rarog/lib/coordinator.mjs +1340 -0
  22. package/plugin/rarog/lib/threads.mjs +350 -0
  23. package/plugin/rarog/skills/coordinator/SKILL.md +111 -0
  24. package/plugin/rarog/skills/coordinator/check-and-merge.md +46 -0
  25. package/plugin/rarog/skills/coordinator/close-thread.md +15 -0
  26. package/plugin/rarog/skills/coordinator/role.md +61 -0
  27. package/plugin/rarog/skills/coordinator/send-back.md +39 -0
  28. package/plugin/rarog/skills/coordinator/start-thread.md +43 -0
  29. package/server/src/bootstrap/coordination.js +49 -0
  30. package/server/src/bootstrap/coordinator-start.js +27 -0
  31. package/server/src/bootstrap/inbox.js +4 -0
  32. package/server/src/bootstrap/push.js +24 -1
  33. package/server/src/companion/catalog.js +1 -1
  34. package/server/src/companion/index.js +2 -4
  35. package/server/src/config/flags.js +4 -0
  36. package/server/src/config-env.js +15 -0
  37. package/server/src/config.js +17 -3
  38. package/server/src/coordination/merge-events.js +86 -0
  39. package/server/src/coordination/merge-prompt.js +244 -0
  40. package/server/src/coordination/registry.js +289 -0
  41. package/server/src/coordination/state.js +94 -0
  42. package/server/src/coordination/summary.js +422 -0
  43. package/server/src/coordination/thread-file.js +245 -0
  44. package/server/src/coordination/thread-git.js +110 -0
  45. package/server/src/coordination/watch.js +237 -0
  46. package/server/src/demo/content/coordinator.js +89 -0
  47. package/server/src/demo/content/en.js +57 -1
  48. package/server/src/demo/content/pl.js +57 -1
  49. package/server/src/demo/inbox.js +12 -0
  50. package/server/src/demo/mock-herdr.js +3 -2
  51. package/server/src/demo/review-routes.js +2 -2
  52. package/server/src/demo/seeds.js +20 -2
  53. package/server/src/drivers/herdr/live-dialog.js +412 -0
  54. package/server/src/drivers/herdr/live-step.js +261 -0
  55. package/server/src/drivers/herdr/pause-gate.js +60 -0
  56. package/server/src/drivers/herdr/returned-prompt.js +4 -1
  57. package/server/src/drivers/herdr/screen-fallback.js +50 -0
  58. package/server/src/drivers/herdr/start-dialog-gate.js +4 -0
  59. package/server/src/drivers/herdr-driver.js +88 -66
  60. package/server/src/files/refusals.js +9 -2
  61. package/server/src/files/session-gate.js +5 -4
  62. package/server/src/git-branch-diff.js +194 -0
  63. package/server/src/herdr/argv.js +34 -3
  64. package/server/src/herdr/audit.js +32 -1
  65. package/server/src/herdr/background/cli-shapes.js +19 -0
  66. package/server/src/herdr/background/queued-prompt.js +46 -0
  67. package/server/src/herdr/background/work.js +12 -0
  68. package/server/src/herdr/client.js +22 -46
  69. package/server/src/herdr/commands/catalog.js +11 -7
  70. package/server/src/herdr/commands/discover.js +33 -1
  71. package/server/src/herdr/commands/index.js +3 -2
  72. package/server/src/herdr/dialogs/index.js +9 -0
  73. package/server/src/herdr/dialogs/layer1/hook-list/hook-list.js +4 -56
  74. package/server/src/herdr/dialogs/live/model.js +220 -0
  75. package/server/src/herdr/dialogs/live/policy.js +108 -0
  76. package/server/src/herdr/dialogs/live/view.js +261 -0
  77. package/server/src/herdr/dialogs/screen/form.js +4 -3
  78. package/server/src/herdr/dialogs/screen/signatures.js +23 -0
  79. package/server/src/herdr/engines.js +96 -0
  80. package/server/src/herdr/history-steps.js +9 -4
  81. package/server/src/herdr/identity.js +20 -5
  82. package/server/src/herdr/jsonl-follow.js +20 -1
  83. package/server/src/herdr/plugin-copy.js +281 -0
  84. package/server/src/herdr/session-index.js +19 -0
  85. package/server/src/herdr/supervisor.js +16 -13
  86. package/server/src/herdr/types.js +1 -0
  87. package/server/src/inbox/card.js +31 -8
  88. package/server/src/inbox/heads.js +1 -0
  89. package/server/src/inbox/inbox.js +21 -4
  90. package/server/src/inbox/removals.js +10 -1
  91. package/server/src/index.js +37 -5
  92. package/server/src/notify/content.js +27 -0
  93. package/server/src/notify/index.js +7 -3
  94. package/server/src/notify/live-activity-state.js +14 -5
  95. package/server/src/notify/policy.js +49 -11
  96. package/server/src/notify/ready-to-merge.js +148 -0
  97. package/server/src/project-root.js +233 -0
  98. package/server/src/routes/sessions.js +68 -2
  99. package/server/src/sessions/branch-diff.js +57 -0
  100. package/server/src/sessions/cli-registry.js +17 -3
  101. package/server/src/sessions/companion-scope.js +2 -1
  102. package/server/src/sessions/consent-cards.js +49 -2
  103. package/server/src/sessions/conversation-lists.js +4 -1
  104. package/server/src/sessions/coordinator-start.js +172 -0
  105. package/server/src/sessions/demo-modules.js +1 -0
  106. package/server/src/sessions/demo-seeds.js +100 -0
  107. package/server/src/sessions/driver-events.js +61 -11
  108. package/server/src/sessions/herdr-lifecycle.js +11 -4
  109. package/server/src/sessions/launch-gate.js +36 -11
  110. package/server/src/sessions/live-dialog.js +69 -0
  111. package/server/src/sessions/manager.js +124 -282
  112. package/server/src/sessions/owner-turn.js +36 -0
  113. package/server/src/sessions/seen-marks.js +31 -12
  114. package/server/src/sessions/session-dialog.js +82 -0
  115. package/server/src/sessions/session-git.js +1 -0
  116. package/server/src/sessions/session-scope.js +6 -5
  117. package/server/src/sessions/session-take-back.js +5 -0
  118. package/server/src/sessions/session.js +72 -7
  119. package/server/src/sessions/state-machine.js +2 -0
  120. package/server/src/sessions/state-sentences.js +87 -30
  121. package/server/src/sessions/waiting-line.js +49 -0
  122. package/server/src/transcript-import.js +20 -2
  123. package/server/src/version.js +4 -0
  124. /package/server/src/{companion/asks-owner.js → asks-owner.js} +0 -0
@@ -20,7 +20,7 @@
20
20
  import { z } from 'zod';
21
21
  import { IROH_ENDPOINT_ID_RE, PAIRING_CODE_RE, irohRelayUrl } from './pairing-link.js';
22
22
  import { sentenceRefSchema } from './sentences/index.js';
23
- import { FILE_ENTRY_KINDS, FILE_TOO_LARGE_ERROR, MAX_ANSWER_TEXT_CHARS, MAX_FILES_PER_MESSAGE, MAX_IMAGES_PER_MESSAGE, MAX_MESSAGE_TEXT_CHARS, PUSH_LABEL_MAX_CHARS, TERM_ID_RE, fileAttachmentSchema, imageDataUrlSchema, inboxHeadSchemaOf, knownDialogIdSchema, refuseReasonSchema, sessionStateSchema, sessionSummarySchema, termListResponseSchema, transcriptMessageSchema, waitingForSchema, } from './protocol.js';
23
+ import { FILE_ENTRY_KINDS, FILE_TOO_LARGE_ERROR, MAX_ANSWER_TEXT_CHARS, MAX_FILES_PER_MESSAGE, MAX_IMAGES_PER_MESSAGE, MAX_MESSAGE_TEXT_CHARS, PUSH_LABEL_MAX_CHARS, TERM_ID_RE, diffFileListSchema, fileAttachmentSchema, gitCommitSchema, imageDataUrlSchema, inboxHeadSchemaOf, knownDialogIdSchema, refuseReasonSchema, sessionStateSchema, sessionSummarySchema, termListResponseSchema, transcriptMessageSchema, waitingForSchema, } from './protocol.js';
24
24
  /*
25
25
  * REST terminala dla apki natywnej: schematy istnieją w `protocol.ts`, tu tylko re-eksport — jedno miejsce
26
26
  * kontraktu REST dla klienta w innym języku, zero kopii.
@@ -808,6 +808,21 @@ export const COMPANION_SPEECH_THROTTLED_ERROR = 'companion-speech-throttled';
808
808
  /** 502: Soniox did not give a key (5xx, timeout, no connection, a reply without a key). */
809
809
  export const COMPANION_SPEECH_UPSTREAM_ERROR = 'companion-speech-upstream';
810
810
  // ---------------------------------------------------------------------------
811
+ // Branch diff of a coordinator's thread (`docs/coordinator.md`, "Protocol contract")
812
+ // ---------------------------------------------------------------------------
813
+ /**
814
+ * 200 of `GET /api/sessions/:id/branch-diff/files`: what the thread's branch changes, in the shape of `diff/files`,
815
+ * compared from its merge base with `base.branch` (the branch of the project's main checkout, chosen by the server);
816
+ * `commits` are the branch commits past that base, newest first, and `head` the full SHA of the branch head the list
817
+ * shows. The patch of one file comes from `GET /api/sessions/:id/branch-diff/file?path=…` as a `DiffFilePatch`, and
818
+ * both routes refuse with the error codes of the session diff routes.
819
+ */
820
+ export const branchDiffFileListSchema = diffFileListSchema.extend({
821
+ commits: z.array(gitCommitSchema),
822
+ base: z.object({ branch: z.string().min(1) }),
823
+ head: z.string().regex(/^[0-9a-f]{40}$/u),
824
+ });
825
+ // ---------------------------------------------------------------------------
811
826
  // Inbox: the cards with their text (`docs/implementation-spec.md`, "Inbox")
812
827
  // ---------------------------------------------------------------------------
813
828
  /**
@@ -13,6 +13,11 @@ export const PUSH_SENTENCES = {
13
13
  'push.body.fallback.permission': { en: 'Open to decide.' },
14
14
  'push.body.fallback.question': { en: 'The agent asked a question. Answer in Rarog.' },
15
15
  'push.body.fallback.stalled': { en: 'A subagent is waiting on its own command.' },
16
+ 'push.body.fallback.ready-to-merge': { en: 'Checks passed. Open to merge.' },
17
+ 'push.detail.merge-ready': {
18
+ en: { one: '{commits} commit, checks passed', other: '{commits} commits, checks passed' },
19
+ args: ['commits:plural'],
20
+ },
16
21
  'push.detail.stalled': { en: 'Subagent "{agent}" is waiting on its own command.', args: ['agent:text'] },
17
22
  'push.body.label': { en: '{label}', args: ['label:text'] },
18
23
  'push.paired-body.mac': {
@@ -32,6 +37,7 @@ export const PUSH_SENTENCES = {
32
37
  'push.title.limit': { en: '✋ Plan limit · {project}', args: ['project:text'] },
33
38
  'push.title.permission': { en: '⏳ Waiting for permission · {project}', args: ['project:text'] },
34
39
  'push.title.question': { en: '❓ Question · {project}', args: ['project:text'] },
40
+ 'push.title.ready-to-merge': { en: '🔀 Ready to merge · {project}', args: ['project:text'] },
35
41
  'push.title.stalled': { en: '⏰ Waiting over 1 h · {project}', args: ['project:text'] },
36
42
  'push.version-title': { en: '🔄 Version changed' },
37
43
  'push.version-body.claude-code': { en: 'Claude Code {from} → {to}', args: ['from:text', 'to:text'] },
@@ -18,6 +18,12 @@ export const REST_SENTENCES = {
18
18
  'rest.bad-origin': { en: 'Request from a disallowed origin.' },
19
19
  'rest.body-contract': { en: "The request body doesn't match the expected format." },
20
20
  'rest.body-unreadable': { en: "Couldn't read the request." },
21
+ 'rest.branch-diff-no-base': {
22
+ en: "The project's main folder isn't on a branch, or this branch has no commit in common with it.",
23
+ },
24
+ 'rest.branch-diff-no-project': {
25
+ en: "This session isn't in a worktree of a project, so it has no branch changes.",
26
+ },
21
27
  'rest.client-log-failed': { en: "Couldn't save the log." },
22
28
  'rest.companion-busy': { en: 'The voice agent is already checking this session. Try again in a moment.' },
23
29
  'rest.companion-claude-only': {
@@ -97,6 +103,9 @@ export const REST_SENTENCES = {
97
103
  en: 'This file has {size} MB. The server sends files up to {limit} MB (RAROG_FILES_MAX_MB).',
98
104
  args: ['size:int', 'limit:int'],
99
105
  },
106
+ 'rest.files-agy': {
107
+ en: "Rarog only observes the Antigravity CLI pane, so it doesn't show the files in its directory.",
108
+ },
100
109
  'rest.files-codex': { en: "Rarog only observes the Codex pane, so it doesn't show the files in its directory." },
101
110
  'rest.files-no-pane': { en: "This session has no herdr pane, so Rarog doesn't show the files in its directory." },
102
111
  'rest.files-not-found': { en: "That file or directory isn't there, or Rarog doesn't show it." },
@@ -1,4 +1,5 @@
1
1
  export const RESTART_SENTENCES = {
2
+ 'restart.agy': { en: "Restart the Antigravity CLI pane in herdr. Rarog shows its state but doesn't manage it." },
2
3
  'restart.background-task-running': { en: 'A background task is running. A restart would interrupt it.' },
3
4
  'restart.busy': { en: 'The session is working or waiting for a decision. You can restart it once it stops.' },
4
5
  'restart.codex': { en: "Restart the Codex pane in herdr. Rarog shows its state but doesn't manage it." },
@@ -20,6 +20,12 @@ export const SESSION_SENTENCES = {
20
20
  en: { one: 'The answer is too long. Keep it within {max} character.', other: 'The answer is too long. Keep it within {max} characters.' },
21
21
  args: ['max:plural'],
22
22
  },
23
+ 'session.agy-close': {
24
+ en: "Close the Antigravity CLI pane in herdr. Rarog shows its state but doesn't manage it.",
25
+ },
26
+ 'session.agy-git': {
27
+ en: 'Rarog only observes the Antigravity CLI pane. Manage git in this project from the terminal or from herdr.',
28
+ },
23
29
  'session.bypass-outside-yolo-roots': {
24
30
  en: 'bypassPermissions mode is allowed only in directories under RAROG_YOLO_ROOTS.',
25
31
  },
@@ -39,6 +45,24 @@ export const SESSION_SENTENCES = {
39
45
  'session.conversation-changed': {
40
46
  en: 'The session moved to another conversation after the voice agent read it. Nothing was sent.',
41
47
  },
48
+ // Refusals of a Launch with the coordinator switch and of a coordinator resume (`sessions/coordinator-start.ts`).
49
+ 'session.coordinator-live': {
50
+ en: 'This project already has a coordinator. Switch to it, or close it before starting a new one.',
51
+ },
52
+ 'session.coordinator-starting': {
53
+ en: 'A coordinator of this project is starting. Wait until it is ready, then try again.',
54
+ },
55
+ 'session.coordinator-not-project': {
56
+ en: "A coordinator starts in the top folder of a project's main git checkout, and {cwd} isn't one.",
57
+ args: ['cwd:text'],
58
+ },
59
+ 'session.coordinator-plugin-missing': {
60
+ en: "Rarog couldn't prepare the coordinator plugin ({reason}), so no coordinator started. The server log has the details.",
61
+ args: ['reason:text'],
62
+ },
63
+ 'session.coordinator-plugin-path': {
64
+ en: "The coordinator plugin's folder in the server's data directory has a space or a shell character in its path, so Claude Code can't load it. No coordinator started.",
65
+ },
42
66
  'session.cwd-denied': { en: "The directory {cwd} isn't allowed. {reason}", args: ['cwd:text', 'reason:code'] },
43
67
  'session.cwd-denied.outside-roots': {
44
68
  en: "The directory {cwd} isn't allowed. This directory is outside the allowed projects ({roots}).",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rarog/server",
3
- "version": "1.1.2-beta.1",
3
+ "version": "1.1.2-beta.2",
4
4
  "description": "Rarog is a free, open-source (MIT) iPhone and iPad app, plus a server on your Mac or Linux machine, that shows the Claude Code sessions running in Herdr TUI and lets you drive them.",
5
5
  "keywords": [
6
6
  "claude-code",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@number0/iroh": "1.2.0",
37
- "@rarog/shared": "1.1.2-beta.1",
37
+ "@rarog/shared": "1.1.2-beta.2",
38
38
  "qrcode": "1.5.4",
39
39
  "ws": "8.21.3",
40
40
  "zod": "4.4.3"
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "rarog",
3
+ "description": "Rarog project coordinator: each request becomes a thread with its own session, branch and worktree, merged into main only by fast-forward after the owner's Merge."
4
+ }
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+ # Entry point of the coordinator plugin. Claude Code 2.1.332 puts this bin/ directory on the Bash tool's PATH while
3
+ # the plugin is loaded (claude --plugin-dir), so a conversation resumed without the plugin has no rarog-coordinator.
4
+ # Every action that changes git, herdr or thread files goes through lib/coordinator.mjs.
5
+ set -euo pipefail
6
+ here="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
7
+ exec node "${here}/../lib/coordinator.mjs" "$@"
@@ -0,0 +1,18 @@
1
+ {
2
+ "hooks": {
3
+ "PreToolUse": [
4
+ {
5
+ "matcher": "SendMessage",
6
+ "hooks": [
7
+ {
8
+ "type": "command",
9
+ "command": "node",
10
+ "args": ["${CLAUDE_PLUGIN_ROOT}/hooks/recipient.mjs"],
11
+ "timeout": 30,
12
+ "onFailure": "block"
13
+ }
14
+ ]
15
+ }
16
+ ]
17
+ }
18
+ }
@@ -0,0 +1,95 @@
1
+ // PreToolUse hook on SendMessage of the coordinator plugin. A message goes through only when the sender is the
2
+ // coordinator (the conversation in the marker .rarog/coordinator.md, in the process whose socket the marker names)
3
+ // and the recipient is an open thread of this project: a thread file without `merged` whose Claude Code process
4
+ // runs.
5
+ // Accepted forms of `to`: "[A] <name>" and "uds:<socket dir>/<pid>.sock", the socket of the thread's process in the
6
+ // sender's own socket directory. "[A] <name> [ref]" is refused: the ref names a process, not a thread, and may
7
+ // belong to a session of another project; with two sessions of one name the coordinator uses the uds: address from
8
+ // `rarog-coordinator status`. Everything else, and every error, is a deny. An exception that escapes exits non-zero,
9
+ // and hooks.json sets onFailure "block", so a crash or a timeout blocks the call as well.
10
+ import fs from 'node:fs';
11
+ import path from 'node:path';
12
+ import {
13
+ THREAD_PREFIX, projectPaths, pathProblem, readThreads, readMarker, processTable, sessionPids, commandHasSession,
14
+ socketAddress, socketDir,
15
+ } from '../lib/threads.mjs';
16
+
17
+ const isObject = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
18
+
19
+ /** Returns null to let the call through, or the reason of the deny. */
20
+ function verdict(input) {
21
+ if (!isObject(input)) return 'the hook input is not a JSON object';
22
+ if (input.tool_name !== 'SendMessage') return `the hook input is for ${JSON.stringify(input.tool_name)}, not SendMessage`;
23
+ if (!isObject(input.tool_input)) return 'the hook input has no tool_input';
24
+ const to = input.tool_input.to;
25
+ if (typeof to !== 'string' || !to.trim()) return 'the message has no recipient';
26
+ const cwd = input.cwd;
27
+ if (typeof cwd !== 'string' || !path.isAbsolute(cwd)) return 'the hook input has no absolute cwd';
28
+ const sender = process.env.CLAUDE_CODE_MESSAGING_SOCKET ?? '';
29
+ if (!path.isAbsolute(sender)) return 'CLAUDE_CODE_MESSAGING_SOCKET is missing in the hook environment';
30
+ let paths;
31
+ try {
32
+ paths = projectPaths(cwd);
33
+ } catch {
34
+ return `${cwd} is not inside a git repository with a main checkout`;
35
+ }
36
+ if (!fs.existsSync(paths.data)) return `there is no coordinator in this project (${paths.data} is missing)`;
37
+ const problem = pathProblem(paths.main, paths.threads);
38
+ if (problem) return `the coordinator directory is unsafe: ${problem}`;
39
+ const marker = readMarker(paths.data);
40
+ if (!marker) return 'there is no coordinator yet; the owner types /rarog:coordinator first';
41
+ if (marker.error) return `the coordinator marker is damaged (${marker.error})`;
42
+ if (marker.marker.conversation !== input.session_id) {
43
+ return 'this conversation is not the coordinator (a copy); it does not message threads';
44
+ }
45
+ if (marker.marker.socket !== sender) {
46
+ return `not the coordinator process: the marker names the socket ${marker.marker.socket}, this process has ${sender}; `
47
+ + 'after a resume run `rarog-coordinator claim` (it records this process), then send again';
48
+ }
49
+ const { threads, errors } = readThreads(paths.threads, paths.main);
50
+ if (errors.length) return `damaged thread files: ${errors.join('; ')}`;
51
+ const procs = processTable();
52
+ const open = threads.filter((t) => !t.merged).map((t) => ({ t, pids: sessionPids(procs, t.session) }));
53
+ if (to.startsWith('uds:')) {
54
+ const socket = to.slice('uds:'.length);
55
+ const match = /^(\d+)\.sock$/.exec(path.basename(socket));
56
+ let isSocket = false;
57
+ try {
58
+ isSocket = fs.lstatSync(socket).isSocket();
59
+ } catch {
60
+ // no such file
61
+ }
62
+ const exact = match && socket === path.join(socketDir(), match[0]);
63
+ const proc = match ? procs.find((p) => p.pid === Number(match[1])) : null;
64
+ if (exact && isSocket && proc && open.some(({ t }) => commandHasSession(proc.command, t.session))) return null;
65
+ } else if (/^\[A\] .+ \[[0-9a-f]{4,16}\]$/.test(to)) {
66
+ return `"${to}": the form "[A] <name> [ref]" is not accepted, because the ref may name a session of another `
67
+ + 'project; write "[A] <name>", or, when two sessions share the name, the thread\'s uds: address from '
68
+ + '`rarog-coordinator status`';
69
+ } else {
70
+ const named = /^\[A\] (.+)$/.exec(to);
71
+ if (named && open.some(({ t, pids }) => t.name === named[1] && pids.length)) return null;
72
+ }
73
+ const reachable = open.filter(({ pids }) => pids.length).map(({ t, pids }) => {
74
+ const address = socketAddress(pids[0]);
75
+ return `"${THREAD_PREFIX}${t.name}"${address ? ` (${address})` : ''}`;
76
+ });
77
+ return `"${to}" is not an open thread of ${paths.main} with a running session; `
78
+ + `open threads: ${reachable.join(', ') || 'none'}`;
79
+ }
80
+
81
+ let reason;
82
+ try {
83
+ reason = verdict(JSON.parse(fs.readFileSync(0, 'utf8')));
84
+ } catch (error) {
85
+ reason = `the recipient check failed (${error.message})`;
86
+ }
87
+ if (reason) {
88
+ process.stdout.write(`${JSON.stringify({
89
+ hookSpecificOutput: {
90
+ hookEventName: 'PreToolUse',
91
+ permissionDecision: 'deny',
92
+ permissionDecisionReason: `rarog coordinator: ${reason}`,
93
+ },
94
+ })}\n`);
95
+ }