@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
|
@@ -14,7 +14,9 @@ import * as crons from './herdr/scheduled-task-poll.js';
|
|
|
14
14
|
import { cliWaitsForPermission, noteConsentRegistryRead } from './herdr/consent-registry-read.js';
|
|
15
15
|
import { PromptQueue, promptEntry } from './herdr/prompt-queue.js';
|
|
16
16
|
import { QueueTakeBack } from './herdr/queue-take-back.js';
|
|
17
|
+
import { PauseGate } from './herdr/pause-gate.js';
|
|
17
18
|
import { ReturnedPrompt } from './herdr/returned-prompt.js';
|
|
19
|
+
import { StartDialogGate, clientNotingScreens } from './herdr/start-dialog-gate.js';
|
|
18
20
|
import { TurnGuard } from './herdr/turn-guard.js';
|
|
19
21
|
import { FormReserve } from './herdr/form-reserve.js';
|
|
20
22
|
import { CliReserve } from './herdr/cli-reserve.js';
|
|
@@ -24,11 +26,13 @@ import { ConsentNoHook } from './herdr/consent-no-hook.js';
|
|
|
24
26
|
import { ScreenFallback } from './herdr/screen-fallback.js';
|
|
25
27
|
import { Layer2Cards, isLayer2Id, layer2HoldsKeys } from './herdr/layer2-card.js';
|
|
26
28
|
import { Layer2Step } from './herdr/layer2-step.js';
|
|
29
|
+
import { LiveDialogCards } from './herdr/live-dialog.js';
|
|
30
|
+
import { LiveStep } from './herdr/live-step.js';
|
|
27
31
|
import { approveContext, auditRefusal, layer2KeyRefusal, refuseDecision, refuseNote, refuseSend, reportStaleDecision, } from './herdr/refusals.js';
|
|
28
|
-
import { ANSWERED_HOOK_SHIELD_MS, CLI_WAITING_PROBES, DECIDED_SHIELD_MS, FORM_SUBMIT_CONFIRM_DELAY_MS, FORM_SUBMIT_GONE_MESSAGE, FORM_SUBMIT_KEY, HOOK_ANSWER_POLL_MS, HOOK_ANSWER_WAIT_MS, HOOK_PERMISSION_REQUEST_EVENT, MULTI_SELECT_MESSAGE, NOTE_NOT_ALLOWED_MESSAGE, NOTE_NO_CHANNEL_MESSAGE, NOTE_WRITE_FAILED_MESSAGE, NO_ANSWER_ON_SCREEN_MESSAGE, NO_DIGIT_MESSAGE, PAUSE_ESCAPE_MESSAGE, SCREEN_ANSWER_REARM_DELAYS_MS, SCREEN_CHANGED_MESSAGE, SCREEN_DIALOG_TOOL, TERMINAL_DIALOG_MESSAGE, TERMINAL_ONLY_MESSAGE, affirmativeOption, alwaysOption, admittedHook, applyMultiSelectOverride, blockCardRecord, confirmFormSubmit, decideCard, dialogShapeOf, measuredConsentHolds, evaluationReqId, fallbackSnippet, formSubmitAbortMessage, hookAnnotations, hookAnswerPartialMessage, besideAtDecision, hookPendingFor, hookPendingFrom, noteNotDeliveredMessage, optionPolicy, otherDialogDump, screenAnswerIndex, screenDialogCard, screenFormReqId, staleDumpProvesOther, } from '../herdr/dialogs/index.js';
|
|
29
|
-
import { shadowAuditFields } from '../herdr/audit.js';
|
|
32
|
+
import { ANSWERED_HOOK_SHIELD_MS, CLI_WAITING_PROBES, DECIDED_SHIELD_MS, FORM_SUBMIT_CONFIRM_DELAY_MS, FORM_SUBMIT_GONE_MESSAGE, FORM_SUBMIT_KEY, HOOK_ANSWER_POLL_MS, HOOK_ANSWER_WAIT_MS, HOOK_PERMISSION_REQUEST_EVENT, MULTI_SELECT_MESSAGE, NOTE_NOT_ALLOWED_MESSAGE, NOTE_NO_CHANNEL_MESSAGE, NOTE_WRITE_FAILED_MESSAGE, NO_ANSWER_ON_SCREEN_MESSAGE, NO_DIGIT_MESSAGE, PAUSE_ESCAPE_MESSAGE, SCREEN_ANSWER_REARM_DELAYS_MS, SCREEN_CHANGED_MESSAGE, SCREEN_DIALOG_TOOL, START_DIALOG_REFUSED_MESSAGE, TERMINAL_DIALOG_MESSAGE, TERMINAL_ONLY_MESSAGE, affirmativeOption, alwaysOption, admittedHook, applyMultiSelectOverride, blockCardRecord, confirmFormSubmit, decideCard, dialogShapeOf, measuredConsentHolds, evaluationReqId, fallbackSnippet, formSubmitAbortMessage, hookAnnotations, hookAnswerPartialMessage, besideAtDecision, hookPendingFor, hookPendingFrom, noteNotDeliveredMessage, optionPolicy, otherDialogDump, screenAnswerIndex, screenDialogCard, screenFormReqId, staleDumpProvesOther, } from '../herdr/dialogs/index.js';
|
|
33
|
+
import { pickLiveFields, shadowAuditFields } from '../herdr/audit.js';
|
|
30
34
|
import { diagnosisFields, originFields } from './herdr/audit-fields.js';
|
|
31
|
-
import { ASK_USER_QUESTION_TOOL, SANDBOX_NETWORK_TOOL,
|
|
35
|
+
import { ASK_USER_QUESTION_TOOL, SANDBOX_NETWORK_TOOL, canonicalLabel, exitDialogTasks, matchKnownDialog, parseOptions, resolveOptions, sameDialogIdentity, sessionPausedDialog, standingConsentDialog, } from '../herdr/dialogs/index.js';
|
|
32
36
|
import { SHADOW_DEADLINE_MS, registryEvidenceFromSignal, shadowCardEligible } from '../herdr/dialogs/index.js';
|
|
33
37
|
import { consentDigitRefused, consentModeNow, consentOnlyEvent } from '../herdr/dialogs/index.js';
|
|
34
38
|
import { collapseFooterMode, parseModeFooter } from '../herdr/dialogs/screen/mode-footer.js';
|
|
@@ -254,12 +258,6 @@ export class HerdrDriver {
|
|
|
254
258
|
#screenText = null;
|
|
255
259
|
/** Kiedy powstał {@link #screenText} — cache dialogu ma TERMIN WAŻNOŚCI. */
|
|
256
260
|
#screenAt = 0;
|
|
257
|
-
/**
|
|
258
|
-
* Numer blokady, w której ostatni odczyt ekranu pokazał pauzę „Session paused” (`#pauseBlocksEscape`);
|
|
259
|
-
* `null` = żaden. Przeżywa odmowę Esc, zgaszoną kartę i odczyt bez dialogu (przemalowanie); zdejmuje go
|
|
260
|
-
* dopiero odczyt z INNYM czytelnym dialogiem, a koniec blokady albo nowa blokada go unieważniają.
|
|
261
|
-
*/
|
|
262
|
-
#pauseSeq = null;
|
|
263
261
|
/** Zegar ponownej oceny stojącego dialogu; `null` = panel nie jest zablokowany. */
|
|
264
262
|
#blockedTimer = null;
|
|
265
263
|
/**
|
|
@@ -293,12 +291,20 @@ export class HerdrDriver {
|
|
|
293
291
|
#screenFallback;
|
|
294
292
|
/** The port of the refusals and their audit funnel: `drivers/herdr/refusals.ts`. */
|
|
295
293
|
#refusals;
|
|
294
|
+
/** No key or text to a start dialog herdr reads as ready: `drivers/herdr/start-dialog-gate.ts`. */
|
|
295
|
+
#startGate;
|
|
296
|
+
/** No Esc on the "Session paused" dialog: `drivers/herdr/pause-gate.ts`. */
|
|
297
|
+
#pauseGate;
|
|
296
298
|
/** The wait behind a command dialog the driver confirmed: `drivers/herdr/command-dialog-settle.ts`. */
|
|
297
299
|
#commandSettle;
|
|
298
300
|
/** The layer 2 card with buttons (`docs/dialog-card.md`): `drivers/herdr/layer2-card.ts`. */
|
|
299
301
|
#layer2Cards;
|
|
300
302
|
/** The key from a layer 2 card, after its proof: `drivers/herdr/layer2-step.ts`. */
|
|
301
303
|
#layer2Step;
|
|
304
|
+
/** The live dialog card (`docs/dialogs.md`, "Live dialog card"): `drivers/herdr/live-dialog.ts`. */
|
|
305
|
+
#live;
|
|
306
|
+
/** A key of the live dialog card, after its checks: `drivers/herdr/live-step.ts`. */
|
|
307
|
+
#liveStep;
|
|
302
308
|
/** Zwalnianie sierot trybu cienia w toku — następny odczyt rejestru nie zaczyna drugiego. */
|
|
303
309
|
#shadowReleasing = false;
|
|
304
310
|
/** The consent channel as the driver sees it: `drivers/herdr/consent-channel.ts`. */
|
|
@@ -330,7 +336,10 @@ export class HerdrDriver {
|
|
|
330
336
|
#pulseEcho = createPulseEcho();
|
|
331
337
|
/** Bieżąca sesja silnika (zmienia ją `/clear`) — potrzebna do `init` z metadanych jsonl. */
|
|
332
338
|
#agentSessionId;
|
|
333
|
-
constructor(handle,
|
|
339
|
+
constructor(handle, driverDeps) {
|
|
340
|
+
// Field reads with attributes feed the start dialog gate too; the other deps are read through from `driverDeps`.
|
|
341
|
+
const deps = Object.create(driverDeps, { client: { enumerable: true, value: clientNotingScreens(driverDeps.client, (text) => { if (!this.#disposed)
|
|
342
|
+
this.#noteStartDialog(text); }) } });
|
|
334
343
|
this.#deps = deps;
|
|
335
344
|
this.#scheduler = deps.scheduler ?? systemScheduler;
|
|
336
345
|
this.#snippet = deps.snippet ?? fallbackSnippet;
|
|
@@ -359,9 +368,21 @@ export class HerdrDriver {
|
|
|
359
368
|
this.#formReserve = new FormReserve({ deps, scheduler: this.#scheduler }, reservePort);
|
|
360
369
|
this.#cliReserve = new CliReserve({ inScope: this.#inScope, form: this.#formReserve }, reservePort);
|
|
361
370
|
this.#refusals = this.#refusalPort();
|
|
371
|
+
this.#startGate = new StartDialogGate({
|
|
372
|
+
startPhase: deps.startPhase ?? (() => null),
|
|
373
|
+
readScreen: () => this.#readDialog(true), system: (text) => { this.#system(text); },
|
|
374
|
+
});
|
|
375
|
+
this.#pauseGate = new PauseGate({
|
|
376
|
+
activeTerminalDialog: () => this.#activeReq?.terminalDialog, blockedSeq: () => this.#blockedSeq,
|
|
377
|
+
blockedNow: () => this.#blockedNow(), readFresh: () => this.#readDialog(true),
|
|
378
|
+
});
|
|
362
379
|
this.#commandSettle = new CommandDialogSettle({ pollMs: deps.modelConfirmPollMs ?? MODEL_CONFIRM_POLL_MS }, {
|
|
363
380
|
disposed: () => this.#disposed,
|
|
364
|
-
readScreen: () => this.#deps.client.readScreen(this.#paneId, 'detection').then((s) =>
|
|
381
|
+
readScreen: () => this.#deps.client.readScreen(this.#paneId, 'detection').then((s) => {
|
|
382
|
+
if (!this.#disposed)
|
|
383
|
+
this.#noteStartDialog(s.text);
|
|
384
|
+
return s.text;
|
|
385
|
+
}, () => null),
|
|
365
386
|
cliHold: () => this.#cliReserve.cliHold, blockedSeq: () => this.#blockedSeq,
|
|
366
387
|
sleep: (ms) => this.#sleep(ms), now: () => this.#scheduler.now(),
|
|
367
388
|
});
|
|
@@ -411,6 +432,22 @@ export class HerdrDriver {
|
|
|
411
432
|
screenText: () => this.#screenText, standing: () => this.#noHook.standing(),
|
|
412
433
|
keyHookWaits: () => this.#promptQueue.keyHookWaits(), pendingCallId: () => this.#pending?.id ?? null,
|
|
413
434
|
});
|
|
435
|
+
this.#live = new LiveDialogCards({
|
|
436
|
+
level: deps.dialogLive ?? 0, inScope: this.#inScope, scheduler: this.#scheduler, pollMs: this.#blockedPollMs,
|
|
437
|
+
graceMs: this.#debounceMs * 2, cliReserve: this.#cliReserve, startDialog: () => this.#startGate.standing(),
|
|
438
|
+
channelCard: (onError) => this.#consentChannel.consentCardStands(onError),
|
|
439
|
+
consentFacts: (toolUse, episode) => this.#screenFallback.liveFacts(toolUse, episode), engine: this.#engine,
|
|
440
|
+
}, {
|
|
441
|
+
disposed: () => this.#disposed, blocked: () => this.#blockedNow(), consentDialog: () => this.#consentDialog,
|
|
442
|
+
blockedAt: () => this.#blockedAt, activeReq: () => this.#activeReq, engineSession: () => this.#agentSessionId,
|
|
443
|
+
shielded: () => this.#answerShieldUp() || this.#decidedShield() !== null, readDialog: () => this.#readDialog(false),
|
|
444
|
+
emit: (live) => { this.#emit({ type: 'dialog-live', ...(live === null ? {} : { live }) }); },
|
|
445
|
+
audit: (fields) => { this.#audit({ method: 'live-card', ...fields }); }, evaluate: () => this.#evaluate(),
|
|
446
|
+
});
|
|
447
|
+
this.#liveStep = new LiveStep({
|
|
448
|
+
cards: this.#live, screenFallback: this.#screenFallback, settleMs: deps.escSettleMs ?? ESC_SETTLE_MS,
|
|
449
|
+
registryRead: deps.consentRegistryRead, engine: this.#engine,
|
|
450
|
+
}, this.#liveStepPort());
|
|
414
451
|
this.#promptQueue.restore(this.#engine === 'claude', () => ++this.#turnGuard.sendGeneration);
|
|
415
452
|
if (this.#follower !== null)
|
|
416
453
|
void this.#pumpFollower(this.#follower);
|
|
@@ -430,10 +467,10 @@ export class HerdrDriver {
|
|
|
430
467
|
cwd: this.#cwd, agentSessionId: handle.agent.agentSessionId,
|
|
431
468
|
})
|
|
432
469
|
: null;
|
|
433
|
-
//
|
|
470
|
+
// Session pull requests: the same scope gate, the main file only.
|
|
434
471
|
this.#pullRequests = createPullRequestPollState(this.#inScope
|
|
435
472
|
? (deps.pullRequestFiles ?? createPullRequestFilesReader)({
|
|
436
|
-
cwd: this.#cwd, agentSessionId: handle.agent.agentSessionId,
|
|
473
|
+
cwd: this.#cwd, agentSessionId: handle.agent.agentSessionId,
|
|
437
474
|
// Ten sam plik, który czyta follower: bez drugiego globu po magazynie i z jego relokacją.
|
|
438
475
|
locate: () => this.#follower?.transcriptOffset?.()?.file ?? null,
|
|
439
476
|
})
|
|
@@ -603,6 +640,10 @@ export class HerdrDriver {
|
|
|
603
640
|
const dialogStands = await this.#commandSettle.settle();
|
|
604
641
|
if (this.#disposed)
|
|
605
642
|
return;
|
|
643
|
+
// A start dialog takes no message, not even one parked to its end: a fresh read, not only the memory.
|
|
644
|
+
const startDialog = this.#startGate.inPhase() && await this.#startGate.refuses();
|
|
645
|
+
if (this.#startDialogHeld(echo, startDialog) || this.#disposed)
|
|
646
|
+
return;
|
|
606
647
|
/*
|
|
607
648
|
* Panel Claude w trakcie tury (albo z wiadomością, która już czeka, albo zaraz po Enterze takiej wiadomości,
|
|
608
649
|
* którego skutku driver jeszcze nie zna): wklejenie, sprawdzenie i osobny Enter
|
|
@@ -776,6 +817,7 @@ export class HerdrDriver {
|
|
|
776
817
|
disposed, paneId, agentSessionId, driverHold, consentCardStands, cliWaiting,
|
|
777
818
|
audit: (entry) => { this.#audit(entry); },
|
|
778
819
|
enqueue: (step) => this.#enqueue(step),
|
|
820
|
+
startDialogStands: () => this.#startGate.refuses(),
|
|
779
821
|
};
|
|
780
822
|
}
|
|
781
823
|
/** Port of the turn guard: driver state it reads and steps that stay in the facade. */
|
|
@@ -856,6 +898,30 @@ export class HerdrDriver {
|
|
|
856
898
|
this.#rearmAfterScreenAnswer(answered);
|
|
857
899
|
return true;
|
|
858
900
|
}
|
|
901
|
+
#liveStepPort() {
|
|
902
|
+
return {
|
|
903
|
+
...this.#layer2StepPort(), audit: (entry) => { this.#audit(entry); },
|
|
904
|
+
sendLiveKey: (key, entry) => this.#liveSendKey(key, entry),
|
|
905
|
+
noteRegistry: (signal) => { this.noteCliWaiting(signal); },
|
|
906
|
+
};
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* One key of the live dialog card: past the start gate and the pause gate (the live card shows the dialog as the
|
|
910
|
+
* terminal does), so not through `#send`. The attempt goes to the audit; a failure tells the transcript as any send.
|
|
911
|
+
*/
|
|
912
|
+
async #liveSendKey(key, entry) {
|
|
913
|
+
const { client } = this.#deps;
|
|
914
|
+
try {
|
|
915
|
+
await (key === 'escape' ? client.sendKeys(this.#paneId, [key]) : client.sendDialogKey(this.#paneId, key));
|
|
916
|
+
this.#audit(entry);
|
|
917
|
+
return 'sent';
|
|
918
|
+
}
|
|
919
|
+
catch (err) {
|
|
920
|
+
this.#audit(entry);
|
|
921
|
+
this.#reportSendError(err);
|
|
922
|
+
return herdrCode(err) === 'herdr-read-only' ? 'off' : 'failed';
|
|
923
|
+
}
|
|
924
|
+
}
|
|
859
925
|
/** Port of the two fallbacks: each module types only its own part, at most 14 members. */
|
|
860
926
|
#reservePort() {
|
|
861
927
|
return {
|
|
@@ -909,6 +975,18 @@ export class HerdrDriver {
|
|
|
909
975
|
this.#follower?.forgetEcho(echo);
|
|
910
976
|
this.#emit({ type: 'echo-refused', token: echo });
|
|
911
977
|
}
|
|
978
|
+
/** No key or text while a start dialog stands (`start-dialog-gate.ts`): the echo back and the sentence. */
|
|
979
|
+
#startDialogHeld(echo, held = this.#startGate.holds()) {
|
|
980
|
+
if (!held)
|
|
981
|
+
return false;
|
|
982
|
+
this.#refuseEcho(echo);
|
|
983
|
+
this.#system(START_DIALOG_REFUSED_MESSAGE);
|
|
984
|
+
return true;
|
|
985
|
+
}
|
|
986
|
+
/** A decision or an interrupt refused over a start dialog: the sentence, and the card judged again. */
|
|
987
|
+
#startDialogRefused(why) {
|
|
988
|
+
return this.#disposed ? STALE : refuseDecision(this.#refusals, START_DIALOG_REFUSED_MESSAGE, why, 'terminal-only');
|
|
989
|
+
}
|
|
912
990
|
/**
|
|
913
991
|
* Prompt z detekcją zawieszenia.
|
|
914
992
|
*
|
|
@@ -1003,6 +1081,8 @@ export class HerdrDriver {
|
|
|
1003
1081
|
}
|
|
1004
1082
|
/** Jedna próba `prompt` z `wait` + wpis dziennika; błędy inne niż stall lecą do transkryptu. */
|
|
1005
1083
|
async #promptAttempt(text, echo, source) {
|
|
1084
|
+
if (this.#startDialogHeld(echo))
|
|
1085
|
+
return 'failed';
|
|
1006
1086
|
try {
|
|
1007
1087
|
await this.#deps.client.prompt(this.#paneId, text, true);
|
|
1008
1088
|
this.#audit(promptEntry(text, source));
|
|
@@ -1046,6 +1126,7 @@ export class HerdrDriver {
|
|
|
1046
1126
|
}
|
|
1047
1127
|
if (this.#disposed)
|
|
1048
1128
|
return false;
|
|
1129
|
+
this.#noteStartDialog(screen);
|
|
1049
1130
|
return screenHoldsNeedle(screen, text);
|
|
1050
1131
|
}
|
|
1051
1132
|
/**
|
|
@@ -1113,12 +1194,16 @@ export class HerdrDriver {
|
|
|
1113
1194
|
// Po wyczerpaniu prób i tak piszemy: kolejne odmowy wyglądałyby jak martwy composer.
|
|
1114
1195
|
return true;
|
|
1115
1196
|
}
|
|
1197
|
+
/** A key of the live dialog card (`drivers/herdr/live-step.ts`); no card outside the work area or off Claude Code. */
|
|
1198
|
+
dialogKey(body) {
|
|
1199
|
+
return this.#liveStep.key(body);
|
|
1200
|
+
}
|
|
1116
1201
|
/**
|
|
1117
1202
|
* Decyzja o czekającym narzędziu.
|
|
1118
1203
|
*
|
|
1119
1204
|
* `deny` nie potrzebuje ani cyfr, ani zgodnego `reqId`: `escape` na dialogu zgody to odmowa, a odmowa nie daje
|
|
1120
1205
|
* narzędziu żadnego prawa. Esc nie wszędzie jest jednak tylko odmową: na dialogu zaufania katalogu zamyka
|
|
1121
|
-
* `claude` (pomiar na CLI 2.1.299), a na pauzie „Session paused” (
|
|
1206
|
+
* `claude` (pomiar na CLI 2.1.299), a na pauzie „Session paused” (`pause-gate.ts`) nie nazywa
|
|
1122
1207
|
* go żadna stopka, więc przy blokadzie pauzy decyduje świeży ekran. `allow` przechodzi tylko
|
|
1123
1208
|
* wtedy, gdy karta pochodzi z udanego cross-checku ekran ↔ jsonl i ma DOKŁADNIE jedną opcję
|
|
1124
1209
|
* „tak, ten jeden raz" — inaczej jest no-opem z wyjaśnieniem w transkrypcie.
|
|
@@ -1134,19 +1219,27 @@ export class HerdrDriver {
|
|
|
1134
1219
|
if (this.#disposed)
|
|
1135
1220
|
return Promise.resolve(STALE);
|
|
1136
1221
|
if (decision === 'deny') {
|
|
1137
|
-
// Bound to the card standing now, before the queue: a layer 2 card takes it only through its step
|
|
1222
|
+
// Bound to the card standing now, before the queue: a layer 2 card takes it only through its step, and a live
|
|
1223
|
+
// card's occurrence takes one key, from either path (a live key in flight refuses the deny).
|
|
1138
1224
|
const bound = this.#layer2Step.bindEscape(this.#activeReq);
|
|
1225
|
+
const liveBound = this.#liveStep.bindDeny();
|
|
1226
|
+
if (liveBound === null)
|
|
1227
|
+
return Promise.resolve(refused('in-flight'));
|
|
1139
1228
|
const step = this.#enqueue(async () => {
|
|
1140
1229
|
// Tryb cienia: plik cienia PRZED klawiszem, reszta kroku bez zmian (bez kanału `shadow` = `null`).
|
|
1141
1230
|
const shadow = this.#shadowChannel() === undefined ? null : await this.#shadowStep('deny', this.#activeReq);
|
|
1142
1231
|
// Jedyny wyjątek od „deny zawsze”: pauza „Session paused” — świeży ekran tuż przed klawiszem.
|
|
1143
|
-
const pause = await this.#pauseBlocksEscape();
|
|
1232
|
+
const pause = await this.#pauseGate.pauseBlocksEscape();
|
|
1144
1233
|
if (pause.blocks) {
|
|
1145
1234
|
this.#shadowKeySent(shadow, false);
|
|
1146
1235
|
if (this.#disposed)
|
|
1147
1236
|
return STALE;
|
|
1148
1237
|
return refuseDecision(this.#refusals, PAUSE_ESCAPE_MESSAGE, 'Esc na pauzie „Session paused”', 'terminal-only');
|
|
1149
1238
|
}
|
|
1239
|
+
if (this.#startGate.inPhase() && await this.#startGate.refuses(pause.text)) {
|
|
1240
|
+
this.#shadowKeySent(shadow, false);
|
|
1241
|
+
return this.#startDialogRefused('start dialog: Esc');
|
|
1242
|
+
}
|
|
1150
1243
|
if (this.#disposed) {
|
|
1151
1244
|
this.#shadowKeySent(shadow, false);
|
|
1152
1245
|
return STALE;
|
|
@@ -1157,8 +1250,9 @@ export class HerdrDriver {
|
|
|
1157
1250
|
this.#shadowKeySent(shadow, false);
|
|
1158
1251
|
return STALE;
|
|
1159
1252
|
}
|
|
1160
|
-
// The layer 2 occurrence bound above, or a layer 2 card issued since: never today's Esc below.
|
|
1161
|
-
|
|
1253
|
+
// The layer 2 occurrence bound above, or a layer 2 card issued since: never today's Esc below. The live
|
|
1254
|
+
// occurrence is used right before the Esc, with no `await` up to it.
|
|
1255
|
+
const layer2 = this.#layer2Step.escapeBound(bound) ?? this.#liveStep.denyKey(liveBound, pause.text);
|
|
1162
1256
|
if (layer2 !== null) {
|
|
1163
1257
|
this.#shadowKeySent(shadow, false);
|
|
1164
1258
|
return layer2;
|
|
@@ -1212,8 +1306,10 @@ export class HerdrDriver {
|
|
|
1212
1306
|
});
|
|
1213
1307
|
// `undefined` = krok wypadł z kolejki (driver zdążył pójść do `dispose`) — nie ma już
|
|
1214
1308
|
// czego odrzucać ani czego zdejmować, więc to jest `stale`, nie odmowa.
|
|
1215
|
-
return step.then((outcome) => outcome ?? STALE);
|
|
1309
|
+
return step.then((outcome) => this.#liveStep.release(liveBound, outcome ?? STALE));
|
|
1216
1310
|
}
|
|
1311
|
+
if (this.#startGate.holds())
|
|
1312
|
+
return Promise.resolve(this.#startDialogRefused('start dialog: approve'));
|
|
1217
1313
|
const active = this.#activeReq;
|
|
1218
1314
|
if (active === null)
|
|
1219
1315
|
return Promise.resolve(STALE);
|
|
@@ -1222,7 +1318,7 @@ export class HerdrDriver {
|
|
|
1222
1318
|
* to any `screen: true` card would land a hold started on a full consent card in the fallback card without
|
|
1223
1319
|
* options that replaced it, ending in "which option, unknown" instead of the truth.
|
|
1224
1320
|
*
|
|
1225
|
-
* Jedyny dozwolony rozjazd: adresowanie SESJĄ (`reqId` = id sesji,
|
|
1321
|
+
* Jedyny dozwolony rozjazd: adresowanie SESJĄ (`reqId` = id sesji, `decideHerdrDialog`)
|
|
1226
1322
|
* dla dialogu z zamkniętej listy sygnatur — taka karta nie ma wpisu w pending managera,
|
|
1227
1323
|
* więc nie ma własnego `reqId`, a `allow` filtruje już manager (`herdrDialog` musi stać).
|
|
1228
1324
|
* Każdy inny rozjazd to tapnięcie w kartę, której już nie ma — mówimy o tym GŁOŚNO,
|
|
@@ -1963,6 +2059,8 @@ export class HerdrDriver {
|
|
|
1963
2059
|
let verdict = await read(true);
|
|
1964
2060
|
if (verdict === null)
|
|
1965
2061
|
return STALE;
|
|
2062
|
+
if (this.#startGate.holds())
|
|
2063
|
+
return this.#startDialogRefused('start dialog: trust step');
|
|
1966
2064
|
if (!verdict.ok)
|
|
1967
2065
|
return refuse(verdict.reason);
|
|
1968
2066
|
const audit = {
|
|
@@ -2728,15 +2826,20 @@ export class HerdrDriver {
|
|
|
2728
2826
|
&& !this.#takeBack.holdsField());
|
|
2729
2827
|
/*
|
|
2730
2828
|
* "Session paused": Esc from the app keyboard with focus outside the card comes here, not through "Deny", and Esc
|
|
2731
|
-
* on the pause stays a refusal (
|
|
2829
|
+
* on the pause stays a refusal (`pause-gate.ts`): before any state change and after the field read above, so
|
|
2732
2830
|
* no read follows the gate before the key. `refuseDecision` restores the card the manager took at the interrupt.
|
|
2733
2831
|
*/
|
|
2734
|
-
|
|
2832
|
+
const pause = await this.#pauseGate.pauseBlocksEscape();
|
|
2833
|
+
if (pause.blocks) {
|
|
2735
2834
|
if (!this.#disposed) {
|
|
2736
2835
|
refuseDecision(this.#refusals, PAUSE_ESCAPE_MESSAGE, 'przerwanie: Esc na pauzie „Session paused”', 'terminal-only');
|
|
2737
2836
|
}
|
|
2738
2837
|
return false;
|
|
2739
2838
|
}
|
|
2839
|
+
if (this.#startGate.inPhase() && await this.#startGate.refuses(pause.text)) {
|
|
2840
|
+
this.#startDialogRefused('interrupt: start dialog');
|
|
2841
|
+
return false;
|
|
2842
|
+
}
|
|
2740
2843
|
/*
|
|
2741
2844
|
* Przerwanie unieważnia watchdog tury: pytanie „wysłane, a panel nie ruszył?" traci
|
|
2742
2845
|
* sens, gdy to człowiek świadomie ubił turę — bez tego watchdog umiał po karencji
|
|
@@ -3034,6 +3137,7 @@ export class HerdrDriver {
|
|
|
3034
3137
|
this.#turnGuard.clearWatchdog();
|
|
3035
3138
|
this.#consentChannel.dispose();
|
|
3036
3139
|
this.#noHook.dispose();
|
|
3140
|
+
this.#live.dispose();
|
|
3037
3141
|
stopTasks(this.#tasks, this.#scheduler);
|
|
3038
3142
|
if (this.#blockedTimer !== null) {
|
|
3039
3143
|
this.#scheduler.clearTimeout(this.#blockedTimer);
|
|
@@ -3256,7 +3360,8 @@ export class HerdrDriver {
|
|
|
3256
3360
|
return null;
|
|
3257
3361
|
this.#screenText = screen.text;
|
|
3258
3362
|
this.#screenAt = this.#scheduler.now();
|
|
3259
|
-
this.#notePause(screen.text);
|
|
3363
|
+
this.#pauseGate.notePause(screen.text);
|
|
3364
|
+
this.#noteStartDialog(screen.text);
|
|
3260
3365
|
return screen.text;
|
|
3261
3366
|
}
|
|
3262
3367
|
catch {
|
|
@@ -3266,46 +3371,13 @@ export class HerdrDriver {
|
|
|
3266
3371
|
}
|
|
3267
3372
|
}
|
|
3268
3373
|
/**
|
|
3269
|
-
*
|
|
3270
|
-
*
|
|
3271
|
-
* Esc zmierzono tylko na pauzie wywołanej atrapą API (CLI 2.1.322), bo prawdziwej pauzy nie wolno wywołać celowo
|
|
3272
|
-
* (to mechanizm bezpieczeństwa modelu), a pauza nie ma stopki, która by go nazywała. Dlatego „Odrzuć" i przerwanie
|
|
3273
|
-
* nie wysyłają na nią klawisza.
|
|
3274
|
-
*
|
|
3275
|
-
* Ekran czytamy ŚWIEŻO, tuż przed klawiszem (`#readDialog(true)` — ten sam ekran trafia do zrzutu odmowy),
|
|
3276
|
-
* przy każdej blokadzie (`#blockedNow`): karta i ostatni odczyt nie dowodzą, że pauzy nie ma — dialog
|
|
3277
|
-
* potrafi się podmienić w miejscu, zanim ocena przeczyta ekran. Bez blokady
|
|
3278
|
-
* i bez podejrzenia Esc idzie jak dotąd, bez odczytu (przerwanie zwykłej tury). Podejrzenie pauzy to karta
|
|
3279
|
-
* pauzy albo ślad pauzy z odczytu w tej blokadzie (`#pauseSeq`, przeżywa odmowę i zgaszoną kartę).
|
|
3280
|
-
* Odmowa, gdy:
|
|
3281
|
-
* - pauza stoi na świeżym ekranie (`sessionPausedDialog` — każdy wariant, także spoza listy);
|
|
3282
|
-
* - przy podejrzeniu: odczyt się nie udał albo ekran nie pokazuje żadnego dialogu (przemalowanie) —
|
|
3283
|
-
* nie wiadomo, czy pauza zeszła.
|
|
3284
|
-
* Inny czytelny dialog = pauza zeszła (ślad gaśnie w `#notePause`), Esc idzie jak dotąd.
|
|
3285
|
-
*
|
|
3286
|
-
* @returns `blocks` = odmowa; `text` = świeży ekran tej bramki (`null` bez odczytu albo po nieudanym), z którego
|
|
3287
|
-
* „Odrzuć” po klawiszu poznaje zamknięty dialog (`#clearHookAfterDecision`)
|
|
3288
|
-
*/
|
|
3289
|
-
async #pauseBlocksEscape() {
|
|
3290
|
-
const suspected = this.#activeReq?.terminalDialog === SESSION_PAUSED_DIALOG
|
|
3291
|
-
|| (this.#pauseSeq === this.#blockedSeq && this.#blockedNow());
|
|
3292
|
-
if (!suspected && !this.#blockedNow())
|
|
3293
|
-
return { blocks: false, text: null };
|
|
3294
|
-
const text = await this.#readDialog(true);
|
|
3295
|
-
if (text === null)
|
|
3296
|
-
return { blocks: suspected, text: null };
|
|
3297
|
-
const fresh = parseOptions(text);
|
|
3298
|
-
return { blocks: fresh === null ? suspected : sessionPausedDialog(fresh), text };
|
|
3299
|
-
}
|
|
3300
|
-
/**
|
|
3301
|
-
* Ślad pauzy z KAŻDEGO odczytu ekranu dialogu (`#pauseSeq`): pauza zapisuje numer blokady, inny czytelny
|
|
3302
|
-
* dialog go zdejmuje, ekran bez dialogu (przemalowanie, odczyt w pół klatki) zostawia go bez zmian.
|
|
3374
|
+
* A successful `detection` read for the start dialog gate: every dialog read and every read of a gate before a key
|
|
3375
|
+
* or text, so the gate's last synchronous check before the client call judges the newest screen.
|
|
3303
3376
|
*/
|
|
3304
|
-
#
|
|
3305
|
-
|
|
3306
|
-
if (
|
|
3307
|
-
|
|
3308
|
-
this.#pauseSeq = sessionPausedDialog(dialog) ? this.#blockedSeq : null;
|
|
3377
|
+
#noteStartDialog(text) {
|
|
3378
|
+
// A start dialog standing up after an own answer is the next dialog, not the repaint of the answered one.
|
|
3379
|
+
if (this.#startGate.note(text) && this.#answeredSeq === this.#blockedSeq)
|
|
3380
|
+
this.#blockedSeq += 1;
|
|
3309
3381
|
}
|
|
3310
3382
|
/** Whether {@link #readDialog} without `force` returns the screen cache instead of reading. */
|
|
3311
3383
|
#screenCached() {
|
|
@@ -3439,12 +3511,7 @@ export class HerdrDriver {
|
|
|
3439
3511
|
scheduler: this.#scheduler,
|
|
3440
3512
|
pollMs: this.#tasksPollMs,
|
|
3441
3513
|
disposed: () => this.#disposed,
|
|
3442
|
-
emit: (tasks) => {
|
|
3443
|
-
this.#emit({ type: 'background-tasks', tasks });
|
|
3444
|
-
// Zmiana listy zadań (start albo koniec agenta, rozkład workflow) bywa jedynym znakiem pracy, gdy plik
|
|
3445
|
-
// główny milczy: agent mógł właśnie utworzyć PR we własnym pliku.
|
|
3446
|
-
this.#schedulePullRequests();
|
|
3447
|
-
},
|
|
3514
|
+
emit: (tasks) => { this.#emit({ type: 'background-tasks', tasks }); },
|
|
3448
3515
|
};
|
|
3449
3516
|
}
|
|
3450
3517
|
/** Contact with `drivers/herdr/pull-request-poll.ts`, built at every call, like `#tasksDeps`. */
|
|
@@ -3452,7 +3519,9 @@ export class HerdrDriver {
|
|
|
3452
3519
|
return {
|
|
3453
3520
|
scheduler: this.#scheduler,
|
|
3454
3521
|
disposed: () => this.#disposed,
|
|
3455
|
-
emit: (
|
|
3522
|
+
emit: ({ linked, windowStart }) => {
|
|
3523
|
+
this.#emit({ type: 'pull-requests', pullRequests: linked, ...(windowStart === null ? {} : { windowStart }) });
|
|
3524
|
+
},
|
|
3456
3525
|
};
|
|
3457
3526
|
}
|
|
3458
3527
|
/** Contact with `drivers/herdr/scheduled-task-poll.ts`, built at every call. */
|
|
@@ -3507,11 +3576,15 @@ export class HerdrDriver {
|
|
|
3507
3576
|
*/
|
|
3508
3577
|
if (event.type === 'tasks') {
|
|
3509
3578
|
noteTasks(this.#tasks, this.#tasksDeps, event);
|
|
3579
|
+
return;
|
|
3580
|
+
}
|
|
3581
|
+
// A pull request link entry: only a read signal. Not a sign of file life (no turn watchdog, no send guard).
|
|
3582
|
+
if (event.type === 'pull-request-entry') {
|
|
3510
3583
|
this.#schedulePullRequests();
|
|
3511
3584
|
return;
|
|
3512
3585
|
}
|
|
3513
3586
|
this.#lastFollowAt = this.#scheduler.now();
|
|
3514
|
-
//
|
|
3587
|
+
// The main file grew: it may hold a PR link entry or the first timed entry (the conversation window).
|
|
3515
3588
|
this.#schedulePullRequests();
|
|
3516
3589
|
crons.scheduleScheduledTasks(this.#crons, this.#cronsDeps);
|
|
3517
3590
|
resetPulseEcho(this.#pulseEcho);
|
|
@@ -3529,13 +3602,14 @@ export class HerdrDriver {
|
|
|
3529
3602
|
return;
|
|
3530
3603
|
}
|
|
3531
3604
|
case 'message': {
|
|
3532
|
-
const { commandOutput, ...message } = event;
|
|
3605
|
+
const { commandOutput, peer, ...message } = event;
|
|
3533
3606
|
// Wpis `user` z pliku (prompt przy Macu, wstrzymane echo, notka harnessu): pole nie trzyma już
|
|
3534
|
-
// zablokowanego promptu pewnie.
|
|
3535
|
-
|
|
3607
|
+
// zablokowanego promptu pewnie. A bubble from another session was typed into no field: it ends nothing there.
|
|
3608
|
+
const typed = event.role === 'user' && peer !== true;
|
|
3609
|
+
if (typed)
|
|
3536
3610
|
this.#turnGuard.blockedLeftover = null;
|
|
3537
3611
|
this.#returnedPrompt.noteFile([event]);
|
|
3538
|
-
if (
|
|
3612
|
+
if (typed && (this.#promptQueue.heldLeftover !== null || this.#promptQueue.submitted !== null)) {
|
|
3539
3613
|
const sent = squashWhitespace(event.blocks.map((block) => (block.type === 'text' ? block.text.text : '')).join(''));
|
|
3540
3614
|
// Pozostałość wstrzymanego promptu albo wiadomości z kolejki wysłana: pole już jej nie trzyma.
|
|
3541
3615
|
if (sent === this.#promptQueue.heldLeftover)
|
|
@@ -3547,7 +3621,8 @@ export class HerdrDriver {
|
|
|
3547
3621
|
// Wiadomość z kolejki wklejeń stoi w pliku bez Entera Raroga: wpis kolejki się kończy.
|
|
3548
3622
|
if (event.echoToken !== undefined)
|
|
3549
3623
|
this.#promptQueue.noteQueuedEcho(event.echoToken);
|
|
3550
|
-
|
|
3624
|
+
// The mark of a message from another session reaches the manager as server-only `notFromOwner`.
|
|
3625
|
+
this.#emit(peer === true ? { ...message, notFromOwner: true } : message);
|
|
3551
3626
|
// Najpierw notka z wynikiem, potem stan: na telefonie wynik stoi, zanim sesja wróci do „czeka”.
|
|
3552
3627
|
if (commandOutput !== undefined)
|
|
3553
3628
|
this.#turnGuard.noteCommandOutput(commandOutput);
|
|
@@ -3655,6 +3730,7 @@ export class HerdrDriver {
|
|
|
3655
3730
|
do {
|
|
3656
3731
|
this.#evaluateAgain = false;
|
|
3657
3732
|
await this.#evaluateOnce();
|
|
3733
|
+
await this.#live.observe();
|
|
3658
3734
|
} while (this.#evaluateAgain && !this.#disposed);
|
|
3659
3735
|
}
|
|
3660
3736
|
finally {
|
|
@@ -3959,6 +4035,7 @@ export class HerdrDriver {
|
|
|
3959
4035
|
// Through the grace of a dialog without a hook trace the card waits too; the judgement orders the evaluation.
|
|
3960
4036
|
if (this.#consentChannel.consentCardWait() || this.#screenFallback.waits(card)) {
|
|
3961
4037
|
this.#undecided = null;
|
|
4038
|
+
this.#live.cardHeld(card.active);
|
|
3962
4039
|
return;
|
|
3963
4040
|
}
|
|
3964
4041
|
}
|
|
@@ -3969,7 +4046,9 @@ export class HerdrDriver {
|
|
|
3969
4046
|
? { active: card.active, cliDialog: 'cliDialog' in event ? event.cliDialog ?? null : null }
|
|
3970
4047
|
: null;
|
|
3971
4048
|
this.#noHook.cardShown(card, event);
|
|
4049
|
+
this.#live.cardShown(card.active, event);
|
|
3972
4050
|
this.#emit(event);
|
|
4051
|
+
this.#startGate.cardShown();
|
|
3973
4052
|
this.#auditBlockCard(card.active);
|
|
3974
4053
|
}
|
|
3975
4054
|
/**
|
|
@@ -4050,6 +4129,7 @@ export class HerdrDriver {
|
|
|
4050
4129
|
}
|
|
4051
4130
|
if (this.#disposed)
|
|
4052
4131
|
return false;
|
|
4132
|
+
this.#noteStartDialog(text);
|
|
4053
4133
|
onScreen?.(text);
|
|
4054
4134
|
const dialog = standingConsentDialog(text);
|
|
4055
4135
|
await this.#noteConsentDialog(dialog, text);
|
|
@@ -4080,7 +4160,7 @@ export class HerdrDriver {
|
|
|
4080
4160
|
// (`refusalDump`) bierze go stamtąd.
|
|
4081
4161
|
this.#screenText = screen;
|
|
4082
4162
|
this.#screenAt = this.#scheduler.now();
|
|
4083
|
-
this.#notePause(screen);
|
|
4163
|
+
this.#pauseGate.notePause(screen);
|
|
4084
4164
|
text = screen;
|
|
4085
4165
|
}
|
|
4086
4166
|
if (this.#disposed || this.#consentDialog !== dialog)
|
|
@@ -4141,7 +4221,7 @@ export class HerdrDriver {
|
|
|
4141
4221
|
* @returns `true`, gdy wywołanie się powiodło.
|
|
4142
4222
|
*/
|
|
4143
4223
|
async #send(call, entry, op = 'message', echo) {
|
|
4144
|
-
if (this.#disposed)
|
|
4224
|
+
if (this.#disposed || this.#startDialogHeld(echo))
|
|
4145
4225
|
return false;
|
|
4146
4226
|
try {
|
|
4147
4227
|
await call();
|
|
@@ -4309,6 +4389,7 @@ export class HerdrDriver {
|
|
|
4309
4389
|
record.layer2Key = entry.layer2Key;
|
|
4310
4390
|
if (entry.layer2Outcome !== undefined)
|
|
4311
4391
|
record.layer2Outcome = entry.layer2Outcome;
|
|
4392
|
+
Object.assign(record, pickLiveFields(entry));
|
|
4312
4393
|
try {
|
|
4313
4394
|
this.#deps.audit.log(record);
|
|
4314
4395
|
}
|
|
@@ -4378,6 +4459,7 @@ export class HerdrDriver {
|
|
|
4378
4459
|
if (mapped.detail !== undefined)
|
|
4379
4460
|
event.detail = mapped.detail;
|
|
4380
4461
|
this.#emit(event);
|
|
4462
|
+
this.#live.stateSent(mapped.state);
|
|
4381
4463
|
}
|
|
4382
4464
|
/** Notka `system` w transkrypcie; tekst Raroga, więc zdanie z rejestru (`say`). */
|
|
4383
4465
|
#system(text) {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { FILES_BAD_PATH_ERROR, FILES_CODEX_ERROR, FILES_NOT_FOUND_ERROR, FILES_OUT_OF_SCOPE_ERROR, FILE_TOO_LARGE_ERROR, } from '@rarog/shared';
|
|
7
7
|
import { say } from '@rarog/shared/sentences';
|
|
8
|
+
import { STATE_ONLY_REFUSALS } from '../herdr/engines.js';
|
|
8
9
|
/** The path failed the shape check; the same sentence as a bad path of the diff routes. */
|
|
9
10
|
export const BAD_PATH = { status: 400, code: FILES_BAD_PATH_ERROR, sentence: say('rest.diff-bad-path') };
|
|
10
11
|
/** Nothing to list or send under the path, or the server never shows it: one answer, so it tells nothing apart. */
|
|
@@ -25,8 +26,14 @@ const CLOSED = new WeakSet();
|
|
|
25
26
|
export function isClosedFolder(refusal) {
|
|
26
27
|
return CLOSED.has(refusal);
|
|
27
28
|
}
|
|
28
|
-
/**
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* An entry of a state-only engine: Rarog only observes it. The wire code is `codex` for every such engine, so an app
|
|
31
|
+
* build that decodes a newer engine as unknown still turns the session to its fallback source; the sentence names
|
|
32
|
+
* the engine.
|
|
33
|
+
*/
|
|
34
|
+
export function stateOnly(engine) {
|
|
35
|
+
return { status: 400, code: FILES_CODEX_ERROR, sentence: STATE_ONLY_REFUSALS[engine].files };
|
|
36
|
+
}
|
|
30
37
|
/** A pane outside the work area, or a session directory outside it on disk. */
|
|
31
38
|
export const OUT_OF_SCOPE = {
|
|
32
39
|
status: 400, code: FILES_OUT_OF_SCOPE_ERROR, sentence: say('rest.files-out-of-scope'),
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
import { homedir } from 'node:os';
|
|
9
9
|
import { inWorkAreaOnDisk, onDiskForms, resolveInWorkArea } from '../config/work-area.js';
|
|
10
10
|
import { FILES_DISK } from './path-rule.js';
|
|
11
|
-
import {
|
|
11
|
+
import { NOT_FOUND, NO_PANE, OUT_OF_SCOPE, closedFolder, stateOnly } from './refusals.js';
|
|
12
|
+
import { isStateOnlyEngine } from '../herdr/engines.js';
|
|
12
13
|
/**
|
|
13
14
|
* The area of the session directory `cwd`: refused when `cwd` lies outside the work area as written or on disk
|
|
14
15
|
* (`out-of-scope`), when the way to it passes a guarded folder that a root opens and the folder gate holds closed
|
|
@@ -34,14 +35,14 @@ export function filesArea(cwd, config, disk = FILES_DISK.area) {
|
|
|
34
35
|
return { ok: true, value: { cwd, realCwd, roots, realRoots: real.roots, home, realHome: real.home } };
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
37
|
-
* The gate of both file routes. An unknown session throws the manager's 404 (`port.require`). A
|
|
38
|
+
* The gate of both file routes. An unknown session throws the manager's 404 (`port.require`). A state-only entry and a
|
|
38
39
|
* pane out of scope are refused before the demo branch, as in the diff gate; the demo has no directories, so a demo
|
|
39
40
|
* session passes without a pane; any other session without a herdr pane is refused.
|
|
40
41
|
*/
|
|
41
42
|
export function filesSession(id, port, disk = FILES_DISK.area) {
|
|
42
43
|
const session = port.require(id);
|
|
43
|
-
if (session.engine
|
|
44
|
-
return { kind: 'refused', refusal:
|
|
44
|
+
if (isStateOnlyEngine(session.engine))
|
|
45
|
+
return { kind: 'refused', refusal: stateOnly(session.engine) };
|
|
45
46
|
if (session.outOfScope === true)
|
|
46
47
|
return { kind: 'refused', refusal: OUT_OF_SCOPE };
|
|
47
48
|
if (port.config.demo)
|