gentle-pi 4.6.0 → 4.7.0
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/README.md +10 -11
- package/assets/agents/gentle-ai-explore.md +1 -0
- package/assets/agents/gentle-ai-verify.md +5 -2
- package/assets/agents/gentle-ai-worker.md +3 -0
- package/assets/agents/jd-fix-agent.md +1 -0
- package/assets/agents/jd-judge-a.md +1 -0
- package/assets/agents/jd-judge-b.md +1 -0
- package/assets/design-canvas/canvas.css +13 -1
- package/assets/design-canvas/canvas.js +11 -2
- package/assets/install-wizard/wizard.js +1 -0
- package/assets/migrations/agent-body-history.json +16 -1
- package/assets/orchestrator-delegation-reference.md +4 -4
- package/assets/orchestrator-delegation.md +1 -1
- package/assets/orchestrator-full-delegation-card.md +65 -0
- package/assets/orchestrator-full-delegation.md +34 -0
- package/assets/orchestrator-memory.md +3 -3
- package/assets/orchestrator-prompts.md +1 -1
- package/assets/orchestrator-skills.md +1 -1
- package/assets/orchestrator-verification.md +7 -5
- package/assets/orchestrator.md +3 -3
- package/bin/gentle-shell.mjs +164 -56
- package/docs/agent-status.md +61 -0
- package/docs/bundled-install.md +7 -5
- package/docs/delegated-verification.md +29 -7
- package/docs/gentle-agents-activity.md +14 -0
- package/docs/gentle-shell.md +54 -16
- package/docs/install-wizard.md +1 -1
- package/docs/permission-modes.md +9 -4
- package/docs/readme-reference.md +75 -30
- package/docs/render-cache-performance.md +11 -1
- package/docs/review-coordinator.md +33 -0
- package/docs/review-request-context.md +19 -0
- package/docs/review-windows-acl.md +18 -0
- package/docs/voice.md +6 -3
- package/docs/yolo-mode.md +5 -5
- package/extensions/ask-user-choice.ts +1 -0
- package/extensions/ask-user-question.ts +1 -0
- package/extensions/child-safety.ts +3 -0
- package/extensions/gentle-agent-status.ts +99 -0
- package/extensions/gentle-agents.ts +326 -34
- package/extensions/gentle-ai.ts +1496 -454
- package/extensions/gentle-shell.ts +293 -63
- package/extensions/gentle-todo.ts +18 -2
- package/extensions/gentle-tps.ts +48 -0
- package/extensions/quiet-tools.ts +38 -8
- package/extensions/skill-registry.ts +175 -18
- package/extensions/startup-banner.ts +30 -3
- package/lib/agent-profile-pin.ts +3 -3
- package/lib/agent-profiles.ts +160 -2
- package/lib/agent-status.ts +105 -0
- package/lib/agents-config.ts +46 -0
- package/lib/agents-history.ts +24 -5
- package/lib/agents-messaging.ts +47 -5
- package/lib/agents-runner.ts +183 -12
- package/lib/auto-permission-runtime.ts +1 -1
- package/lib/bounded-writer-admission.ts +13 -1
- package/lib/card-content-policy.ts +8 -6
- package/lib/command-palette.ts +133 -17
- package/lib/context-backstop.ts +14 -5
- package/lib/destructive-command-guard.ts +48 -4
- package/lib/execution-surface-guard.ts +20 -0
- package/lib/exploration-budget.ts +4 -2
- package/lib/gentle-ai-binary.ts +1 -1
- package/lib/gentle-design.ts +3 -0
- package/lib/gentle-shell-bundled.ts +6 -19
- package/lib/gentle-shell-launcher.ts +43 -8
- package/lib/herdr-activity.ts +14 -2
- package/lib/herdr-busy.ts +45 -0
- package/lib/image-attachments.ts +33 -0
- package/lib/image-disk-cache.ts +137 -0
- package/lib/inprocess-reviewer.ts +270 -140
- package/lib/jobs-view.ts +198 -11
- package/lib/model-routing-authority.ts +22 -4
- package/lib/native-choice-list.ts +20 -2
- package/lib/native-review-cli.ts +96 -19
- package/lib/orchestrator-mode-policy.ts +105 -0
- package/lib/questionnaire/questionnaire-view.ts +105 -12
- package/lib/rdd-mode-control.ts +32 -0
- package/lib/reply-language-anchor.ts +104 -0
- package/lib/review-blocker.ts +92 -0
- package/lib/review-candidate-symlink-scan.ts +136 -0
- package/lib/review-candidate-view-owner.ts +81 -44
- package/lib/review-continuation-registry.ts +99 -0
- package/lib/review-coordinator.ts +163 -0
- package/lib/review-failure-facts.ts +49 -0
- package/lib/review-host-relay.ts +46 -10
- package/lib/review-integration-v2.ts +7 -1
- package/lib/review-relay-phase-timing.ts +45 -0
- package/lib/review-start-context.ts +17 -0
- package/lib/session-profile-freeze.ts +4 -2
- package/lib/shell-bar.ts +140 -58
- package/lib/shell-changes.ts +2 -0
- package/lib/shell-panel.ts +17 -3
- package/lib/shell-sidebar-layout.ts +112 -40
- package/lib/shell-sidebar.ts +7 -0
- package/lib/shell-todo.ts +10 -3
- package/lib/verifier-admission.ts +1 -1
- package/lib/visual-customization-policy.ts +36 -16
- package/lib/visual-customize-view.ts +216 -21
- package/lib/visual-layout-preview.ts +9 -5
- package/lib/visual-profiles.ts +2 -2
- package/lib/windows-session-transport.ts +53 -2
- package/lib/yolo-session-policy.ts +40 -15
- package/package.json +2 -1
- package/runtime/gentle-ai-binary.mjs +1 -1
- package/runtime/gentle-shell-bundled.mjs +6 -19
- package/runtime/gentle-shell-launcher.mjs +42 -7
- package/runtime/native-review-cli.mjs +93 -16
- package/runtime/review-integration-v2.mjs +7 -1
- package/scripts/build-full-delegation-card.mjs +175 -0
- package/scripts/bundled-install.mjs +38 -8
- package/scripts/download-progress.mjs +68 -0
- package/scripts/gentle-ai-installer.mjs +41 -18
- package/scripts/gentle-ai-proxy.mjs +294 -0
- package/scripts/install-gentle-ai.mjs +14 -1
- package/scripts/installer-preflight.mjs +5 -5
- package/scripts/installer-runner.mjs +27 -12
- package/scripts/installer-server.mjs +8 -7
- package/scripts/render-cache-host.mjs +72 -0
- package/scripts/render-cache-performance-worker.mjs +5 -4
- package/scripts/render-cache-performance.mjs +6 -1
- package/scripts/run-test-suite.mjs +40 -28
- package/scripts/verify-package-files.mjs +12 -2
- package/scripts/voice-worker.cjs +32 -6
- package/skills/design/SKILL.md +11 -8
- package/skills/gentle-ai/SKILL.md +2 -2
- package/skills/gentle-ui-design/SKILL.md +46 -0
- package/skills/gentle-ui-design/references/adaptive-interfaces.md +46 -0
- package/skills/gentle-ui-design/references/browse-and-compare.md +62 -0
- package/skills/gentle-ui-design/references/composition-and-feedback.md +56 -0
- package/skills/gentle-ui-design/references/task-and-content.md +60 -0
- package/skills/skill-registry/SKILL.md +4 -2
- package/skills/work-unit-commits/SKILL.md +6 -7
- package/tests/agent-home.test.ts +28 -9
- package/tests/agent-profiles-workflow.test.ts +163 -0
- package/tests/agent-risk-escalation.test.ts +1 -1
- package/tests/agent-status.test.ts +143 -0
- package/tests/agents-config.test.ts +96 -0
- package/tests/agents-history.test.ts +31 -0
- package/tests/agents-jobs-frames.test.ts +93 -0
- package/tests/agents-prompt-lifecycle-runtime.test.ts +376 -0
- package/tests/agents-runner-drain.test.ts +193 -0
- package/tests/agents-runner.test.ts +178 -2
- package/tests/append-system-prompt-route.test.ts +4 -1
- package/tests/ask-user-choice.test.ts +4 -3
- package/tests/ask-user-question.test.ts +97 -0
- package/tests/auto-permission-runtime.test.ts +1 -1
- package/tests/autonomous-guard.test.ts +346 -10
- package/tests/bounded-stop-contract.test.ts +43 -3
- package/tests/bridge-cost.test.ts +19 -4
- package/tests/bundled-install.test.ts +30 -5
- package/tests/card-content-policy.test.ts +3 -3
- package/tests/chained-pr-skill.test.ts +8 -6
- package/tests/child-safety.test.ts +11 -0
- package/tests/codegraph-tools.test.ts +11 -5
- package/tests/command-palette.test.ts +284 -1
- package/tests/delegate-for-reason-contract.test.ts +3 -3
- package/tests/design-canvas-assets.test.ts +185 -2
- package/tests/destructive-command-guard.test.ts +52 -0
- package/tests/download-progress.test.ts +71 -0
- package/tests/execution-surface-guard.test.ts +55 -0
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +9 -5
- package/tests/fixtures/proxy-tls/proxy.crt +19 -0
- package/tests/fixtures/proxy-tls/proxy.key +28 -0
- package/tests/fixtures/session-profile-v1/gentle-ai-reviewer.ts +89 -0
- package/tests/fixtures/session-profile-v1/replay.ts +53 -6
- package/tests/full-delegation-closure.test.ts +131 -0
- package/tests/full-delegation-notices.test.ts +76 -0
- package/tests/generic-agent-tools.test.ts +3 -3
- package/tests/gentle-agent-status.test.ts +74 -0
- package/tests/gentle-agents-child-jobs.test.ts +237 -0
- package/tests/gentle-agents.test.ts +1070 -12
- package/tests/gentle-ai-binary.test.ts +3 -1
- package/tests/gentle-ai-elapsed-store.test.ts +19 -0
- package/tests/gentle-ai-exploration-budget.test.ts +18 -2
- package/tests/gentle-ai-installer.test.ts +134 -51
- package/tests/gentle-ai-proxy.test.ts +434 -0
- package/tests/gentle-ai.test.ts +113 -38
- package/tests/gentle-design.test.ts +21 -0
- package/tests/gentle-herdr-activity.test.ts +9 -6
- package/tests/gentle-shell-bin.test.ts +123 -0
- package/tests/gentle-shell-bundled.test.ts +207 -31
- package/tests/gentle-shell-launcher.test.ts +77 -10
- package/tests/gentle-shell.test.ts +899 -59
- package/tests/gentle-todo.test.ts +19 -2
- package/tests/gentle-tps.test.ts +123 -0
- package/tests/gentle-ui-design-skill.test.ts +59 -0
- package/tests/herdr-busy.test.ts +59 -0
- package/tests/herdr-task-summary-policy.test.ts +8 -4
- package/tests/image-disk-cache.test.ts +163 -0
- package/tests/independent-recovery-delivery.test.ts +83 -0
- package/tests/inprocess-reviewer.test.ts +176 -4
- package/tests/installer-posix-bootstrap.test.ts +1 -1
- package/tests/installer-preflight.test.ts +5 -4
- package/tests/installer-runner.test.ts +79 -44
- package/tests/installer-server.test.ts +14 -11
- package/tests/jobs-view.test.ts +260 -6
- package/tests/modal-mouse-boundaries.test.ts +136 -0
- package/tests/model-routing-authority.test.ts +178 -2
- package/tests/native-choice-list.test.ts +77 -2
- package/tests/native-review-capability-contract.test.ts +7 -1
- package/tests/native-review-cli.test.ts +269 -1
- package/tests/no-self-pause-contract.test.ts +4 -1
- package/tests/odd-routing-canonical-ratchet.test.ts +3 -3
- package/tests/orchestrator-budget.test.ts +7 -2
- package/tests/orchestrator-delegation-mode.test.ts +153 -0
- package/tests/orchestrator-mode-policy.test.ts +175 -0
- package/tests/orchestrator-prompt-budget.test.ts +3 -1
- package/tests/orchestrator-rdd-ownership.test.ts +2 -2
- package/tests/package-manifest.test.ts +11 -9
- package/tests/permission-allowlist.test.ts +202 -0
- package/tests/pi-update-launcher.test.ts +8 -0
- package/tests/pnpm-workspace-config.test.ts +58 -0
- package/tests/primary-session-prompt.test.ts +13 -0
- package/tests/profile-pin.test.ts +29 -2
- package/tests/profile-tier-footer.test.ts +5 -0
- package/tests/profiles-panel-delegation-mode.test.ts +422 -0
- package/tests/questionnaire-view.test.ts +115 -0
- package/tests/quiet-bash-runtime.test.ts +1 -1
- package/tests/quiet-tool-rendering.test.ts +48 -0
- package/tests/rdd-aware-verification-contract.test.ts +16 -11
- package/tests/rdd-customize.test.ts +287 -0
- package/tests/rdd-mode-cache.test.ts +450 -0
- package/tests/rdd-mode-control.test.ts +407 -0
- package/tests/rdd-mode-scope-regression.test.ts +137 -0
- package/tests/rdd-off-independent-regression.test.ts +69 -0
- package/tests/rdd-status-line.test.ts +18 -0
- package/tests/render-cache-performance.test.ts +171 -2
- package/tests/reply-language-anchor.test.ts +173 -0
- package/tests/review-agent-end-preflight.test.ts +1 -1
- package/tests/review-blocker.test.ts +193 -0
- package/tests/review-candidate-owner-retry.test.ts +1 -1
- package/tests/review-candidate-symlink-scan.test.ts +157 -0
- package/tests/review-candidate-view.test.ts +1 -1
- package/tests/review-candidate-windows-boundary.test.ts +131 -0
- package/tests/review-candidate-windows-probe.test.ts +63 -0
- package/tests/review-committed-restart-ack.test.ts +129 -0
- package/tests/review-continuation-registry.test.ts +76 -0
- package/tests/review-controller-native-routing.test.ts +261 -5
- package/tests/review-controller-workspace-root.test.ts +230 -3
- package/tests/review-controller.test.ts +96 -11
- package/tests/review-coordinator-runtime.test.ts +117 -0
- package/tests/review-coordinator.test.ts +195 -0
- package/tests/review-failure-facts.test.ts +87 -0
- package/tests/review-host-relay-routing.test.ts +258 -4
- package/tests/review-host-relay.test.ts +39 -0
- package/tests/review-integration-v2.test.ts +46 -3
- package/tests/review-json-arguments.test.ts +65 -10
- package/tests/review-last-event-closure.test.ts +68 -0
- package/tests/review-loadout-rdd-off-sdk.test.ts +65 -31
- package/tests/review-owner-identity.test.ts +60 -24
- package/tests/review-relay-phase-timing.test.ts +128 -0
- package/tests/review-relay-transport-agent.test.ts +12 -2
- package/tests/review-reviewer-evidence.test.ts +183 -0
- package/tests/review-risk-assessment.test.ts +74 -3
- package/tests/review-session-standing-permission-controller.test.ts +21 -1
- package/tests/review-start-context.test.ts +19 -0
- package/tests/review-tool-prose-budget.test.ts +121 -0
- package/tests/run-test-suite.test.ts +122 -1
- package/tests/runtime-harness.mjs +4 -1
- package/tests/sensitive-path-tools.test.ts +181 -5
- package/tests/session-profile-append-controller-pi.test.ts +60 -31
- package/tests/session-profile-binding.test.ts +19 -1
- package/tests/session-profile-disk-reader-pi.test.ts +58 -16
- package/tests/session-profile-v1-compat.test.ts +35 -1
- package/tests/shell-bar.test.ts +186 -42
- package/tests/shell-panel.test.ts +50 -22
- package/tests/shell-sidebar-fullscreen.test.ts +5 -5
- package/tests/shell-sidebar-layout.test.ts +294 -23
- package/tests/shell-sidebar-scroll-benchmark.test.ts +1 -1
- package/tests/shell-surface-transparent.test.ts +89 -0
- package/tests/shell-todo.test.ts +12 -0
- package/tests/skill-registry.test.ts +838 -5
- package/tests/startup-banner.test.ts +152 -1
- package/tests/startup-home-repo.test.ts +2 -0
- package/tests/support/review-coordinator-runtime.ts +69 -0
- package/tests/task-size-routing-contract.test.ts +5 -3
- package/tests/verifier-admission.test.ts +49 -0
- package/tests/verify-first-launch-contract.test.ts +78 -3
- package/tests/visual-customization-policy.test.ts +39 -6
- package/tests/visual-customize-view.test.ts +573 -9
- package/tests/visual-layout-preview.test.ts +15 -1
- package/tests/visual-profiles.test.ts +11 -0
- package/tests/voice-worker.test.ts +73 -2
- package/tests/windows-session-transport.test.ts +126 -0
- package/tests/work-continuity-contract.test.ts +28 -0
- package/tests/writer-feature-document-admission.test.ts +92 -0
- package/tests/yolo-customize.test.ts +27 -4
- package/tests/yolo-mode.test.ts +23 -18
- package/tests/yolo-session-policy.test.ts +270 -1
|
@@ -41,14 +41,14 @@ import { requireSessionProfileAuthority } from "../lib/session-profile-authority
|
|
|
41
41
|
import { resolveBackgroundSubagentsPolicy } from "../lib/background-subagents-policy.ts";
|
|
42
42
|
import { installBackgroundCacheWarming } from "../lib/background-cache-warming.ts";
|
|
43
43
|
import { isFinished, MISSING_TOOLS_NOTE_PREFIX, TASK_EVENT, TASK_STATUS, TaskStore, type AskRequest, type TaskRecord } from "../lib/agents-protocol.ts";
|
|
44
|
-
import { AgentRunner, piCommand, abortReasonText, REQUESTED_TOOLS_ENV, type AskAnswer, type RunnerDeps, type TaskRequest } from "../lib/agents-runner.ts";
|
|
44
|
+
import { AgentRunner, piCommand, abortReasonText, CHILD_JOBS_ENV, REQUESTED_TOOLS_ENV, type AskAnswer, type RunnerDeps, type TaskRequest } from "../lib/agents-runner.ts";
|
|
45
45
|
import { parseChildPackageInjection } from "../lib/child-package-injection.ts";
|
|
46
|
-
import { ChildMessenger, type IpcEndpoint } from "../lib/agents-messaging.ts";
|
|
46
|
+
import { ChildMessenger, formatChildJobState, type IpcEndpoint } from "../lib/agents-messaging.ts";
|
|
47
47
|
import { ActiveSessionClient, ActiveSessionListener, SessionPresenceError, SessionPresenceRegistry, type PresenceRecord, type ReceivedNotification, type SentNotification, type SessionPresenceCandidate } from "../lib/agents-session-transport.ts";
|
|
48
|
-
import { WindowsActiveSessionClient, WindowsActiveSessionListener, WindowsSessionPresenceRegistry, type WindowsSessionRegistryPhaseObserver } from "../lib/windows-session-transport.ts";
|
|
48
|
+
import { WindowsActiveSessionClient, WindowsActiveSessionListener, WindowsSessionPresenceRegistry, WindowsSessionRegistryPhaseSequence, isWindowsSessionBootstrapDiagnosticCode, type WindowsSessionBootstrapDiagnosticCode, type WindowsSessionBootstrapDiagnosticObserver, type WindowsSessionRegistryPhaseObserver } from "../lib/windows-session-transport.ts";
|
|
49
49
|
import { hasReviewSessionPermission, resolveCanonicalGitRepositoryIdentitySync, type ReviewSessionManager } from "../lib/review-session-standing-permission.ts";
|
|
50
50
|
import { inheritedUnsafeGitEnvironmentKeys } from "../lib/review-repository.ts";
|
|
51
|
-
import { historyDir, loadHistory, loadStoredTask, pruneHistory, saveTask } from "../lib/agents-history.ts";
|
|
51
|
+
import { historyDir, loadHistory, loadStoredTask, pruneHistory, saveTask, type StoredTask } from "../lib/agents-history.ts";
|
|
52
52
|
import { sessionToMarkdown } from "../lib/agents-transcript.ts";
|
|
53
53
|
import { AgentsView } from "../lib/agents-view.ts";
|
|
54
54
|
import { withOverlayRepaint } from "../lib/overlay-repaint.ts";
|
|
@@ -67,6 +67,7 @@ import { OrchestratorScopeCache, type RepositoryFact } from "../lib/orchestrator
|
|
|
67
67
|
import { createRpcActivityPublisher, type RpcActivityPublisher } from "../lib/agents-rpc-publisher.ts";
|
|
68
68
|
import { isInteractiveRpcHost } from "../lib/rpc-host.ts";
|
|
69
69
|
import { createNativeFullscreenInteraction } from "../lib/native-fullscreen-interaction.ts";
|
|
70
|
+
import { HERDR_BUSY_CHANNEL, nextHerdrBusyAction, type HerdrBusyEmitted } from "../lib/herdr-busy.ts";
|
|
70
71
|
import { AGENTS_GLYPH, agentsCardTone, agentsSpend, agentsSummary, renderAgentsAlert, renderAgentsCard, renderAgentsSection, widgetExpiryMs, widgetRows } from "../lib/agents-widget.ts";
|
|
71
72
|
import { CARD_TONE, cardAwaitingResult, cardBodyRows, cardBottom, cardInnerWidth, cardRunningLine, cardTop, floatRows, headingFits, markCardResult, panelHeaderRow, panelInnerWidth, renderCard, type CardRowContext, type CardTheme, type CardTone } from "../lib/shell-card.ts";
|
|
72
73
|
import { openInExternalEditor } from "./gentle-shell.ts";
|
|
@@ -100,6 +101,31 @@ function messagePeerLabel(profile: string, sessionId: string): string | undefine
|
|
|
100
101
|
return matches.length === 1 && matches[0].recent ? sanitizeDisplayLabel(matches[0].label) || undefined : undefined;
|
|
101
102
|
} catch { return undefined; }
|
|
102
103
|
}
|
|
104
|
+
/** Human-readable labels for the recipient picker. A raw session id gives a person
|
|
105
|
+
* nothing to choose by, so the published session label and the workspace are used when
|
|
106
|
+
* they exist, and a short id suffix keeps every label unique: the chosen label is mapped
|
|
107
|
+
* back to a peer by exact match, so a collision would select the wrong one. */
|
|
108
|
+
function recipientSelectionLabels(profile: string, candidates: readonly PresenceRecord[], activations: readonly PresenceRecord[] = candidates): string[] {
|
|
109
|
+
let discovered: ReturnType<typeof discoverOrchestrators> = [];
|
|
110
|
+
// Discovery must see every activation: it fails closed when one session resolves to
|
|
111
|
+
// several, and deduplicating before this point would silently label an ambiguous peer.
|
|
112
|
+
try { discovered = discoverOrchestrators(profile, activations); } catch { /* labels are best-effort, never routing */ }
|
|
113
|
+
const peersById = new Map(discovered.map(peer => [peer.sessionId, peer] as const));
|
|
114
|
+
const bases = candidates.map((candidate) => {
|
|
115
|
+
const peer = peersById.get(candidate.sessionId);
|
|
116
|
+
const name = peer?.label ?? peer?.legacyLabel;
|
|
117
|
+
if (!name) return "Orchestrator";
|
|
118
|
+
const workspace = peer?.workspace?.split(/[\\/]/).filter(Boolean).at(-1);
|
|
119
|
+
return workspace && workspace !== name ? `${name} (${workspace})` : name;
|
|
120
|
+
});
|
|
121
|
+
// Short ids stay whole (fixtures and test sessions); long ones are suffixed.
|
|
122
|
+
const suffix = (sessionId: string, length: number): string => sessionId.length <= 8 ? sessionId : sessionId.slice(-length);
|
|
123
|
+
for (const length of [4, 6, 8]) {
|
|
124
|
+
const labels = bases.map((base, index) => `${base} · ${suffix(candidates[index]!.sessionId, length)}`);
|
|
125
|
+
if (new Set(labels).size === labels.length) return labels;
|
|
126
|
+
}
|
|
127
|
+
return bases.map((base, index) => `${base} · ${candidates[index]!.sessionId}`);
|
|
128
|
+
}
|
|
103
129
|
export const AGENTS_STALE_RESULT_TYPE = "gentle-agents.stale-result";
|
|
104
130
|
export const AGENTS_STALE_NOTICE_TYPE = "gentle-agents.stale-notice";
|
|
105
131
|
const RENDER_COALESCE_MS = 400;
|
|
@@ -125,6 +151,12 @@ const NATIVE_PARENT_WAKE_TEXT = `${PARENT_WAKE_TEXT} Reply in the language of th
|
|
|
125
151
|
// How long a dispatched wake may take to start a parent run before a later
|
|
126
152
|
// delivery may send another one.
|
|
127
153
|
export const PARENT_WAKE_GRACE_MS = 30_000;
|
|
154
|
+
// How often a parent that is busy without a run is re-checked while content is
|
|
155
|
+
// held for it. See `armHoldRecheck`.
|
|
156
|
+
export const HOLD_RECHECK_MS = 1000;
|
|
157
|
+
// How long a user prompt seen at `input` suppresses the idle wake while it is
|
|
158
|
+
// still in its pre-run phase. See the `input` handler.
|
|
159
|
+
export const INPUT_PROMPT_GRACE_MS = 2000;
|
|
128
160
|
// A delivery or wake the host rejected while the parent was idle is retried
|
|
129
161
|
// after the grace at most this many times in a row, so a permanently broken
|
|
130
162
|
// runtime never retries forever.
|
|
@@ -152,7 +184,7 @@ export interface SessionTransportClient {
|
|
|
152
184
|
}
|
|
153
185
|
|
|
154
186
|
export interface SessionTransportFactory {
|
|
155
|
-
createRegistry(agentHome: string, observeWindowsPhase?: WindowsSessionRegistryPhaseObserver): Promise<SessionTransportRegistry>;
|
|
187
|
+
createRegistry(agentHome: string, observeWindowsPhase?: WindowsSessionRegistryPhaseObserver, observeWindowsBootstrap?: WindowsSessionBootstrapDiagnosticObserver): Promise<SessionTransportRegistry>;
|
|
156
188
|
createListener(registry: SessionTransportRegistry, sessionId: string, onNotification: (notification: ReceivedNotification) => Promise<void>): SessionTransportListener;
|
|
157
189
|
createClient(registry: SessionTransportRegistry, sessionId: string): SessionTransportClient;
|
|
158
190
|
}
|
|
@@ -383,6 +415,46 @@ function registerChildMessaging(pi: ExtensionAPI, ipc: IpcEndpoint): void {
|
|
|
383
415
|
});
|
|
384
416
|
}
|
|
385
417
|
|
|
418
|
+
// gentle-shell#2266: a child admitted for background jobs registers the tools
|
|
419
|
+
// against its own private registry and reports its job state back over owned
|
|
420
|
+
// IPC, so the runner can drain one bounded window at settlement instead of
|
|
421
|
+
// killing a job mid-flight. The monitor stays parent-only.
|
|
422
|
+
function registerChildBackgroundJobs(pi: ExtensionAPI, env: NodeJS.ProcessEnv, overrides: Partial<AgentsDeps>, ipc: IpcEndpoint): void {
|
|
423
|
+
const home = overrides.home ?? os.homedir();
|
|
424
|
+
const agentHome = overrides.agentHome ?? resolveAgentHomeDirectory({ env, home, agentHome: overrides.agentHome, homeOverridden: overrides.home !== undefined });
|
|
425
|
+
const now = overrides.now ?? (() => Date.now());
|
|
426
|
+
let outputDir: string | undefined;
|
|
427
|
+
let nextFrame = 0;
|
|
428
|
+
const reportJobs = (): void => {
|
|
429
|
+
const running = jobs.running();
|
|
430
|
+
try { ipc.send({ id: `j${++nextFrame}`, kind: "job", message: formatChildJobState({ running, pending: running > 0 }) }); }
|
|
431
|
+
catch { /* A lost report only costs the drain, never the job. */ }
|
|
432
|
+
};
|
|
433
|
+
const jobs = createJobRegistry({
|
|
434
|
+
outputDir: overrides.jobOutputDir ?? (() => (outputDir ??= mkdtempSync(join(os.tmpdir(), "gentle-jobs-")))),
|
|
435
|
+
now,
|
|
436
|
+
shell: overrides.jobShell ?? ((cwd) => {
|
|
437
|
+
const settings = SettingsManager.create(cwd, agentHome);
|
|
438
|
+
return { operations: createLocalBashOperations({ shellPath: settings.getShellPath() }), commandPrefix: settings.getShellCommandPrefix() };
|
|
439
|
+
}),
|
|
440
|
+
onSettled: (job: JobRecord) => {
|
|
441
|
+
reportJobs();
|
|
442
|
+
try { pi.sendMessage({ customType: JOB_NOTICE_TYPE, content: jobNoticeText(job), display: true, details: jobDetails(job) }, { deliverAs: "steer", triggerTurn: true }); }
|
|
443
|
+
catch { /* The notice is best-effort; the job outcome and the drain still stand. */ }
|
|
444
|
+
},
|
|
445
|
+
});
|
|
446
|
+
registerBackgroundJobTools(pi, { registry: jobs, sessionId: (ctx) => ctx.sessionManager.getSessionId() ?? "", now, onChange: reportJobs });
|
|
447
|
+
// agent_settled reports the jobs still running so the runner can drain before
|
|
448
|
+
// it requests the orderly shutdown.
|
|
449
|
+
pi.on("agent_settled", () => reportJobs());
|
|
450
|
+
pi.on("session_shutdown", () => {
|
|
451
|
+
if (!outputDir) return;
|
|
452
|
+
const dir = outputDir;
|
|
453
|
+
outputDir = undefined;
|
|
454
|
+
try { rmSync(dir, { recursive: true, force: true }); } catch { /* A leftover temp directory is harmless. */ }
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
|
|
386
458
|
const posixSessionTransport: SessionTransportFactory = {
|
|
387
459
|
createRegistry(agentHome) { return SessionPresenceRegistry.create(agentHome); },
|
|
388
460
|
createListener(registry: SessionPresenceRegistry, sessionId, onNotification) { return Object.assign(new ActiveSessionListener(registry, sessionId, onNotification), { closesRegistry: false }); },
|
|
@@ -390,7 +462,7 @@ const posixSessionTransport: SessionTransportFactory = {
|
|
|
390
462
|
};
|
|
391
463
|
|
|
392
464
|
const windowsSessionTransport: SessionTransportFactory = {
|
|
393
|
-
createRegistry(agentHome, observeWindowsPhase) { return WindowsSessionPresenceRegistry.create(agentHome, observeWindowsPhase); },
|
|
465
|
+
createRegistry(agentHome, observeWindowsPhase, observeWindowsBootstrap) { return WindowsSessionPresenceRegistry.create(agentHome, observeWindowsPhase, observeWindowsBootstrap); },
|
|
394
466
|
createListener(registry: WindowsSessionPresenceRegistry, sessionId, onNotification) { return Object.assign(new WindowsActiveSessionListener(registry, sessionId, onNotification), { closesRegistry: true }); },
|
|
395
467
|
createClient(registry: WindowsSessionPresenceRegistry, sessionId) { return new WindowsActiveSessionClient(registry, sessionId); },
|
|
396
468
|
};
|
|
@@ -681,7 +753,10 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
681
753
|
pi.on("tool_call", () => ({ block: true, reason: "Retired SDD child launch is not supported." }));
|
|
682
754
|
return;
|
|
683
755
|
}
|
|
684
|
-
if (childIpc)
|
|
756
|
+
if (childIpc) {
|
|
757
|
+
registerChildMessaging(pi, childIpc);
|
|
758
|
+
if (env[CHILD_JOBS_ENV] === "1") registerChildBackgroundJobs(pi, env, overrides, childIpc);
|
|
759
|
+
}
|
|
685
760
|
registerMissingToolsCheck(pi, env);
|
|
686
761
|
return;
|
|
687
762
|
}
|
|
@@ -708,6 +783,8 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
708
783
|
const stopStatusNotifications = publishTaskStatusChanges(store, pi.events, () => performance.now());
|
|
709
784
|
pi.on("session_shutdown", () => { stopStatusNotifications(); });
|
|
710
785
|
const restoredTaskIds = new Set<string>();
|
|
786
|
+
// The latest resumed-session history restoration; list_tasks waits for it.
|
|
787
|
+
let sessionRestoration: Promise<void> = Promise.resolve();
|
|
711
788
|
const tasksDir = historyDir(deps.home, agentHome);
|
|
712
789
|
let ui: ExtensionContext["ui"] | undefined;
|
|
713
790
|
// The session that owns the Agents widget, so a click on an agent row opens its /gentle:agents view.
|
|
@@ -941,6 +1018,8 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
941
1018
|
type SessionTransport = { generation: number; sessionId: string; sessionManager: ExtensionContext["sessionManager"]; client: SessionTransportClient; listener: SessionTransportListener; registry: SessionTransportRegistry; close(): Promise<void> };
|
|
942
1019
|
let transportGeneration = 0;
|
|
943
1020
|
let activeSessionTransport: SessionTransport | undefined;
|
|
1021
|
+
// A session whose first startup failed gets exactly one later re-arm attempt.
|
|
1022
|
+
let transportRearm: { sessionManager: ExtensionContext["sessionManager"]; sessionId: string; ctx: ExtensionContext } | undefined;
|
|
944
1023
|
const pendingTransportStartups = new Set<Promise<void>>();
|
|
945
1024
|
const validTransportSessionId = (value: unknown): value is string => typeof value === "string" && /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/.test(value);
|
|
946
1025
|
const closeSessionTransport = async (transport: SessionTransport | undefined) => {
|
|
@@ -952,16 +1031,22 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
952
1031
|
operation.then(() => { pendingTransportStartups.delete(operation); }, () => { pendingTransportStartups.delete(operation); });
|
|
953
1032
|
return operation;
|
|
954
1033
|
};
|
|
955
|
-
const startSessionTransport = (ctx: ExtensionContext) => {
|
|
1034
|
+
const startSessionTransport = (ctx: ExtensionContext, rearm = false) => {
|
|
956
1035
|
const previous = activeSessionTransport;
|
|
957
1036
|
const generation = ++transportGeneration;
|
|
958
1037
|
const sessionManager = ctx.sessionManager;
|
|
959
1038
|
activeSessionTransport = undefined;
|
|
1039
|
+
transportRearm = undefined;
|
|
960
1040
|
const operation = (async () => {
|
|
961
1041
|
let registry: SessionTransportRegistry | undefined;
|
|
962
1042
|
let listener: SessionTransportListener | undefined;
|
|
963
1043
|
let client: SessionTransportClient | undefined;
|
|
964
1044
|
let closePromise: Promise<void> | undefined;
|
|
1045
|
+
let sessionId: string | undefined;
|
|
1046
|
+
let startupPhase: "registry" | "listener" = "registry";
|
|
1047
|
+
const phases = new WindowsSessionRegistryPhaseSequence();
|
|
1048
|
+
let bootstrap: WindowsSessionBootstrapDiagnosticCode | undefined;
|
|
1049
|
+
const observeBootstrap = (code: WindowsSessionBootstrapDiagnosticCode) => { if (bootstrap === undefined && isWindowsSessionBootstrapDiagnosticCode(code)) bootstrap = code; return undefined; };
|
|
965
1050
|
const closeStartupTransport = () => {
|
|
966
1051
|
if (closePromise) return closePromise;
|
|
967
1052
|
closePromise = Promise.resolve().then(async () => {
|
|
@@ -975,17 +1060,18 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
975
1060
|
};
|
|
976
1061
|
try {
|
|
977
1062
|
if (previous) trackTransportOperation(closeSessionTransport(previous));
|
|
978
|
-
|
|
1063
|
+
sessionId = sessionManager.getSessionId();
|
|
979
1064
|
if (!validTransportSessionId(sessionId) || sessions !== sessionManager || generation !== transportGeneration) return;
|
|
980
|
-
registry = await sessionTransport.createRegistry(agentHome);
|
|
1065
|
+
registry = await sessionTransport.createRegistry(agentHome, (event) => phases.observe(event), observeBootstrap);
|
|
981
1066
|
if (sessions !== sessionManager || generation !== transportGeneration) {
|
|
982
1067
|
await closeStartupTransport();
|
|
983
1068
|
return;
|
|
984
1069
|
}
|
|
1070
|
+
startupPhase = "listener";
|
|
985
1071
|
listener = sessionTransport.createListener(registry, sessionId, async (notification) => {
|
|
986
1072
|
const active = activeSessionTransport;
|
|
987
1073
|
if (!active || active.generation !== generation || active.sessionManager !== sessionManager || active.sessionId !== sessionId || sessions !== sessionManager || activeSessionId() !== sessionId) throw new Error("stale session transport");
|
|
988
|
-
|
|
1074
|
+
deliverOrchestratorMessage({ customType: AGENTS_ORCHESTRATOR_MESSAGE_TYPE, content: `Session message from ${notification.senderSessionId} (correlation ${notification.id}): ${notification.message}`, display: true, details: { gentleAgents: { senderSessionId: notification.senderSessionId, recipientSessionId: sessionId, correlationId: notification.id, direction: "incoming", message: notification.message, senderLabel: messagePeerLabel(agentHome, notification.senderSessionId), recipientLabel: sanitizeDisplayLabel(sessionManager.getSessionName?.() ?? "") } } }, sessionId);
|
|
989
1075
|
});
|
|
990
1076
|
client = sessionTransport.createClient(registry, sessionId);
|
|
991
1077
|
if (sessions !== sessionManager || generation !== transportGeneration || activeSessionId() !== sessionId) {
|
|
@@ -1009,15 +1095,35 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1009
1095
|
publishActivityPrompt();
|
|
1010
1096
|
} catch {
|
|
1011
1097
|
if (activeSessionTransport?.generation === generation) activeSessionTransport = undefined;
|
|
1098
|
+
// Only fixed, validated observer fields cross the UI boundary. Never
|
|
1099
|
+
// interpolate the exception or report a retired session's failure.
|
|
1100
|
+
const current = () => sessions === sessionManager && generation === transportGeneration && validTransportSessionId(sessionId) && activeSessionId() === sessionId;
|
|
1101
|
+
if (current()) {
|
|
1102
|
+
const observation = phases.snapshot();
|
|
1103
|
+
const diagnostic = startupPhase === "registry" && observation.availability === "observed" && observation.firstFailurePhase !== null
|
|
1104
|
+
? `phase=${observation.firstFailurePhase} class=${observation.firstFailureClass} code=${observation.firstFailureCode} lastStartupMarker=${observation.lastStartupMarker ?? "unavailable"}`
|
|
1105
|
+
: `phase=${startupPhase} diagnostics=unavailable`;
|
|
1106
|
+
try { ctx.ui.notify(`Session transport startup failed: ${diagnostic}${bootstrap ? ` bootstrap=${bootstrap}` : ""}.`, "warning"); } catch {}
|
|
1107
|
+
}
|
|
1012
1108
|
await closeStartupTransport();
|
|
1109
|
+
// Armed only after cleanup, so the re-arm never overlaps the failed helper.
|
|
1110
|
+
if (!rearm && current()) transportRearm = { sessionManager, sessionId: sessionId!, ctx };
|
|
1013
1111
|
}
|
|
1014
1112
|
})();
|
|
1015
1113
|
trackTransportOperation(operation);
|
|
1016
1114
|
return operation;
|
|
1017
1115
|
};
|
|
1116
|
+
// The single re-arm runs on a later session event of the same session while it
|
|
1117
|
+
// still has no transport; its own failure warns again and arms nothing.
|
|
1118
|
+
const rearmSessionTransport = (ctx: ExtensionContext | undefined) => {
|
|
1119
|
+
const pending = transportRearm;
|
|
1120
|
+
if (!pending || ctx?.sessionManager !== pending.sessionManager || sessions !== pending.sessionManager || activeSessionId() !== pending.sessionId || activeSessionTransport) return;
|
|
1121
|
+
void startSessionTransport(pending.ctx, true);
|
|
1122
|
+
};
|
|
1018
1123
|
const shutdownSessionTransport = async () => {
|
|
1019
1124
|
const active = activeSessionTransport;
|
|
1020
1125
|
activeSessionTransport = undefined;
|
|
1126
|
+
transportRearm = undefined;
|
|
1021
1127
|
transportGeneration++;
|
|
1022
1128
|
if (active) await closeSessionTransport(active);
|
|
1023
1129
|
while (pendingTransportStartups.size > 0) {
|
|
@@ -1072,6 +1178,17 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1072
1178
|
.catch(() => {});
|
|
1073
1179
|
};
|
|
1074
1180
|
|
|
1181
|
+
// A launched task is written to disk immediately so abrupt parent process
|
|
1182
|
+
// termination (SIGKILL, host reboot, crash) leaves a durable record (#1741).
|
|
1183
|
+
// Pruning is deferred until final persistence in onFinish. saveTask keeps
|
|
1184
|
+
// one task's writes in call order, and a task that is already terminal is
|
|
1185
|
+
// skipped here so its onFinish record is the last one on disk.
|
|
1186
|
+
const persistLaunch = (id: string) => {
|
|
1187
|
+
const task = store.get(id);
|
|
1188
|
+
if (!task || isFinished(task.status)) return;
|
|
1189
|
+
void saveTask(tasksDir, task, store.thread(id)).catch(() => {});
|
|
1190
|
+
};
|
|
1191
|
+
|
|
1075
1192
|
// A background result used to be handed straight to the host as a followUp
|
|
1076
1193
|
// message, but the host only drains that queue when the parent agent stops
|
|
1077
1194
|
// calling tools entirely, so in a long orchestrator run the notification
|
|
@@ -1185,17 +1302,21 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1185
1302
|
// Idle wake-up state. Child content stored while the parent is idle owes a
|
|
1186
1303
|
// wake, and one wake covers everything stored before the run it starts.
|
|
1187
1304
|
// While a prompt is starting (a dispatched wake, or any prompt seen at
|
|
1188
|
-
// before_agent_start) no second wake is sent: two prompts racing through
|
|
1305
|
+
// input or before_agent_start) no second wake is sent: two prompts racing through
|
|
1189
1306
|
// Pi's asynchronous pre-run phase can both reach the agent, and the loser
|
|
1190
1307
|
// resets the winner's run state. A prompt that never starts a run (handled
|
|
1191
1308
|
// by an input handler, or rejected) emits no extension event, so the
|
|
1192
|
-
// starting state expires after PARENT_WAKE_GRACE_MS
|
|
1193
|
-
// sent then; it never suppresses later wakes for longer than that.
|
|
1309
|
+
// starting state expires after PARENT_WAKE_GRACE_MS (INPUT_PROMPT_GRACE_MS
|
|
1310
|
+
// when marked at input) and an owed wake is sent then; it never suppresses later wakes for longer than that.
|
|
1194
1311
|
let wakeOwed = false;
|
|
1195
1312
|
let wakeQueued = false;
|
|
1196
1313
|
let promptStarting = false;
|
|
1197
1314
|
let cancelPromptGrace: (() => void) | undefined;
|
|
1198
1315
|
let cancelBoundaryFlush: (() => void) | undefined;
|
|
1316
|
+
let cancelHoldRecheck: (() => void) | undefined;
|
|
1317
|
+
// Completions sit in an opaque queue; this notes that one may be waiting.
|
|
1318
|
+
// It is cleared by the next flush that reaches a deliverable route.
|
|
1319
|
+
let completionsMaybePending = false;
|
|
1199
1320
|
// An idle parent has no turn boundary coming, so a failed idle delivery or
|
|
1200
1321
|
// wake is retried by one bounded timer that runs a full flush.
|
|
1201
1322
|
let cancelDeliveryRetry: (() => void) | undefined;
|
|
@@ -1235,6 +1356,11 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1235
1356
|
// A parent that is busy without a run (compaction, or a prompt's pre-run
|
|
1236
1357
|
// compaction) is not streaming, so steer + triggerTurn would also start a
|
|
1237
1358
|
// direct turn. Its content stays queued ("hold") until a later boundary.
|
|
1359
|
+
//
|
|
1360
|
+
// Three sources use this one router: child completions, child messages
|
|
1361
|
+
// (queries and notifications), and incoming orchestrator session messages.
|
|
1362
|
+
// The route decision is also the single point where a receiver-side
|
|
1363
|
+
// admission policy for session messages (#1518) would plug in.
|
|
1238
1364
|
type ParentRoute = "idle" | "run" | "hold";
|
|
1239
1365
|
// Throws for a missing or stale parent context, so delivery fails closed.
|
|
1240
1366
|
const parentRoute = (): ParentRoute => {
|
|
@@ -1253,14 +1379,36 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1253
1379
|
cancelPromptGrace?.();
|
|
1254
1380
|
cancelPromptGrace = undefined;
|
|
1255
1381
|
};
|
|
1256
|
-
const beginPromptStart = () => {
|
|
1382
|
+
const beginPromptStart = (graceMs = PARENT_WAKE_GRACE_MS) => {
|
|
1257
1383
|
endPromptStart();
|
|
1258
1384
|
promptStarting = true;
|
|
1259
1385
|
cancelPromptGrace = deps.schedule(() => {
|
|
1260
1386
|
cancelPromptGrace = undefined;
|
|
1261
1387
|
promptStarting = false;
|
|
1262
1388
|
requestWake();
|
|
1263
|
-
},
|
|
1389
|
+
}, graceMs);
|
|
1390
|
+
};
|
|
1391
|
+
|
|
1392
|
+
const hasHeldContent = (): boolean =>
|
|
1393
|
+
heldOrchestratorMessages.length > 0 || wakeOwed || completionsMaybePending || messages.pendingCount() > 0 || jobNotices.length > 0;
|
|
1394
|
+
const stopHoldRecheck = () => {
|
|
1395
|
+
cancelHoldRecheck?.();
|
|
1396
|
+
cancelHoldRecheck = undefined;
|
|
1397
|
+
};
|
|
1398
|
+
// Events (`agent_*`, `turn_end`, `session_compact*`, `session_tree`) are the
|
|
1399
|
+
// fast path that releases held content. They are not a guarantee: a busy
|
|
1400
|
+
// state without a run can end without any event (a cancelled `/tree`
|
|
1401
|
+
// summarization emits none) or be added to the host later. So while content
|
|
1402
|
+
// is held for a parent that is busy without a run, one re-check is armed;
|
|
1403
|
+
// it re-arms itself only while that state and the held content persist.
|
|
1404
|
+
// Nothing is armed when nothing is held, and an idle or running parent is
|
|
1405
|
+
// never polled.
|
|
1406
|
+
const armHoldRecheck = () => {
|
|
1407
|
+
if (cancelHoldRecheck || !hasHeldContent()) return;
|
|
1408
|
+
cancelHoldRecheck = deps.schedule(() => {
|
|
1409
|
+
cancelHoldRecheck = undefined;
|
|
1410
|
+
flushAll();
|
|
1411
|
+
}, HOLD_RECHECK_MS);
|
|
1264
1412
|
};
|
|
1265
1413
|
|
|
1266
1414
|
// Every wake requested during one synchronous delivery pass is coalesced
|
|
@@ -1277,6 +1425,7 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1277
1425
|
try { route = parentRoute(); } catch { return; }
|
|
1278
1426
|
// A run in progress already carries the stored content; a parent busy
|
|
1279
1427
|
// without a run keeps the wake owed until a later boundary flush.
|
|
1428
|
+
if (route === "hold") armHoldRecheck();
|
|
1280
1429
|
if (route !== "idle") return;
|
|
1281
1430
|
wakeOwed = false;
|
|
1282
1431
|
endDeliveryRetry();
|
|
@@ -1307,9 +1456,12 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1307
1456
|
}
|
|
1308
1457
|
};
|
|
1309
1458
|
|
|
1310
|
-
|
|
1459
|
+
// `runMode` is how a message joins a run in progress: child content steers
|
|
1460
|
+
// (see the #867 rationale above); an orchestrator session message is a
|
|
1461
|
+
// follow-up, so it never interrupts the turn the parent is working on.
|
|
1462
|
+
const sendToParent = (message: Parameters<ExtensionAPI["sendMessage"]>[0], route: Exclude<ParentRoute, "hold">, runMode: "steer" | "followUp" = "steer") => {
|
|
1311
1463
|
if (route === "run") {
|
|
1312
|
-
pi.sendMessage(message, { deliverAs:
|
|
1464
|
+
pi.sendMessage(message, { deliverAs: runMode, triggerTurn: true });
|
|
1313
1465
|
return;
|
|
1314
1466
|
}
|
|
1315
1467
|
pi.sendMessage(message, { triggerTurn: false });
|
|
@@ -1324,6 +1476,35 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1324
1476
|
sendToParent({ customType: AGENTS_RESULT_TYPE, content: completionText(task), display: true, details: taskDetails(task) }, route);
|
|
1325
1477
|
};
|
|
1326
1478
|
|
|
1479
|
+
// Incoming orchestrator session messages. The transport has already
|
|
1480
|
+
// acknowledged the sender when the listener runs, so a message held for a
|
|
1481
|
+
// busy parent that is then dropped by a session change is lost, exactly like
|
|
1482
|
+
// pending child content. A stale or missing parent context throws instead,
|
|
1483
|
+
// so the sender learns that delivery failed.
|
|
1484
|
+
interface HeldOrchestratorMessage { message: Parameters<ExtensionAPI["sendMessage"]>[0]; recipientSessionId: string }
|
|
1485
|
+
let heldOrchestratorMessages: HeldOrchestratorMessage[] = [];
|
|
1486
|
+
const deliverOrchestratorMessage = (message: Parameters<ExtensionAPI["sendMessage"]>[0], recipientSessionId: string) => {
|
|
1487
|
+
const route = parentRoute();
|
|
1488
|
+
if (route === "hold") {
|
|
1489
|
+
heldOrchestratorMessages.push({ message, recipientSessionId });
|
|
1490
|
+
armHoldRecheck();
|
|
1491
|
+
return;
|
|
1492
|
+
}
|
|
1493
|
+
sendToParent(message, route, "followUp");
|
|
1494
|
+
};
|
|
1495
|
+
const flushOrchestratorMessages = () => {
|
|
1496
|
+
if (heldOrchestratorMessages.length === 0) return;
|
|
1497
|
+
const route = deliveryRoute(false);
|
|
1498
|
+
if (!route) return;
|
|
1499
|
+
const held = heldOrchestratorMessages;
|
|
1500
|
+
heldOrchestratorMessages = [];
|
|
1501
|
+
for (const { message, recipientSessionId } of held) {
|
|
1502
|
+
if (activeSessionId() !== recipientSessionId) continue;
|
|
1503
|
+
try { sendToParent(message, route, "followUp"); }
|
|
1504
|
+
catch { /* Best-effort delivery: at most once, even if forwarding fails. */ }
|
|
1505
|
+
}
|
|
1506
|
+
};
|
|
1507
|
+
|
|
1327
1508
|
// A stale report must not re-enter the LLM conversation, but the parent is
|
|
1328
1509
|
// told never to poll: it gets a compact model-facing notice naming the task,
|
|
1329
1510
|
// and the human gets durable TUI-only content.
|
|
@@ -1352,7 +1533,12 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1352
1533
|
const deliveryRoute = (rethrow: boolean): Exclude<ParentRoute, "hold"> | undefined => {
|
|
1353
1534
|
try {
|
|
1354
1535
|
const route = parentRoute();
|
|
1355
|
-
|
|
1536
|
+
if (route === "hold") {
|
|
1537
|
+
armHoldRecheck();
|
|
1538
|
+
return undefined;
|
|
1539
|
+
}
|
|
1540
|
+
stopHoldRecheck();
|
|
1541
|
+
return route;
|
|
1356
1542
|
} catch (error) {
|
|
1357
1543
|
if (rethrow) throw error;
|
|
1358
1544
|
return undefined;
|
|
@@ -1375,6 +1561,7 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1375
1561
|
const flushCompletions = () => {
|
|
1376
1562
|
const route = deliveryRoute(false);
|
|
1377
1563
|
if (!route) return;
|
|
1564
|
+
completionsMaybePending = false;
|
|
1378
1565
|
for (const entry of completions.takeDeliverable(deps.now())) {
|
|
1379
1566
|
try {
|
|
1380
1567
|
if (entry.stale) deliverStale(entry.task, entry.settledAt, route);
|
|
@@ -1384,6 +1571,8 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1384
1571
|
// lose the completion: it waits for the next boundary instead, and
|
|
1385
1572
|
// an idle parent, which has none coming, gets a bounded retry.
|
|
1386
1573
|
completions.requeue(entry);
|
|
1574
|
+
// Still pending, so a later held-only re-check must see it.
|
|
1575
|
+
completionsMaybePending = true;
|
|
1387
1576
|
if (route === "idle") armDeliveryRetry();
|
|
1388
1577
|
}
|
|
1389
1578
|
}
|
|
@@ -1414,6 +1603,7 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1414
1603
|
};
|
|
1415
1604
|
|
|
1416
1605
|
const flushAll = () => {
|
|
1606
|
+
flushOrchestratorMessages();
|
|
1417
1607
|
flushMessages();
|
|
1418
1608
|
flushCompletions();
|
|
1419
1609
|
flushJobNotices();
|
|
@@ -1441,7 +1631,10 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1441
1631
|
wakeVisibilityWarning = false;
|
|
1442
1632
|
parentRunActive = false;
|
|
1443
1633
|
wakeOwed = false;
|
|
1634
|
+
heldOrchestratorMessages = [];
|
|
1635
|
+
completionsMaybePending = false;
|
|
1444
1636
|
endPromptStart();
|
|
1637
|
+
stopHoldRecheck();
|
|
1445
1638
|
cancelBoundaryFlush?.();
|
|
1446
1639
|
cancelBoundaryFlush = undefined;
|
|
1447
1640
|
endDeliveryRetry();
|
|
@@ -1501,6 +1694,7 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1501
1694
|
const settleCompletion = (task: TaskRecord) => {
|
|
1502
1695
|
messages.invalidateTask(task.id);
|
|
1503
1696
|
completions.enqueue(task, deps.now());
|
|
1697
|
+
completionsMaybePending = true;
|
|
1504
1698
|
if (activeAgentRuns === 0) flushAll();
|
|
1505
1699
|
};
|
|
1506
1700
|
|
|
@@ -1548,6 +1742,23 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1548
1742
|
pi.on("turn_end", () => flushAll());
|
|
1549
1743
|
pi.on("session_compact", scheduleBoundaryFlush);
|
|
1550
1744
|
pi.on("session_compact_failed", scheduleBoundaryFlush);
|
|
1745
|
+
pi.on("session_tree", scheduleBoundaryFlush);
|
|
1746
|
+
// A user prompt is "starting" from `input`, through input handlers, auth and
|
|
1747
|
+
// model checks, until `before_agent_start`, while the host still reports
|
|
1748
|
+
// idle. A wake dispatched in that window races the prompt into
|
|
1749
|
+
// Agent.prompt(): the user's prompt can be rejected as already processing.
|
|
1750
|
+
// The starting prompt carries the stored content itself, so no wake is
|
|
1751
|
+
// needed. An input another extension handles never starts a run and emits
|
|
1752
|
+
// no event, so this suppression expires quickly (INPUT_PROMPT_GRACE_MS) and
|
|
1753
|
+
// the owed wake then goes out; a pre-run phase longer than that only
|
|
1754
|
+
// re-opens the old window. A pre-prompt compaction makes the route "hold",
|
|
1755
|
+
// and `before_agent_start` re-arms the starting state. A start window that
|
|
1756
|
+
// is already open is never shortened: a dispatched wake reaches `input`
|
|
1757
|
+
// too, and its own PARENT_WAKE_GRACE_MS window must keep a second wake out.
|
|
1758
|
+
pi.on("input", (event) => {
|
|
1759
|
+
if (parentRunActive || promptStarting || event.streamingBehavior !== undefined) return;
|
|
1760
|
+
beginPromptStart(INPUT_PROMPT_GRACE_MS);
|
|
1761
|
+
});
|
|
1551
1762
|
|
|
1552
1763
|
const runner = new AgentRunner(store, loadAgentsConfig({ cwd: process.cwd(), home: deps.home, agentHome }), deps, {
|
|
1553
1764
|
askUser: (_taskId, ask, raw) => answerThroughUi(ui, ask, raw),
|
|
@@ -1761,16 +1972,39 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1761
1972
|
return confirmation;
|
|
1762
1973
|
};
|
|
1763
1974
|
|
|
1975
|
+
// A task stored on disk that never reached a terminal state was in flight
|
|
1976
|
+
// when the parent process was abruptly terminated (kill -9, host reboot,
|
|
1977
|
+
// OOM). When loaded into a new process where it has no live runner, it is
|
|
1978
|
+
// reconciled into a terminal failed state and updated on disk (#1741).
|
|
1979
|
+
const reconcileStored = async (stored: StoredTask): Promise<StoredTask> => {
|
|
1980
|
+
if (isFinished(stored.task.status)) return stored;
|
|
1981
|
+
const reconciledTask: TaskRecord = {
|
|
1982
|
+
...stored.task,
|
|
1983
|
+
status: TASK_STATUS.FAILED,
|
|
1984
|
+
error: stored.task.error ?? "interrupted: parent process terminated while task was in flight",
|
|
1985
|
+
lastStep: "interrupted",
|
|
1986
|
+
endedAt: stored.task.endedAt ?? deps.now(),
|
|
1987
|
+
};
|
|
1988
|
+
try { await saveTask(tasksDir, reconciledTask, stored.thread); } catch { /* best effort */ }
|
|
1989
|
+
return { task: reconciledTask, thread: stored.thread };
|
|
1990
|
+
};
|
|
1991
|
+
|
|
1764
1992
|
// Tasks from earlier sessions come back from disk on demand.
|
|
1765
1993
|
const resolveTask = async (id: string): Promise<TaskRecord | undefined> => {
|
|
1766
1994
|
const live = store.get(id);
|
|
1767
|
-
if (live) return live;
|
|
1995
|
+
if (live && !restoredTaskIds.has(id)) return live;
|
|
1768
1996
|
const stored = await loadStoredTask(tasksDir, id);
|
|
1769
1997
|
if (stored) {
|
|
1770
|
-
|
|
1771
|
-
|
|
1998
|
+
if (!isFinished(stored.task.status) && stored.task.parentSessionId !== activeSessionId()) {
|
|
1999
|
+
return undefined;
|
|
2000
|
+
}
|
|
2001
|
+
const reconciled = await reconcileStored(stored);
|
|
2002
|
+
restoredTaskIds.add(reconciled.task.id);
|
|
2003
|
+
store.restore(reconciled.task, reconciled.thread);
|
|
2004
|
+
store.update(reconciled.task.id, reconciled.task);
|
|
2005
|
+
return reconciled.task;
|
|
1772
2006
|
}
|
|
1773
|
-
return
|
|
2007
|
+
return live;
|
|
1774
2008
|
};
|
|
1775
2009
|
|
|
1776
2010
|
// A guessed id ("1") leads back to real ids instead of a dead end, so the
|
|
@@ -1801,8 +2035,12 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1801
2035
|
// The session may have moved on while disk was read; a stale restore
|
|
1802
2036
|
// must never land in the wrong session's store.
|
|
1803
2037
|
if (ctx.sessionManager.getSessionId() !== sessionId) return;
|
|
1804
|
-
|
|
1805
|
-
|
|
2038
|
+
// An in-flight record has no live runner here, so it is reconciled
|
|
2039
|
+
// before the widget or store can show it as still running (#1741).
|
|
2040
|
+
const own = history.filter(({ task }) => task.parentSessionId === sessionId && !store.get(task.id));
|
|
2041
|
+
const reconciled = await Promise.all(own.map(reconcileStored));
|
|
2042
|
+
if (ctx.sessionManager.getSessionId() !== sessionId) return;
|
|
2043
|
+
for (const { task, thread } of reconciled) {
|
|
1806
2044
|
if (store.restore(task, thread)) restoredTaskIds.add(task.id);
|
|
1807
2045
|
}
|
|
1808
2046
|
} catch { /* Partial history is acceptable; the live session keeps running. */ }
|
|
@@ -1879,9 +2117,35 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
1879
2117
|
await writeFile(path, markdown, "utf8");
|
|
1880
2118
|
return path;
|
|
1881
2119
|
};
|
|
2120
|
+
// gentle-shell#626: herdr's pane busy while owned subagents of the active
|
|
2121
|
+
// session run, even when the parent itself settled around a background
|
|
2122
|
+
// child. Pure edge-triggered projection (lib/herdr-busy.ts), recomputed on
|
|
2123
|
+
// every summary notification and on the session lifecycle edges; the
|
|
2124
|
+
// consumer owns blocked-over-busy precedence, so no gating happens here.
|
|
2125
|
+
let emittedBusy: HerdrBusyEmitted;
|
|
2126
|
+
const refreshHerdrBusy = (): void => {
|
|
2127
|
+
const sessionId = activeSessionId();
|
|
2128
|
+
if (!sessionId) {
|
|
2129
|
+
// No active session owns work: never raise, and lower anything this
|
|
2130
|
+
// runtime already raised so busy never outlives its session.
|
|
2131
|
+
if (emittedBusy?.active) pi.events.emit(HERDR_BUSY_CHANNEL, { active: false });
|
|
2132
|
+
emittedBusy = { active: false };
|
|
2133
|
+
return;
|
|
2134
|
+
}
|
|
2135
|
+
const action = nextHerdrBusyAction(store.list(sessionId).filter((task) => ownedTaskIds.has(task.id)), emittedBusy);
|
|
2136
|
+
if (action.kind === "none") return;
|
|
2137
|
+
if (action.kind === "lower") pi.events.emit(HERDR_BUSY_CHANNEL, { active: false });
|
|
2138
|
+
else {
|
|
2139
|
+
if (action.kind === "lower-then-raise") pi.events.emit(HERDR_BUSY_CHANNEL, { active: false });
|
|
2140
|
+
pi.events.emit(HERDR_BUSY_CHANNEL, { active: true, label: action.label });
|
|
2141
|
+
}
|
|
2142
|
+
emittedBusy = action.kind === "lower" ? { active: false } : { active: true, label: action.label };
|
|
2143
|
+
};
|
|
2144
|
+
|
|
1882
2145
|
// A status change is worth a frame right away; deltas inside a task are
|
|
1883
2146
|
// coalesced so a chatty child cannot flood the terminal.
|
|
1884
2147
|
store.subscribeSummary(() => {
|
|
2148
|
+
refreshHerdrBusy();
|
|
1885
2149
|
publishActivity();
|
|
1886
2150
|
if (sidebarTui) invalidateSidebar(sidebarTui);
|
|
1887
2151
|
host?.requestRender();
|
|
@@ -2263,6 +2527,7 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
2263
2527
|
launched = true;
|
|
2264
2528
|
const foreign = foreignRequests.get(request);
|
|
2265
2529
|
if (foreign && launchedTaskId) foreignTasks.set(launchedTaskId, foreign);
|
|
2530
|
+
if (launchedTaskId) persistLaunch(launchedTaskId);
|
|
2266
2531
|
},
|
|
2267
2532
|
...(observe ? { canCollectResponseObservations: metrics.valid, prepareResponseObservations: async () => {
|
|
2268
2533
|
if (metrics.finished || owner !== metricsOwner || request.parentSessionId !== activeSessionId() || !runtimeMetricsEnvAllows(deps.env)) return false;
|
|
@@ -2277,8 +2542,10 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
2277
2542
|
const foreignRequest = foreignRequests.get(request);
|
|
2278
2543
|
if (launched && foreignRequest) foreignTasks.set(task.id, foreignRequest);
|
|
2279
2544
|
ownedTaskIds.add(task.id);
|
|
2545
|
+
persistLaunch(task.id);
|
|
2280
2546
|
publishWork?.(task.id);
|
|
2281
2547
|
publishActivityPrompt(); // Admission's summary notification precedes runtime ownership.
|
|
2548
|
+
refreshHerdrBusy(); // So does the busy raise: ownership lands after that notification.
|
|
2282
2549
|
store.subscribe(task.id, () => { publishActivity(); requestRender(); });
|
|
2283
2550
|
if (request.mode === AGENT_MODE.BACKGROUND) return text(`Started ${task.agent} in the background as task ${task.id}. Retain that id; completion is pushed automatically. Never sleep or periodically poll subagent_status/subagent_result for completion or cache maintenance. Inspect status only at a real orchestration decision boundary; never relaunch equivalent queued/running work.`, taskDetails(task));
|
|
2284
2551
|
// A tool call aborted by the host (a human interrupting the turn, a timeout)
|
|
@@ -2689,15 +2956,18 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
2689
2956
|
}
|
|
2690
2957
|
if (recipient === undefined) {
|
|
2691
2958
|
try {
|
|
2692
|
-
const
|
|
2959
|
+
const activations = (await transport.listener.registry.listActivations(transport.sessionId)).filter((candidate) => candidate.sessionId !== transport.sessionId);
|
|
2960
|
+
// A transport may report more than one activation for one session; the picker maps
|
|
2961
|
+
// the chosen label back to a single activation, so keep one entry per session ID.
|
|
2962
|
+
const candidates = [...new Map(activations.map((candidate) => [candidate.sessionId, candidate] as const)).values()];
|
|
2693
2963
|
if (activeTransportFor(ctx) !== transport || signal?.aborted) return text("Message selection was cancelled.", { error: "cancelled" });
|
|
2694
2964
|
if (candidates.length === 0) return text("No other sessions are currently advertised; message delivery is unavailable.", { error: "unavailable" });
|
|
2695
2965
|
if (candidates.length === 1) {
|
|
2696
2966
|
recipient = candidates[0].sessionId;
|
|
2697
2967
|
activation = candidates[0];
|
|
2698
|
-
} else
|
|
2699
|
-
|
|
2700
|
-
|
|
2968
|
+
} else {
|
|
2969
|
+
const labels = recipientSelectionLabels(agentHome, candidates, activations);
|
|
2970
|
+
if (!ctx.hasUI) return text(`Several recipient orchestrators are available. Ask the user to choose one of these recipient labels; do not ask for a session ID:\n${labels.map((label) => `- ${label}`).join("\n")}\nSending still requires interactive human consent.`, { gentleAgents: { candidates: candidates.map((candidate, index) => ({ label: labels[index]!, sessionId: candidate.sessionId })) } });
|
|
2701
2971
|
const selected = await ctx.ui.select("Select recipient orchestrator", labels, { signal });
|
|
2702
2972
|
if (selected === undefined || activeTransportFor(ctx) !== transport || signal?.aborted) return text("Message selection was cancelled.", { error: "cancelled" });
|
|
2703
2973
|
const index = labels.indexOf(selected);
|
|
@@ -2810,8 +3080,16 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
2810
3080
|
});
|
|
2811
3081
|
|
|
2812
3082
|
tool("list_tasks", "List the subagent tasks of this session, newest first.", { properties: {} }, async (_params, ctx) => {
|
|
2813
|
-
|
|
2814
|
-
|
|
3083
|
+
await sessionRestoration;
|
|
3084
|
+
const sessionId = ctx.sessionManager.getSessionId() ?? "";
|
|
3085
|
+
const tasks = store.list(sessionId);
|
|
3086
|
+
for (const task of tasks) {
|
|
3087
|
+
if (!isFinished(task.status) && restoredTaskIds.has(task.id)) {
|
|
3088
|
+
await resolveTask(task.id);
|
|
3089
|
+
}
|
|
3090
|
+
}
|
|
3091
|
+
const reconciledTasks = store.list(sessionId);
|
|
3092
|
+
return text(reconciledTasks.length === 0 ? "No subagent tasks in this session." : reconciledTasks.map(describeTask).join("\n"));
|
|
2815
3093
|
});
|
|
2816
3094
|
|
|
2817
3095
|
tool("reply", "Reply once to a live query from a child of the current parent session.", { required: ["task_id", "request_id", "message"], properties: { task_id: { type: "string" }, request_id: { type: "string" }, message: { type: "string" } } }, async (params, ctx) => {
|
|
@@ -2864,7 +3142,7 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
2864
3142
|
}
|
|
2865
3143
|
|
|
2866
3144
|
pi.registerCommand(JOBS_COMMAND_NAME, {
|
|
2867
|
-
description: "Show background jobs: running first, newest first within each group; status, command, output tail; s
|
|
3145
|
+
description: "Show background jobs: running first, newest first within each group; status, command, output tail. Click a job to inspect it; click Stop or press s to stop the selected running job.",
|
|
2868
3146
|
handler: async (_args, ctx) => {
|
|
2869
3147
|
if (!ctx.hasUI) return;
|
|
2870
3148
|
if (ctx.mode !== "tui") {
|
|
@@ -2954,12 +3232,21 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
2954
3232
|
// resolveTask path for anything else.
|
|
2955
3233
|
const sessionId = ctx.sessionManager.getSessionId();
|
|
2956
3234
|
const preexisting = event.reason === "resume" || (event.reason === "startup" && ctx.sessionManager.getEntries().length > 0);
|
|
2957
|
-
if (preexisting && sessionId)
|
|
3235
|
+
if (preexisting && sessionId) sessionRestoration = restoreSessionHistory(ctx, sessionId);
|
|
2958
3236
|
try {
|
|
2959
3237
|
presence = startPresence(ctx.sessionManager);
|
|
2960
3238
|
resetActivityPublish();
|
|
2961
3239
|
publishActivityPrompt();
|
|
2962
|
-
} catch {
|
|
3240
|
+
} catch {
|
|
3241
|
+
presence = undefined;
|
|
3242
|
+
// Fixed text only: the failure may carry a profile path or session id.
|
|
3243
|
+
try { ctx.ui.notify("Session presence unavailable: phase=presence class=transport code=presence-cleared.", "warning"); } catch {}
|
|
3244
|
+
}
|
|
3245
|
+
// /reload and /resume recompute busy from live owned work only: a task
|
|
3246
|
+
// restored from disk never enters ownedTaskIds, so counting it would
|
|
3247
|
+
// report working for work this runtime no longer owns. An unchanged
|
|
3248
|
+
// label dedups; a session without owned running work lowers.
|
|
3249
|
+
refreshHerdrBusy();
|
|
2963
3250
|
void startSessionTransport(ctx);
|
|
2964
3251
|
// The desktop app's own pi process: publish live subagent state through
|
|
2965
3252
|
// setWidget's RPC-mode string[] path. Plain headless RPC (no variable) and
|
|
@@ -2985,9 +3272,14 @@ export default function gentleAgents(pi: ExtensionAPI, env: NodeJS.ProcessEnv =
|
|
|
2985
3272
|
rpcActivityPublisher.start();
|
|
2986
3273
|
}
|
|
2987
3274
|
});
|
|
3275
|
+
pi.on("agent_start", (_event, ctx) => rearmSessionTransport(ctx));
|
|
3276
|
+
pi.on("turn_end", (_event, ctx) => rearmSessionTransport(ctx));
|
|
2988
3277
|
pi.on("session_shutdown", async () => {
|
|
2989
3278
|
completions.dropAll();
|
|
2990
3279
|
messages.dropAll();
|
|
3280
|
+
// No stale busy may survive the runtime.
|
|
3281
|
+
if (emittedBusy?.active) pi.events.emit(HERDR_BUSY_CHANNEL, { active: false });
|
|
3282
|
+
emittedBusy = { active: false };
|
|
2991
3283
|
// Jobs never outlive their session: a stopped job sends no notice.
|
|
2992
3284
|
monitors.cancelAll();
|
|
2993
3285
|
const jobsStopped = jobs.stopAll();
|