@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
|
@@ -22,7 +22,7 @@ import { withoutAutoDeny } from './auto-deny.js';
|
|
|
22
22
|
import { headerAboveEdge, operationAbove } from './operation.js';
|
|
23
23
|
import { trimmedLines } from './text.js';
|
|
24
24
|
import { DIALOG_TAIL_LINES, blockTopOf, dialogRegions, framedDialogText } from './region.js';
|
|
25
|
-
import { OPTION_LINE_PATTERN, guideMap, isCompleteOptionSet, optionsCloseRegion, optionsIn, selectedOptionIn, selectedWithLabel,
|
|
25
|
+
import { OPTION_LINE_PATTERN, guideMap, isCompleteOptionSet, optionsCloseRegion, optionsIn, selectedOptionIn, selectedWithLabel, unframe, } from './options.js';
|
|
26
26
|
import { contentEscalates } from '../policy/escalation.js';
|
|
27
27
|
import { blockFromSubagent, dialogBlock, fileDialogTitle, lineBelow, regionCallTrace, toolNaming, } from './block.js';
|
|
28
28
|
import { PLAN_DIALOG_PATTERN, PLAN_EXIT_CONFIRM_PATTERN, SANDBOX_NETWORK_TOOL, dialogKind } from './kinds.js';
|
|
@@ -32,7 +32,7 @@ import { planFooterFile } from './plan-file.js';
|
|
|
32
32
|
import { NOTES_EDITING_MARKER, formFooter, formMultiSelect, formSubmitMode, questionFrom } from './form.js';
|
|
33
33
|
import { confirmFrom } from './confirm.js';
|
|
34
34
|
import { fileDialogShown } from './file-dialog.js';
|
|
35
|
-
import { digitlessChoiceBelow, lastRunStart } from './option-run.js';
|
|
35
|
+
import { digitlessChoiceBelow, lastRunStart, regionLine } from './option-run.js';
|
|
36
36
|
/** Czy na ekranie stoi dialog, który z definicji NIE MA wpisu w jsonl ani zrzutu hooka? */
|
|
37
37
|
export function screenOnlyDialog(text) {
|
|
38
38
|
const dialog = parseOptions(text);
|
|
@@ -77,7 +77,7 @@ export function dialogThreadOnScreen(text) {
|
|
|
77
77
|
*/
|
|
78
78
|
export function optionRegion(lines, labels) {
|
|
79
79
|
for (const candidate of dialogRegions(lines)) {
|
|
80
|
-
const region = candidate.lines.map(
|
|
80
|
+
const region = candidate.lines.map(regionLine);
|
|
81
81
|
const raw = candidate.lines.map(unframe);
|
|
82
82
|
// Tryb zatwierdzania liczymy PRZED opcjami: wariant `preview` wyłącza czytanie opisów
|
|
83
83
|
// (ramka podglądu stoi dokładnie tam, gdzie w drugim wariancie stoi opis).
|
|
@@ -400,12 +400,67 @@ export const SCREEN_SIGNATURES = {
|
|
|
400
400
|
pattern: /^ (\S.*)$/,
|
|
401
401
|
cli: '2.1.319',
|
|
402
402
|
},
|
|
403
|
+
trustArrowWarningOpen: {
|
|
404
|
+
what: 'start of the pre-approved permissions warning in the trust dialog block, without the margin',
|
|
405
|
+
// `dialog-trust-preapproved-2.1.332.txt`. The count and the settings file names vary with the folder, and a
|
|
406
|
+
// narrow pane wraps the line, so the pattern takes the start only.
|
|
407
|
+
pattern: /^⚠ This folder pre-approves /,
|
|
408
|
+
cli: '2.1.332',
|
|
409
|
+
},
|
|
410
|
+
trustArrowWarningClose: {
|
|
411
|
+
what: 'sentence that ends the pre-approved permissions warning in the trust dialog block, without the margin',
|
|
412
|
+
// `dialog-trust-preapproved-2.1.332.txt`
|
|
413
|
+
pattern: /^These will apply without asking\./,
|
|
414
|
+
cli: '2.1.332',
|
|
415
|
+
},
|
|
416
|
+
trustArrowWarningListLine: {
|
|
417
|
+
what: 'permission list line of the warning: a three-space margin, the same shape as an option line without `❯`',
|
|
418
|
+
// `dialog-trust-preapproved-2.1.332.txt`: the first list line has this margin, a wrapped rest has one space.
|
|
419
|
+
pattern: /^ {3}(\S.*)$/,
|
|
420
|
+
cli: '2.1.332',
|
|
421
|
+
},
|
|
403
422
|
trustArrowFooter: {
|
|
404
423
|
what: 'stopka dialogu zaufania bez cyfr — ostatnia linia bloku',
|
|
405
424
|
// `kontrolny/zaufanie-2.1.319.txt`
|
|
406
425
|
pattern: /^Enter to confirm · Esc to cancel$/,
|
|
407
426
|
cli: '2.1.319',
|
|
408
427
|
},
|
|
428
|
+
/*
|
|
429
|
+
* Start dialog about external imports: it stands before the prompt field when a memory file of the project (or its
|
|
430
|
+
* `.claude/rules`) imports a file outside the project, and herdr reads it as `idle` (its blocked rules look for
|
|
431
|
+
* "esc to cancel"). Captures `kontrolny/importy-zewnetrzne-*-2.1.332.txt` at 139 columns.
|
|
432
|
+
*/
|
|
433
|
+
startDialogImportsTitle: {
|
|
434
|
+
what: 'title line of the external imports start dialog, the first line under the bare rule of its block',
|
|
435
|
+
// `kontrolny/importy-zewnetrzne-2.1.332.txt`
|
|
436
|
+
pattern: /^Allow external CLAUDE\.md file imports\?$/,
|
|
437
|
+
cli: '2.1.332',
|
|
438
|
+
},
|
|
439
|
+
startDialogImportsNoOption: {
|
|
440
|
+
what: 'decline option of the external imports start dialog (no digit), the label without the cursor column',
|
|
441
|
+
// `kontrolny/importy-zewnetrzne-2.1.332.txt` (cursor on it), `kontrolny/importy-zewnetrzne-po-down-2.1.332.txt`
|
|
442
|
+
pattern: /^No, disable external imports$/,
|
|
443
|
+
cli: '2.1.332',
|
|
444
|
+
},
|
|
445
|
+
startDialogImportsYesOption: {
|
|
446
|
+
what: 'allow option of the external imports start dialog (no digit), the label without the cursor column',
|
|
447
|
+
// `kontrolny/importy-zewnetrzne-po-down-2.1.332.txt` (cursor on it after `down`)
|
|
448
|
+
pattern: /^Yes, allow external imports$/,
|
|
449
|
+
cli: '2.1.332',
|
|
450
|
+
},
|
|
451
|
+
startDialogImportsOptionLine: {
|
|
452
|
+
what: 'option line of the external imports start dialog: two-space margin, cursor column (`❯` or a space), a '
|
|
453
|
+
+ 'space, the label',
|
|
454
|
+
// `kontrolny/importy-zewnetrzne-2.1.332.txt`, `kontrolny/importy-zewnetrzne-po-down-2.1.332.txt`
|
|
455
|
+
pattern: /^ {2}(?:(❯)| ) (\S.*)$/,
|
|
456
|
+
cli: '2.1.332',
|
|
457
|
+
},
|
|
458
|
+
startDialogImportsFooter: {
|
|
459
|
+
what: 'key footer of the external imports start dialog, the last line of the screen',
|
|
460
|
+
// `kontrolny/importy-zewnetrzne-2.1.332.txt`, also under the cut top of `…-dluga-lista-2.1.332.txt`
|
|
461
|
+
pattern: /^Enter to confirm · Esc to disable$/,
|
|
462
|
+
cli: '2.1.332',
|
|
463
|
+
},
|
|
409
464
|
knownDialogModel: {
|
|
410
465
|
what: 'tytuł bloku dialogu zmiany modelu („Switch model?”), nie zdanie gdziekolwiek na ekranie',
|
|
411
466
|
pattern: /^Switch model\?$/,
|
|
@@ -866,6 +921,29 @@ export const SCREEN_SIGNATURES = {
|
|
|
866
921
|
pattern: /(?:^|\s)[↑↓]$|^[↑↓]\s/u,
|
|
867
922
|
cli: '2.1.312',
|
|
868
923
|
},
|
|
924
|
+
hiddenLinesMarker: {
|
|
925
|
+
what: 'line-count marker under the options of a tall dialog ("↑ 54 more lines"): the dialog is cut at the top by '
|
|
926
|
+
+ 'that many lines; it also matches the list scroll marker, so the live card reads it first',
|
|
927
|
+
// `measured/zgoda-bash-wysoka-2.1.328.txt` (Bash consent with a 90-line command in a 52-row pane)
|
|
928
|
+
pattern: /^ *↑ (\d+) more lines$/u,
|
|
929
|
+
cli: '2.1.328',
|
|
930
|
+
},
|
|
931
|
+
dialogCursorMark: {
|
|
932
|
+
what: 'cursor glyph of a dialog option (`❯ 1. Yes`, `❯ No, exit`): the live card counts it in the whole dialog '
|
|
933
|
+
+ 'region and reads the option under it',
|
|
934
|
+
// `measured/multiselect-2.1.328.txt`, `kontrolny/zaufanie-2.1.319.txt`
|
|
935
|
+
pattern: '❯',
|
|
936
|
+
cli: '2.1.328',
|
|
937
|
+
},
|
|
938
|
+
negativeOption: {
|
|
939
|
+
what: 'option label that declines ("No", "No, exit", "No, disable external imports"): choosing it saves nothing, '
|
|
940
|
+
+ 'so escalation markers in the dialog content do not make it lasting; numbered options that end on it at the '
|
|
941
|
+
+ 'bottom of the screen count as the whole set of a dialog without a key footer',
|
|
942
|
+
// `kontrolny/tryb-bypass-2.1.319.txt`, `kontrolny/importy-zewnetrzne-2.1.332.txt`, without a key footer:
|
|
943
|
+
// `measured/zgoda-webfetch-2.1.322.txt`, `measured/exitplanmode-bez-planu-2.1.328.txt`, `dialog-model-switch.txt`
|
|
944
|
+
pattern: /^no\b/iu,
|
|
945
|
+
cli: '2.1.332',
|
|
946
|
+
},
|
|
869
947
|
optionLabelCut: {
|
|
870
948
|
what: 'wielokropek na końcu etykiety opcji albo jej linii: etykieta ucięta na szerokości kolumny',
|
|
871
949
|
// `measured/picker-model-2.1.312-26kol.txt` („Defau…”: kolumna etykiety ucięta wielokropkiem)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Start dialog: a screen herdr reads as ready (`idle`, `interactive_ready`) while Claude Code has not reached its
|
|
3
|
+
* prompt field, because a dialog stands before it. The predicate says whether such a screen stands and, for the
|
|
4
|
+
* measured external imports dialog, which one. It is pure: what the launcher does with the answer (the wait, the
|
|
5
|
+
* stable screen over time) lives in `herdr/start-dialog-wait.ts`; no key ever comes from here.
|
|
6
|
+
*
|
|
7
|
+
* The external imports dialog is proven from the bottom of the screen: its key footer as the last line and, above
|
|
8
|
+
* it, the closed pair of its two options with exactly one `❯`. A long import list pushes the block's rule, title and
|
|
9
|
+
* first paths above the pane edge, so neither the rule nor the title is required; when the rule is on the screen,
|
|
10
|
+
* the line under it must be the measured title.
|
|
11
|
+
*/
|
|
12
|
+
import { composerRegionState } from '../../../drivers/herdr/commands.js';
|
|
13
|
+
import { blockTopOf } from './region.js';
|
|
14
|
+
import { SCREEN_SIGNATURES } from './signatures.js';
|
|
15
|
+
import { MEANINGFUL_PATTERN, trimmedLines } from './text.js';
|
|
16
|
+
const TITLE = SCREEN_SIGNATURES.startDialogImportsTitle.pattern;
|
|
17
|
+
const NO_OPTION = SCREEN_SIGNATURES.startDialogImportsNoOption.pattern;
|
|
18
|
+
const YES_OPTION = SCREEN_SIGNATURES.startDialogImportsYesOption.pattern;
|
|
19
|
+
const OPTION_LINE = SCREEN_SIGNATURES.startDialogImportsOptionLine.pattern;
|
|
20
|
+
const FOOTER = SCREEN_SIGNATURES.startDialogImportsFooter.pattern;
|
|
21
|
+
const blank = (line) => (line ?? '').trim() === '';
|
|
22
|
+
/** The first non-blank line under the nearest bare block rule above line `end`, trimmed; `null` without a rule. */
|
|
23
|
+
function blockTitle(lines, end) {
|
|
24
|
+
const top = blockTopOf(lines, end, { kinds: ['bare'] });
|
|
25
|
+
if (top === null)
|
|
26
|
+
return null;
|
|
27
|
+
for (let at = top.line + 1; at < end; at += 1) {
|
|
28
|
+
if (!blank(lines[at]))
|
|
29
|
+
return (lines[at] ?? '').trim();
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Index of the "No" line of the external imports option pair, or `null`: the footer is the last line, only blank
|
|
35
|
+
* lines stand between it and the pair, the pair is "No" then "Yes" with the measured margin and exactly one `❯`, and
|
|
36
|
+
* the line above the pair is blank (or above the pane edge), so no third option hides there.
|
|
37
|
+
*/
|
|
38
|
+
function importsPairAt(lines) {
|
|
39
|
+
const footer = lines.length - 1;
|
|
40
|
+
if (footer < 0 || !FOOTER.test((lines[footer] ?? '').trim()))
|
|
41
|
+
return null;
|
|
42
|
+
let at = footer - 1;
|
|
43
|
+
while (at >= 0 && blank(lines[at]))
|
|
44
|
+
at -= 1;
|
|
45
|
+
const yes = OPTION_LINE.exec(lines[at] ?? '');
|
|
46
|
+
const no = OPTION_LINE.exec(lines[at - 1] ?? '');
|
|
47
|
+
if (yes === null || no === null || !blank(lines[at - 2]))
|
|
48
|
+
return null;
|
|
49
|
+
if (!NO_OPTION.test(no[2] ?? '') || !YES_OPTION.test(yes[2] ?? ''))
|
|
50
|
+
return null;
|
|
51
|
+
return (no[1] === undefined) === (yes[1] === undefined) ? null : at - 1;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The start dialog on `screenText`, or `null` when the screen shows no start dialog: the prompt field is visible
|
|
55
|
+
* (Claude Code reached its prompt) or the screen has no text at all (nothing was drawn or read).
|
|
56
|
+
*
|
|
57
|
+
* @param screenText raw pane screen (ANSI allowed)
|
|
58
|
+
*/
|
|
59
|
+
export function startDialogOf(screenText) {
|
|
60
|
+
const lines = trimmedLines(screenText);
|
|
61
|
+
if (!lines.some((line) => MEANINGFUL_PATTERN.test(line)))
|
|
62
|
+
return null;
|
|
63
|
+
if (composerRegionState(screenText) !== 'unknown')
|
|
64
|
+
return null;
|
|
65
|
+
const pair = importsPairAt(lines);
|
|
66
|
+
if (pair !== null) {
|
|
67
|
+
const title = blockTitle(lines, pair);
|
|
68
|
+
if (title === null || TITLE.test(title))
|
|
69
|
+
return { id: 'external-imports', title };
|
|
70
|
+
}
|
|
71
|
+
return { id: null, title: blockTitle(lines, lines.length) };
|
|
72
|
+
}
|
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
* kolumny kursora, etykieta opcji, cyfra), także oddzielonej pustą linią. Każdy inny kształt (trzecia opcja, ucięta
|
|
11
11
|
* góra albo dół, cyfry, zawinięty folder) daje `null`, czyli kartę bez przycisku. Moduł jest czysty: decyzję
|
|
12
12
|
* o klawiszu podejmuje `send/trust-step.ts`.
|
|
13
|
+
*
|
|
14
|
+
* One exception to the option-shaped line rule: the warning about permissions the folder pre-approves (Claude Code
|
|
15
|
+
* 2.1.332). Between its opening line "⚠ This folder pre-approves …:" and its closing sentence "These will apply
|
|
16
|
+
* without asking." a line may carry the three-space margin of the permission list, which is the indent of an option
|
|
17
|
+
* line. The folder's settings write that list, so it still may not hold `❯`, an option label or a numbered option,
|
|
18
|
+
* and a warning without its closing sentence gives `null`.
|
|
13
19
|
*/
|
|
14
20
|
import { createHash } from 'node:crypto';
|
|
15
21
|
import path from 'node:path';
|
|
@@ -24,6 +30,9 @@ const CURSOR_MARK = SCREEN_SIGNATURES.trustArrowCursorMark.pattern;
|
|
|
24
30
|
const CONTENT_LINE = SCREEN_SIGNATURES.trustArrowContentLine.pattern;
|
|
25
31
|
const DIGIT_OPTION = SCREEN_SIGNATURES.optionLine.pattern;
|
|
26
32
|
const FOOTER = SCREEN_SIGNATURES.trustArrowFooter.pattern;
|
|
33
|
+
const WARNING_OPEN = SCREEN_SIGNATURES.trustArrowWarningOpen.pattern;
|
|
34
|
+
const WARNING_CLOSE = SCREEN_SIGNATURES.trustArrowWarningClose.pattern;
|
|
35
|
+
const WARNING_LIST_LINE = SCREEN_SIGNATURES.trustArrowWarningListLine.pattern;
|
|
27
36
|
const blank = (line) => (line ?? '').trim() === '';
|
|
28
37
|
/** Opcja z dokładnym wcięciem z pomiaru albo `null`: linia bez kolumny kursora opcją nie jest. */
|
|
29
38
|
function optionOf(line) {
|
|
@@ -37,12 +46,42 @@ function optionOf(line) {
|
|
|
37
46
|
* bez `❯` i bez etykiety opcji (z cyfrą albo bez).
|
|
38
47
|
*/
|
|
39
48
|
function plainLine(line) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
49
|
+
return blank(line) || textOf(line, CONTENT_LINE) !== null;
|
|
50
|
+
}
|
|
51
|
+
/** Text of a block line with the given margin, or `null`: no such margin, `❯`, an option label or a numbered option. */
|
|
52
|
+
function textOf(line, margin) {
|
|
53
|
+
const text = margin.exec(line)?.[1];
|
|
43
54
|
if (text === undefined || CURSOR_MARK.test(line))
|
|
44
|
-
return
|
|
45
|
-
return
|
|
55
|
+
return null;
|
|
56
|
+
return NO_OPTION.test(text) || YES_OPTION.test(text) || DIGIT_OPTION.test(text) ? null : text;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Whether the block lines outside the option pair hold no further list position. A line is blank or block text with
|
|
60
|
+
* the one-space margin. Inside the pre-approved permissions warning a line is never blank and may carry the
|
|
61
|
+
* three-space margin of the permission list instead; the warning must close before the option pair.
|
|
62
|
+
*/
|
|
63
|
+
function onlyPlainLines(lines, from, to, first, last) {
|
|
64
|
+
let inWarning = false;
|
|
65
|
+
for (let index = from; index < to; index += 1) {
|
|
66
|
+
const line = lines[index] ?? '';
|
|
67
|
+
if (index === first || index === last) {
|
|
68
|
+
if (inWarning)
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
else if (inWarning) {
|
|
72
|
+
const text = textOf(line, CONTENT_LINE);
|
|
73
|
+
if (text === null && textOf(line, WARNING_LIST_LINE) === null)
|
|
74
|
+
return false;
|
|
75
|
+
if (text !== null && WARNING_CLOSE.test(text))
|
|
76
|
+
inWarning = false;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
if (!plainLine(line))
|
|
80
|
+
return false;
|
|
81
|
+
inWarning = WARNING_OPEN.test(textOf(line, CONTENT_LINE) ?? '');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return !inWarning;
|
|
46
85
|
}
|
|
47
86
|
/**
|
|
48
87
|
* Dialog zaufania bez cyfr albo `null`, gdy ekran nie pokazuje go w całości.
|
|
@@ -78,10 +117,8 @@ export function parseTrustArrowDialog(screenText) {
|
|
|
78
117
|
if (block.ambiguous || block.top === -1 || block.title?.kind !== 'known' || block.title.id !== 'trust')
|
|
79
118
|
return null;
|
|
80
119
|
// Od kreski do stopki jedyną listą jest para opcji: pusta linia nie chowa dodatkowej pozycji.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
120
|
+
if (!onlyPlainLines(lines, block.top + 1, footer, first, last))
|
|
121
|
+
return null;
|
|
85
122
|
const content = lines.slice(block.top + 1, first).map(unbox).join(' ');
|
|
86
123
|
if (!SCREEN_SIGNATURES.knownDialogTrust.pattern.test(content))
|
|
87
124
|
return null;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine registry of herdr agents: the only place that knows the agent kinds herdr reports (`agent` of an
|
|
3
|
+
* `agent.list` record), which of them Rarog admits, which are state-only and how their pane title becomes a card
|
|
4
|
+
* title, and which sentence refuses each action on a state-only card. It does not read the socket and keeps no state;
|
|
5
|
+
* the input filter in `client.ts` and every gate on an entry, card or session ask it instead of comparing kind
|
|
6
|
+
* literals themselves.
|
|
7
|
+
*/
|
|
8
|
+
import { basename } from 'node:path';
|
|
9
|
+
import { say } from '@rarog/shared/sentences';
|
|
10
|
+
/**
|
|
11
|
+
* Whether an engine is state-only. The rule is "not Claude", so a new engine gets the state-only gates without
|
|
12
|
+
* touching them. `undefined` is Claude: a session or summary without an `engine` field.
|
|
13
|
+
*/
|
|
14
|
+
export function isStateOnlyEngine(engine) {
|
|
15
|
+
return engine !== undefined && engine !== 'claude';
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Refusal sentences per state-only engine: the one place that picks a sentence by engine. The gates that throw them
|
|
19
|
+
* are the server's boundary, not the client's copy: an old client or `curl` may still ask for these actions, and a
|
|
20
|
+
* state-only entry must give state alone.
|
|
21
|
+
*/
|
|
22
|
+
export const STATE_ONLY_REFUSALS = {
|
|
23
|
+
codex: {
|
|
24
|
+
close: say('session.codex-close'), git: say('session.codex-git'), restart: say('restart.codex'),
|
|
25
|
+
files: say('rest.files-codex'),
|
|
26
|
+
},
|
|
27
|
+
agy: {
|
|
28
|
+
close: say('session.agy-close'), git: say('session.agy-git'), restart: say('restart.agy'),
|
|
29
|
+
files: say('rest.files-agy'),
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The engine of a raw herdr agent kind, or `null` when the pane does not exist for Rarog.
|
|
34
|
+
*
|
|
35
|
+
* Bramka silnika. `codex` i `agy` wchodzą WYŁĄCZNIE przy jawnej fladze, każdy przy swojej; każdy inny agent
|
|
36
|
+
* (`future-agent`, `aider`, …) odpada tak jak dotąd — Rarog nie zna ani jego stopki, ani
|
|
37
|
+
* jego pliku treści, więc wiersz w sidebarze byłby obietnicą bez pokrycia.
|
|
38
|
+
*/
|
|
39
|
+
export function engineOfAgent(agent, flags) {
|
|
40
|
+
if (agent === 'claude')
|
|
41
|
+
return 'claude';
|
|
42
|
+
if (agent === 'codex' && flags.codexStatus)
|
|
43
|
+
return 'codex';
|
|
44
|
+
if (agent === 'agy' && flags.agyStatus)
|
|
45
|
+
return 'agy';
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
/** Klatka spinnera Codexa: znak brajlowski (U+2800–U+28FF) z odstępem za nim. */
|
|
49
|
+
const CODEX_SPINNER_RE = /^[⠀-⣿]+\s*/u;
|
|
50
|
+
/**
|
|
51
|
+
* Prefix of a Codex title while an approval waits. Codex CLI 0.171.0 alternates the mark between `!` and `.` about
|
|
52
|
+
* once a second at the same state number, so a kept prefix would change the card title every second.
|
|
53
|
+
*/
|
|
54
|
+
const CODEX_ACTION_REQUIRED_RE = /^\[ [!.] \] Action Required \| /u;
|
|
55
|
+
/**
|
|
56
|
+
* Tytuł Codexa → tytuł dla karty. JEDNO miejsce, w którym znika spinner i katalog.
|
|
57
|
+
*
|
|
58
|
+
* Zmierzone na żywym herdr 0.9.0: `terminal_title_stripped` Codexa ma kształt
|
|
59
|
+
* `<pierwszy prompt> | <katalog>`, w trakcie pracy z wiodącą klatką spinnera braille (`⠴ …`),
|
|
60
|
+
* a przed pierwszym promptem jest SAMĄ nazwą katalogu.
|
|
61
|
+
*
|
|
62
|
+
* Normalizacja musi być tutaj, a nie w warstwie widoku, z dwóch powodów: nadzorca porównuje
|
|
63
|
+
* tytuły między migawkami, więc kolejne klatki spinnera zgłaszałyby `titleChanged` kilka razy
|
|
64
|
+
* na sekundę, a manager ma dostać w zdarzeniu tekst, który da się pokazać bez dalszej obróbki.
|
|
65
|
+
* Sufiks katalogu zdejmujemy, bo nazwę projektu wiersz w kliencie i tak bierze z `cwd` — zostawiony
|
|
66
|
+
* dublowałby ją w każdym wierszu.
|
|
67
|
+
*/
|
|
68
|
+
export function normalizeCodexTitle(raw, cwd) {
|
|
69
|
+
const dir = basename(cwd);
|
|
70
|
+
let title = raw.replace(CODEX_SPINNER_RE, '').replace(CODEX_ACTION_REQUIRED_RE, '').trim();
|
|
71
|
+
if (dir !== '' && title.endsWith(` | ${dir}`)) {
|
|
72
|
+
title = title.slice(0, title.length - dir.length - 3).trim();
|
|
73
|
+
}
|
|
74
|
+
// Tytuł równy samej nazwie katalogu = panel PRZED pierwszym promptem. Pusty string znaczy
|
|
75
|
+
// „nie ma tytułu", a manager zamienia go na nazwę katalogu tą samą regułą co dla Claude.
|
|
76
|
+
return title === dir ? '' : title;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The `agy` command line as a pane title: `agy` alone or followed by its arguments. herdr 0.9.5 reports the command
|
|
80
|
+
* line as the title of an Antigravity CLI 1.5.18 pane for the whole life of the agent, also after a prompt.
|
|
81
|
+
*/
|
|
82
|
+
const AGY_COMMAND_LINE_RE = /^agy(?:\s|$)/u;
|
|
83
|
+
/** agy title → card title: the command line is no title (the card is named after its directory), any other passes. */
|
|
84
|
+
function normalizeAgyTitle(raw) {
|
|
85
|
+
return AGY_COMMAND_LINE_RE.test(raw.trim()) ? '' : raw;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Pane title of a state-only engine → card title. An empty string means "no title": the manager then names the
|
|
89
|
+
* card after its directory, as for Claude.
|
|
90
|
+
*/
|
|
91
|
+
export function normalizeEngineTitle(engine, title, cwd) {
|
|
92
|
+
switch (engine) {
|
|
93
|
+
case 'codex': return normalizeCodexTitle(title, cwd);
|
|
94
|
+
case 'agy': return normalizeAgyTitle(title);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -84,6 +84,7 @@ export async function readHistoryTail(read, path, size, opts) {
|
|
|
84
84
|
const parsed = parseTranscriptTail(complete, {
|
|
85
85
|
dropFirstLine: false, limit: opts.limit, ...(opts.promptBlock ? {} : { promptBlock: false }),
|
|
86
86
|
...(opts.turnMarks === true ? { turnMarks: true } : {}),
|
|
87
|
+
...(opts.crossSessionPrompts === true ? { crossSessionPrompts: true } : {}),
|
|
87
88
|
});
|
|
88
89
|
tail = {
|
|
89
90
|
complete,
|
|
@@ -142,7 +143,9 @@ export function historyMessages(entries, port) {
|
|
|
142
143
|
}
|
|
143
144
|
const follow = port.follow(m);
|
|
144
145
|
const command = m.command !== undefined;
|
|
145
|
-
|
|
146
|
+
// A message from another session is no echo of a send from Rarog, even with the same text.
|
|
147
|
+
const echoable = m.notice === undefined && m.peer !== true
|
|
148
|
+
&& (command ? m.command?.part === 'invocation' : m.role === 'user');
|
|
146
149
|
const echo = echoable ? port.takeEcho(m, command) : null;
|
|
147
150
|
if (echo === null)
|
|
148
151
|
messages.push(follow);
|
|
@@ -152,16 +155,18 @@ export function historyMessages(entries, port) {
|
|
|
152
155
|
return messages;
|
|
153
156
|
}
|
|
154
157
|
/**
|
|
155
|
-
* Znacznik wyniku komendy jest dla drivera: manager dostaje wiadomości bez niego.
|
|
158
|
+
* Znacznik wyniku komendy jest dla drivera: manager dostaje wiadomości bez niego. The mark of a message from another
|
|
159
|
+
* session serves the driver (`ReturnedPrompt.noteHistory`) and reaches the manager as `notFromOwner`, server-only
|
|
160
|
+
* knowledge for the owner's turn.
|
|
156
161
|
*
|
|
157
162
|
* @returns the messages for the manager and the name of the last command output in the batch, if any.
|
|
158
163
|
*/
|
|
159
164
|
export function withoutCommandOutput(messages) {
|
|
160
165
|
let output;
|
|
161
|
-
const stripped = messages.map(({ commandOutput, ...message }) => {
|
|
166
|
+
const stripped = messages.map(({ commandOutput, peer, ...message }) => {
|
|
162
167
|
if (commandOutput !== undefined)
|
|
163
168
|
output = commandOutput;
|
|
164
|
-
return message;
|
|
169
|
+
return peer === true ? { ...message, notFromOwner: true } : message;
|
|
165
170
|
});
|
|
166
171
|
return { messages: stripped, output };
|
|
167
172
|
}
|
|
@@ -132,7 +132,8 @@ function loadState(file) {
|
|
|
132
132
|
const entry = raw;
|
|
133
133
|
if (typeof entry.key !== 'string' || entry.key === '')
|
|
134
134
|
continue;
|
|
135
|
-
|
|
135
|
+
// `''` is the address of a state-only card without a session ID: the pane alone (`key`).
|
|
136
|
+
if (typeof entry.agentSessionId !== 'string')
|
|
136
137
|
continue;
|
|
137
138
|
// Numer stanu MUSI być skończoną liczbą: `NaN` w porównaniu jest zawsze fałszem, więc
|
|
138
139
|
// wpis-śmieć znaczyłby „widziane" albo „niewidziane" zależnie od strony nierówności.
|
|
@@ -151,6 +152,15 @@ function loadState(file) {
|
|
|
151
152
|
}
|
|
152
153
|
return { aliases, seen };
|
|
153
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Whether an entry's engine session answers a read at this session. `''` addresses a state-only card without a
|
|
157
|
+
* session ID by its pane and matches either way: a session ID that herdr starts or stops reporting for the same pane
|
|
158
|
+
* keeps the mark, while two different session IDs never match. The callers compare the state number for equality,
|
|
159
|
+
* and only a state-only card writes or reads `''`.
|
|
160
|
+
*/
|
|
161
|
+
function sameSession(stored, asked) {
|
|
162
|
+
return stored === asked || stored === '' || asked === '';
|
|
163
|
+
}
|
|
154
164
|
/**
|
|
155
165
|
* Aliasy sesji i znaczniki `seen`, trzymane w RAM i utrwalane ATOMOWO (tmp + rename).
|
|
156
166
|
*
|
|
@@ -212,7 +222,7 @@ export function createHiddenStore(opts) {
|
|
|
212
222
|
return {
|
|
213
223
|
seenSeq(key, agentSessionId) {
|
|
214
224
|
const entry = seen.get(key);
|
|
215
|
-
if (entry === undefined || entry.agentSessionId
|
|
225
|
+
if (entry === undefined || !sameSession(entry.agentSessionId, agentSessionId))
|
|
216
226
|
return undefined;
|
|
217
227
|
return entry.unseen === true ? undefined : entry.stateChangeSeq;
|
|
218
228
|
},
|
|
@@ -220,7 +230,11 @@ export function createHiddenStore(opts) {
|
|
|
220
230
|
const current = seen.get(key);
|
|
221
231
|
if (current?.agentSessionId === agentSessionId
|
|
222
232
|
&& current.unseen !== true
|
|
223
|
-
|
|
233
|
+
// A pane address (`''`) gets its key back after a herdr server restart with the state number counted from
|
|
234
|
+
// zero, so a receipt at a lower number there is a new one and replaces the entry.
|
|
235
|
+
&& (agentSessionId === ''
|
|
236
|
+
? current.stateChangeSeq === stateChangeSeq
|
|
237
|
+
: current.stateChangeSeq >= stateChangeSeq)) {
|
|
224
238
|
// Znacznik już obejmuje ten stan — zapis niczego by nie zmienił, a przy 17 panelach
|
|
225
239
|
// odświeżanych co 30 s byłby stałym ruchem na dysku.
|
|
226
240
|
if (current.by === by)
|
|
@@ -236,13 +250,14 @@ export function createHiddenStore(opts) {
|
|
|
236
250
|
},
|
|
237
251
|
seenBy(key, agentSessionId) {
|
|
238
252
|
const entry = seen.get(key);
|
|
239
|
-
if (entry === undefined || entry.agentSessionId
|
|
253
|
+
if (entry === undefined || !sameSession(entry.agentSessionId, agentSessionId) || entry.unseen === true) {
|
|
240
254
|
return undefined;
|
|
255
|
+
}
|
|
241
256
|
return entry.by;
|
|
242
257
|
},
|
|
243
258
|
unseenSeq(key, agentSessionId) {
|
|
244
259
|
const entry = seen.get(key);
|
|
245
|
-
if (entry === undefined || entry.agentSessionId
|
|
260
|
+
if (entry === undefined || !sameSession(entry.agentSessionId, agentSessionId))
|
|
246
261
|
return undefined;
|
|
247
262
|
return entry.unseen === true ? entry.stateChangeSeq : undefined;
|
|
248
263
|
},
|
|
@@ -45,7 +45,7 @@ import { ENGINE_SESSION_ID_PATTERN, IMAGE_PLACEHOLDER, isHiddenTurnInput, parseI
|
|
|
45
45
|
import { FileEchoPairing } from './commands/index.js';
|
|
46
46
|
import { historyMessages, readHistoryTail, readRange, sizeOf } from './history-steps.js';
|
|
47
47
|
import { compactPostTokensFrom, compactPreTokensFrom, createUsageTracker, isMainCompactBoundary, usageFrom, } from './jsonl-usage.js';
|
|
48
|
-
import { artifactsSignature, createArtifactsTracker, createBackgroundTasksTracker, scanMainFileBefore, } from './background/index.js';
|
|
48
|
+
import { artifactsSignature, createArtifactsTracker, createBackgroundTasksTracker, isPullRequestLinkEntry, scanMainFileBefore, } from './background/index.js';
|
|
49
49
|
import { emptyCarry, takeLines } from './background/jsonl-lines.js';
|
|
50
50
|
import { toolActivity, toolEndActivity, toolInputsByName } from './jsonl-activity.js';
|
|
51
51
|
import { MAIN_SCAN_MAX_BYTES } from './background/main-scan.js';
|
|
@@ -92,6 +92,8 @@ export const ARTIFACTS_RESCAN_LOG = 'artifact scan after a file truncation or sk
|
|
|
92
92
|
export const ARTIFACTS_RESCAN_SKIPPED_LOG = 'artifacts before the file truncation or skip are not visible';
|
|
93
93
|
/** Okno batchowania emisji — 100 ms wystarczy telefonowi, a ratuje SSE przy 17 panelach. */
|
|
94
94
|
export const FOLLOW_BATCH_MS = 100;
|
|
95
|
+
/** Events without content: they do not take the last place of a batch from the activity indicator. */
|
|
96
|
+
const CONTENTLESS = new Set(['turn-input', 'echo-dropped', 'pull-request-entry']);
|
|
95
97
|
/** Siatka bezpieczeństwa: `fs.watch` gubi zdarzenia na części systemów plików. */
|
|
96
98
|
export const FOLLOW_STAT_TICK_MS = 2_000;
|
|
97
99
|
/** Plik jeszcze nie istnieje: gęsty poll przez pierwszą minutę… */
|
|
@@ -365,6 +367,8 @@ class Follower {
|
|
|
365
367
|
#tasksScan;
|
|
366
368
|
/** Rozpoznanie promptu zablokowanego przez hook (`JsonlFollowOptions.promptBlock`). */
|
|
367
369
|
#promptBlock;
|
|
370
|
+
#crossSessionPromptsOf;
|
|
371
|
+
#onEntry;
|
|
368
372
|
/** Identyfikator sesji silnika; `null` = nie przeszedł wzorca, transkryptu nie będzie. */
|
|
369
373
|
#agentSessionId = null;
|
|
370
374
|
/** Rośnie przy każdym otwarciu sesji silnika; unieważnia odczyty w locie (patrz `#openSession`). */
|
|
@@ -578,6 +582,8 @@ class Follower {
|
|
|
578
582
|
this.#tasksScan = { ...opts.tasksScan, logBytes: opts.tasksScan?.logBytes ?? TASKS_SCAN_LOG_BYTES };
|
|
579
583
|
this.#usage = createUsageTracker(this.#knownContextLimit);
|
|
580
584
|
this.#promptBlock = opts.promptBlock !== false;
|
|
585
|
+
this.#crossSessionPromptsOf = opts.crossSessionPrompts ?? (() => false);
|
|
586
|
+
this.#onEntry = opts.onEntry;
|
|
581
587
|
// Unknown until a history read replaces the tracker; a read that fails before that must not answer "empty".
|
|
582
588
|
this.#cliQueue.lose();
|
|
583
589
|
this.#openSession(opts.agentSessionId);
|
|
@@ -1075,6 +1081,7 @@ class Follower {
|
|
|
1075
1081
|
return readHistoryTail((p, start, length) => this.#io.readRange(p, start, length), path, size, {
|
|
1076
1082
|
firstWindow: this.#historyBytes, maxBytes: this.#historyMaxBytes, limit: this.#historyMessages,
|
|
1077
1083
|
promptBlock: this.#promptBlock, stale: () => this.#stale(gen),
|
|
1084
|
+
...(this.#crossSessionPrompts() ? { crossSessionPrompts: true } : {}),
|
|
1078
1085
|
});
|
|
1079
1086
|
}
|
|
1080
1087
|
/**
|
|
@@ -1674,17 +1681,25 @@ class Follower {
|
|
|
1674
1681
|
for (const line of combined.slice(0, cut).split('\n'))
|
|
1675
1682
|
this.#handleLine(line);
|
|
1676
1683
|
}
|
|
1684
|
+
#crossSessionPrompts() {
|
|
1685
|
+
return this.#agentSessionId !== null && this.#crossSessionPromptsOf(this.#agentSessionId);
|
|
1686
|
+
}
|
|
1677
1687
|
#handleLine(line) {
|
|
1678
1688
|
// Dwa niezależne przebiegi po tej samej linii: `#noteRaw` bierze to, czego parser treści
|
|
1679
1689
|
// nie zwraca (surowy `input`, `id`, `usage`, tryb), a `parseImportLine` — treść.
|
|
1680
1690
|
const raw = parseJsonlEntry(line);
|
|
1691
|
+
if (raw !== null && this.#agentSessionId !== null)
|
|
1692
|
+
this.#onEntry?.(this.#agentSessionId, raw);
|
|
1681
1693
|
const openBefore = this.#pending.open;
|
|
1682
1694
|
this.#noteRaw(raw);
|
|
1683
1695
|
// The end of the call on the row (live tail only): the row moves to a call still open, or to `thinking`.
|
|
1684
1696
|
const ended = toolEndActivity(raw, openBefore, this.#pending.open);
|
|
1685
1697
|
if (ended !== null)
|
|
1686
1698
|
this.#push({ type: 'activity', ...ended });
|
|
1687
|
-
const entry = parseImportLine(line,
|
|
1699
|
+
const entry = parseImportLine(line, {
|
|
1700
|
+
...(this.#promptBlock ? {} : { promptBlock: false }),
|
|
1701
|
+
...(this.#crossSessionPrompts() ? { crossSessionPrompts: true } : {}),
|
|
1702
|
+
});
|
|
1688
1703
|
// The call entry that repeats the plain "/compact" entry before it gives nothing, as in the history.
|
|
1689
1704
|
if (entry !== null && this.#fileEcho.repeats(entry.fileEcho, entry.message !== null))
|
|
1690
1705
|
return;
|
|
@@ -1697,6 +1712,8 @@ class Follower {
|
|
|
1697
1712
|
this.#push({ type: 'turn-input' });
|
|
1698
1713
|
else if (isMainCompactBoundary(raw))
|
|
1699
1714
|
this.#push({ type: 'turn-input', kind: 'compaction' });
|
|
1715
|
+
else if (isPullRequestLinkEntry(raw))
|
|
1716
|
+
this.#push({ type: 'pull-request-entry' });
|
|
1700
1717
|
return;
|
|
1701
1718
|
}
|
|
1702
1719
|
const message = entry.message;
|
|
@@ -1720,6 +1737,11 @@ class Follower {
|
|
|
1720
1737
|
this.#push({ type: 'message', role: 'user', blocks: message.blocks, notice: message.notice });
|
|
1721
1738
|
return;
|
|
1722
1739
|
}
|
|
1740
|
+
// A message from another session is not a send from Rarog either, even with the same text.
|
|
1741
|
+
if (message.peer === true) {
|
|
1742
|
+
this.#push({ type: 'message', role: 'user', blocks: message.blocks, peer: true });
|
|
1743
|
+
return;
|
|
1744
|
+
}
|
|
1723
1745
|
// Echo własnego promptu gasimy TU, a nie w managerze (patrz nagłówek pliku). Wiadomości
|
|
1724
1746
|
// z niego nie ma, ale fakt zostaje: CLI właśnie wzięło ten prompt do tury (kolejka zmierzona
|
|
1725
1747
|
// na 2.1.299). Manager liczy go też przy wysyłce, tyle że prompt wysłany w trakcie tury trafia tu
|
|
@@ -1768,6 +1790,7 @@ class Follower {
|
|
|
1768
1790
|
* Wywołanie komendy zapamiętuje swoją nazwę, a wynik dostaje `commandOutput` z nazwą z wpisu albo
|
|
1769
1791
|
* z ostatniego wywołania — driver kończy po nim komendę lokalną wysłaną z Raroga. Wołane dla
|
|
1770
1792
|
* KAŻDEJ wiadomości w kolejności pliku (historia i tail), także dla wywołania zgaszonego echem.
|
|
1793
|
+
* The mark of a message from another session goes on to the driver (`FollowMessage.peer`).
|
|
1771
1794
|
*/
|
|
1772
1795
|
#followMessage(message) {
|
|
1773
1796
|
const { command, ...rest } = message;
|
|
@@ -2321,7 +2344,7 @@ class Follower {
|
|
|
2321
2344
|
let last = events.length - 1;
|
|
2322
2345
|
// Zdarzenia bez treści (wejście tury, wypadnięty wpis echa) nie odbierają wskaźnikowi aktywności
|
|
2323
2346
|
// miejsca ostatniego w partii.
|
|
2324
|
-
while (last >= 0 && (events[last]?.type
|
|
2347
|
+
while (last >= 0 && CONTENTLESS.has(events[last]?.type ?? ''))
|
|
2325
2348
|
last -= 1;
|
|
2326
2349
|
for (let i = 0; i < events.length; i += 1) {
|
|
2327
2350
|
const event = events[i];
|