@rarog/server 1.1.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.
- package/node_modules/@rarog/shared/package.json +1 -1
- package/node_modules/@rarog/shared/src/decode.js +46 -1
- package/node_modules/@rarog/shared/src/notify-copy.js +2 -0
- package/node_modules/@rarog/shared/src/protocol/background.js +7 -0
- package/node_modules/@rarog/shared/src/protocol/context.js +57 -0
- package/node_modules/@rarog/shared/src/protocol/coordination.js +42 -0
- package/node_modules/@rarog/shared/src/protocol/dialog-live.js +117 -0
- package/node_modules/@rarog/shared/src/protocol/files.js +1 -1
- package/node_modules/@rarog/shared/src/protocol/inbox.js +6 -0
- package/node_modules/@rarog/shared/src/protocol/presence.js +47 -0
- package/node_modules/@rarog/shared/src/protocol.js +14 -146
- package/node_modules/@rarog/shared/src/rest.js +16 -1
- package/node_modules/@rarog/shared/src/sentences/dialogs.js +10 -0
- package/node_modules/@rarog/shared/src/sentences/push.js +9 -0
- package/node_modules/@rarog/shared/src/sentences/rest.js +9 -0
- package/node_modules/@rarog/shared/src/sentences/restart.js +1 -0
- package/node_modules/@rarog/shared/src/sentences/session.js +24 -0
- package/package.json +2 -2
- package/plugin/rarog/.claude-plugin/plugin.json +4 -0
- package/plugin/rarog/bin/rarog-coordinator +7 -0
- package/plugin/rarog/hooks/hooks.json +18 -0
- package/plugin/rarog/hooks/recipient.mjs +95 -0
- package/plugin/rarog/lib/coordinator.mjs +1340 -0
- package/plugin/rarog/lib/threads.mjs +350 -0
- package/plugin/rarog/skills/coordinator/SKILL.md +111 -0
- package/plugin/rarog/skills/coordinator/check-and-merge.md +46 -0
- package/plugin/rarog/skills/coordinator/close-thread.md +15 -0
- package/plugin/rarog/skills/coordinator/role.md +61 -0
- package/plugin/rarog/skills/coordinator/send-back.md +39 -0
- package/plugin/rarog/skills/coordinator/start-thread.md +43 -0
- package/server/src/bootstrap/coordination.js +49 -0
- package/server/src/bootstrap/coordinator-start.js +27 -0
- package/server/src/bootstrap/inbox.js +4 -0
- package/server/src/bootstrap/pr-status.js +15 -7
- package/server/src/bootstrap/push.js +59 -5
- package/server/src/cli/doctor-pr-status.js +10 -6
- package/server/src/companion/catalog.js +1 -1
- package/server/src/companion/index.js +2 -4
- package/server/src/config/flags.js +4 -0
- package/server/src/config-env.js +15 -0
- package/server/src/config.js +17 -3
- package/server/src/coordination/merge-events.js +86 -0
- package/server/src/coordination/merge-prompt.js +244 -0
- package/server/src/coordination/registry.js +289 -0
- package/server/src/coordination/state.js +94 -0
- package/server/src/coordination/summary.js +422 -0
- package/server/src/coordination/thread-file.js +245 -0
- package/server/src/coordination/thread-git.js +110 -0
- package/server/src/coordination/watch.js +237 -0
- package/server/src/demo/content/coordinator.js +89 -0
- package/server/src/demo/content/en.js +57 -1
- package/server/src/demo/content/pl.js +57 -1
- package/server/src/demo/control.js +4 -2
- package/server/src/demo/inbox.js +12 -0
- package/server/src/demo/mock-herdr.js +5 -4
- package/server/src/demo/review-routes.js +2 -2
- package/server/src/demo/scenarios.js +31 -17
- package/server/src/demo/seeds.js +82 -40
- package/server/src/drivers/herdr/live-dialog.js +412 -0
- package/server/src/drivers/herdr/live-step.js +261 -0
- package/server/src/drivers/herdr/pause-gate.js +60 -0
- package/server/src/drivers/herdr/pull-request-poll.js +5 -5
- package/server/src/drivers/herdr/queue-take-back.js +4 -0
- package/server/src/drivers/herdr/returned-prompt.js +4 -1
- package/server/src/drivers/herdr/screen-fallback.js +50 -0
- package/server/src/drivers/herdr/start-dialog-gate.js +136 -0
- package/server/src/drivers/herdr-driver.js +159 -77
- package/server/src/files/refusals.js +9 -2
- package/server/src/files/session-gate.js +5 -4
- package/server/src/git-branch-diff.js +194 -0
- package/server/src/herdr/argv.js +34 -3
- package/server/src/herdr/audit.js +32 -1
- package/server/src/herdr/background/cli-shapes.js +35 -15
- package/server/src/herdr/background/index.js +7 -7
- package/server/src/herdr/background/merge.js +17 -5
- package/server/src/herdr/background/notification.js +0 -4
- package/server/src/herdr/background/pull-request-files.js +53 -161
- package/server/src/herdr/background/pull-requests.js +54 -632
- package/server/src/herdr/background/queued-prompt.js +46 -0
- package/server/src/herdr/background/work.js +96 -0
- package/server/src/herdr/client.js +22 -46
- package/server/src/herdr/commands/catalog.js +11 -7
- package/server/src/herdr/commands/discover.js +33 -1
- package/server/src/herdr/commands/index.js +3 -2
- package/server/src/herdr/dialogs/copy.js +7 -0
- package/server/src/herdr/dialogs/index.js +13 -1
- package/server/src/herdr/dialogs/layer1/hook-list/hook-list.js +4 -56
- package/server/src/herdr/dialogs/live/model.js +220 -0
- package/server/src/herdr/dialogs/live/policy.js +108 -0
- package/server/src/herdr/dialogs/live/view.js +261 -0
- package/server/src/herdr/dialogs/screen/form.js +6 -4
- package/server/src/herdr/dialogs/screen/option-run.js +25 -3
- package/server/src/herdr/dialogs/screen/parse.js +3 -3
- package/server/src/herdr/dialogs/screen/signatures.js +78 -0
- package/server/src/herdr/dialogs/screen/start-dialog.js +72 -0
- package/server/src/herdr/dialogs/screen/trust-arrow.js +46 -9
- package/server/src/herdr/engines.js +96 -0
- package/server/src/herdr/history-steps.js +9 -4
- package/server/src/herdr/identity.js +20 -5
- package/server/src/herdr/jsonl-follow.js +26 -3
- package/server/src/herdr/label-code.js +104 -0
- package/server/src/herdr/label-migration.js +142 -0
- package/server/src/herdr/launcher.js +30 -5
- package/server/src/herdr/plugin-copy.js +281 -0
- package/server/src/herdr/provenance.js +80 -40
- package/server/src/herdr/session-index.js +19 -0
- package/server/src/herdr/start-dialog-wait.js +96 -0
- package/server/src/herdr/supervisor.js +49 -23
- package/server/src/herdr/types.js +1 -0
- package/server/src/herdr/workspace-resolver.js +5 -4
- package/server/src/inbox/card.js +31 -8
- package/server/src/inbox/heads.js +1 -0
- package/server/src/inbox/inbox.js +21 -4
- package/server/src/inbox/removals.js +10 -1
- package/server/src/index.js +45 -8
- package/server/src/notify/apns-payload.js +5 -3
- package/server/src/notify/content.js +64 -0
- package/server/src/notify/index.js +11 -3
- package/server/src/notify/live-activity-state.js +19 -6
- package/server/src/notify/live-activity.js +5 -2
- package/server/src/notify/policy.js +53 -13
- package/server/src/notify/ready-to-merge.js +148 -0
- package/server/src/notify/stalled-wait.js +213 -0
- package/server/src/pr-status/facts.js +87 -0
- package/server/src/pr-status/gh.js +76 -9
- package/server/src/pr-status/index.js +1 -10
- package/server/src/pr-status/source.js +20 -6
- package/server/src/pr-status/tracker.js +32 -9
- package/server/src/project-root.js +233 -0
- package/server/src/routes/sessions.js +68 -2
- package/server/src/sessions/branch-diff.js +57 -0
- package/server/src/sessions/cli-registry.js +17 -3
- package/server/src/sessions/companion-scope.js +2 -1
- package/server/src/sessions/consent-cards.js +49 -2
- package/server/src/sessions/conversation-lists.js +11 -2
- package/server/src/sessions/coordinator-start.js +172 -0
- package/server/src/sessions/demo-modules.js +1 -0
- package/server/src/sessions/demo-seeds.js +100 -0
- package/server/src/sessions/driver-events.js +68 -14
- package/server/src/sessions/herdr-lifecycle.js +11 -4
- package/server/src/sessions/interrupt-windows.js +28 -4
- package/server/src/sessions/launch-gate.js +36 -11
- package/server/src/sessions/live-dialog.js +69 -0
- package/server/src/sessions/manager.js +138 -287
- package/server/src/sessions/owner-turn.js +36 -0
- package/server/src/sessions/pr-status-link.js +64 -16
- package/server/src/sessions/seen-marks.js +31 -12
- package/server/src/sessions/session-dialog.js +82 -0
- package/server/src/sessions/session-git.js +1 -0
- package/server/src/sessions/session-scope.js +6 -5
- package/server/src/sessions/session-take-back.js +5 -0
- package/server/src/sessions/session.js +82 -10
- package/server/src/sessions/state-machine.js +13 -0
- package/server/src/sessions/state-sentences.js +87 -30
- package/server/src/sessions/test-session.js +50 -0
- package/server/src/sessions/waiting-line.js +49 -0
- package/server/src/term/herdr-backend.js +15 -12
- package/server/src/term/lifecycle.js +4 -6
- package/server/src/transcript-import.js +20 -2
- package/server/src/version.js +4 -0
- /package/server/src/{companion/asks-owner.js → asks-owner.js} +0 -0
|
@@ -161,7 +161,6 @@ export const HERDR_RESUME_MESSAGE = say('rest.bad-state');
|
|
|
161
161
|
* przychodzi PRZED `/exit` — sesja jest nietknięta i człowiek ma wiedzieć, co zrobić, żeby
|
|
162
162
|
* restart przeszedł.
|
|
163
163
|
*/
|
|
164
|
-
export const RESTART_CODEX_MESSAGE = say('restart.codex');
|
|
165
164
|
export const RESTART_IN_PROGRESS_MESSAGE = say('restart.in-progress');
|
|
166
165
|
export const RESTART_NO_PANEL_MESSAGE = say('restart.no-panel');
|
|
167
166
|
export const RESTART_UNSUPPORTED_MESSAGE = say('restart.unsupported');
|
|
@@ -332,26 +331,6 @@ export const RESUME_UNVERIFIABLE_MESSAGE = say('session.resume-unverifiable');
|
|
|
332
331
|
* warunek techniczny „jest czym adresować taba".
|
|
333
332
|
*/
|
|
334
333
|
export const HERDR_NOT_OWNED_MESSAGE = say('session.close-not-owned');
|
|
335
|
-
/**
|
|
336
|
-
* 409 na `closePanel: true` dla panelu CODEXA.
|
|
337
|
-
*
|
|
338
|
-
* Granica władzy stoi TU, a nie w copy klienta: nowy klient „×" dla Codexa nie rysuje, ale stary
|
|
339
|
-
* (w dawnej PWA: otwarta od wczoraj zakładka) rysuje go dalej — i jego żądanie doszłoby do `tab.close`
|
|
340
|
-
* dokładnie tak samo jak dla panelu Claude. Wpis Codexa daje wyłącznie STAN; zamknięcie
|
|
341
|
-
* cudzego panelu byłoby jedyną władzą, jaką by dawał, a tej nie obiecywaliśmy.
|
|
342
|
-
*/
|
|
343
|
-
export const HERDR_CODEX_CLOSE_MESSAGE = say('session.codex-close');
|
|
344
|
-
/**
|
|
345
|
-
* 400 na diff sesji z karty Codexa.
|
|
346
|
-
*
|
|
347
|
-
* `diff` pyta o `engine` i `outOfScope` jak każda metoda karty (bramka zasięgu). Bez tego
|
|
348
|
-
* dla wpisu Codexa byłaby to władza: treść katalogu panelu (bywa spoza `RAROG_HERDR_ROOTS`) wydana z karty, która
|
|
349
|
-
* obiecuje SAM STAN. Zdanie „wpis
|
|
350
|
-
* nie dokłada Rarogowi ani grama władzy" ma być prawdą po stronie SERWERA, a nie tylko
|
|
351
|
-
* w kliencie. Wiersz gita w nagłówku (gałąź, liczniki) zostaje: to ten sam odczyt, który karta
|
|
352
|
-
* i tak pokazuje na liście.
|
|
353
|
-
*/
|
|
354
|
-
export const HERDR_CODEX_GIT_MESSAGE = say('session.codex-git');
|
|
355
334
|
/**
|
|
356
335
|
* 409 na przerwanie sesji bez podpiętego drivera.
|
|
357
336
|
*
|
|
@@ -410,7 +389,8 @@ export const HERDR_OUT_OF_SCOPE_MESSAGE = say('session.out-of-scope');
|
|
|
410
389
|
*
|
|
411
390
|
* Diff roboczy to TREŚĆ katalogu. Panel poza zasięgiem nie oddaje transkryptu ani wycinka ekranu
|
|
412
391
|
* i nie ma nawet linii gita, a `diff` do tego dnia jego katalog oddawał — jedyna metoda karty bez
|
|
413
|
-
* bramki zasięgu
|
|
392
|
+
* bramki zasięgu. A state-only card is refused by the same gate with its engine's sentence
|
|
393
|
+
* (`STATE_ONLY_REFUSALS` in `herdr/engines.ts`).
|
|
414
394
|
*/
|
|
415
395
|
export const HERDR_OUT_OF_SCOPE_DIFF_MESSAGE = say('session.out-of-scope-diff');
|
|
416
396
|
/** 400 for a send while the write channel is closed (`RAROG_HERDR_SEND=0`). */
|
|
@@ -542,8 +522,10 @@ export function inTurn(state) {
|
|
|
542
522
|
*/
|
|
543
523
|
export function startsTurn(event) {
|
|
544
524
|
return event.type === 'turn-start' || event.type === 'agent-working'
|
|
545
|
-
|| event.type === 'resumed' || event.type === 'agent-blocked';
|
|
525
|
+
|| event.type === 'resumed' || event.type === 'agent-blocked' || event.type === 'subagent-consent-pending';
|
|
546
526
|
}
|
|
527
|
+
/** A complete tally with no input yet. */
|
|
528
|
+
const ZERO_TALLY = { standbyNotices: 0, artifactWatch: 0, other: 0, toolCalls: 0, compactions: 0 };
|
|
547
529
|
/**
|
|
548
530
|
* Rachunek wiadomości tury PO jej końcu (`Session.turnInput`).
|
|
549
531
|
*
|
|
@@ -553,19 +535,94 @@ export function startsTurn(event) {
|
|
|
553
535
|
* 2 s), a koniec tury melduje herdr, niezależnie. Spóźniona notka o postoju doliczyłaby się do
|
|
554
536
|
* NASTĘPNEJ tury i wyciszyła jej „gotowe". Rachunek po takim końcu jest więc niepełny
|
|
555
537
|
* (`undefined`) do kolejnego końca tury: jedna tura bez wnioskowania, czyli zwykłe „gotowe".
|
|
538
|
+
* Not so when a subagent woke from standby in that window (`subagentWakes`): the turn was the woken subagent's work
|
|
539
|
+
* in the pane, its standby notice usually arrives a second after the turn end, and it must count towards the next
|
|
540
|
+
* turn, so the tally starts from zero.
|
|
556
541
|
*
|
|
557
|
-
*
|
|
558
|
-
*
|
|
559
|
-
*
|
|
560
|
-
*
|
|
561
|
-
* (inaczej prompt startowy sesji założonej z Raroga nie liczyłby się nigdzie).
|
|
542
|
+
* Second exception: a session that is standing up (`started` in `#applyTransition`: the first exit from a turn of
|
|
543
|
+
* a card created in `starting`, the zero turn included). That is no turn end but a pane that came up, so the tally
|
|
544
|
+
* stays as the attach left it; {@link closeTurnTally} starts it from zero only when the attach history was read
|
|
545
|
+
* (otherwise the start prompt of a session created from Rarog would count nowhere).
|
|
562
546
|
*/
|
|
563
547
|
export function nextTurnInput(ended, started) {
|
|
564
548
|
if (started)
|
|
565
549
|
return undefined;
|
|
566
550
|
// Pusty = bez wejścia. Wywołania narzędzi wejściem nie są: tura musiała mieć przyczynę.
|
|
567
|
-
const empty = ended !== undefined && noInputYet(ended);
|
|
568
|
-
return empty ? undefined : {
|
|
551
|
+
const empty = ended !== undefined && noInputYet(ended) && (ended.subagentWakes ?? 0) === 0;
|
|
552
|
+
return empty ? undefined : { ...ZERO_TALLY };
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Subagents that woke from standby on a task list swap (`agentsWoken` in `herdr/background/work.ts`) go into the
|
|
556
|
+
* tally of the current window. Like input, they count from turn end to turn end: the wake shows on the list before
|
|
557
|
+
* herdr reports the pane working. An incomplete tally stays incomplete. A wake that herdr never turned into a turn
|
|
558
|
+
* stays in the tally until the next turn end; a turn with any input is judged by that input alone.
|
|
559
|
+
*/
|
|
560
|
+
export function noteSubagentWakes(session, wakes) {
|
|
561
|
+
const turn = session.turnInput;
|
|
562
|
+
if (wakes === 0 || turn === undefined)
|
|
563
|
+
return;
|
|
564
|
+
session.turnInput = { ...turn, subagentWakes: (turn.subagentWakes ?? 0) + wakes };
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* A new driver: the tally is incomplete. With the attach time (a pane just adopted, whose card state is the snapshot
|
|
568
|
+
* read for it) its history may start the tally from zero ({@link tallyAfterHistory}). Without it (a pane started from
|
|
569
|
+
* Rarog, a driver attached again after a herdr outage, whose card state may be older than the outage) the tally
|
|
570
|
+
* stays incomplete until the next turn end.
|
|
571
|
+
*/
|
|
572
|
+
export function tallyOnAttach(session, atMs) {
|
|
573
|
+
session.turnInput = undefined;
|
|
574
|
+
session.turnTallyAttach = atMs === undefined ? undefined : { atMs, historyRead: false };
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* The tally stays incomplete until the next turn end and the attach no longer starts it: the file continuity was
|
|
578
|
+
* lost (the new conversation's history may hold the prompt of a running turn) or a zero turn settled.
|
|
579
|
+
*/
|
|
580
|
+
export function dropTurnTally(session) {
|
|
581
|
+
session.turnInput = undefined;
|
|
582
|
+
session.turnTallyAttach = undefined;
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* The tally after a history portion. History is not counted, so the tally is incomplete, except for the attach
|
|
586
|
+
* history of a pane just adopted ({@link tallyOnAttach}) when it is out of a turn: everything before the attach then stands in that history, and
|
|
587
|
+
* the tally starts from zero. A card still standing up (`awaitingFirstTurn`) does not know yet where the pane
|
|
588
|
+
* stands, so its first exit decides ({@link closeTurnTally}). A pane in a turn keeps the tally incomplete, and so
|
|
589
|
+
* does history written after the attach: a pane with no conversation file at attach gets the first prompt of the
|
|
590
|
+
* fresh conversation as history. Known gap: "out of a turn" is the state the card shows, which herdr reports
|
|
591
|
+
* `working` late (the working grace) and which right after the attach is the adoption snapshot, so a turn started
|
|
592
|
+
* in those seconds before the attach looks idle and its prompt, in the history, is not counted.
|
|
593
|
+
*/
|
|
594
|
+
export function tallyAfterHistory(session, messages) {
|
|
595
|
+
session.turnInput = undefined;
|
|
596
|
+
const attach = session.turnTallyAttach;
|
|
597
|
+
if (attach === undefined)
|
|
598
|
+
return;
|
|
599
|
+
// An unreadable time counts as written after the attach: nothing is inferred from it.
|
|
600
|
+
const beforeAttach = messages.every((message) => Date.parse(message.at) <= attach.atMs);
|
|
601
|
+
if (!beforeAttach || (inTurn(session.state) && !session.awaitingFirstTurn)) {
|
|
602
|
+
session.turnTallyAttach = undefined;
|
|
603
|
+
}
|
|
604
|
+
else if (session.awaitingFirstTurn) {
|
|
605
|
+
session.turnTallyAttach = { ...attach, historyRead: true };
|
|
606
|
+
}
|
|
607
|
+
else {
|
|
608
|
+
session.turnInput = { ...ZERO_TALLY };
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* The tally at a turn exit (`leavesTurn` in `#applyTransition`), after the scheduler got the ended one. A real turn
|
|
613
|
+
* end follows {@link nextTurnInput} and ends the attach. The first exit of a card standing up (`started`) starts
|
|
614
|
+
* from zero when the attach history was read while it stood up; before that history the attach waits for it.
|
|
615
|
+
*/
|
|
616
|
+
export function closeTurnTally(session, started) {
|
|
617
|
+
const attach = session.turnTallyAttach;
|
|
618
|
+
if (started && attach !== undefined) {
|
|
619
|
+
session.turnInput = attach.historyRead ? { ...ZERO_TALLY } : undefined;
|
|
620
|
+
if (attach.historyRead)
|
|
621
|
+
session.turnTallyAttach = undefined;
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
session.turnTallyAttach = undefined;
|
|
625
|
+
session.turnInput = nextTurnInput(session.turnInput, started);
|
|
569
626
|
}
|
|
570
627
|
/**
|
|
571
628
|
* Jak długo po końcu tury po samym meldunku o artefakcie spóźnione wywołanie narzędzia z pliku
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test session rule: a session whose working directory lies in a temporary directory. Agents that run tests and
|
|
3
|
+
* measurements start helper sessions in the Claude Code scratchpad (`/tmp/claude-<uid>/`, on macOS also written
|
|
4
|
+
* `/private/tmp/claude-<uid>/`) or in the temporary directory of this process (`os.tmpdir()`, `$TMPDIR`; on macOS
|
|
5
|
+
* also its on-disk form under `/private`). One function over a path, without state;
|
|
6
|
+
* the manager passes the fact to the notification scheduler, which keeps the rule for "done".
|
|
7
|
+
*/
|
|
8
|
+
import os from 'node:os';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import { DIRECT_DISK } from '../folder-gate/disk.js';
|
|
11
|
+
/** The server process: `process.getuid()`, `os.tmpdir()` and `realpath` through the work-area disk port. */
|
|
12
|
+
export function systemTempDirEnv() {
|
|
13
|
+
return {
|
|
14
|
+
uid: typeof process.getuid === 'function' ? process.getuid() : undefined,
|
|
15
|
+
tmpdir: os.tmpdir(),
|
|
16
|
+
realpath: (file) => DIRECT_DISK.sync('realpath', { path: file }),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** The path as written and, when it resolves, on disk; both normalized without a trailing slash. */
|
|
20
|
+
function spellings(file, realpath) {
|
|
21
|
+
const written = path.resolve(file);
|
|
22
|
+
try {
|
|
23
|
+
const real = path.resolve(realpath(written));
|
|
24
|
+
return real === written ? [written] : [written, real];
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return [written];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Whether `cwd` is the scratchpad root of Claude Code for this user, the temporary directory of the server, or lies
|
|
32
|
+
* below one of them. A prefix matches on a directory boundary only: `/tmp/claude-501-other/` is not under
|
|
33
|
+
* `/tmp/claude-501/`. Never throws: it runs on every state transition of every session.
|
|
34
|
+
*/
|
|
35
|
+
export function inTemporaryDirectory(cwd, env = systemTempDirEnv()) {
|
|
36
|
+
if (cwd === '')
|
|
37
|
+
return false;
|
|
38
|
+
try {
|
|
39
|
+
const scratchpad = env.uid === undefined ? undefined : `claude-${String(env.uid)}`;
|
|
40
|
+
const written = scratchpad === undefined ? [] : [`/tmp/${scratchpad}`, `/private/tmp/${scratchpad}`];
|
|
41
|
+
if (env.tmpdir !== '')
|
|
42
|
+
written.push(env.tmpdir);
|
|
43
|
+
// The filesystem root would make every path temporary.
|
|
44
|
+
const roots = written.flatMap((root) => spellings(root, env.realpath)).filter((root) => root !== path.sep);
|
|
45
|
+
return spellings(cwd, env.realpath).some((candidate) => roots.some((root) => candidate === root || candidate.startsWith(root + path.sep)));
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { EXIT_PLAN_MODE_TOOL, WAITING_TEXT_MAX } from '@rarog/shared';
|
|
7
7
|
// Ta sama etykieta, którą dostaje wiersz tool-calla w transkrypcie — patrz `decisionText`.
|
|
8
8
|
import { summarizeToolInput } from '../drivers/tool-summary.js';
|
|
9
|
+
import { DECISION_STATES } from './state-sentences.js';
|
|
9
10
|
/**
|
|
10
11
|
* Treść decyzji do JEDNEJ linii karty listy: pierwsza linia, przycięta do `WAITING_TEXT_MAX`.
|
|
11
12
|
*
|
|
@@ -70,3 +71,51 @@ export function decisionText(permission) {
|
|
|
70
71
|
// Bez trafionego klucza `summarizeToolInput` oddaje NAZWĘ narzędzia — a ta stoi już obok.
|
|
71
72
|
return summary === permission.toolName ? '' : summary;
|
|
72
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Skrót stojącej decyzji dla LISTY — fakty, nie gotowy napis.
|
|
76
|
+
*
|
|
77
|
+
* Liczony z `#pending` przy każdym `#summaryOf` i nigdzie nie zapamiętywany: wpis znika
|
|
78
|
+
* razem z kartą (`permission-cleared`, `#expirePending`, odpowiedź), więc nie ma kodu,
|
|
79
|
+
* który musiałby to pole kasować — a takiego kodu nikt nie wywoła w ścieżce, o której
|
|
80
|
+
* zapomniał. Pierwsza karta w kolejce, bo SDK potrafi zgłosić kilka naraz, a linia karty
|
|
81
|
+
* ma jeden wiersz; kolejne widać po wejściu w sesję.
|
|
82
|
+
*
|
|
83
|
+
* Dialog z ekranu (`herdrDialog`) świadomie NIE ma tu wpisu: jego rodzaj jedzie kanałem
|
|
84
|
+
* globalnym własnym polem, więc drugi opis tej samej rzeczy byłby dwoma źródłami
|
|
85
|
+
* prawdy o jednym dialogu.
|
|
86
|
+
*/
|
|
87
|
+
export function waitingFor(session, pending, consentRequests) {
|
|
88
|
+
if (!DECISION_STATES.includes(session.state))
|
|
89
|
+
return undefined;
|
|
90
|
+
// Karta kanału zgód liczy się jako „czeka na człowieka” wyłącznie w stanie `pending`.
|
|
91
|
+
const permission = pending.permissionsFor(session.id)[0]
|
|
92
|
+
?? consentRequests(session).find((request) => request.state === 'pending');
|
|
93
|
+
if (permission !== undefined) {
|
|
94
|
+
const text = waitingText(decisionText(permission));
|
|
95
|
+
return {
|
|
96
|
+
kind: 'permission',
|
|
97
|
+
tool: permission.toolName,
|
|
98
|
+
...(text === '' ? {} : { text }),
|
|
99
|
+
// Lista mówi „plan" z tego pola, nie z nazwy `ExitPlanMode`.
|
|
100
|
+
subject: permission.subject ?? permissionSubject(permission.toolName),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
const question = pending.questionsFor(session.id)[0];
|
|
104
|
+
if (question === undefined)
|
|
105
|
+
return undefined;
|
|
106
|
+
const text = waitingText(question.questions[0]?.question ?? '');
|
|
107
|
+
return {
|
|
108
|
+
kind: 'question',
|
|
109
|
+
...(text === '' ? {} : { text }),
|
|
110
|
+
// „1" nie jest informacją: numeracja na karcie ma sens dopiero od dwóch pytań.
|
|
111
|
+
...(question.questions.length > 1 ? { count: question.questions.length } : {}),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Przedmiot zgody: wyjście z trybu planu albo zwykłe narzędzie. Jedyne miejsce, w którym
|
|
116
|
+
* nazwa `ExitPlanMode` staje się faktem dla klienta — telefon buduje kartę planu z pola
|
|
117
|
+
* `subject`, a nazwy narzędzia CLI nie zna.
|
|
118
|
+
*/
|
|
119
|
+
export function permissionSubject(toolName) {
|
|
120
|
+
return toolName === EXIT_PLAN_MODE_TOOL ? 'plan' : 'tool';
|
|
121
|
+
}
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
* 3. **Zero logowania treści.** Bajty ekranu przechodzą przez ten moduł do gniazd WS i nie
|
|
22
22
|
* trafiają ani do logu, ani do pliku stanu. Na dysku zostaje jeden plik z samymi
|
|
23
23
|
* identyfikatorami paneli, ich katalogami i znacznikiem czasu (`term-herdr.json`).
|
|
24
|
-
* 4. **Pochodzenie panelu = jego ETYKIETA `
|
|
24
|
+
* 4. **Pochodzenie panelu = jego ETYKIETA `rt:<id>`, władza = token.** Token
|
|
25
25
|
* `rarog-term` ginie przy restarcie serwera herdr, etykieta panelu (`pane.rename`) — nie, bo
|
|
26
26
|
* herdr trzyma ją w snapshotcie. `reconcile()` przywraca token panelom z etykietą (jeden
|
|
27
27
|
* przebieg naraz, wspólny mutex z zakładaniem), niczego przy tym nie zamyka, a niepewny wynik
|
|
28
28
|
* znaczy odmowę zamiast drugiego taba obok. The label leads with the tab label
|
|
29
|
-
* (`<tab label> ·
|
|
29
|
+
* (`<tab label> · rt:<id>`), so herdr's Go-to names the pane like its tab.
|
|
30
30
|
* 5. **Etykieta TABA to slot albo rola plus katalog** (`rarog 1 · rarog`) — przy
|
|
31
31
|
* zakładaniu i, dla tabów w starym formacie, przy migracji w `reconcile`. Tylko tab jednopanelowy
|
|
32
32
|
* z naszym panelem i etykietą „1” z `workspace.create`; nazwa nadana ręcznie zostaje
|
|
@@ -39,8 +39,9 @@ import { TERM_ID_RE, TERM_PROC_MAX_LENGTH } from '@rarog/shared';
|
|
|
39
39
|
import { say } from '@rarog/shared/sentences';
|
|
40
40
|
import { redact } from '../auth/index.js';
|
|
41
41
|
import { RAROG_TERM_PANE_TOKEN, termPaneTokenOf } from '../config.js';
|
|
42
|
+
import { isLegacyPaneLabel } from '../herdr/label-migration.js';
|
|
42
43
|
import { decideProjectWorkspace, sharedProjectPlacement } from '../herdr/project-workspace.js';
|
|
43
|
-
import {
|
|
44
|
+
import { paneLabelTermId, realProjectPath, termPaneLabel, terminalTabLabel, } from '../herdr/provenance.js';
|
|
44
45
|
import { HerdrUnavailableError } from '../herdr/socket.js';
|
|
45
46
|
import { HerdrReadOnlyError, isBareShellForeground } from '../herdr/types.js';
|
|
46
47
|
import { matchTermId } from './lifecycle.js';
|
|
@@ -478,10 +479,9 @@ export function createHerdrBackend(options) {
|
|
|
478
479
|
paneId, source: RAROG_TERM_METADATA_SOURCE, tokens: { [RAROG_TERM_TOKEN]: id },
|
|
479
480
|
});
|
|
480
481
|
}
|
|
481
|
-
/** Tożsamość z etykiety `
|
|
482
|
+
/** Tożsamość z etykiety `rt:<id>` panelu albo `null` (brak, cudza, panel Claude). */
|
|
482
483
|
function labelIdOf(pane) {
|
|
483
|
-
|
|
484
|
-
return provenance?.kind === 'term' ? provenance.value : null;
|
|
484
|
+
return paneLabelTermId(pane.label);
|
|
485
485
|
}
|
|
486
486
|
/**
|
|
487
487
|
* Tożsamość z tokenu `rarog-term` albo `null`. Wartość spoza kształtu `TERM_ID_RE` nie jest
|
|
@@ -542,8 +542,8 @@ export function createHerdrBackend(options) {
|
|
|
542
542
|
* JEDEN przebieg odzyskiwania. Kroki:
|
|
543
543
|
*
|
|
544
544
|
* 1. Świeży `pane.list` (pełny wiersz z etykietą) i `listPaneIds` (pełny inwentarz obecności).
|
|
545
|
-
* 2. Etykieta `
|
|
546
|
-
* (panel w starym formacie) → `pane.rename` na `
|
|
545
|
+
* 2. Etykieta `rt:<id>` bez tokenu → token wraca (bez TTL). Token bez etykiety
|
|
546
|
+
* (panel w starym formacie) → `pane.rename` na `rt:<token>`. Tożsamość obecna na więcej niż
|
|
547
547
|
* jednym panelu albo panel z etykietą i INNYM tokenem → konflikt: nie ruszamy żadnego.
|
|
548
548
|
* 3. Prune `term-herdr.json` wyłącznie po `listPaneIds`.
|
|
549
549
|
* 4. Wynik: potwierdzone, przywrócone, zmigrowane, nieznane (timeout mutacji) i konflikty.
|
|
@@ -760,7 +760,7 @@ export function createHerdrBackend(options) {
|
|
|
760
760
|
/**
|
|
761
761
|
* MIGRACJA etykiet tabów terminala w starym formacie — krok `reconcile`, pod jego mutexem.
|
|
762
762
|
*
|
|
763
|
-
* Panel z potwierdzoną tożsamością (token) i NASZĄ etykietą panelu `
|
|
763
|
+
* Panel z potwierdzoną tożsamością (token) i NASZĄ etykietą panelu `rt:<id>` (także
|
|
764
764
|
* nadaną w tym samym przebiegu), tab jednopanelowy z etykietą z {@link LEGACY_TERM_TAB_LABELS}
|
|
765
765
|
* → `tab.rename` na nowy format. Inna etykieta taba = ręczna, nietknięta; split (więcej niż jeden panel) — nietknięty, bo tab nie jest wtedy „terminala". Katalog i slot bierzemy
|
|
766
766
|
* z pliku stanu (katalog powstania), a gdy ten nie pasuje — z bieżącego `cwd` panelu; żadna
|
|
@@ -768,7 +768,7 @@ export function createHerdrBackend(options) {
|
|
|
768
768
|
* potwierdzeniem stanu. Etykieta jest deterministyczna, więc śladu nie potrzebuje.
|
|
769
769
|
* `RAROG_HERDR_TAB_LABELS=0` gasi ten krok w całości.
|
|
770
770
|
*
|
|
771
|
-
* The same step gives a bare pane label `
|
|
771
|
+
* The same step gives a bare pane label `rt:<id>` its description: the terminal tab
|
|
772
772
|
* label from the same identity and directory, so a pane without a match keeps its old label.
|
|
773
773
|
* Single-pane tabs only, each write behind its own fresh confirmation.
|
|
774
774
|
*
|
|
@@ -788,6 +788,9 @@ export function createHerdrBackend(options) {
|
|
|
788
788
|
// jego tab też zostaje jego.
|
|
789
789
|
if (labelIdOf(pane) !== id && !labelledNow.has(pane.paneId))
|
|
790
790
|
continue;
|
|
791
|
+
// An old-format label is rewritten by the label migration first; its description comes on a later pass.
|
|
792
|
+
if (isLegacyPaneLabel(pane.label))
|
|
793
|
+
continue;
|
|
791
794
|
const checkKey = `${pane.paneId}|${id}|${pane.tabId}`;
|
|
792
795
|
if (tabLabelChecked.has(checkKey))
|
|
793
796
|
continue;
|
|
@@ -847,7 +850,7 @@ export function createHerdrBackend(options) {
|
|
|
847
850
|
}
|
|
848
851
|
}
|
|
849
852
|
/*
|
|
850
|
-
* The pane label: a bare `
|
|
853
|
+
* The pane label: a bare `rt:<id>` gets the terminal tab label in front, so herdr's
|
|
851
854
|
* Go-to names the pane like its tab. A label that already has a description stays (Rarog
|
|
852
855
|
* wrote it, or a human chose it within the pattern), which makes the step idempotent.
|
|
853
856
|
*/
|
|
@@ -959,7 +962,7 @@ export function createHerdrBackend(options) {
|
|
|
959
962
|
* (etykieta Raroga tej ścieżki albo `cwd` panelu w projekcie); bez dowodu nowy workspace.
|
|
960
963
|
* Samo `pane.cwd` nie wystarcza: dryfuje z każdym `cd`, więc tab projektu A wchodziłby do
|
|
961
964
|
* workspace'u projektu B. Sloty jednego projektu trzymają się razem dzięki etykiecie
|
|
962
|
-
* `
|
|
965
|
+
* `rt:<id>` pierwszego slotu (dowód mocny).
|
|
963
966
|
*/
|
|
964
967
|
/*
|
|
965
968
|
* Pisownie dla rozpoznania etykiet: `cwd` z rejestru i katalogi powstania
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { createHash } from 'node:crypto';
|
|
11
11
|
import { isPopupRole, TERM_ID_LENGTH, TERM_ROLES, TERM_SLOTS_MAX } from '@rarog/shared';
|
|
12
|
-
import {
|
|
12
|
+
import { paneLabelTermId } from '../herdr/provenance.js';
|
|
13
13
|
/**
|
|
14
14
|
* Tożsamość terminala: `sha256(realpath(cwd))` (slot 1) albo `sha256(realpath(cwd) + NUL + N)`
|
|
15
15
|
* (slot N ≥ 2), skrócony do 16 hex.
|
|
@@ -72,17 +72,15 @@ export function matchTermId(id, realCwd) {
|
|
|
72
72
|
return null;
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
|
-
* Etykieta PANELU (`
|
|
75
|
+
* Etykieta PANELU (`rt:<id>`) → tożsamość terminala TEGO katalogu albo `null`.
|
|
76
76
|
*
|
|
77
77
|
* `null` dla etykiety spoza wzorca (`parsePaneLabel`), etykiety panelu Claude i identyfikatora,
|
|
78
78
|
* który nie jest hashem tej ścieżki przy żadnym slocie ani roli. Czysta: czyta tylko napis
|
|
79
79
|
* i ścieżkę, niczego nie rozwiązuje na dysku.
|
|
80
80
|
*/
|
|
81
81
|
export function matchTermLabel(label, realCwd) {
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
return null;
|
|
85
|
-
return matchTermId(provenance.value, realCwd);
|
|
82
|
+
const id = paneLabelTermId(label);
|
|
83
|
+
return id === null ? null : matchTermId(id, realCwd);
|
|
86
84
|
}
|
|
87
85
|
// ---------------------------------------------------------------------------
|
|
88
86
|
// Karencja i bezpiecznik respawnu
|
|
@@ -29,7 +29,7 @@ import { CLI_PLUMBING_TAGS } from './herdr/commands/registry.js';
|
|
|
29
29
|
import { INTERRUPTION_TEXT, parseJsonlEntry } from './herdr/jsonl-pending.js';
|
|
30
30
|
import { isMainCompactBoundary } from './herdr/jsonl-usage.js';
|
|
31
31
|
import { FileEchoPairing, plainFileEchoOf, systemEntryNote, userEntryNote } from './herdr/commands/transcript.js';
|
|
32
|
-
import { queuedHumanPrompt } from './herdr/background/queued-prompt.js';
|
|
32
|
+
import { crossSessionPrompt, queuedHumanPrompt } from './herdr/background/queued-prompt.js';
|
|
33
33
|
import { MAX_TRANSCRIPT_MESSAGES } from './sessions/session.js';
|
|
34
34
|
import { MAX_TOOL_DETAIL, clipForDisplay, toolCallSemantics, toolDiffText, toolInputText, } from './drivers/tool-text.js';
|
|
35
35
|
import { summarizeToolInput } from './drivers/tool-summary.js';
|
|
@@ -343,6 +343,18 @@ export function parseImportLine(line, opts = {}) {
|
|
|
343
343
|
? { role: 'user', message: null, conversational: false }
|
|
344
344
|
: { role: 'user', message: { role: 'user', blocks, at: queued.at }, conversational: true };
|
|
345
345
|
}
|
|
346
|
+
/*
|
|
347
|
+
* A message from another session, idle (meta `user` entry) or absorbed into a turn (queue attachment): both carry
|
|
348
|
+
* the bare text in the origin, so both give the same bubble without the envelope and the preamble for the model.
|
|
349
|
+
* Only on request; otherwise the entry falls to the meta rule below and stays hidden.
|
|
350
|
+
*/
|
|
351
|
+
const peer = opts.crossSessionPrompts === true ? crossSessionPrompt(value) : null;
|
|
352
|
+
if (peer !== null) {
|
|
353
|
+
const blocks = userBlocksFrom(peer.body);
|
|
354
|
+
return blocks.length === 0
|
|
355
|
+
? { role: 'user', message: null, conversational: false }
|
|
356
|
+
: { role: 'user', message: { role: 'user', blocks, at: peer.at, peer: true }, conversational: true };
|
|
357
|
+
}
|
|
346
358
|
// Wpisy meta (podsumowania CLI) i sidechainy (podagenci) nie są rozmową człowieka z agentem.
|
|
347
359
|
// Reguła dotyczy WSZYSTKICH ról: transkrypt podagenta w głównym wątku byłby szumem, a nie historią.
|
|
348
360
|
//
|
|
@@ -466,8 +478,12 @@ export function parseTranscriptTail(text, opts) {
|
|
|
466
478
|
let openTurn = null;
|
|
467
479
|
const result = { messages };
|
|
468
480
|
const fileEcho = new FileEchoPairing();
|
|
481
|
+
const lineOpts = {
|
|
482
|
+
...(opts.promptBlock === false ? { promptBlock: false } : {}),
|
|
483
|
+
...(opts.crossSessionPrompts === true ? { crossSessionPrompts: true } : {}),
|
|
484
|
+
};
|
|
469
485
|
for (const line of lines) {
|
|
470
|
-
const entry = parseImportLine(line,
|
|
486
|
+
const entry = parseImportLine(line, lineOpts);
|
|
471
487
|
if (entry === null) {
|
|
472
488
|
// A mark stays out of the "/compact" pairing, as every entry without a parse result does.
|
|
473
489
|
const mark = opts.turnMarks === true ? turnMarkOf(line) : null;
|
|
@@ -575,5 +591,7 @@ export async function importTranscript(cwd, engineSessionId, opts = {}) {
|
|
|
575
591
|
const parseOpts = { dropFirstLine: tail.truncated };
|
|
576
592
|
if (opts.limit !== undefined)
|
|
577
593
|
parseOpts.limit = opts.limit;
|
|
594
|
+
if (opts.crossSessionPrompts === true)
|
|
595
|
+
parseOpts.crossSessionPrompts = true;
|
|
578
596
|
return parseTranscriptTail(tail.text, parseOpts);
|
|
579
597
|
}
|
package/server/src/version.js
CHANGED
|
@@ -53,9 +53,13 @@ export const RAROG_VERSION = readPackageVersion();
|
|
|
53
53
|
* `GET /api/sessions/:id/companion/turns` and the field `companionSessions` in `GET /api/version`. A capability of
|
|
54
54
|
* the code, not of the configuration: whether the mode works (`RAROG_COMPANION_SESSIONS` next to a working voice
|
|
55
55
|
* agent) says `companionSessions`.
|
|
56
|
+
* - `coordination` — the server knows the project coordinator (`docs/coordinator.md`): a Launch body with
|
|
57
|
+
* `coordinator: true` starts one, the summaries carry `projectRoot` and `coordination`, and
|
|
58
|
+
* `GET /api/sessions/:id/branch-diff/files` and `…/branch-diff/file?path=` answer. A capability of the code.
|
|
56
59
|
*/
|
|
57
60
|
export const SERVER_CAPABILITIES = [
|
|
58
61
|
'device-auth', 'pair', 'pair-from-device', 'push-relay', 'push-e2e-v2', 'companion', 'companion-sessions',
|
|
62
|
+
'coordination',
|
|
59
63
|
];
|
|
60
64
|
/**
|
|
61
65
|
* `inbox` — the server keeps an Inbox card per session: `GET /api/stream?inbox=1` adds the Inbox heads, and
|
|
File without changes
|