@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
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Start a thread
|
|
2
|
+
|
|
3
|
+
One owner request is one thread. You never do the request's work yourself.
|
|
4
|
+
|
|
5
|
+
1. `command -v rarog-coordinator` (rule 1).
|
|
6
|
+
2. Name. Choose a short English name for the request: ASCII letters, digits, hyphens and single spaces, at most
|
|
7
|
+
24 characters and 4 words, for example `Fix checkout`. No `;`, `$(`, quotes or other symbols: the tool refuses
|
|
8
|
+
them. The thread's session is called `[A] <name>`; the owner types `Merge: <name>`.
|
|
9
|
+
3. Free name. Call ListAgents. If any session, in any project, is called `[A] <name>`, choose another name.
|
|
10
|
+
4. Run (Bash, `dangerouslyDisableSandbox: true`, `timeout: 600000`):
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
rarog-coordinator start --name "<name>" --goal "<the owner's request in one sentence, in the owner's words>"
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
It makes the worktree `<main>/.claude/worktrees/<slug>` on a new branch `<slug>` from local `main`, runs `init`,
|
|
17
|
+
writes the thread file, opens a herdr tab in the main checkout with
|
|
18
|
+
`claude --worktree <slug> --session-id <id> --name "[A] <name>"` in your permission mode and model, and checks
|
|
19
|
+
that the thread runs inside its worktree. Run one `start` at a time, never two in parallel tool calls: `start`
|
|
20
|
+
holds the metadata lock for its whole run.
|
|
21
|
+
- `refused start: metadata lock … is held`: another `start` or `claim` runs; run this `start` again after it
|
|
22
|
+
ends. `… is STALE` or `… in an unknown state`: show the line to the owner; never remove the lock yourself.
|
|
23
|
+
- `refused start: branch <slug> moved while start read it …`: someone committed on that branch; choose another
|
|
24
|
+
name.
|
|
25
|
+
- Another `refused start:` or `failed start:`: tell the owner the reason in one sentence and send no brief.
|
|
26
|
+
Running `start` again with the same name finishes a half-made start.
|
|
27
|
+
5. Brief. Only after `ok start:`, SendMessage to `"[A] <name>"` with `notify_when_idle: true` and this text, filled
|
|
28
|
+
in (the goal in the owner's words, the rest as written):
|
|
29
|
+
|
|
30
|
+
```text
|
|
31
|
+
You are the thread "[A] <name>" of the coordinator "[C] <Project>".
|
|
32
|
+
Goal (the owner's words): <goal>
|
|
33
|
+
You work only in your worktree <worktree> on branch <slug>; Claude Code started you there.
|
|
34
|
+
Commit your work on that branch. When the goal is done and committed, SendMessage to "[C] <Project>":
|
|
35
|
+
"done: <commit> <one line>". If you cannot go on, send "blocked: <reason>".
|
|
36
|
+
You write only to "[C] <Project>". ListAgents shows sessions of other projects too: never write to them.
|
|
37
|
+
Do not merge into main and do not push. Rebase onto main only when the coordinator asks you to.
|
|
38
|
+
The coordinator checks your branch and merges it after the owner's Merge.
|
|
39
|
+
Ask the owner only through your question dialog (AskUserQuestion); the coordinator does not answer for the owner.
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
6. `rarog-coordinator note "<name>" --next "waiting for done"`.
|
|
43
|
+
7. Tell the owner one line: thread `[A] <name>` started, and what it does.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server start: the coordination fields of the session summaries (`coordination/summary.ts`). It opens the
|
|
3
|
+
* coordinator registry from the data directory once, builds the overlay the manager gets in its configuration, and
|
|
4
|
+
* feeds it the manager's event stream. The demo gets none: its seeds carry fixed fields and it reads no disk.
|
|
5
|
+
*/
|
|
6
|
+
import { homedir } from 'node:os';
|
|
7
|
+
import { openCoordinatorRegistry } from '../coordination/registry.js';
|
|
8
|
+
import { SessionCoordination } from '../coordination/summary.js';
|
|
9
|
+
import { gitReadEnv, spawnGitArgs } from '../git-status.js';
|
|
10
|
+
import { createJsonlFollower } from '../herdr/jsonl-follow.js';
|
|
11
|
+
/** The overlay of this start, or `null` in the demo. */
|
|
12
|
+
export function createCoordination(config, deps) {
|
|
13
|
+
if (config.demo)
|
|
14
|
+
return null;
|
|
15
|
+
return new SessionCoordination({
|
|
16
|
+
registry: deps.options?.registry ?? openCoordinatorRegistry({ dataDir: config.dataDir, log: deps.log }),
|
|
17
|
+
roots: config.herdrRoots,
|
|
18
|
+
home: deps.home ?? homedir(),
|
|
19
|
+
run: deps.options?.run ?? spawnGitArgs(gitReadEnv(config.gitEnvBase)),
|
|
20
|
+
...(deps.options?.pluginOf === undefined ? {} : { pluginOf: deps.options.pluginOf }),
|
|
21
|
+
...(deps.options?.watcher === undefined ? {} : { watcher: deps.options.watcher }),
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* State and git events of the sessions move roles and merge states, which `state` frames do not carry; so does a new
|
|
26
|
+
* conversation in a pane, which changes no other field.
|
|
27
|
+
*/
|
|
28
|
+
export function wireCoordination(coordination, manager) {
|
|
29
|
+
// A `state` frame goes to the global and the session stream, a `git-status` frame to the session stream: one each.
|
|
30
|
+
manager.onEvent((scope, _seq, event) => {
|
|
31
|
+
if (scope === 'global' ? event.type === 'state' : event.type === 'git-status')
|
|
32
|
+
coordination.noteEvent(event);
|
|
33
|
+
});
|
|
34
|
+
manager.onConversationChange((sessionId) => { coordination.conversationChanged(sessionId); });
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The transcript follower of every herdr pane: a message from another session is a prompt bubble only while the
|
|
38
|
+
* conversation is a coordinator's thread or a coordinator (`SessionCoordination.crossSessionPrompts`), asked at every
|
|
39
|
+
* line, and every entry of the live tail goes to the overlay for the Merge events. `base`: tests only (store root, no
|
|
40
|
+
* `fs.watch`).
|
|
41
|
+
*/
|
|
42
|
+
export function coordinationFollower(coordination, base = {}) {
|
|
43
|
+
return (opts) => createJsonlFollower({
|
|
44
|
+
...base, ...opts,
|
|
45
|
+
crossSessionPrompts: (conversation) => coordination.crossSessionPrompts(conversation),
|
|
46
|
+
// A live coordinator's Merge prompts and turn ends (`SessionCoordination.transcriptEntry`).
|
|
47
|
+
onEntry: (conversation, entry) => { coordination.transcriptEntry(conversation, entry); },
|
|
48
|
+
});
|
|
49
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { openCoordinatorRegistry } from '../coordination/registry.js';
|
|
2
|
+
import { ensurePluginCopy } from '../herdr/plugin-copy.js';
|
|
3
|
+
import { CoordinatorStart } from '../sessions/coordinator-start.js';
|
|
4
|
+
/** The registry of this start, or `null` in the demo. */
|
|
5
|
+
export function openCoordinators(config, log) {
|
|
6
|
+
return config.demo ? null : openCoordinatorRegistry({ dataDir: config.dataDir, log });
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Whether a session's process runs with the coordinator plugin: a fact the server produced when it started the
|
|
10
|
+
* process (`ManagerApi.pluginDirOf`), never a client's word. The manager exists after the overlay, so it is read late;
|
|
11
|
+
* before it exists no session has the plugin.
|
|
12
|
+
*/
|
|
13
|
+
export function pluginFact(manager) {
|
|
14
|
+
return (sessionId) => manager()?.pluginDirOf(sessionId) != null;
|
|
15
|
+
}
|
|
16
|
+
/** The decision the manager gets in its configuration: plugin copies in the data directory, roles in the registry. */
|
|
17
|
+
export function createCoordinatorStart(config, deps) {
|
|
18
|
+
return new CoordinatorStart({
|
|
19
|
+
registry: deps.registry,
|
|
20
|
+
pluginCopy: (inUse) => ensurePluginCopy({
|
|
21
|
+
dataDir: config.dataDir, inUse, ...(deps.installRoot === undefined ? {} : { installRoot: deps.installRoot }),
|
|
22
|
+
}),
|
|
23
|
+
// A confirmed role reaches the summaries the same way as a new conversation in a pane.
|
|
24
|
+
roleChanged: (sessionId) => { deps.coordination.conversationChanged(sessionId); },
|
|
25
|
+
log: deps.log,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -24,6 +24,7 @@ export function startInbox(deps) {
|
|
|
24
24
|
log: deps.log,
|
|
25
25
|
...(deps.debounceMs === undefined ? {} : { debounceMs: deps.debounceMs }),
|
|
26
26
|
...(deps.timing === undefined ? {} : { timing: deps.timing }),
|
|
27
|
+
...(deps.checkedOf === undefined ? {} : { checkedOf: deps.checkedOf }),
|
|
27
28
|
}, manager);
|
|
28
29
|
manager.onEvent((scope, _seq, event) => { inbox.noteEvent(scope, event); });
|
|
29
30
|
manager.onConversationChange((sessionId) => { inbox.noteConversation(sessionId); });
|
|
@@ -41,11 +42,14 @@ export async function assembleInbox(deps) {
|
|
|
41
42
|
return null;
|
|
42
43
|
const demo = config.demo ? await import('../demo/inbox.js') : null;
|
|
43
44
|
const port = demo === null ? manager : demo.demoInboxManager(manager);
|
|
45
|
+
// The demo has no coordination overlay; its ready thread's checked commit comes from the seed.
|
|
46
|
+
const checkedOf = deps.checkedOf ?? demo?.demoCheckedOf(port);
|
|
44
47
|
const inbox = startInbox({
|
|
45
48
|
manager: port, ready: deps.ready, dataDir: config.dataDir, promptBlock: config.promptBlock, log: deps.log,
|
|
46
49
|
...(demo === null ? {} : { readSegments: demo.createDemoSegmentReader(port) }),
|
|
47
50
|
...(deps.locate === undefined ? {} : { locate: deps.locate }),
|
|
48
51
|
...(deps.debounceMs === undefined ? {} : { debounceMs: deps.debounceMs }),
|
|
52
|
+
...(checkedOf === undefined ? {} : { checkedOf }),
|
|
49
53
|
});
|
|
50
54
|
const heads = new InboxHeads(inbox);
|
|
51
55
|
if (demo !== null)
|
|
@@ -2,21 +2,25 @@ import { createFixedPrStateSource, createGhSource, createPrStatusTracker } from
|
|
|
2
2
|
/** Tracker and port over a source; the change callback goes to the listener the manager registers. */
|
|
3
3
|
export function createPrStatusLink(opts) {
|
|
4
4
|
let listener = null;
|
|
5
|
-
const tracker = createPrStatusTracker({ ...opts, onChange: (
|
|
5
|
+
const tracker = createPrStatusTracker({ ...opts, onChange: (change) => { listener?.(change); } });
|
|
6
6
|
return {
|
|
7
7
|
tracker,
|
|
8
8
|
port: {
|
|
9
9
|
stateOf: (url) => tracker.stateOf(url),
|
|
10
|
+
factsOf: (url) => tracker.factsOf(url),
|
|
11
|
+
viewerLogin: () => tracker.viewerLogin(),
|
|
10
12
|
setSessionUrls: (sessionId, urls) => { tracker.setSessionUrls(sessionId, urls); },
|
|
13
|
+
setSessionLinks: (sessionId, urls) => { tracker.setSessionLinks(sessionId, urls); },
|
|
11
14
|
dropSession: (sessionId) => { tracker.dropSession(sessionId); },
|
|
12
15
|
listen: (onChange) => { listener = onChange; },
|
|
13
16
|
},
|
|
14
17
|
};
|
|
15
18
|
}
|
|
16
19
|
/**
|
|
17
|
-
* The PR status of this process, or `null` when `RAROG_PR_STATUS=0`. The demo source is
|
|
18
|
-
* content set (`demoContent`, `null` outside the demo
|
|
19
|
-
*
|
|
20
|
+
* The PR status of this process, or `null` when `RAROG_PR_STATUS=0`. The demo source is the fixed GitHub of the
|
|
21
|
+
* active content set (`demoContent`, `null` outside the demo; states, titles, authors, the demo login) read without
|
|
22
|
+
* delay and without a connected client, so a demo list gets its facts and state at once; it is loaded lazily, like
|
|
23
|
+
* the rest of the demo content.
|
|
20
24
|
*/
|
|
21
25
|
export async function createPrStatus(config, log, demoContent, deps = {}) {
|
|
22
26
|
if (!config.prStatusEnabled)
|
|
@@ -25,10 +29,14 @@ export async function createPrStatus(config, log, demoContent, deps = {}) {
|
|
|
25
29
|
if (config.demo) {
|
|
26
30
|
if (demoContent === null)
|
|
27
31
|
throw new Error('createPrStatus: demo mode requires demoContent');
|
|
28
|
-
const {
|
|
29
|
-
|
|
30
|
-
source: createFixedPrStateSource(
|
|
32
|
+
const { demoGitHub } = await import('../demo/seeds.js');
|
|
33
|
+
const link = createPrStatusLink({
|
|
34
|
+
source: createFixedPrStateSource(demoGitHub(demoContent)), log: logLine, newUrlDelayMs: 0,
|
|
31
35
|
});
|
|
36
|
+
// The fixed map starts no process: it is read whatever the client count, so a scenario created before the app
|
|
37
|
+
// connects has its list at once.
|
|
38
|
+
link.tracker.setClientConnected(true);
|
|
39
|
+
return { ...link, tracker: { ...link.tracker, setClientConnected: () => undefined } };
|
|
32
40
|
}
|
|
33
41
|
const ghSource = deps.ghSource ?? createGhSource;
|
|
34
42
|
return createPrStatusLink({ source: ghSource({ env: { ...config.prStatusEnvBase } }), log: logLine });
|
|
@@ -2,8 +2,43 @@ import { createApnsChannel } from '../notify/apns-channel.js';
|
|
|
2
2
|
import { createFanoutSink } from '../notify/fanout.js';
|
|
3
3
|
import { Notifier, sessionLook } from '../notify/index.js';
|
|
4
4
|
import { Presence } from '../notify/presence.js';
|
|
5
|
+
import { createReadyToMergeAlert, readyToMergeFactsOf } from '../notify/ready-to-merge.js';
|
|
6
|
+
import { createStalledWaitAlert } from '../notify/stalled-wait.js';
|
|
7
|
+
import { inTemporaryDirectory } from '../sessions/test-session.js';
|
|
5
8
|
/** Start log phrase when `RAROG_PUSH_RELAY_URL` has a bad value (`docs/server-config.md`). */
|
|
6
9
|
export const PUSH_RELAY_DISABLED_LOG = 'push: push relay off';
|
|
10
|
+
/**
|
|
11
|
+
* The ready-to-merge push behind the manager's stream: every `session-changed` of a thread hands in its facts with
|
|
12
|
+
* the `checked` commit of its thread file; another conversation in the session drops its memory.
|
|
13
|
+
*/
|
|
14
|
+
export function wireReadyToMerge(alert, manager, checkedOf) {
|
|
15
|
+
manager.onEvent((scope, _seq, event) => {
|
|
16
|
+
if (scope !== 'global' || event.type !== 'session-changed')
|
|
17
|
+
return;
|
|
18
|
+
const facts = readyToMergeFactsOf(event.session, checkedOf(event.session.id));
|
|
19
|
+
if (facts === undefined)
|
|
20
|
+
alert.forget(event.session.id);
|
|
21
|
+
else
|
|
22
|
+
alert.update(facts);
|
|
23
|
+
});
|
|
24
|
+
manager.onConversationChange((sessionId) => { alert.forget(sessionId); });
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The stalled wait alarm behind the manager's listener: the session facts of the push (`title`, `label`, `termId`) and
|
|
28
|
+
* the test session rule (`inTemporaryDirectory(cwd)`) come from the session at every list swap.
|
|
29
|
+
*/
|
|
30
|
+
export function stalledWaitListener(alert, testSession = inTemporaryDirectory) {
|
|
31
|
+
return {
|
|
32
|
+
stuckWaits: (session, waits) => {
|
|
33
|
+
alert.update({
|
|
34
|
+
sessionId: session.id, project: session.title, testSession: testSession(session.cwd),
|
|
35
|
+
...(session.label === undefined ? {} : { label: session.label }),
|
|
36
|
+
...(session.termId === undefined ? {} : { termId: session.termId }),
|
|
37
|
+
}, waits);
|
|
38
|
+
},
|
|
39
|
+
forget: (sessionId) => { alert.forget(sessionId); },
|
|
40
|
+
};
|
|
41
|
+
}
|
|
7
42
|
export function createPush(config, deps) {
|
|
8
43
|
const { managerRef, devices, macStats, log } = deps;
|
|
9
44
|
/*
|
|
@@ -44,6 +79,10 @@ export function createPush(config, deps) {
|
|
|
44
79
|
// Klucze push urządzeń i filtr tokenów odpiętych: magazyn `devices.json` powstał wcześniej.
|
|
45
80
|
pairedDevices: devices,
|
|
46
81
|
});
|
|
82
|
+
// Plakietka na ikonie = sesje, które STOJĄ i czekają na człowieka (`waiting-permission`
|
|
83
|
+
// i `waiting-question`). Liczona w chwili WYSYŁKI.
|
|
84
|
+
const badge = () => (managerRef()?.list() ?? [])
|
|
85
|
+
.filter((s) => s.state === 'waiting-permission' || s.state === 'waiting-question').length;
|
|
47
86
|
/*
|
|
48
87
|
* Harmonogram powstaje WYŁĄCZNIE z kanałem APNs — to jedyny kanał zdolny wysłać baner. Bez
|
|
49
88
|
* niego nie ma też obecności w routerze (`main()`), więc `POST /api/presence` jest no-opem.
|
|
@@ -55,12 +94,17 @@ export function createPush(config, deps) {
|
|
|
55
94
|
// Dźwięk „skończył” z kafla Live Activity: zlecany przy wysłanym „gotowe”.
|
|
56
95
|
sink: createFanoutSink({ apns: apns.sink, chime: () => apns.liveActivity.chime() }),
|
|
57
96
|
look: (id) => sessionLook(managerRef()?.get(id)),
|
|
58
|
-
|
|
59
|
-
// i `waiting-question`). Liczona w chwili WYSYŁKI.
|
|
60
|
-
badge: () => (managerRef()?.list() ?? [])
|
|
61
|
-
.filter((s) => s.state === 'waiting-permission' || s.state === 'waiting-question').length,
|
|
97
|
+
badge,
|
|
62
98
|
})
|
|
63
99
|
: null;
|
|
100
|
+
// The stalled wait alarm sends through the same sink, next to the scheduler and never through it.
|
|
101
|
+
const alert = apns === undefined ? undefined : createStalledWaitAlert({
|
|
102
|
+
send: (content) => apns.sink.send(content), presence, badge, log: (line) => { log.info(line); },
|
|
103
|
+
});
|
|
104
|
+
// The ready-to-merge push too: a thread turning ready is no state transition of its session.
|
|
105
|
+
const readyToMerge = apns === undefined ? undefined : createReadyToMergeAlert({
|
|
106
|
+
send: (content) => apns.sink.send(content), presence, badge, log: (line) => { log.info(line); },
|
|
107
|
+
});
|
|
64
108
|
if (notifier !== null && apns !== undefined) {
|
|
65
109
|
// Powrót do Raroga kasuje czekające banery i dźwięki kafla, które jeszcze nie wyszły.
|
|
66
110
|
const liveActivity = apns.liveActivity;
|
|
@@ -84,5 +128,15 @@ export function createPush(config, deps) {
|
|
|
84
128
|
// Przepustki dla wpisów, które ich nie mają albo którym kończy się termin; bez przekaźnika — nic.
|
|
85
129
|
apns.passes?.start();
|
|
86
130
|
}
|
|
87
|
-
return {
|
|
131
|
+
return {
|
|
132
|
+
presence, apns, notifier,
|
|
133
|
+
stalledWait: alert === undefined ? undefined : stalledWaitListener(alert),
|
|
134
|
+
readyToMerge,
|
|
135
|
+
close: () => {
|
|
136
|
+
// The alarms only stop their timers (nothing to wait for), so the channel starts closing at once, as before.
|
|
137
|
+
void alert?.close();
|
|
138
|
+
void readyToMerge?.close();
|
|
139
|
+
return apns?.close() ?? Promise.resolve();
|
|
140
|
+
},
|
|
141
|
+
};
|
|
88
142
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `rarog doctor`: the PR status line (`docs/pull-requests.md`).
|
|
3
|
-
*
|
|
4
|
-
* `gh
|
|
2
|
+
* `rarog doctor`: the PR status line (`docs/pull-requests.md`). Session cards list only PRs whose author GitHub
|
|
3
|
+
* confirms through the `gh` login, so without `gh` in the closed directory list and a login they show no PRs. It
|
|
4
|
+
* looks for `gh` the way the server does (the closed directory list, `~/` from the service environment that
|
|
5
|
+
* `buildServeEnv` gives), then runs `gh auth status --active --no-refresh --hostname github.com` with the same closed
|
|
6
|
+
* environment as the server's reads.
|
|
5
7
|
*
|
|
6
8
|
* `RAROG_PR_STATUS=0` = info; the demo and its review mode (`RAROG_DEMO`, as `bootstrap/pr-status.ts` decides) = info
|
|
7
9
|
* about the fixed state source, no lookup; no `gh` = warn with a fix; not logged in, a `gh` too old for the check's
|
|
@@ -15,14 +17,16 @@ import { GH_AUTH_ARGV, GH_DIRECTORIES, GH_HOST, checkGhAuth, findGh } from '../p
|
|
|
15
17
|
const LOGIN = `gh auth login --hostname ${GH_HOST}`;
|
|
16
18
|
const CHECK = `gh ${GH_AUTH_ARGV.join(' ')}`;
|
|
17
19
|
const CHECK_FLAGS = GH_AUTH_ARGV.filter((arg) => arg === '--active' || arg === '--no-refresh').join(' ');
|
|
20
|
+
/** Without GitHub's answer no linked PR is confirmed as the user's, so the cards list none. */
|
|
21
|
+
const NO_PRS = ', so session cards show no PRs';
|
|
18
22
|
/** The line for given facts; no process, no disk. */
|
|
19
23
|
export function prStatusLineOf(input) {
|
|
20
24
|
if (input.flag.trim() === '0')
|
|
21
|
-
return { verdict: 'info', text: `PR status: off (${PR_STATUS_ENV}=0)` };
|
|
25
|
+
return { verdict: 'info', text: `PR status: off (${PR_STATUS_ENV}=0)${NO_PRS}` };
|
|
22
26
|
if (input.gh === null) {
|
|
23
27
|
return {
|
|
24
28
|
verdict: 'warn',
|
|
25
|
-
text: `PR status: gh not found in ${(input.directories ?? GH_DIRECTORIES).join(', ')}
|
|
29
|
+
text: `PR status: gh not found in ${(input.directories ?? GH_DIRECTORIES).join(', ')}${NO_PRS}`,
|
|
26
30
|
repair: `install the GitHub CLI (gh) in one of these directories, run ${LOGIN} and restart the server,`
|
|
27
31
|
+ ` or set ${PR_STATUS_ENV}=0 in config.json`,
|
|
28
32
|
};
|
|
@@ -32,7 +36,7 @@ export function prStatusLineOf(input) {
|
|
|
32
36
|
if (input.auth === 'not-logged-in') {
|
|
33
37
|
return {
|
|
34
38
|
verdict: 'warn',
|
|
35
|
-
text: `PR status: ${input.gh} is not logged in to ${GH_HOST}
|
|
39
|
+
text: `PR status: ${input.gh} is not logged in to ${GH_HOST}${NO_PRS}`,
|
|
36
40
|
repair: `${LOGIN} as the user the service runs as; the server picks it up within 30 min, without a restart`,
|
|
37
41
|
};
|
|
38
42
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { messageAsksOwner } from '
|
|
1
|
+
import { messageAsksOwner } from '../asks-owner.js';
|
|
2
2
|
/**
|
|
3
3
|
* The catalog now. A row carries the session id, `conversation` (the token of its engine conversation, the same
|
|
4
4
|
* function as the turns route), `stateSince` as the session list carries it and `asksOwner: true` only while the
|
|
@@ -28,9 +28,8 @@
|
|
|
28
28
|
* - `conversation.ts` — opaque token of a session's engine conversation (`conversationToken`): HMAC under a key drawn
|
|
29
29
|
* at server start, so it changes with the conversation and with every restart.
|
|
30
30
|
* - `catalog.ts` — the session catalog behind `GET /api/companion/sessions`: one row per session in the voice agent's
|
|
31
|
-
* scope, from the server's memory (`companionCatalog`)
|
|
32
|
-
*
|
|
33
|
-
* blocks of each text block (`messageAsksOwner`, `textAsksOwner`).
|
|
31
|
+
* scope, from the server's memory (`companionCatalog`); whether an agent message asks the owner comes from
|
|
32
|
+
* `server/src/asks-owner.ts`.
|
|
34
33
|
* - `index.ts` — this entry.
|
|
35
34
|
*/
|
|
36
35
|
export { assembleCompanion, createCompanionFeature } from './ask.js';
|
|
@@ -43,4 +42,3 @@ export { TURNS_FIRST_WINDOW, assembleCompanionTurns, createCompanionTurns, isTur
|
|
|
43
42
|
export { TURNS_MAX_READS, readSettledTurns } from './turns-settle.js';
|
|
44
43
|
export { CONVERSATION_TOKEN_CHARS, conversationToken, conversationTokens } from './conversation.js';
|
|
45
44
|
export { companionCatalog } from './catalog.js';
|
|
46
|
-
export { ASKS_OWNER_MARKERS, messageAsksOwner, textAsksOwner } from './asks-owner.js';
|
|
@@ -59,6 +59,10 @@ export function parseCodexStatusEnabled(raw) {
|
|
|
59
59
|
return true;
|
|
60
60
|
return !(raw === '0' || raw === 'false');
|
|
61
61
|
}
|
|
62
|
+
/** Flag of the agy row; no value = ON, for the same reason as {@link parseCodexStatusEnabled}. `0` hides agy rows. */
|
|
63
|
+
export function parseAgyStatusEnabled(raw) {
|
|
64
|
+
return parseCodexStatusEnabled(raw);
|
|
65
|
+
}
|
|
62
66
|
/** Preferencja wykrycia dialogu z rejestru CLI; brak wartości = WŁĄCZONE. */
|
|
63
67
|
export function parseCliWaiting(raw) {
|
|
64
68
|
if (raw === undefined || raw.trim() === '')
|
package/server/src/config-env.js
CHANGED
|
@@ -71,6 +71,12 @@ export const NOTES_ENV = 'RAROG_NOTES';
|
|
|
71
71
|
* każda inna. Flaga wyłącza wiersz Codexa bez zmiany kodu.
|
|
72
72
|
*/
|
|
73
73
|
export const CODEX_STATUS_ENV = 'RAROG_CODEX_STATUS';
|
|
74
|
+
/**
|
|
75
|
+
* Flag of the AGY ROW, the twin of {@link CODEX_STATUS_ENV}. `0` = `agent === 'agy'` panes (Antigravity CLI) do not
|
|
76
|
+
* exist for Rarog. Not a killswitch for the same reason: the entry sends nothing, reads no screen, and its only
|
|
77
|
+
* mutation (`agent.focus`) is under `RAROG_HERDR_SEND`.
|
|
78
|
+
*/
|
|
79
|
+
export const AGY_STATUS_ENV = 'RAROG_AGY_STATUS';
|
|
74
80
|
/**
|
|
75
81
|
* Preferencja WYKRYCIA DIALOGU Z REJESTRU SESJI CLI. `0` = Rarog nie czyta
|
|
76
82
|
* `~/.claude/sessions/<pid>.json` co 1,5 s i widzi dialog tylko wtedy, gdy herdr zgłosi
|
|
@@ -182,6 +188,13 @@ export const CONSENT_RESTART_GRACE_ENV = 'RAROG_CONSENT_RESTART_GRACE';
|
|
|
182
188
|
* wysyła, więc to NIE jest szósty killswitch. Flaga kanału zgody jej nie zmienia i odwrotnie.
|
|
183
189
|
*/
|
|
184
190
|
export const DIALOG_LAYER2_ENV = 'RAROG_DIALOG_LAYER2';
|
|
191
|
+
/**
|
|
192
|
+
* Level of the live dialog card (`docs/dialogs.md`, "Live dialog card"): `0` = no live card (the kill switch), missing
|
|
193
|
+
* or `1` = the live card with Enter only on dialogs with light guards (a question, a dialog), `2` = Enter on a consent
|
|
194
|
+
* dialog too, under the consent guards; any other value is a configuration error at start. Read once at start and
|
|
195
|
+
* passed to the driver (`HerdrDriverDeps.dialogLive`).
|
|
196
|
+
*/
|
|
197
|
+
export const DIALOG_LIVE_ENV = 'RAROG_DIALOG_LIVE';
|
|
185
198
|
/**
|
|
186
199
|
* Folder gate kill switch (`docs/macos-folders.md`): missing or empty = on on macOS and off elsewhere, `1` = on,
|
|
187
200
|
* `0` = off; any other value is a config error at start, also in the demo, which never runs the gate. On, a disk call
|
|
@@ -389,6 +402,7 @@ export const SERVER_ENV = {
|
|
|
389
402
|
[VOICE_ENV]: 'plain',
|
|
390
403
|
[NOTES_ENV]: 'plain',
|
|
391
404
|
[CODEX_STATUS_ENV]: 'plain',
|
|
405
|
+
[AGY_STATUS_ENV]: 'plain',
|
|
392
406
|
[CLI_WAITING_ENV]: 'plain',
|
|
393
407
|
[GIT_FILE_DETAILS_ENV]: 'plain',
|
|
394
408
|
[AGENT_FILES_ENV]: 'plain',
|
|
@@ -400,6 +414,7 @@ export const SERVER_ENV = {
|
|
|
400
414
|
[CONSENT_ALWAYS_ENV]: 'plain',
|
|
401
415
|
[CONSENT_RESTART_GRACE_ENV]: 'plain',
|
|
402
416
|
[DIALOG_LAYER2_ENV]: 'plain',
|
|
417
|
+
[DIALOG_LIVE_ENV]: 'plain',
|
|
403
418
|
[FOLDER_GATE_ENV]: 'plain',
|
|
404
419
|
[SSE_GZIP_ENV]: 'plain',
|
|
405
420
|
[COMPANION_ENV]: 'plain',
|
package/server/src/config.js
CHANGED
|
@@ -15,7 +15,7 @@ import path from 'node:path';
|
|
|
15
15
|
import { MAX_TRANSCRIPT_MESSAGES } from '@rarog/shared';
|
|
16
16
|
import { BUNDLE_ID_RE } from '@rarog/shared/rest';
|
|
17
17
|
import { dataDirConflictMessage, resolveDataDir } from '@rarog/shared/data-dir';
|
|
18
|
-
import { AGENT_FILES_ENV, APNS_ENV_NAMES, APNS_KEY_ID_ENV, APNS_KEY_PATH_ENV, APNS_TEAM_ID_ENV, APNS_TOPIC_ENV, CLAUDE_ENV_CLEAR_ENV, ConfigError, CLI_WAITING_ENV, CODEX_STATUS_ENV, COMPANION_ENV, COMPANION_MODEL_ENV, COMPANION_SESSIONS_ENV, COMPANION_ENV_PASSTHROUGH, CONSENT_CHANNEL_ENV, CONSENT_PROOF_ENV, CONSENT_ALWAYS_ENV, CONSENT_RESTART_GRACE_ENV, DEMO_CONTENT_ENV, DEMO_LANG_ENV, DEMO_REVIEW_CODE_ENV, DIALOG_LAYER2_ENV, FOLDER_GATE_ENV, GIT_ENV_PASSTHROUGH, GIT_ENV_PREFIX, GIT_FILE_DETAILS_ENV, HERDR_BIN_ENV, HERDR_LAUNCH_ENV, HERDR_ROOTS_ENV, HERDR_SEEN_FOCUS_ENV, HERDR_SEND_ENV, HERDR_SOCKET_ENV, HERDR_TAB_LABELS_ENV, INBOX_ENV, FILES_ENV, FILES_MAX_MB_ENV, IROH_ENV, IROH_KEY_ENV, IROH_PORT_ENV, IROH_RELAY_ENV, MAX_PANES_ENV, MIN_CLIENT_BUILD_ENV, NOTES_ENV, PROJECT_ROOTS_ENV, PROMPT_BLOCK_ENV, PUSH_E2E_ENV, PUSH_ENV, PR_STATUS_ENV, PR_STATUS_ENV_PASSTHROUGH, PUSH_RELAY_URL_ENV, QUEUE_ECHO_ENV, REFUSAL_DUMPS_ENV, SONIOX_API_HOST_ENV, SONIOX_API_KEY_ENV, OPENAI_API_KEY_ENV, SSE_GZIP_ENV, TALL_DIALOG_GUARD_ENV, TERM_ENV, TERM_ENV_PASSTHROUGH, TERM_IDLE_DAYS_ENV, TERM_MAX_ENV, VOICE_ENV, YOLO_ROOTS_ENV, readEnv, } from './config-env.js';
|
|
18
|
+
import { AGENT_FILES_ENV, AGY_STATUS_ENV, APNS_ENV_NAMES, APNS_KEY_ID_ENV, APNS_KEY_PATH_ENV, APNS_TEAM_ID_ENV, APNS_TOPIC_ENV, CLAUDE_ENV_CLEAR_ENV, ConfigError, CLI_WAITING_ENV, CODEX_STATUS_ENV, COMPANION_ENV, COMPANION_MODEL_ENV, COMPANION_SESSIONS_ENV, COMPANION_ENV_PASSTHROUGH, CONSENT_CHANNEL_ENV, CONSENT_PROOF_ENV, CONSENT_ALWAYS_ENV, CONSENT_RESTART_GRACE_ENV, DEMO_CONTENT_ENV, DEMO_LANG_ENV, DEMO_REVIEW_CODE_ENV, DIALOG_LAYER2_ENV, DIALOG_LIVE_ENV, FOLDER_GATE_ENV, GIT_ENV_PASSTHROUGH, GIT_ENV_PREFIX, GIT_FILE_DETAILS_ENV, HERDR_BIN_ENV, HERDR_LAUNCH_ENV, HERDR_ROOTS_ENV, HERDR_SEEN_FOCUS_ENV, HERDR_SEND_ENV, HERDR_SOCKET_ENV, HERDR_TAB_LABELS_ENV, INBOX_ENV, FILES_ENV, FILES_MAX_MB_ENV, IROH_ENV, IROH_KEY_ENV, IROH_PORT_ENV, IROH_RELAY_ENV, MAX_PANES_ENV, MIN_CLIENT_BUILD_ENV, NOTES_ENV, PROJECT_ROOTS_ENV, PROMPT_BLOCK_ENV, PUSH_E2E_ENV, PUSH_ENV, PR_STATUS_ENV, PR_STATUS_ENV_PASSTHROUGH, PUSH_RELAY_URL_ENV, QUEUE_ECHO_ENV, REFUSAL_DUMPS_ENV, SONIOX_API_HOST_ENV, SONIOX_API_KEY_ENV, OPENAI_API_KEY_ENV, SSE_GZIP_ENV, TALL_DIALOG_GUARD_ENV, TERM_ENV, TERM_ENV_PASSTHROUGH, TERM_IDLE_DAYS_ENV, TERM_MAX_ENV, VOICE_ENV, YOLO_ROOTS_ENV, readEnv, } from './config-env.js';
|
|
19
19
|
import { RAROG_VERSION } from './version.js';
|
|
20
20
|
import { INSTALL_MODE } from './install/mode.js';
|
|
21
21
|
import { DEVICES_FILENAME, activeDeviceEpochs } from './auth/devices-store.js';
|
|
@@ -24,7 +24,7 @@ import { CONSENT_PROOF_RULES } from './herdr/dialogs/layer1/contract.js';
|
|
|
24
24
|
import { readAccountDefaultEffort, readAccountDefaultModel } from './config/claude-account.js';
|
|
25
25
|
import { minClientBuildOf, parseMinClientBuild } from './config/clients.js';
|
|
26
26
|
import { DEMO_REVIEW_MAX_DEVICES, assertDemoReviewOrigins, demoEnabled, parseDemoContent, parseDemoLang, parseDemoReview, } from './config/demo.js';
|
|
27
|
-
import { COMPANION_MODEL_DEFAULT, COMPANION_MODEL_PATTERN, parseAgentFiles, parseCliWaiting, parseCodexStatusEnabled, parseCompanionEnabled, parseCompanionModel, parseCompanionSessionsEnabled, parseConsentRestartGrace, parseGitFileDetails, parseInboxEnabled, parseNotesEnabled, parsePrStatusEnabled, parsePromptBlock, parseQueueEcho, parseRefusalDumps, parseSseGzip, } from './config/flags.js';
|
|
27
|
+
import { COMPANION_MODEL_DEFAULT, COMPANION_MODEL_PATTERN, parseAgentFiles, parseAgyStatusEnabled, parseCliWaiting, parseCodexStatusEnabled, parseCompanionEnabled, parseCompanionModel, parseCompanionSessionsEnabled, parseConsentRestartGrace, parseGitFileDetails, parseInboxEnabled, parseNotesEnabled, parsePrStatusEnabled, parsePromptBlock, parseQueueEcho, parseRefusalDumps, parseSseGzip, } from './config/flags.js';
|
|
28
28
|
import { parseFilesEnabled, parseFilesMaxBytes } from './config/files.js';
|
|
29
29
|
import { DEFAULT_MAX_PANES, defaultHerdrSocket, parseHerdrLaunch, parseHerdrSeenFocus, parseHerdrSend, parseHerdrSocket, parseHerdrTabLabels, parseMaxPanes, } from './config/herdr.js';
|
|
30
30
|
import { DEFAULT_PORT, MAX_BODY_BYTES, RAROG_HOST, assertLoopbackHost, demoOrigins, parseIroh, parseOrigins, parsePort, } from './config/listen.js';
|
|
@@ -37,7 +37,7 @@ import { VOICE_TOKEN_HOURLY_CAP, VOICE_TOKEN_MIN_INTERVAL_MS, parseVoiceEnabled
|
|
|
37
37
|
* `loadConfig` below passes the values in. This file re-exports their names, so imports from `config.ts`
|
|
38
38
|
* stay as they are.
|
|
39
39
|
*/
|
|
40
|
-
export { COMPANION_MODEL_DEFAULT, COMPANION_MODEL_PATTERN, parseCompanionModel, DEFAULT_HERDR_BIN, DEFAULT_MAX_PANES, DEFAULT_PORT, DEFAULT_TERM_IDLE_DAYS, DEFAULT_TERM_MAX, DEMO_REVIEW_MAX_DEVICES, MAX_BODY_BYTES, RAROG_HOST, RAROG_TERM_PANE_TOKEN, TERM_START_RETRY_MS, TERM_TOKEN_REFRESH_MS, VOICE_TOKEN_HOURLY_CAP, VOICE_TOKEN_MIN_INTERVAL_MS, assertLoopbackHost, defaultHerdrSocket, demoOrigins, expandTilde, isInsideAnyRoot, isInsideAnyRootReal, parseAgentFiles, parseCliWaiting, parseCodexStatusEnabled, parseCompanionEnabled, parseGitFileDetails, parseHerdrBin, parseHerdrLaunch, parseHerdrRoots, parseHerdrSeenFocus, parseHerdrSend, parseHerdrSocket, parseHerdrTabLabels, parseMinClientBuild, parseNotesEnabled, parseProjectRoots, parsePromptBlock, parsePushE2e, parsePushEnabled, parsePushRelay, parseQueueEcho, parseRefusalDumps, parseSseGzip, parseTermEnabled, parseTermIdleDays, parseTermMax, parseVoiceEnabled, parseYoloRoots, readAccountDefaultEffort, readAccountDefaultModel, termPaneTokenOf, validateProjectCwd, };
|
|
40
|
+
export { COMPANION_MODEL_DEFAULT, COMPANION_MODEL_PATTERN, parseCompanionModel, DEFAULT_HERDR_BIN, DEFAULT_MAX_PANES, DEFAULT_PORT, DEFAULT_TERM_IDLE_DAYS, DEFAULT_TERM_MAX, DEMO_REVIEW_MAX_DEVICES, MAX_BODY_BYTES, RAROG_HOST, RAROG_TERM_PANE_TOKEN, TERM_START_RETRY_MS, TERM_TOKEN_REFRESH_MS, VOICE_TOKEN_HOURLY_CAP, VOICE_TOKEN_MIN_INTERVAL_MS, assertLoopbackHost, defaultHerdrSocket, demoOrigins, expandTilde, isInsideAnyRoot, isInsideAnyRootReal, parseAgentFiles, parseAgyStatusEnabled, parseCliWaiting, parseCodexStatusEnabled, parseCompanionEnabled, parseGitFileDetails, parseHerdrBin, parseHerdrLaunch, parseHerdrRoots, parseHerdrSeenFocus, parseHerdrSend, parseHerdrSocket, parseHerdrTabLabels, parseMinClientBuild, parseNotesEnabled, parseProjectRoots, parsePromptBlock, parsePushE2e, parsePushEnabled, parsePushRelay, parseQueueEcho, parseRefusalDumps, parseSseGzip, parseTermEnabled, parseTermIdleDays, parseTermMax, parseVoiceEnabled, parseYoloRoots, readAccountDefaultEffort, readAccountDefaultModel, termPaneTokenOf, validateProjectCwd, };
|
|
41
41
|
/** Błąd konfiguracji (definicja w `config-env.ts`, bo rzuca go też odczyt zmiennej). */
|
|
42
42
|
export { ConfigError };
|
|
43
43
|
// ---------------------------------------------------------------------------
|
|
@@ -528,6 +528,17 @@ export function parseDialogLayer2(raw) {
|
|
|
528
528
|
return true;
|
|
529
529
|
throw new ConfigError(`${DIALOG_LAYER2_ENV} takes 1 or 0 (got: ${value}).`);
|
|
530
530
|
}
|
|
531
|
+
/** The live dialog card level: missing, empty or `0` = off, `1` or `2`; any other value stops the start. */
|
|
532
|
+
export function parseDialogLive(raw) {
|
|
533
|
+
const value = raw?.trim() ?? '';
|
|
534
|
+
if (value === '0')
|
|
535
|
+
return 0;
|
|
536
|
+
if (value === '' || value === '1')
|
|
537
|
+
return 1;
|
|
538
|
+
if (value === '2')
|
|
539
|
+
return 2;
|
|
540
|
+
throw new ConfigError(`${DIALOG_LIVE_ENV} takes 0, 1 or 2 (got: ${value}).`);
|
|
541
|
+
}
|
|
531
542
|
/**
|
|
532
543
|
* The folder gate flag: missing or empty = the platform decides (on on macOS, where the consent windows are), `1` = on,
|
|
533
544
|
* `0` = off; any other value stops the start, so a typo never leaves the server in another mode than the owner meant.
|
|
@@ -694,6 +705,8 @@ export function loadConfig(env = process.env, mode = INSTALL_MODE) {
|
|
|
694
705
|
* przypadkowe.
|
|
695
706
|
*/
|
|
696
707
|
codexStatusEnabled: !demo && parseCodexStatusEnabled(readEnv(env, CODEX_STATUS_ENV)),
|
|
708
|
+
// Off in demo for the same reason as the Codex row: the entry comes only from a live herdr `agent.list`.
|
|
709
|
+
agyStatusEnabled: !demo && parseAgyStatusEnabled(readEnv(env, AGY_STATUS_ENV)),
|
|
697
710
|
/*
|
|
698
711
|
* Rejestr CLI wyłączony w demo BEZWARUNKOWO: tryb pokazowy nie czyta rejestru procesów Maca
|
|
699
712
|
* (czytnika wydań w demo nie ma wcale), a jego sesje są fikcyjne.
|
|
@@ -721,6 +734,7 @@ export function loadConfig(env = process.env, mode = INSTALL_MODE) {
|
|
|
721
734
|
consentRestartGraceMs: parseConsentRestartGrace(readEnv(env, CONSENT_RESTART_GRACE_ENV)),
|
|
722
735
|
// W demo bez skutku (mock nie ma drivera herdr), ale zła wartość zatrzymuje start tak samo.
|
|
723
736
|
dialogLayer2: parseDialogLayer2(readEnv(env, DIALOG_LAYER2_ENV)),
|
|
737
|
+
dialogLive: parseDialogLive(readEnv(env, DIALOG_LIVE_ENV)),
|
|
724
738
|
// Off in demo unconditionally: the demo reads nothing of the host's folders; a wrong value stops the start there.
|
|
725
739
|
folderGate: parseFolderGate(readEnv(env, FOLDER_GATE_ENV), process.platform) && !demo,
|
|
726
740
|
sseGzip: parseSseGzip(readEnv(env, SSE_GZIP_ENV)),
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { isTurnEnd } from '../herdr/jsonl-pending.js';
|
|
2
|
+
import { MergeEpisodes, peerMessageOf } from './merge-prompt.js';
|
|
3
|
+
import { threadNamed } from './thread-file.js';
|
|
4
|
+
function timeOf(entry) {
|
|
5
|
+
const raw = typeof entry === 'object' && entry !== null ? entry.timestamp : undefined;
|
|
6
|
+
if (typeof raw !== 'string')
|
|
7
|
+
return null;
|
|
8
|
+
const at = Date.parse(raw);
|
|
9
|
+
return Number.isNaN(at) ? null : at;
|
|
10
|
+
}
|
|
11
|
+
export class MergeEvents {
|
|
12
|
+
#byProject = new Map();
|
|
13
|
+
#now;
|
|
14
|
+
constructor(now) {
|
|
15
|
+
this.#now = now;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The coordinator of `project` runs `conversation` from now on: an entry older than this moment is history, so a
|
|
19
|
+
* Merge in it is no request. The same conversation keeps its episodes.
|
|
20
|
+
*/
|
|
21
|
+
started(project, conversation) {
|
|
22
|
+
if (this.#byProject.get(project)?.conversation === conversation)
|
|
23
|
+
return;
|
|
24
|
+
this.#byProject.set(project, { conversation, episodes: new MergeEpisodes(this.#now()), checked: new Map() });
|
|
25
|
+
}
|
|
26
|
+
/** The project has no live coordinator: its episodes go with the process that worked on them. */
|
|
27
|
+
ended(project) {
|
|
28
|
+
this.#byProject.delete(project);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* One entry of the coordinator's transcript, in file order: a Merge prompt for a thread starts its episode, the end
|
|
32
|
+
* of a turn (also an interrupted one) ends the running ones at the moment the turn ended. Returns the names whose
|
|
33
|
+
* episode changed.
|
|
34
|
+
*/
|
|
35
|
+
coordinatorEntry(project, conversation, entry, threads) {
|
|
36
|
+
const coordinator = this.#byProject.get(project);
|
|
37
|
+
if (coordinator?.conversation !== conversation)
|
|
38
|
+
return [];
|
|
39
|
+
const changed = [];
|
|
40
|
+
const name = coordinator.episodes.note(entry, (one) => threadNamed(threads, one) !== undefined);
|
|
41
|
+
if (name !== null) {
|
|
42
|
+
coordinator.checked.set(name, threadNamed(threads, name)?.checked ?? undefined);
|
|
43
|
+
changed.push(name);
|
|
44
|
+
}
|
|
45
|
+
const end = isTurnEnd(entry) ? timeOf(entry) : null;
|
|
46
|
+
if (end !== null)
|
|
47
|
+
changed.push(...coordinator.episodes.coordinatorStopped(end));
|
|
48
|
+
return changed;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* One entry of the transcript of the thread `name`, in file order: a message from another session whose sender is a
|
|
52
|
+
* live process of the coordinator's conversation sends the thread back. `livePids` gives those processes from the
|
|
53
|
+
* CLI process registry; `null` (unknown) recognises no send-back. Returns true when the entry changed the episode.
|
|
54
|
+
*/
|
|
55
|
+
threadEntry(project, name, entry, livePids) {
|
|
56
|
+
const coordinator = this.#byProject.get(project);
|
|
57
|
+
if (coordinator === undefined)
|
|
58
|
+
return false;
|
|
59
|
+
const message = peerMessageOf(entry);
|
|
60
|
+
if (message?.pid === undefined || livePids(coordinator.conversation)?.includes(message.pid) !== true)
|
|
61
|
+
return false;
|
|
62
|
+
return coordinator.episodes.sentBack(name, message.at);
|
|
63
|
+
}
|
|
64
|
+
/** The thread file of `name` records the merge; true when that ended a running episode. */
|
|
65
|
+
merged(project, name) {
|
|
66
|
+
return this.#byProject.get(project)?.episodes.merged(name, this.#now()) ?? false;
|
|
67
|
+
}
|
|
68
|
+
/** The Merge events of the thread `name`, oldest first; none without a Merge since its coordinator took the role. */
|
|
69
|
+
eventsOf(project, name) {
|
|
70
|
+
const coordinator = this.#byProject.get(project);
|
|
71
|
+
const episode = coordinator?.episodes.episodeOf(name);
|
|
72
|
+
if (coordinator === undefined || episode === undefined)
|
|
73
|
+
return [];
|
|
74
|
+
const checked = coordinator.checked.get(name);
|
|
75
|
+
const events = [{
|
|
76
|
+
kind: 'merge-delivered', at: new Date(episode.since).toISOString(), ...(checked === undefined ? {} : { checked }),
|
|
77
|
+
}];
|
|
78
|
+
if (episode.phase === 'merging')
|
|
79
|
+
return events;
|
|
80
|
+
const at = new Date(episode.endedAt).toISOString();
|
|
81
|
+
events.push(episode.how === 'sent-back'
|
|
82
|
+
? { kind: 'peer-message', at, from: 'coordinator' }
|
|
83
|
+
: { kind: 'coordinator-stopped', at });
|
|
84
|
+
return events;
|
|
85
|
+
}
|
|
86
|
+
}
|