@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 @@
|
|
|
22
22
|
* złotych ramek (`shared/test/sse-fixtures.test.ts` sprawdza nim `degrades`, które czyta Swift).
|
|
23
23
|
*/
|
|
24
24
|
import { z } from 'zod';
|
|
25
|
-
import { activityEventSchema, activitySchema, backgroundTaskSchema, blockSchema, contextLimitStateSchema, deltaEventSchema, folderAccessEventSchema, gitFileDetailSchema, gitStatusEventSchema, helloEventSchema, herdrStatusEventSchema, inboxCardKindSchema, inboxDialogKindSchema, inboxEventSchemas, inboxHeadSchemaOf, macFolderBlockSchema, macFolderStateSchema, messageAttachmentSchema, messageEventSchema, notesEventSchema, parseServerEvent, permissionPendingEventSchema, permissionRequestObjectSchema, permissionRequestSchema, permissionResolvedEventSchema, permissionSettledEventSchema, questionOptionSchema, questionPendingEventSchema, questionRequestSchema, questionSchema, questionResolvedEventSchema, sessionChangedEventSchema, sessionPullRequestSchema, sessionStateSchema, sessionsSnapshotEventSchema, sessionSummarySchema, stateEventSchema, transcriptMessageSchema, transcriptNoticeSchema, transcriptSnapshotEventSchema, usageEventSchema, toolCallBlockObjectSchema, waitingForSchema, withDetailTruncation, withDisplayTextTruncation, } from './protocol.js';
|
|
25
|
+
import { activityEventSchema, activitySchema, backgroundTaskSchema, blockSchema, contextLimitStateSchema, deltaEventSchema, dialogLiveKeySchema, folderAccessEventSchema, gitFileDetailSchema, gitStatusEventSchema, helloEventSchema, herdrDialogLiveSchema, herdrStatusEventSchema, inboxCardKindSchema, inboxDialogKindSchema, inboxEventSchemas, inboxHeadSchemaOf, macFolderBlockSchema, macFolderStateSchema, messageAttachmentSchema, messageEventSchema, notesEventSchema, parseServerEvent, permissionPendingEventSchema, permissionRequestObjectSchema, permissionRequestSchema, permissionResolvedEventSchema, permissionSettledEventSchema, questionOptionSchema, questionPendingEventSchema, questionRequestSchema, questionSchema, questionResolvedEventSchema, SESSION_COORDINATION_ROLES, sessionChangedEventSchema, sessionCoordinationSchema, sessionPullRequestSchema, sessionStateSchema, sessionsSnapshotEventSchema, sessionSummarySchema, stateEventSchema, threadMergeSchema, transcriptMessageSchema, transcriptNoticeSchema, transcriptSnapshotEventSchema, usageEventSchema, toolCallBlockObjectSchema, waitingForSchema, withDetailTruncation, withDisplayTextTruncation, } from './protocol.js';
|
|
26
26
|
/**
|
|
27
27
|
* Wartownik „ta wersja klienta tego nie zna". Zarezerwowany w KLIENCIE: serwer go nie nadaje
|
|
28
28
|
* i nie zna (schematy ścisłe), więc w polu stanu nie pomyli się z żadną prawdziwą wartością.
|
|
@@ -51,6 +51,11 @@ export const DEGRADATIONS = {
|
|
|
51
51
|
herdrDialogReason: undefined,
|
|
52
52
|
/** Klasa dialogu z rejestru CLI — bez pola karta mówi to, co bez rejestru. */
|
|
53
53
|
cliDialog: undefined,
|
|
54
|
+
/**
|
|
55
|
+
* `SessionSummary.herdrDialogLive` with an unknown key in `keys` or an unknown `refuse`: the whole live card drops, so
|
|
56
|
+
* the app shows the card without buttons the server sends next to it, never a key row it cannot read in full.
|
|
57
|
+
*/
|
|
58
|
+
herdrDialogLive: undefined,
|
|
54
59
|
/** Nie `undefined`: brak pola znaczy „Claude", a nieznanego silnika nie wolno czytać jak Claude. */
|
|
55
60
|
engine: UNSUPPORTED,
|
|
56
61
|
'context.kind': undefined,
|
|
@@ -59,6 +64,8 @@ export const DEGRADATIONS = {
|
|
|
59
64
|
'activity.kind': undefined,
|
|
60
65
|
'waitingFor.kind': undefined,
|
|
61
66
|
'backgroundTasks.kind': UNSUPPORTED,
|
|
67
|
+
/** `BackgroundTask.ownCommandWait`: an unknown stage drops the field, so the task reads as without a known wait. */
|
|
68
|
+
'backgroundTasks.ownCommandWait': undefined,
|
|
62
69
|
/** Notka systemowa — nie udaje ani człowieka, ani agenta. */
|
|
63
70
|
'message.role': 'system',
|
|
64
71
|
/** Blok zastępczy `{ type: 'unsupported' }`; reszta pól nieznanego bloku jest odcinana. */
|
|
@@ -111,6 +118,12 @@ export const DEGRADATIONS = {
|
|
|
111
118
|
'pullRequests.state': undefined,
|
|
112
119
|
/** `SessionSummary.seenBy`: an unknown picker drops the field, so the received result reads as a human's. */
|
|
113
120
|
seenBy: undefined,
|
|
121
|
+
/**
|
|
122
|
+
* `SessionSummary.coordination` with an unknown `role`, or a thread whose `merge` has an unknown `state` or
|
|
123
|
+
* `outcome`: the whole field drops, so the session reads as an ordinary one and the app offers no Merge on a state
|
|
124
|
+
* it cannot read. The rest of the summary stays.
|
|
125
|
+
*/
|
|
126
|
+
coordination: undefined,
|
|
114
127
|
/**
|
|
115
128
|
* An `inbox-heads` head with an unknown `kind`, `state` or `dialog`: that head drops out of the list and the other
|
|
116
129
|
* heads stay, so a card kind added later does not empty an older app's Inbox. A single `inbox-head` with such a
|
|
@@ -191,6 +204,35 @@ function buildSchemas(raw) {
|
|
|
191
204
|
}),
|
|
192
205
|
unknownObject('kind', waitingForSchema.shape.kind.options, undefined),
|
|
193
206
|
]);
|
|
207
|
+
/*
|
|
208
|
+
* `coordination`: an unknown role, or an unknown merge `state` or `outcome` of a thread, drops the whole field. Any
|
|
209
|
+
* other broken value (a string `commits`, a `null`, a missing `name`) still rejects the frame.
|
|
210
|
+
*/
|
|
211
|
+
const [, threadRole] = sessionCoordinationSchema.options;
|
|
212
|
+
const mergeShape = threadMergeSchema.shape;
|
|
213
|
+
const unknownMerge = (known) => unknownOf(known).transform(or(undefined));
|
|
214
|
+
const unreadableThread = threadRole.extend({
|
|
215
|
+
merge: threadMergeSchema.extend({
|
|
216
|
+
state: z.union([mergeShape.state, unknownMerge(mergeShape.state.options)]),
|
|
217
|
+
outcome: z.union([mergeShape.outcome.unwrap(), unknownMerge(mergeShape.outcome.unwrap().options)]).optional(),
|
|
218
|
+
}),
|
|
219
|
+
}).transform((value) => (raw ? value : undefined));
|
|
220
|
+
const coordination = z.union([
|
|
221
|
+
sessionCoordinationSchema,
|
|
222
|
+
unreadableThread,
|
|
223
|
+
unknownObject('role', SESSION_COORDINATION_ROLES, undefined),
|
|
224
|
+
]);
|
|
225
|
+
/*
|
|
226
|
+
* The live dialog card: an unknown string in `keys` or `refuse` drops the whole field (in the raw view the field
|
|
227
|
+
* keeps its markers, so the degradation names the key). Any other broken field still rejects the frame.
|
|
228
|
+
*/
|
|
229
|
+
const dialogLive = z.union([
|
|
230
|
+
herdrDialogLiveSchema,
|
|
231
|
+
herdrDialogLiveSchema.extend({
|
|
232
|
+
keys: z.array(lenient(dialogLiveKeySchema, undefined)),
|
|
233
|
+
refuse: lenientOpt(herdrDialogLiveSchema.shape.refuse, undefined),
|
|
234
|
+
}).transform((live) => (raw ? live : undefined)),
|
|
235
|
+
]);
|
|
194
236
|
const summaryShape = sessionSummarySchema.shape;
|
|
195
237
|
const summary = sessionSummarySchema.extend({
|
|
196
238
|
state: lenient(summaryShape.state, UNSUPPORTED),
|
|
@@ -199,17 +241,20 @@ function buildSchemas(raw) {
|
|
|
199
241
|
herdrDialog: lenientOpt(summaryShape.herdrDialog, undefined),
|
|
200
242
|
herdrDialogReason: lenientOpt(summaryShape.herdrDialogReason, undefined),
|
|
201
243
|
cliDialog: lenientOpt(summaryShape.cliDialog, undefined),
|
|
244
|
+
herdrDialogLive: dialogLive.optional(),
|
|
202
245
|
seenBy: lenientOpt(summaryShape.seenBy, undefined),
|
|
203
246
|
engine: lenientOpt(summaryShape.engine, UNSUPPORTED),
|
|
204
247
|
context: context.optional(),
|
|
205
248
|
activity: activity.optional(),
|
|
206
249
|
backgroundTasks: z.array(backgroundTaskSchema.extend({
|
|
207
250
|
kind: lenient(backgroundTaskSchema.shape.kind, UNSUPPORTED),
|
|
251
|
+
ownCommandWait: lenientOpt(backgroundTaskSchema.shape.ownCommandWait, undefined),
|
|
208
252
|
})).optional(),
|
|
209
253
|
waitingFor: waitingFor.optional(),
|
|
210
254
|
pullRequests: z.array(sessionPullRequestSchema.extend({
|
|
211
255
|
state: lenientOpt(sessionPullRequestSchema.shape.state, undefined),
|
|
212
256
|
})).optional(),
|
|
257
|
+
coordination: coordination.optional(),
|
|
213
258
|
});
|
|
214
259
|
const [textBlock, , imageBlock] = blockSchema.options;
|
|
215
260
|
// Baza bez reguły `truncation`: `.extend` nie nadpisuje pól obiektu z regułą, więc regułę nakładamy na widok.
|
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
* Re-exported unchanged by `shared/src/protocol.ts`; code imports the names from there.
|
|
6
6
|
*/
|
|
7
7
|
import { z } from 'zod';
|
|
8
|
+
/**
|
|
9
|
+
* How long a subagent in standby has waited on its own background command (`BackgroundTask.ownCommandWait`), on the
|
|
10
|
+
* server clock from `waitingSince`: `short` below 30 minutes, `long` from 30, `stuck` from 60
|
|
11
|
+
* (`docs/subagent-long-wait.md`). Wire values; a new meaning is a new value.
|
|
12
|
+
*/
|
|
13
|
+
export const OWN_COMMAND_WAITS = ['short', 'long', 'stuck'];
|
|
8
14
|
/**
|
|
9
15
|
* PR state on GitHub (`SessionPullRequest.state`): the wire values, lowercase. `draft` is an open PR marked as a draft
|
|
10
16
|
* on GitHub; only an open PR can be one.
|
|
@@ -41,6 +47,7 @@ export const backgroundTaskSchema = z.object({
|
|
|
41
47
|
// nieznane klucze, więc bez tych linii klient parsujący tym schematem by ich nie zobaczył.
|
|
42
48
|
waitingSince: z.string().optional(),
|
|
43
49
|
ownTasks: z.array(agentOwnTaskSchema).optional(),
|
|
50
|
+
ownCommandWait: z.enum(OWN_COMMAND_WAITS).optional(),
|
|
44
51
|
});
|
|
45
52
|
const _agentOwnTaskSchemaMatchesType = true;
|
|
46
53
|
const _agentOwnTaskTypeMatchesSchema = true;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protocol contract, context window area: the context usage of an engine session, the known or unknown window and
|
|
3
|
+
* the table of windows known for sure.
|
|
4
|
+
*
|
|
5
|
+
* Re-exported unchanged by `shared/src/protocol.ts`; code imports the names from there.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
export const sessionUsageSchema = z.object({
|
|
9
|
+
contextTokens: z.number(),
|
|
10
|
+
contextLimit: z.number(),
|
|
11
|
+
});
|
|
12
|
+
export const contextLimitStateSchema = z.discriminatedUnion('kind', [
|
|
13
|
+
z.object({ kind: z.literal('unknown'), tokens: z.number(), atLeast: z.number().optional() }),
|
|
14
|
+
z.object({
|
|
15
|
+
kind: z.literal('known'),
|
|
16
|
+
tokens: z.number(),
|
|
17
|
+
limit: z.number(),
|
|
18
|
+
source: z.enum(['compact-boundary', 'model', 'statusline']),
|
|
19
|
+
}),
|
|
20
|
+
]);
|
|
21
|
+
const _contextLimitSchemaMatchesType = true;
|
|
22
|
+
const _contextLimitTypeMatchesSchema = true;
|
|
23
|
+
void _contextLimitSchemaMatchesType;
|
|
24
|
+
void _contextLimitTypeMatchesSchema;
|
|
25
|
+
/**
|
|
26
|
+
* Okna kontekstu, które znamy na pewno — dla aliasów z flag Raroga (`fable`, `opus[1m]`, …) oraz
|
|
27
|
+
* dla pełnych identyfikatorów Fable ROZWIĄZANYCH z jsonl (follower potwierdza nimi limit sesji).
|
|
28
|
+
* `opus[1m]` = 1M (`contextWindow: 1000000` in `--output-format json`).
|
|
29
|
+
* The bare alias `opus` = 1M (Claude Code 2.1.280): `claude --model opus` resolves to
|
|
30
|
+
* `claude-opus-5-5` with `contextWindow: 1000000`, and `opus[1m]` to `claude-opus-5-5[1m]` with the
|
|
31
|
+
* SAME window — Opus 5.5 has 1M without a variant, like Fable 5.1. The full id `claude-opus-5-5`
|
|
32
|
+
* is in the table because a session on the account's default model (`opus`, no flag) gets its
|
|
33
|
+
* window only from jsonl and without this entry would stay `unknown`.
|
|
34
|
+
*
|
|
35
|
+
* The model list carries only the `fable` alias, yet the full Fable ids stay in this table on
|
|
36
|
+
* purpose: Rarog also reads sessions started outside it, and transcripts with these ids exist.
|
|
37
|
+
* Dropping an entry would not revoke the model — it would take the known window from those
|
|
38
|
+
* sessions and drop the context bar to `unknown`.
|
|
39
|
+
*
|
|
40
|
+
* Fable = 1M, measured on THIS account: the account has the `claude-fable-5[1m]` variant,
|
|
41
|
+
* transcripts carry window sums up to 885 852, manual compactions at `preTokens` 744 448,
|
|
42
|
+
* and herdr shows 14% exactly when the window sum is 148 704 (148 704 / 1M). A 200 000 limit
|
|
43
|
+
* would understate the window fivefold and raise the colour alarm at a third of the session.
|
|
44
|
+
*
|
|
45
|
+
* Sesja bez flagi `--model` na innym modelu niż fable startuje jako `unknown`: aliasy flag
|
|
46
|
+
* (`fable`/`sonnet`/`opus`/`haiku`) nigdy nie są identyfikatorem z jsonl, a wariantu `[1m]`
|
|
47
|
+
* modeli spoza rodziny Fable jsonl nie odróżnia. Alias `fable` = 1M, bo obie znane wersje
|
|
48
|
+
* (5 z pomiaru, 5.1 z dokumentacji) mają to samo okno.
|
|
49
|
+
*
|
|
50
|
+
* Fable 5.1 = 1M z dokumentacji API: 1M to dla `claude-fable-5-1` maksimum
|
|
51
|
+
* I domyślne okno zarazem, więc wariantu `[1m]` ten model nie ma i czysty identyfikator
|
|
52
|
+
* nie zaniża limitu tak, jak robił to `claude-fable-5` bez nawiasu.
|
|
53
|
+
*/
|
|
54
|
+
export const KNOWN_CONTEXT_LIMITS = {
|
|
55
|
+
fable: 1_000_000, 'opus[1m]': 1_000_000, opus: 1_000_000, sonnet: 200_000, haiku: 200_000,
|
|
56
|
+
'claude-fable-5': 1_000_000, 'claude-fable-5-1': 1_000_000, 'claude-opus-5-5': 1_000_000,
|
|
57
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protocol contract, coordination area: the project coordinator and its threads as a session summary carries them
|
|
3
|
+
* (`docs/coordinator.md`, "Protocol contract").
|
|
4
|
+
*
|
|
5
|
+
* A coordinator is a session that starts threads, each one a session of its own on a branch in a worktree. The server
|
|
6
|
+
* reads the thread files the coordinator writes and says per summary which role the session has and whether a thread
|
|
7
|
+
* is ready to merge, merging or merged; the app derives none of it itself. A worktree session's summary also carries
|
|
8
|
+
* `projectRoot`, the main checkout it belongs to, so the app can group it under its project. All fields are additive.
|
|
9
|
+
*
|
|
10
|
+
* Re-exported unchanged by `shared/src/protocol.ts`; code imports the names from there.
|
|
11
|
+
*/
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
/**
|
|
14
|
+
* `ready`: the coordinator's checks passed on the branch head, the worktree is clean and the thread is idle;
|
|
15
|
+
* `merging`: the coordinator received Merge for this thread and works on it; `merged`: the branch is on `main`.
|
|
16
|
+
*/
|
|
17
|
+
export const THREAD_MERGE_STATES = ['ready', 'merging', 'merged'];
|
|
18
|
+
/** `not-merged`: `ready` again after a Merge that ended without a merge. */
|
|
19
|
+
export const THREAD_MERGE_OUTCOMES = ['not-merged'];
|
|
20
|
+
export const SESSION_COORDINATION_ROLES = ['coordinator', 'thread'];
|
|
21
|
+
export const threadMergeSchema = z.object({
|
|
22
|
+
state: z.enum(THREAD_MERGE_STATES),
|
|
23
|
+
commits: z.number().int().nonnegative(),
|
|
24
|
+
files: z.number().int().nonnegative(),
|
|
25
|
+
since: z.string(),
|
|
26
|
+
outcome: z.enum(THREAD_MERGE_OUTCOMES).optional(),
|
|
27
|
+
});
|
|
28
|
+
export const coordinatorRoleSchema = z.object({
|
|
29
|
+
role: z.literal('coordinator'),
|
|
30
|
+
threads: z.number().int().nonnegative(),
|
|
31
|
+
});
|
|
32
|
+
export const threadRoleSchema = z.object({
|
|
33
|
+
role: z.literal('thread'),
|
|
34
|
+
name: z.string().min(1),
|
|
35
|
+
coordinatorId: z.string().min(1).optional(),
|
|
36
|
+
merge: threadMergeSchema.optional(),
|
|
37
|
+
});
|
|
38
|
+
export const sessionCoordinationSchema = z.discriminatedUnion('role', [coordinatorRoleSchema, threadRoleSchema]);
|
|
39
|
+
const _coordinationSchemaMatchesType = true;
|
|
40
|
+
const _coordinationTypeMatchesSchema = true;
|
|
41
|
+
void _coordinationSchemaMatchesType;
|
|
42
|
+
void _coordinationTypeMatchesSchema;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protocol contract, dialog card area: the closed lists behind the dialog fields of the session summary (known
|
|
3
|
+
* dialogs, CLI dialog classes, refusal reasons, live card keys) and the fields themselves (`herdrDialog`,
|
|
4
|
+
* `herdrDialogReason`, `herdrDialogScreen`, `cliDialog`, `herdrDialogLive`). `SessionSummary` extends
|
|
5
|
+
* {@link SessionDialogFields}, and `sessionSummarySchema` spreads {@link sessionDialogFieldsShape} in the place of these
|
|
6
|
+
* keys. The body and the answer of `POST /api/sessions/:id/dialog-key` live here too.
|
|
7
|
+
*
|
|
8
|
+
* Re-exported unchanged by `shared/src/protocol.ts`; code imports the names from there.
|
|
9
|
+
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
/**
|
|
12
|
+
* Dialogi spoza jsonl, które Rarog ROZUMIE na tyle, żeby wystawić przyciski.
|
|
13
|
+
*
|
|
14
|
+
* Lista jest ZAMKNIĘTA i jest odbiciem `KNOWN_DIALOGS` z `server/src/herdr/screen.ts` — nie
|
|
15
|
+
* rośnie „przy okazji". Dialog bez odpowiednika w jsonl to dokładnie ta sytuacja, w której
|
|
16
|
+
* Rarog nie wie, co zatwierdza (zgoda MCP, wyjście z trybu plan), więc wszystko spoza tej
|
|
17
|
+
* listy zostaje przy wycinku ekranu i „Odrzuć dialog" — bez przycisku zatwierdzania.
|
|
18
|
+
*/
|
|
19
|
+
export const KNOWN_DIALOG_IDS = ['trust', 'model'];
|
|
20
|
+
export const knownDialogIdSchema = z.enum(KNOWN_DIALOG_IDS);
|
|
21
|
+
/**
|
|
22
|
+
* Klasa dialogu, który rejestr sesji Claude Code zgłasza jako stojący.
|
|
23
|
+
*
|
|
24
|
+
* Serwer czyta ją z pola `waitingFor` pliku `~/.claude/sessions/<pid>.json` i tłumaczy dosłowne
|
|
25
|
+
* nazwy CLI (`permission prompt`, `input needed`, `sandbox request`…) na te krótkie, własne nazwy
|
|
26
|
+
* Raroga (`server/src/cli-version.ts`) — klient nazw CLI nie zna. `other` = dialog jest, tylko nie
|
|
27
|
+
* wiadomo jaki. Lista stoi w protokole, bo czytają ją obie strony: serwer (czytnik, driver,
|
|
28
|
+
* dziennik odmów) i klient (`SessionSummary.cliDialog`).
|
|
29
|
+
*/
|
|
30
|
+
export const CLI_DIALOG_CLASSES = [
|
|
31
|
+
'permission', 'input', 'sandbox', 'worker', 'dialog', 'goal', 'other',
|
|
32
|
+
];
|
|
33
|
+
export const cliDialogClassSchema = z.enum(CLI_DIALOG_CLASSES);
|
|
34
|
+
/**
|
|
35
|
+
* Powody, dla których decyzja z telefonu NIE wyszła do panelu — ZAMKNIĘTA lista.
|
|
36
|
+
*
|
|
37
|
+
* Jedna unia obsługuje trzy rzeczy naraz i to jest cały powód, dla którego mieszka
|
|
38
|
+
* w protokole, a nie po stronie serwera: kontrakt drivera (`DecisionOutcome`), dziennik
|
|
39
|
+
* audytu (`method: "refuse"` — wpisy mają się SUMOWAĆ, `summarizeRefusals` serwera)
|
|
40
|
+
* i ciało odpowiedzi 422 czytane przez klienta. Dwie równoległe listy rozjechałyby się przy
|
|
41
|
+
* pierwszym nowym powodzie, a wtedy licznik odmów przestałby odpowiadać na pytanie
|
|
42
|
+
* „czy ścieżka cyfrowa realnie zawodzi".
|
|
43
|
+
*
|
|
44
|
+
* Powody dzielą się na trzy grupy i tylko dwie ostatnie wracają kodem 422:
|
|
45
|
+
* - **ocena karty** (`mismatch`, `unreadable`, `no-jsonl`) — Rarog nie umiał złożyć karty
|
|
46
|
+
* z przyciskami; nikt jeszcze o nic nie prosił, więc nie ma żądania, na które odpowiedzieć;
|
|
47
|
+
* - **decyzja** (`multi-select` … `send-failed`) — człowiek tapnął, a klawisz nie wyszedł;
|
|
48
|
+
* - **blokada** (`in-flight`) — powstaje w MANAGERZE, nie w driverze: decyzja o tej karcie
|
|
49
|
+
* właśnie leci z drugiego urządzenia. Do dziennika audytu nie trafia nigdy (`auditRefusal`
|
|
50
|
+
* woła wyłącznie driver), więc obietnicy „wpisy się SUMUJĄ" nie narusza.
|
|
51
|
+
*
|
|
52
|
+
* Lista stoi PRZED sekcją schematów, bo `sessionSummarySchema.herdrDialogReason` jej używa,
|
|
53
|
+
* a `z.enum` czyta stałą w chwili budowy schematu.
|
|
54
|
+
*/
|
|
55
|
+
export const REFUSE_REASONS = [
|
|
56
|
+
'mismatch', 'unreadable', 'no-jsonl', 'multi-select', 'no-digit', 'terminal-only',
|
|
57
|
+
'screen-changed', 'stale-card', 'form-submit', 'send-failed', 'in-flight',
|
|
58
|
+
/** Dialog ZGODY CLI (np. „Teach auto mode…") stoi w panelu, choć herdr widzi `idle`. */
|
|
59
|
+
'consent-dialog',
|
|
60
|
+
];
|
|
61
|
+
export const refuseReasonSchema = z.enum(REFUSE_REASONS);
|
|
62
|
+
/**
|
|
63
|
+
* Keys the live dialog card sends to the dialog in the pane: a closed list, the only keys
|
|
64
|
+
* `POST /api/sessions/:id/dialog-key` takes.
|
|
65
|
+
*/
|
|
66
|
+
export const DIALOG_LIVE_KEYS = ['escape', 'up', 'down', 'enter'];
|
|
67
|
+
export const dialogLiveKeySchema = z.enum(DIALOG_LIVE_KEYS);
|
|
68
|
+
/**
|
|
69
|
+
* The live dialog card (`SessionSummary.herdrDialogLive`): the dialog region of the pane as text, refreshed while the
|
|
70
|
+
* dialog stands, with the keys the server takes now.
|
|
71
|
+
*
|
|
72
|
+
* The server sends it next to the card without buttons, never in place of it: an app that does not know the field
|
|
73
|
+
* shows that card. `id` names one occurrence of the card (bound to the engine session and the registry episode when the
|
|
74
|
+
* server issued it); `rev` grows with every change of the view inside it. A key request names both, so a key aimed at
|
|
75
|
+
* another view does not reach the pane.
|
|
76
|
+
*/
|
|
77
|
+
export const herdrDialogLiveSchema = z.object({
|
|
78
|
+
/** The occurrence of the card, opaque to the client (the server issues `lv:` and 12 hex digits). */
|
|
79
|
+
id: z.string().min(1),
|
|
80
|
+
/** The view revision inside the occurrence. */
|
|
81
|
+
rev: z.number().int().nonnegative(),
|
|
82
|
+
/** The dialog region, top rule to the last footer line, capped by the server. */
|
|
83
|
+
text: z.string(),
|
|
84
|
+
/** The full label of the option under the cursor, with its continuation lines; `null` = Enter is not available. */
|
|
85
|
+
cursorLabel: z.string().nullable(),
|
|
86
|
+
/** The keys the server takes now. */
|
|
87
|
+
keys: z.array(dialogLiveKeySchema),
|
|
88
|
+
/** Why Enter is not available. */
|
|
89
|
+
refuse: refuseReasonSchema.optional(),
|
|
90
|
+
/** The option under the cursor has a lasting effect (settings, a mode). */
|
|
91
|
+
lasting: z.boolean().optional(),
|
|
92
|
+
/** The dialog is cut at the top: the number of hidden lines, `null` = cut, number unknown; absent = not cut. */
|
|
93
|
+
hiddenAbove: z.number().int().min(1).nullable().optional(),
|
|
94
|
+
/** The full operation from the transcript's `tool_use` entry, when Rarog knows it. */
|
|
95
|
+
operation: z.string().optional(),
|
|
96
|
+
});
|
|
97
|
+
/** Body of `POST /api/sessions/:id/dialog-key`: the occurrence and the view revision the device shows, and the key. */
|
|
98
|
+
export const dialogKeyBodySchema = z.object({
|
|
99
|
+
id: z.string().min(1).max(64),
|
|
100
|
+
rev: z.number().int().nonnegative(),
|
|
101
|
+
key: dialogLiveKeySchema,
|
|
102
|
+
});
|
|
103
|
+
/**
|
|
104
|
+
* 200 of `POST /api/sessions/:id/dialog-key`: the key went out; `live` is the card from a fresh read after the key
|
|
105
|
+
* (also when the screen did not change), `null` = the dialog closed.
|
|
106
|
+
*/
|
|
107
|
+
export const dialogKeyResponseSchema = z.object({
|
|
108
|
+
live: herdrDialogLiveSchema.nullable(),
|
|
109
|
+
});
|
|
110
|
+
/** Schemas of {@link SessionDialogFields}, spread into `sessionSummarySchema` in the place of these keys. */
|
|
111
|
+
export const sessionDialogFieldsShape = {
|
|
112
|
+
herdrDialog: knownDialogIdSchema.optional(),
|
|
113
|
+
herdrDialogReason: refuseReasonSchema.optional(),
|
|
114
|
+
herdrDialogScreen: z.string().optional(),
|
|
115
|
+
cliDialog: cliDialogClassSchema.optional(),
|
|
116
|
+
herdrDialogLive: herdrDialogLiveSchema.optional(),
|
|
117
|
+
};
|
|
@@ -21,7 +21,7 @@ function byCodeUnits(a, b) {
|
|
|
21
21
|
export const FILES_BAD_PATH_ERROR = 'bad-path';
|
|
22
22
|
/** 400: the session's directory is outside the work area, or the session has no pane: its files stay on the server. */
|
|
23
23
|
export const FILES_OUT_OF_SCOPE_ERROR = 'out-of-scope';
|
|
24
|
-
/** 400: a Codex
|
|
24
|
+
/** 400: an entry of a state-only engine (Codex, agy), which Rarog only observes; the name stays `codex` on the wire. */
|
|
25
25
|
export const FILES_CODEX_ERROR = 'codex';
|
|
26
26
|
/**
|
|
27
27
|
* 404: nothing to list or send under this path: it does not exist, or the server never shows it (a segment that
|
|
@@ -15,6 +15,11 @@ export const inboxCardKindSchema = z.enum(INBOX_CARD_KINDS);
|
|
|
15
15
|
/** What a `decision` card waits for: a permission card, a question card, or a dialog in the pane without a card. */
|
|
16
16
|
export const INBOX_DIALOG_KINDS = ['permission', 'question', 'panel'];
|
|
17
17
|
export const inboxDialogKindSchema = z.enum(INBOX_DIALOG_KINDS);
|
|
18
|
+
export const inboxCardMergeSchema = z.object({
|
|
19
|
+
name: z.string().min(1),
|
|
20
|
+
coordinatorId: z.string().min(1),
|
|
21
|
+
checked: z.string().regex(/^[0-9a-f]{40}$/u),
|
|
22
|
+
});
|
|
18
23
|
/** The head schema over the protocol's session state schema. */
|
|
19
24
|
export function inboxHeadSchemaOf(state) {
|
|
20
25
|
return z.object({
|
|
@@ -25,6 +30,7 @@ export function inboxHeadSchemaOf(state) {
|
|
|
25
30
|
state,
|
|
26
31
|
at: z.string(),
|
|
27
32
|
dialog: inboxDialogKindSchema.optional(),
|
|
33
|
+
merge: inboxCardMergeSchema.optional(),
|
|
28
34
|
});
|
|
29
35
|
}
|
|
30
36
|
/** The three event schemas, in the order of {@link InboxEventOf}, for the protocol's event union. */
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protocol contract, presence area: the presence beacon `POST /api/presence` and how long it holds
|
|
3
|
+
* (`PRESENCE_TTL_MS`).
|
|
4
|
+
*
|
|
5
|
+
* Re-exported unchanged by `shared/src/protocol.ts`; code imports the names from there.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
/**
|
|
9
|
+
* Beacon obecności (`POST /api/presence`) — jedyny kanał, którym klient mówi serwerowi
|
|
10
|
+
* „patrzę" albo „już nie patrzę".
|
|
11
|
+
*
|
|
12
|
+
* Istnieje, bo obecności NIE DA SIĘ wywnioskować z otwartego strumienia SSE: iOS usypia apkę
|
|
13
|
+
* w tle, a gniazdo potrafi jeszcze chwilę wisieć. Serwer widziałby wtedy „klient jest" przy
|
|
14
|
+
* zgaszonym ekranie i wysyłał powiadomienia dokładnie wtedy, gdy nie miał prawa — czyli
|
|
15
|
+
* powtórzyłby błąd hooków, tylko z innego powodu.
|
|
16
|
+
*
|
|
17
|
+
* Klient odpowiada na heartbeat SSE, DOPÓKI jest widoczny, i zgłasza zmianę od razu przy
|
|
18
|
+
* `visibilitychange`. Koszt: jedno małe żądanie na 25 s przy otwartej apce, ZERO w tle.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Po tylu ms bez potwierdzenia serwer przestaje uważać klienta za obecnego.
|
|
22
|
+
*
|
|
23
|
+
* Stała mieszka w protokole, bo jest KONTRAKTEM między dwiema stronami, a nie szczegółem
|
|
24
|
+
* którejś z nich: serwer po niej wygasza obecność, a klient musi odświeżać się wyraźnie
|
|
25
|
+
* CZĘŚCIEJ — jedno zgubione żądanie na kiepskim LTE nie ma prawa zamienić patrzącego
|
|
26
|
+
* człowieka w nieobecnego i wypchnąć powiadomienia, którego nikt nie chciał.
|
|
27
|
+
*
|
|
28
|
+
* 40 s covers two presence beacons of the native app (every 20 s), so one lost request is tolerated.
|
|
29
|
+
*/
|
|
30
|
+
export const PRESENCE_TTL_MS = 40_000;
|
|
31
|
+
export const presenceBodySchema = z.object({
|
|
32
|
+
/**
|
|
33
|
+
* Identyfikator KARTY, nie użytkownika — losowany przy starcie skryptu i żyjący tyle, co
|
|
34
|
+
* dokument. Serwer używa go wyłącznie do odróżnienia dwóch urządzeń (telefon i iPad mogą
|
|
35
|
+
* patrzeć naraz) i nie wiąże go z niczym trwałym.
|
|
36
|
+
*/
|
|
37
|
+
clientId: z.string().min(1).max(64),
|
|
38
|
+
/** `document.visibilityState !== 'hidden'`. */
|
|
39
|
+
visible: z.boolean(),
|
|
40
|
+
/**
|
|
41
|
+
* Sesja, której TRANSKRYPT jest otwarty. Brak = lista, ustawienia, terminal.
|
|
42
|
+
*
|
|
43
|
+
* Osobna informacja od `visible` i o czym innym: `visible` gasi push (patrzysz w Raroga
|
|
44
|
+
* gdziekolwiek), a to pole gasi sygnał o sesji, na którą i tak patrzysz.
|
|
45
|
+
*/
|
|
46
|
+
sessionId: z.string().min(1).max(128).optional(),
|
|
47
|
+
});
|