@blackbelt-technology/pi-dashboard-extension 0.5.4 → 0.6.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/.pi/skills/browser/LICENSE +201 -0
- package/.pi/skills/browser/SKILL.md +105 -0
- package/.pi/skills/browser/UPSTREAM.md +46 -0
- package/.pi/skills/browser/references/electron.md +351 -0
- package/.pi/skills/browser/references/web.md +2789 -0
- package/.pi/skills/browser/scripts/detect-dashboard.sh +55 -0
- package/.pi/skills/doctor/AGENTS.md +27 -0
- package/.pi/skills/doctor/SKILL.md +89 -0
- package/.pi/skills/doctor/_lib/checks.ts +177 -0
- package/.pi/skills/doctor/_lib/derive-tokens.ts +43 -0
- package/.pi/skills/doctor/_lib/front-matter.ts +122 -0
- package/.pi/skills/doctor/_lib/index.ts +14 -0
- package/.pi/skills/doctor/_lib/knowledge-hash.ts +74 -0
- package/.pi/skills/doctor/_lib/provenance.ts +50 -0
- package/.pi/skills/doctor/_lib/regenerate.ts +100 -0
- package/.pi/skills/doctor/_lib/router.ts +155 -0
- package/.pi/skills/doctor/_lib/server-tier.ts +62 -0
- package/.pi/skills/doctor/modules/build-reload.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/build-reload.md +51 -0
- package/.pi/skills/doctor/modules/env-node.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/env-node.md +49 -0
- package/.pi/skills/doctor/modules/install-topology.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/install-topology.md +53 -0
- package/.pi/skills/doctor/modules/model-resolution.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/model-resolution.md +53 -0
- package/.pi/skills/doctor/modules/peers.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/peers.md +57 -0
- package/.pi/skills/doctor/modules/pi-resolution.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/pi-resolution.md +60 -0
- package/.pi/skills/doctor/modules/plugins-bridges.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/plugins-bridges.md +56 -0
- package/.pi/skills/pi-dashboard/SKILL.md +68 -0
- package/.pi/skills/pi-dashboard/commands/README.md +45 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-flow-abort.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-flow-auto.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-git-branches.md +6 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-git-init.md +8 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-git-stash-pop.md +8 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-list-models.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-peer-list.md +6 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-peer-scan.md +6 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-pin-list.md +5 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-proposal-archive.md +6 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-proposal-attach.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-proposal-detach.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-server-config.md +5 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-server-health.md +6 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-server-tunnel-off.md +6 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-server-tunnel-on.md +6 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-server-tunnel-status.md +6 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-abort-all.md +14 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-abort.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-diff.md +11 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-fork.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-hide.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-info.md +11 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-kill.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-list-active.md +8 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-list-here.md +8 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-list.md +6 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-model.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-rename.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-resume.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-spawn.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-tell.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-thinking.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-unhide.md +10 -0
- package/.pi/skills/pi-dashboard/references/api-reference.md +30 -0
- package/.pi/skills/pi-dashboard/references/recipes.md +38 -0
- package/.pi/skills/pi-dashboard/references/slash-commands.md +71 -0
- package/.pi/skills/pi-dashboard/scripts/dashboard-api.sh +6 -0
- package/.pi/skills/pi-dashboard/scripts/dashboard-bus.ts +217 -0
- package/.pi/skills/project-init/SKILL.md +279 -0
- package/.pi/skills/project-init/dox-doctrine.md +104 -0
- package/.pi/skills/project-init/profiles/coding/AGENTS.md.tmpl +111 -0
- package/.pi/skills/project-init/profiles/coding/profile.json +5 -0
- package/.pi/skills/project-init/profiles/coding/prompts/plan-change.md +5 -0
- package/.pi/skills/project-init/profiles/coding/prompts/tdd-loop.md +6 -0
- package/.pi/skills/project-init/profiles/coding/settings.json.tmpl +9 -0
- package/.pi/skills/project-init/profiles/docs/AGENTS.md.tmpl +37 -0
- package/.pi/skills/project-init/profiles/docs/profile.json +4 -0
- package/.pi/skills/project-init/profiles/docs/prompts/draft-page.md +5 -0
- package/.pi/skills/project-init/profiles/docs/settings.json.tmpl +9 -0
- package/package.json +12 -4
- package/src/AGENTS.md +56 -0
- package/src/__tests__/abort-latch.test.ts +97 -0
- package/src/__tests__/agent-settled.test.ts +82 -0
- package/src/__tests__/artifact-roots.test.ts +83 -0
- package/src/__tests__/ask-user-attachments.test.ts +106 -0
- package/src/__tests__/ask-user-tool.test.ts +90 -27
- package/src/__tests__/auto-session-namer.test.ts +339 -0
- package/src/__tests__/bridge-default-model-apply.test.ts +242 -0
- package/src/__tests__/bridge-default-model-gate.test.ts +6 -3
- package/src/__tests__/bridge-followup-mutation.test.ts +217 -0
- package/src/__tests__/bridge-followup-queue-drain.test.ts +266 -0
- package/src/__tests__/bridge-hasui-flip.test.ts +109 -0
- package/src/__tests__/bridge-no-queue-mutation.test.ts +112 -0
- package/src/__tests__/bridge-plugin-emit-event.test.ts +44 -0
- package/src/__tests__/bridge-shutdown-reset.test.ts +57 -136
- package/src/__tests__/bridge-slash-command-routing.test.ts +7 -7
- package/src/__tests__/bridge-stop-after-turn.test.ts +72 -0
- package/src/__tests__/bridge-system-followup.test.ts +163 -0
- package/src/__tests__/bridge-thinking-level-select.test.ts +68 -0
- package/src/__tests__/browser-skill-registered.test.ts +84 -0
- package/src/__tests__/build-provider-catalogue.test.ts +35 -1
- package/src/__tests__/command-handler.test.ts +331 -35
- package/src/__tests__/commit-draft.test.ts +100 -0
- package/src/__tests__/connection-dropped-frames.test.ts +78 -0
- package/src/__tests__/custom-provider-apikey-roundtrip.test.ts +128 -0
- package/src/__tests__/cwd-missing-probe.test.ts +82 -0
- package/src/__tests__/dashboard-commands-shipped.test.ts +53 -0
- package/src/__tests__/dashboard-context-injector.test.ts +190 -0
- package/src/__tests__/doctor/checks.test.ts +121 -0
- package/src/__tests__/doctor/modules.test.ts +64 -0
- package/src/__tests__/doctor/provenance-hash.test.ts +94 -0
- package/src/__tests__/doctor/router.test.ts +143 -0
- package/src/__tests__/empty-actionable-guard-config.test.ts +32 -0
- package/src/__tests__/empty-actionable-guard.test.ts +73 -0
- package/src/__tests__/enrich-model-metadata.test.ts +21 -0
- package/src/__tests__/extension-slash-command-detection.test.ts +37 -1
- package/src/__tests__/filter-enabled-models.test.ts +151 -0
- package/src/__tests__/fixtures/turn-actionability-fixtures.ts +69 -0
- package/src/__tests__/git-info-status.test.ts +73 -0
- package/src/__tests__/git-poll.test.ts +69 -0
- package/src/__tests__/markdown-image-inliner.test.ts +37 -0
- package/src/__tests__/model-resolve.test.ts +379 -0
- package/src/__tests__/pi-version-tracker.test.ts +109 -0
- package/src/__tests__/process-scanner.test.ts +112 -22
- package/src/__tests__/project-init-detect-stack.test.ts +61 -0
- package/src/__tests__/project-init-dox-kb-config.test.ts +53 -0
- package/src/__tests__/project-init-profiles.test.ts +84 -0
- package/src/__tests__/project-init-scaffold.test.ts +139 -0
- package/src/__tests__/project-init-seed-doctrine.test.ts +100 -0
- package/src/__tests__/project-trust.test.ts +92 -0
- package/src/__tests__/prompt-expander.test.ts +191 -1
- package/src/__tests__/provider-register-reload.test.ts +36 -6
- package/src/__tests__/provider-register-thinking-levels.test.ts +51 -0
- package/src/__tests__/retry-tracker.test.ts +75 -70
- package/src/__tests__/role-manager.test.ts +585 -0
- package/src/__tests__/role-model-tools-registry-readiness.test.ts +114 -0
- package/src/__tests__/role-model-tools.test.ts +229 -0
- package/src/__tests__/search-files-completeness.test.ts +111 -0
- package/src/__tests__/search-files-ranking.test.ts +168 -0
- package/src/__tests__/server-auto-start.test.ts +121 -4
- package/src/__tests__/server-launcher-launch.test.ts +24 -6
- package/src/__tests__/server-launcher.test.ts +19 -2
- package/src/__tests__/session-sync.test.ts +36 -0
- package/src/__tests__/subagent-frame-buffer.test.ts +239 -0
- package/src/__tests__/tool-result-image-inliner.test.ts +206 -0
- package/src/__tests__/tui-prompt-adapter.test.ts +70 -64
- package/src/__tests__/turn-actionability.test.ts +86 -0
- package/src/__tests__/vcs-info.test.ts +145 -4
- package/src/__tests__/visibility-intent.test.ts +43 -0
- package/src/abort-latch.ts +55 -0
- package/src/abort-latch.ts.AGENTS.md +3 -0
- package/src/agent-settled.ts +72 -0
- package/src/agent-settled.ts.AGENTS.md +3 -0
- package/src/artifact-roots.ts +73 -0
- package/src/artifact-roots.ts.AGENTS.md +3 -0
- package/src/ask-user-attachments.ts +121 -0
- package/src/ask-user-attachments.ts.AGENTS.md +3 -0
- package/src/ask-user-tool.ts +56 -58
- package/src/ask-user-tool.ts.AGENTS.md +3 -0
- package/src/auto-session-namer.ts +334 -0
- package/src/auto-session-namer.ts.AGENTS.md +3 -0
- package/src/bridge-context.ts +86 -8
- package/src/bridge-context.ts.AGENTS.md +3 -0
- package/src/bridge-default-model-gate.ts +22 -6
- package/src/bridge-default-model-gate.ts.AGENTS.md +3 -0
- package/src/bridge.ts +1241 -360
- package/src/bridge.ts.AGENTS.md +3 -0
- package/src/canvas-tool.ts +107 -0
- package/src/command-handler.ts +490 -51
- package/src/command-handler.ts.AGENTS.md +3 -0
- package/src/commit-draft-agent.ts +114 -0
- package/src/commit-draft-agent.ts.AGENTS.md +3 -0
- package/src/commit-draft.ts +136 -0
- package/src/commit-draft.ts.AGENTS.md +3 -0
- package/src/connection.ts +32 -1
- package/src/connection.ts.AGENTS.md +3 -0
- package/src/dashboard-context-injector.ts +124 -0
- package/src/dashboard-context-injector.ts.AGENTS.md +3 -0
- package/src/dashboard-default-adapter.ts.AGENTS.md +3 -0
- package/src/dev-build.ts.AGENTS.md +3 -0
- package/src/empty-actionable-guard-config.ts +32 -0
- package/src/empty-actionable-guard-config.ts.AGENTS.md +3 -0
- package/src/empty-actionable-guard.ts +90 -0
- package/src/empty-actionable-guard.ts.AGENTS.md +3 -0
- package/src/event-forwarder.ts.AGENTS.md +3 -0
- package/src/flow-event-wiring.ts +4 -14
- package/src/flow-event-wiring.ts.AGENTS.md +3 -0
- package/src/git-link-builder.ts.AGENTS.md +3 -0
- package/src/git-poll.ts +38 -0
- package/src/git-poll.ts.AGENTS.md +3 -0
- package/src/hasui-flip.ts +56 -0
- package/src/hasui-flip.ts.AGENTS.md +3 -0
- package/src/markdown-image-inliner.ts +45 -2
- package/src/markdown-image-inliner.ts.AGENTS.md +3 -0
- package/src/model-tracker.ts +145 -19
- package/src/model-tracker.ts.AGENTS.md +3 -0
- package/src/multiselect-decode.ts.AGENTS.md +3 -0
- package/src/multiselect-list.ts.AGENTS.md +3 -0
- package/src/multiselect-polyfill.ts.AGENTS.md +3 -0
- package/src/process-metrics.ts.AGENTS.md +3 -0
- package/src/process-scanner.ts +114 -103
- package/src/process-scanner.ts.AGENTS.md +3 -0
- package/src/project-init/AGENTS.md +12 -0
- package/src/project-init/detect-stack.ts +146 -0
- package/src/project-init/dox-kb-config.ts +47 -0
- package/src/project-init/profiles.ts +135 -0
- package/src/project-init/scaffold.ts +192 -0
- package/src/project-init/seed-doctrine.ts +95 -0
- package/src/project-trust.ts +63 -0
- package/src/project-trust.ts.AGENTS.md +3 -0
- package/src/prompt-bus.ts +10 -1
- package/src/prompt-bus.ts.AGENTS.md +3 -0
- package/src/prompt-expander.ts +238 -37
- package/src/prompt-expander.ts.AGENTS.md +3 -0
- package/src/provider-register.ts +323 -54
- package/src/provider-register.ts.AGENTS.md +3 -0
- package/src/retry-tracker.ts +64 -39
- package/src/retry-tracker.ts.AGENTS.md +3 -0
- package/src/role-manager.ts +436 -0
- package/src/role-manager.ts.AGENTS.md +3 -0
- package/src/role-model-tools.ts +301 -0
- package/src/role-model-tools.ts.AGENTS.md +3 -0
- package/src/server-auto-start.ts +59 -23
- package/src/server-auto-start.ts.AGENTS.md +3 -0
- package/src/server-launcher.ts +56 -16
- package/src/server-launcher.ts.AGENTS.md +3 -0
- package/src/session-sync.ts +111 -15
- package/src/session-sync.ts.AGENTS.md +3 -0
- package/src/slash-dispatch.ts +13 -11
- package/src/slash-dispatch.ts.AGENTS.md +3 -0
- package/src/source-detector.ts.AGENTS.md +3 -0
- package/src/subagent-frame-buffer.ts +220 -0
- package/src/subagent-frame-buffer.ts.AGENTS.md +3 -0
- package/src/tool-result-image-inliner.ts +204 -0
- package/src/tool-result-image-inliner.ts.AGENTS.md +3 -0
- package/src/tui-prompt-adapter.ts +123 -0
- package/src/tui-prompt-adapter.ts.AGENTS.md +3 -0
- package/src/turn-actionability.ts +117 -0
- package/src/turn-actionability.ts.AGENTS.md +3 -0
- package/src/ui-modules.ts.AGENTS.md +3 -0
- package/src/vcs-info.ts +91 -129
- package/src/vcs-info.ts.AGENTS.md +3 -0
- package/src/visibility-intent.ts +34 -0
- package/src/visibility-intent.ts.AGENTS.md +3 -0
- package/src/__tests__/bridge-retry-ordering.test.ts +0 -148
- package/src/__tests__/bridge-shadow-queue-drain.test.ts +0 -221
- package/src/__tests__/fixtures/usage-limit-error-strings.ts +0 -127
- package/src/__tests__/usage-limit-orderer.test.ts +0 -117
- package/src/__tests__/vcs-info-jj.test.ts +0 -145
- package/src/usage-limit-orderer.ts +0 -93
package/src/session-sync.ts
CHANGED
|
@@ -2,13 +2,82 @@
|
|
|
2
2
|
* Session sync: register, replay, and handle session changes.
|
|
3
3
|
* Extracted from bridge.ts for clarity.
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
|
|
6
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
7
|
+
import { homedir } from "node:os";
|
|
8
|
+
import { join } from "node:path";
|
|
8
9
|
import { replayEntriesAsEvents } from "@blackbelt-technology/pi-dashboard-shared/state-replay.js";
|
|
9
|
-
import { gatherGitInfo, gatherJjInfo } from "./vcs-info.js";
|
|
10
10
|
import type { FlowInfo } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
11
|
-
import
|
|
11
|
+
import * as minimatchNS from "minimatch";
|
|
12
|
+
import type { BridgeContext } from "./bridge-context.js";
|
|
13
|
+
import { extractFirstMessage, filterHiddenCommands, getCurrentModelString } from "./bridge-context.js";
|
|
14
|
+
import { buildProviderCatalogue, toModelInfo } from "./provider-register.js";
|
|
15
|
+
import { detectSessionSource } from "./source-detector.js";
|
|
16
|
+
import { detectIsGitRepo, gatherGitInfo } from "./vcs-info.js";
|
|
17
|
+
|
|
18
|
+
// minimatch's entry shape varies by version/runtime (v10 exposes a named
|
|
19
|
+
// `minimatch`; v3/CJS-interop exposes it as the default). A namespace import
|
|
20
|
+
// normalises across both.
|
|
21
|
+
type MinimatchFn = (target: string, pattern: string, opts?: { nocase?: boolean }) => boolean;
|
|
22
|
+
const minimatch: MinimatchFn =
|
|
23
|
+
(minimatchNS as { minimatch?: MinimatchFn }).minimatch ??
|
|
24
|
+
(minimatchNS as unknown as { default?: MinimatchFn }).default ??
|
|
25
|
+
(minimatchNS as unknown as MinimatchFn);
|
|
26
|
+
|
|
27
|
+
// Mirror pi core (core/model-resolver.ts): a trailing `:<thinkingLevel>` on a
|
|
28
|
+
// pattern selects a thinking level and is not part of the model match.
|
|
29
|
+
const VALID_THINKING_LEVELS = new Set(["off", "minimal", "low", "medium", "high", "xhigh", "max"]);
|
|
30
|
+
|
|
31
|
+
function stripThinkingLevel(pattern: string): string {
|
|
32
|
+
const colonIdx = pattern.lastIndexOf(":");
|
|
33
|
+
if (colonIdx !== -1 && VALID_THINKING_LEVELS.has(pattern.slice(colonIdx + 1))) {
|
|
34
|
+
return pattern.slice(0, colonIdx);
|
|
35
|
+
}
|
|
36
|
+
return pattern;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Filter a models array to only include models matching the `enabledModels`
|
|
41
|
+
* patterns from `~/.pi/agent/settings.json`. When `enabledModels` is absent or
|
|
42
|
+
* empty the full list is returned unchanged.
|
|
43
|
+
*
|
|
44
|
+
* Matching mirrors pi core's `resolveModelScope`: each pattern is tested with
|
|
45
|
+
* minimatch (case-insensitive) against both the canonical `provider/id` and the
|
|
46
|
+
* bare `id`, so exact refs (`anthropic/claude-sonnet-4-6`), provider wildcards
|
|
47
|
+
* (`anthropic/*`), and bare globs (`*sonnet*`) all work. A trailing
|
|
48
|
+
* `:<thinkingLevel>` suffix is stripped before matching.
|
|
49
|
+
*/
|
|
50
|
+
export function filterByEnabledModels<T extends { provider: string; id: string }>(models: T[]): T[] {
|
|
51
|
+
try {
|
|
52
|
+
const settingsPath = join(homedir(), ".pi", "agent", "settings.json");
|
|
53
|
+
if (!existsSync(settingsPath)) return models;
|
|
54
|
+
const settings = JSON.parse(readFileSync(settingsPath, "utf-8"));
|
|
55
|
+
const rawPatterns: unknown[] | undefined = settings.enabledModels;
|
|
56
|
+
if (!Array.isArray(rawPatterns) || rawPatterns.length === 0) return models;
|
|
57
|
+
|
|
58
|
+
const patterns: string[] = [];
|
|
59
|
+
for (let i = 0; i < rawPatterns.length; i++) {
|
|
60
|
+
const entry = rawPatterns[i];
|
|
61
|
+
if (typeof entry === "string") {
|
|
62
|
+
patterns.push(stripThinkingLevel(entry));
|
|
63
|
+
} else {
|
|
64
|
+
console.warn(
|
|
65
|
+
`[pi-dashboard] enabledModels[${i}]: expected string, got ${typeof entry}. Skipping.`,
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (patterns.length === 0) return models;
|
|
70
|
+
|
|
71
|
+
return models.filter((m) => {
|
|
72
|
+
const fullId = `${m.provider}/${m.id}`;
|
|
73
|
+
return patterns.some(
|
|
74
|
+
(p) => minimatch(fullId, p, { nocase: true }) || minimatch(m.id, p, { nocase: true }),
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
} catch {
|
|
78
|
+
return models; // fall back to full list on any error
|
|
79
|
+
}
|
|
80
|
+
}
|
|
12
81
|
|
|
13
82
|
/**
|
|
14
83
|
* Send full state sync to the server (session_register, commands, flows, models).
|
|
@@ -47,7 +116,23 @@ export function sendStateSync(
|
|
|
47
116
|
// registers (reattach after dashboard restart, in-process Ctrl+F fork)
|
|
48
117
|
// omit it because the sessionId is already known to the server.
|
|
49
118
|
// See change: spawn-correlation-token (Decision 3).
|
|
50
|
-
|
|
119
|
+
//
|
|
120
|
+
// The token is SINGLE-USE. After reading it on the first register we scrub
|
|
121
|
+
// `process.env.PI_DASHBOARD_SPAWN_TOKEN` so any pi process this pi later
|
|
122
|
+
// spawns (subagent, nested `pi`, reload) does NOT inherit and re-report the
|
|
123
|
+
// consumed token. See change: fix-spawn-token-env-leak.
|
|
124
|
+
let spawnToken: string | undefined;
|
|
125
|
+
if (isFirstRegister) {
|
|
126
|
+
spawnToken = process.env.PI_DASHBOARD_SPAWN_TOKEN;
|
|
127
|
+
delete process.env.PI_DASHBOARD_SPAWN_TOKEN;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Strong, restart-survival flag, derived from the capture-once boolean
|
|
131
|
+
// (captured at bridge startup BEFORE the token was scrubbed), not a live
|
|
132
|
+
// env read — the token is intentionally removed after first register.
|
|
133
|
+
// Sent on every register (unlike spawnToken which fires only on the first).
|
|
134
|
+
// See change: fix-spawn-token-env-leak.
|
|
135
|
+
const dashboardSpawned = bc.dashboardSpawned;
|
|
51
136
|
|
|
52
137
|
bc.connection.send({
|
|
53
138
|
type: "session_register",
|
|
@@ -63,7 +148,11 @@ export function sendStateSync(
|
|
|
63
148
|
eventCount,
|
|
64
149
|
pid: process.pid,
|
|
65
150
|
registerReason,
|
|
151
|
+
// Tri-state git-repo signal computed synchronously (no git_info_update
|
|
152
|
+
// arrival race). See change: gate-session-worktree-button-on-git.
|
|
153
|
+
isGitRepo: detectIsGitRepo(process.cwd()),
|
|
66
154
|
...(spawnToken ? { spawnToken } : {}),
|
|
155
|
+
...(dashboardSpawned ? { dashboardSpawned: true } : {}),
|
|
67
156
|
});
|
|
68
157
|
|
|
69
158
|
bc.hasRegisteredOnce = true;
|
|
@@ -77,10 +166,7 @@ export function sendStateSync(
|
|
|
77
166
|
|
|
78
167
|
if (bc.cachedModelRegistry) {
|
|
79
168
|
try {
|
|
80
|
-
const models = bc.cachedModelRegistry.getAvailable().map(
|
|
81
|
-
provider: m.provider,
|
|
82
|
-
id: m.id,
|
|
83
|
-
}));
|
|
169
|
+
const models = filterByEnabledModels(bc.cachedModelRegistry.getAvailable().map(toModelInfo));
|
|
84
170
|
bc.connection.send({ type: "models_list", sessionId: bc.sessionId, models });
|
|
85
171
|
// See change: replace-hardcoded-provider-lists.
|
|
86
172
|
bc.connection.send({ type: "providers_list", sessionId: bc.sessionId, providers: buildProviderCatalogue() });
|
|
@@ -121,6 +207,7 @@ export function handleSessionChange(
|
|
|
121
207
|
bc.lastFirstMessage = firstMessage;
|
|
122
208
|
bc.lastGitBranch = undefined;
|
|
123
209
|
bc.lastGitPrNumber = undefined;
|
|
210
|
+
bc.lastGitWorktreeJson = undefined;
|
|
124
211
|
bc.lastSessionName = bc.pi.getSessionName() ?? "";
|
|
125
212
|
bc.lastModel = getCurrentModelString(bc);
|
|
126
213
|
bc.lastThinkingLevel = (bc.pi as any).getThinkingLevel?.() ?? undefined;
|
|
@@ -136,6 +223,9 @@ export function handleSessionChange(
|
|
|
136
223
|
// handleSessionChange always mints a fresh sessionId (new/fork/resume),
|
|
137
224
|
// so registerReason is unconditionally "spawn" — even after the bridge
|
|
138
225
|
// has previously reattached. See change: reattach-move-to-front.
|
|
226
|
+
// dashboardSpawned from the capture-once boolean (token already scrubbed).
|
|
227
|
+
// See change: fix-spawn-token-env-leak.
|
|
228
|
+
const dashboardSpawned = bc.dashboardSpawned;
|
|
139
229
|
bc.connection.send({
|
|
140
230
|
type: "session_register",
|
|
141
231
|
sessionId: bc.sessionId,
|
|
@@ -146,10 +236,13 @@ export function handleSessionChange(
|
|
|
146
236
|
thinkingLevel: bc.lastThinkingLevel,
|
|
147
237
|
sessionFile: bc.lastSessionFile,
|
|
148
238
|
sessionDir: bc.lastSessionDir,
|
|
239
|
+
...(dashboardSpawned ? { dashboardSpawned: true } : {}),
|
|
149
240
|
firstMessage,
|
|
150
241
|
eventCount,
|
|
151
242
|
pid: process.pid,
|
|
152
243
|
registerReason: "spawn",
|
|
244
|
+
// See change: gate-session-worktree-button-on-git.
|
|
245
|
+
isGitRepo: detectIsGitRepo(ctx.cwd),
|
|
153
246
|
});
|
|
154
247
|
|
|
155
248
|
replaySessionEntries(bc);
|
|
@@ -160,7 +253,13 @@ export function handleSessionChange(
|
|
|
160
253
|
if (gitInfo) {
|
|
161
254
|
bc.lastGitBranch = gitInfo.gitBranch;
|
|
162
255
|
bc.lastGitPrNumber = gitInfo.gitPrNumber;
|
|
163
|
-
bc.
|
|
256
|
+
bc.lastGitWorktreeJson = gitInfo.gitWorktree ? JSON.stringify(gitInfo.gitWorktree) : "null";
|
|
257
|
+
bc.connection.send({
|
|
258
|
+
type: "git_info_update",
|
|
259
|
+
sessionId: bc.sessionId,
|
|
260
|
+
...gitInfo,
|
|
261
|
+
gitWorktree: gitInfo.gitWorktree ?? null,
|
|
262
|
+
});
|
|
164
263
|
}
|
|
165
264
|
|
|
166
265
|
const commands = filterHiddenCommands(bc.pi.getCommands());
|
|
@@ -171,10 +270,7 @@ export function handleSessionChange(
|
|
|
171
270
|
|
|
172
271
|
if (bc.cachedModelRegistry) {
|
|
173
272
|
try {
|
|
174
|
-
const models = bc.cachedModelRegistry.getAvailable().map(
|
|
175
|
-
provider: m.provider,
|
|
176
|
-
id: m.id,
|
|
177
|
-
}));
|
|
273
|
+
const models = filterByEnabledModels(bc.cachedModelRegistry.getAvailable().map(toModelInfo));
|
|
178
274
|
bc.connection.send({ type: "models_list", sessionId: bc.sessionId, models });
|
|
179
275
|
// See change: replace-hardcoded-provider-lists.
|
|
180
276
|
bc.connection.send({ type: "providers_list", sessionId: bc.sessionId, providers: buildProviderCatalogue() });
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
# session-sync.ts — index
|
|
2
|
+
|
|
3
|
+
Session register/replay/switch lifecycle. Exports `sendStateSync`, `replaySessionEntries`, `handleSessionChange`. First register tagged `registerReason:"spawn"` (scrubs single-use `PI_DASHBOARD_SPAWN_TOKEN`); reconnects tagged `"reattach"`. Sends commands_list, flows_list, models_list, providers_list, git_info_update. Delegates to `detectSessionSource`, `gatherGitInfo`, `buildProviderCatalogue`.
|
package/src/slash-dispatch.ts
CHANGED
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
* the per-session RPC keeper UDS and emits the terminal command_feedback).
|
|
11
11
|
* - Path D: `pi.dispatchCommand` absent AND the bridge is NOT headless
|
|
12
12
|
* (tmux / wt) OR no `connection` was supplied → emit
|
|
13
|
-
* `command_feedback {status:"error"}` with a hint
|
|
14
|
-
*
|
|
13
|
+
* `command_feedback {status:"error"}` with a hint explaining that
|
|
14
|
+
* terminal-hosted sessions (tmux / Windows Terminal) own pi's stdin
|
|
15
|
+
* themselves and therefore cannot accept dispatched extension commands.
|
|
15
16
|
* Note: pi.sendUserMessage() hardcodes expandPromptTemplates: false, which
|
|
16
17
|
* skips _tryExecuteExtensionCommand; extension commands sent this way
|
|
17
18
|
* become regular LLM messages. This is a pi limitation — the bridge has
|
|
@@ -123,16 +124,17 @@ export async function tryDispatchExtensionCommand(
|
|
|
123
124
|
}
|
|
124
125
|
|
|
125
126
|
// Path D: No dispatchCommand, not headless (tmux / wt) or no connection.
|
|
126
|
-
//
|
|
127
|
-
//
|
|
128
|
-
//
|
|
129
|
-
//
|
|
130
|
-
//
|
|
131
|
-
// See change: fix-slash-dispatch-delivery.
|
|
127
|
+
// Dashboard-spawned headless sessions dispatch through the RPC keeper
|
|
128
|
+
// sidecar (always-on as of change `enable-rpc-keeper-by-default`). For
|
|
129
|
+
// tmux / Windows Terminal sessions the user's terminal owns pi's stdin,
|
|
130
|
+
// so the keeper cannot inject — the command becomes a regular LLM message
|
|
131
|
+
// unless the user upgrades to a pi version that exposes `pi.dispatchCommand`
|
|
132
|
+
// (Path B). See change: fix-slash-dispatch-delivery, enable-rpc-keeper-by-default.
|
|
132
133
|
const RPC_KEEPER_HINT =
|
|
133
|
-
"Extension slash commands cannot be dispatched from
|
|
134
|
-
"
|
|
135
|
-
|
|
134
|
+
"Extension slash commands cannot be dispatched from this session shape " +
|
|
135
|
+
"(typically tmux or Windows Terminal sessions, where the user's terminal " +
|
|
136
|
+
"owns pi's stdin). Dashboard-spawned headless sessions support slash " +
|
|
137
|
+
"commands natively.";
|
|
136
138
|
emitFeedback(sink, sessionId, text, "error", RPC_KEEPER_HINT);
|
|
137
139
|
return true;
|
|
138
140
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
# slash-dispatch.ts — index
|
|
2
|
+
|
|
3
|
+
Extension slash-command dispatch (routing-step 9). Exports `tryDispatchExtensionCommand`, `FeedbackSink`, `DispatchConnection`. Three paths: B `pi.dispatchCommand` direct; C headless RPC `dispatch_extension_command` to server; D tmux/WT error feedback. Guarantees exactly one `started` + one terminal event. Non-extension text returns `false` (caller falls through).
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
# source-detector.ts — index
|
|
2
|
+
|
|
3
|
+
Detects session source env. Exports `detectSessionSource(hasUI?, sessionFile?)` → `SessionSource`. TUI attached → `tui`/`tmux` (ZED_TERM/TMUX). Headless → reads `.meta.json` sidecar via `readSessionMeta` for `"dashboard"`; else `zed`/`tmux`/`tui`.
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SubagentFrameBuffer — makes the running-subagent timeline reconcilable
|
|
3
|
+
* instead of fire-and-forget.
|
|
4
|
+
*
|
|
5
|
+
* Background: the bridge's `pi.events.emit` intercept forwards subagent
|
|
6
|
+
* lifecycle frames (`subagents:created/started/completed/failed`) as
|
|
7
|
+
* `event_forward` messages, but only while `sessionReady && isActive()`.
|
|
8
|
+
* Frames emitted during a not-ready window (reconnect / discovery / `/reload`
|
|
9
|
+
* / bridge takeover) were silently dropped, so a running subagent's detail
|
|
10
|
+
* panel stayed empty or stale until the next tick — or until completion, when
|
|
11
|
+
* the durable reducer backfill kicks in. See change:
|
|
12
|
+
* fix-subagent-live-detail-reliability.
|
|
13
|
+
*
|
|
14
|
+
* This buffer closes that gap two ways:
|
|
15
|
+
* - D1 buffer-and-flush: while not ready, retain the latest frame per
|
|
16
|
+
* `agentId` (each frame carries a FULL snapshot, so latest supersedes
|
|
17
|
+
* older ones) in a bounded map, and drain it on the next re-register.
|
|
18
|
+
* - D2 resync: keep the latest snapshot of each RUNNING subagent so the
|
|
19
|
+
* client can pull current state after a gap that outlived the buffer
|
|
20
|
+
* (long disconnect) or when opening detail for a running subagent whose
|
|
21
|
+
* `entries[]` is empty. Finished subagents are dropped from the snapshot
|
|
22
|
+
* map — the durable completed-case backfill already covers them, so a
|
|
23
|
+
* resync for an unknown/finished agent is a no-op.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/** A subagent EventBus frame: the raw channel name plus its data payload. */
|
|
27
|
+
export interface SubagentFrame {
|
|
28
|
+
channel: string;
|
|
29
|
+
data: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** EventBus channels that carry subagent lifecycle frames. */
|
|
33
|
+
export const SUBAGENT_CHANNELS = new Set<string>([
|
|
34
|
+
"subagents:created",
|
|
35
|
+
"subagents:started",
|
|
36
|
+
"subagents:completed",
|
|
37
|
+
"subagents:failed",
|
|
38
|
+
]);
|
|
39
|
+
|
|
40
|
+
/** Channels that terminate a subagent run (drop it from the resync snapshots). */
|
|
41
|
+
const TERMINAL_CHANNELS = new Set<string>(["subagents:completed", "subagents:failed"]);
|
|
42
|
+
|
|
43
|
+
export interface SubagentFrameStats {
|
|
44
|
+
/** Frames forwarded live (ready path). */
|
|
45
|
+
forwarded: number;
|
|
46
|
+
/** Frames buffered because the bridge was not ready. */
|
|
47
|
+
buffered: number;
|
|
48
|
+
/** Frames drained + forwarded on re-register. */
|
|
49
|
+
flushed: number;
|
|
50
|
+
/** Not-ready frames that could not be buffered (no `agentId`). */
|
|
51
|
+
droppedNoAgentId: number;
|
|
52
|
+
/** Frames/snapshots evicted because the 64-agent bound was exceeded. */
|
|
53
|
+
overflowEvicted: number;
|
|
54
|
+
/** Resync requests received. */
|
|
55
|
+
resyncRequests: number;
|
|
56
|
+
/** Resync requests answered with a snapshot. */
|
|
57
|
+
resyncServed: number;
|
|
58
|
+
/** Resync requests served via the fast `agentId` key. */
|
|
59
|
+
resyncByAgentId: number;
|
|
60
|
+
/** Resync requests served via the derived `agentSessionId` values-scan. */
|
|
61
|
+
resyncByAgentSessionId: number;
|
|
62
|
+
/** Resync requests for an unknown/finished agent (no-op). */
|
|
63
|
+
resyncNoop: number;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export class SubagentFrameBuffer {
|
|
67
|
+
/** agentId → latest buffered frame (retained across a not-ready window). */
|
|
68
|
+
private readonly pending = new Map<string, SubagentFrame>();
|
|
69
|
+
/** agentId → latest snapshot of a still-running subagent (for resync). */
|
|
70
|
+
private readonly snapshots = new Map<string, SubagentFrame>();
|
|
71
|
+
|
|
72
|
+
readonly stats: SubagentFrameStats = {
|
|
73
|
+
forwarded: 0,
|
|
74
|
+
buffered: 0,
|
|
75
|
+
flushed: 0,
|
|
76
|
+
droppedNoAgentId: 0,
|
|
77
|
+
overflowEvicted: 0,
|
|
78
|
+
resyncRequests: 0,
|
|
79
|
+
resyncServed: 0,
|
|
80
|
+
resyncByAgentId: 0,
|
|
81
|
+
resyncByAgentSessionId: 0,
|
|
82
|
+
resyncNoop: 0,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/** @param maxAgents bound on distinct buffered agents (drop-oldest beyond it). */
|
|
86
|
+
constructor(private readonly maxAgents = 64) {}
|
|
87
|
+
|
|
88
|
+
static isSubagentChannel(channel: string): boolean {
|
|
89
|
+
return SUBAGENT_CHANNELS.has(channel);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
static agentIdOf(data: Record<string, unknown> | undefined): string | undefined {
|
|
93
|
+
return data && typeof data.id === "string" ? data.id : undefined;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The runner session id (v7) a frame carries on its `details`, if any. The
|
|
98
|
+
* producer (>= 0.2.3) sets `agentSessionId` on `AgentDetails` = the frame
|
|
99
|
+
* `data.details` payload. Absent → undefined (older producer).
|
|
100
|
+
*/
|
|
101
|
+
static agentSessionIdOf(data: Record<string, unknown> | undefined): string | undefined {
|
|
102
|
+
const details = data?.details as Record<string, unknown> | undefined;
|
|
103
|
+
return details && typeof details.agentSessionId === "string" ? details.agentSessionId : undefined;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Evict the oldest-inserted keys from `map` until it fits `maxAgents`.
|
|
108
|
+
* Each eviction is real data loss, so it bumps the overflow counter.
|
|
109
|
+
*/
|
|
110
|
+
private evictToBound(map: Map<string, SubagentFrame>): void {
|
|
111
|
+
while (map.size > this.maxAgents) {
|
|
112
|
+
const oldest = map.keys().next().value;
|
|
113
|
+
if (oldest === undefined) break;
|
|
114
|
+
map.delete(oldest);
|
|
115
|
+
this.stats.overflowEvicted += 1;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Update the running-subagent snapshot map. Called for every subagent frame
|
|
121
|
+
* regardless of ready state so a resync can always return current state.
|
|
122
|
+
* Bounded to `maxAgents` with the same latest-wins / drop-oldest policy as
|
|
123
|
+
* `pending`, so retained resync snapshots cannot grow unbounded.
|
|
124
|
+
*/
|
|
125
|
+
private track(channel: string, agentId: string, data: Record<string, unknown>): void {
|
|
126
|
+
if (TERMINAL_CHANNELS.has(channel)) {
|
|
127
|
+
this.snapshots.delete(agentId);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
// Re-insert to move this agent to the most-recent position, then bound.
|
|
131
|
+
this.snapshots.delete(agentId);
|
|
132
|
+
this.snapshots.set(agentId, { channel, data });
|
|
133
|
+
this.evictToBound(this.snapshots);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Record a subagent frame that IS being forwarded live. Updates the resync
|
|
138
|
+
* snapshot and the forwarded counter. Call on the ready path.
|
|
139
|
+
*/
|
|
140
|
+
markForwarded(channel: string, data: Record<string, unknown>): void {
|
|
141
|
+
const agentId = SubagentFrameBuffer.agentIdOf(data);
|
|
142
|
+
if (agentId) this.track(channel, agentId, data);
|
|
143
|
+
this.stats.forwarded += 1;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Buffer a subagent frame emitted while the bridge is NOT ready. Retains the
|
|
148
|
+
* latest frame per `agentId`; when the distinct-agent bound is exceeded,
|
|
149
|
+
* evicts the oldest-inserted agent. Returns true if buffered, false if it
|
|
150
|
+
* could not be buffered (no `agentId` on the frame).
|
|
151
|
+
*/
|
|
152
|
+
buffer(channel: string, data: Record<string, unknown>): boolean {
|
|
153
|
+
const agentId = SubagentFrameBuffer.agentIdOf(data);
|
|
154
|
+
if (!agentId) {
|
|
155
|
+
this.stats.droppedNoAgentId += 1;
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
this.track(channel, agentId, data);
|
|
159
|
+
// Re-insert to move this agent to the most-recent position (emission order).
|
|
160
|
+
this.pending.delete(agentId);
|
|
161
|
+
this.pending.set(agentId, { channel, data });
|
|
162
|
+
this.evictToBound(this.pending);
|
|
163
|
+
this.stats.buffered += 1;
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Drain the buffered frames in emission order (oldest-inserted agent first).
|
|
169
|
+
* Clears the buffer; the caller forwards each returned frame. The resync
|
|
170
|
+
* snapshots are intentionally NOT cleared — a subagent can still be running.
|
|
171
|
+
*/
|
|
172
|
+
drain(): SubagentFrame[] {
|
|
173
|
+
const out = [...this.pending.values()];
|
|
174
|
+
this.pending.clear();
|
|
175
|
+
this.stats.flushed += out.length;
|
|
176
|
+
return out;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Resync (D2): the latest retained snapshot for a running subagent, or
|
|
181
|
+
* undefined for an unknown/finished agent (caller replies with nothing).
|
|
182
|
+
*
|
|
183
|
+
* The incoming `id` may be EITHER the v4 `agentId` (fast-path key lookup) or
|
|
184
|
+
* the v7 runner `agentSessionId` carried on a frame's `details` (derived
|
|
185
|
+
* values-scan fallback). The mapping is a pure function of the already-bounded
|
|
186
|
+
* (≤ maxAgents) `snapshots` map — no separate alias index, no `finished` set —
|
|
187
|
+
* so it cannot leak or diverge. The scan is O(≤ maxAgents) on a rare,
|
|
188
|
+
* user-initiated cold path. Terminal/evicted runs retain no snapshot, so both
|
|
189
|
+
* ids resolve to nothing. See change: resolve-subagent-inspector-by-session-id (D3).
|
|
190
|
+
*/
|
|
191
|
+
resync(id: string): SubagentFrame | undefined {
|
|
192
|
+
this.stats.resyncRequests += 1;
|
|
193
|
+
const byAgentId = this.snapshots.get(id);
|
|
194
|
+
if (byAgentId) {
|
|
195
|
+
this.stats.resyncServed += 1;
|
|
196
|
+
this.stats.resyncByAgentId += 1;
|
|
197
|
+
return byAgentId;
|
|
198
|
+
}
|
|
199
|
+
for (const snap of this.snapshots.values()) {
|
|
200
|
+
if (SubagentFrameBuffer.agentSessionIdOf(snap.data) === id) {
|
|
201
|
+
this.stats.resyncServed += 1;
|
|
202
|
+
this.stats.resyncByAgentSessionId += 1;
|
|
203
|
+
return snap;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
this.stats.resyncNoop += 1;
|
|
207
|
+
return undefined;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** Drop all retained state (session change / shutdown). */
|
|
211
|
+
reset(): void {
|
|
212
|
+
this.pending.clear();
|
|
213
|
+
this.snapshots.clear();
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** Number of distinct agents currently buffered. */
|
|
217
|
+
get pendingSize(): number {
|
|
218
|
+
return this.pending.size;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
# subagent-frame-buffer.ts — index
|
|
2
|
+
|
|
3
|
+
Pure class `SubagentFrameBuffer` + `SUBAGENT_CHANNELS` set. Makes running-subagent timeline reconcilable. D1: `buffer(channel,data)` retains latest frame per `agentId` while bridge not ready (bounded `maxAgents`=64, drop-oldest, re-insert=most-recent); `drain()` returns buffered frames emission-order + clears (bridge flushes on re-register). D2: tracks latest snapshot per RUNNING agent (dropped on `subagents:completed`/`failed`), BOUNDED to `maxAgents` (same latest-wins/drop-oldest as `pending` via `evictToBound`) so resync storage stays bounded; `resync(agentId)` returns it or undefined (unknown/finished no-op). `markForwarded` counts ready-path + updates snapshot. `reset()` on session change/shutdown. `stats` counters (forwarded/buffered/flushed/droppedNoAgentId/overflowEvicted/resync*). Statics `isSubagentChannel`, `agentIdOf`. See change: fix-subagent-live-detail-reliability.
|