@blackbelt-technology/pi-agent-dashboard 0.10.0 → 0.11.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/AGENTS.md +2 -2
- package/README.md +47 -6
- package/docs/architecture.md +1369 -63
- package/package.json +14 -9
- package/packages/extension/package.json +5 -3
- package/packages/extension/src/bridge-handlers/dispatch.ts +57 -3
- package/packages/extension/src/bridge-handlers/instance.ts +10 -1
- package/packages/extension/src/bridge-handlers/lifecycle.ts +65 -26
- package/packages/extension/src/bridge-ticket-client.ts +61 -7
- package/packages/extension/src/bridge-tls-checks.ts +79 -0
- package/packages/extension/src/bridge.ts +41 -28
- package/packages/extension/src/canvas-tool.ts +2 -0
- package/packages/extension/src/command-handler.ts +80 -6
- package/packages/extension/src/connect-target.ts +23 -0
- package/packages/extension/src/connection.ts +30 -7
- package/packages/extension/src/dashboard-http-origin.ts +88 -0
- package/packages/extension/src/dev-build.ts +11 -1
- package/packages/extension/src/git-link-builder.ts +11 -2
- package/packages/extension/src/inbound-limits.ts +138 -0
- package/packages/extension/src/local-token-header.ts +77 -6
- package/packages/extension/src/model-refresh.ts +69 -0
- package/packages/extension/src/pinned-endpoint.ts +44 -0
- package/packages/extension/src/project-trust-live.ts +143 -0
- package/packages/extension/src/project-trust.ts +159 -20
- package/packages/extension/src/provider-register.ts +59 -18
- package/packages/extension/src/remote-registration-gate.ts +21 -21
- package/packages/extension/src/remote-upgrade-preparer.ts +104 -0
- package/packages/extension/src/role-model-tools.ts +47 -6
- package/packages/extension/src/server-auto-start.ts +1 -1
- package/packages/extension/src/server-proof-probe.ts +117 -0
- package/packages/extension/src/session-sync.ts +42 -12
- package/packages/extension/src/vault-delivery.ts +11 -1
- package/packages/server/package.json +8 -8
- package/packages/server/src/access/access-grants.ts +61 -8
- package/packages/server/src/access/access-health.ts +10 -0
- package/packages/server/src/access/access-plane.ts +5 -1
- package/packages/server/src/access/containment-gate.ts +55 -17
- package/packages/server/src/access/cwd-verdict.ts +3 -3
- package/packages/server/src/access/pi-trust-live.ts +244 -0
- package/packages/server/src/access/pi-trust-mirror-service.ts +44 -11
- package/packages/server/src/access/planes.ts +106 -1
- package/packages/server/src/access/preview-egress-store.ts +153 -0
- package/packages/server/src/access/prompt-channel.ts +5 -0
- package/packages/server/src/access/provisioning-wiring.ts +113 -0
- package/packages/server/src/access/provisioning.ts +763 -0
- package/packages/server/src/access/yolo-session.ts +54 -2
- package/packages/server/src/acp-bridge/acp-session-adapter.ts +8 -3
- package/packages/server/src/agent-events/agent-event-hub.ts +158 -0
- package/packages/server/src/auth/audit-log.ts +80 -0
- package/packages/server/src/auth/auth-plugin.ts +44 -25
- package/packages/server/src/auth/auth.ts +24 -4
- package/packages/server/src/auth/bearer-auth.ts +52 -12
- package/packages/server/src/auth/cors-origin.ts +76 -29
- package/packages/server/src/auth/csp-report-paths.ts +31 -0
- package/packages/server/src/auth/csp-report-sink.ts +302 -0
- package/packages/server/src/auth/csp-report-store.ts +406 -0
- package/packages/server/src/auth/csp.ts +105 -9
- package/packages/server/src/auth/dashboard-credential-store.ts +4 -0
- package/packages/server/src/auth/dashboard-state-caller.ts +29 -0
- package/packages/server/src/auth/local-proof-refusal-log.ts +89 -0
- package/packages/server/src/auth/local-proof.ts +69 -18
- package/packages/server/src/auth/localhost-guard.ts +48 -10
- package/packages/server/src/auth/nav-intent.ts +72 -0
- package/packages/server/src/auth/passkey/passkey-assets.ts +99 -0
- package/packages/server/src/auth/passkey/passkey-pages.ts +17 -81
- package/packages/server/src/auth/passkey/passkey-routes.ts +8 -0
- package/packages/server/src/auth/pi-legacy-credentials.ts +3 -0
- package/packages/server/src/auth/plugin-server-trust.ts +29 -0
- package/packages/server/src/auth/plugin-trust-store.ts +103 -0
- package/packages/server/src/auth/proven-tls.ts +45 -0
- package/packages/server/src/auth/provider-auth-storage.ts +6 -1
- package/packages/server/src/auth/radius-mcp.ts +1 -1
- package/packages/server/src/auth/request-principal.ts +32 -0
- package/packages/server/src/auth/secret-rotation.ts +246 -0
- package/packages/server/src/auth/secure-origin.ts +56 -0
- package/packages/server/src/auth/serve-app-host.ts +111 -11
- package/packages/server/src/auth/ws-ticket.ts +39 -1
- package/packages/server/src/auth/ws-upgrade-reject-log.ts +4 -1
- package/packages/server/src/browser-handlers/directory-handler.ts +23 -0
- package/packages/server/src/browser-handlers/folder-gate.ts +55 -0
- package/packages/server/src/browser-handlers/handler-context.ts +25 -2
- package/packages/server/src/browser-handlers/session-action-handler.ts +9 -1
- package/packages/server/src/browser-handlers/subscription-handler.ts +100 -2
- package/packages/server/src/browser-handlers/terminal-handler.ts +108 -10
- package/packages/server/src/canvas/canvas-accumulator.ts +35 -7
- package/packages/server/src/cli.ts +210 -39
- package/packages/server/src/config-api.ts +23 -1
- package/packages/server/src/config-snapshot.ts +48 -1
- package/packages/server/src/directory-service.ts +160 -54
- package/packages/server/src/event-wiring.ts +143 -108
- package/packages/server/src/git-worktree/git-operations.ts +44 -10
- package/packages/server/src/git-worktree/redact-git-text.ts +124 -0
- package/packages/server/src/git-worktree/ref-arg.ts +39 -0
- package/packages/server/src/git-worktree/worktree-init-trust.ts +43 -1
- package/packages/server/src/identity/http-road-classification.ts +13 -1
- package/packages/server/src/identity/ws-message-scope.ts +1 -0
- package/packages/server/src/identity/ws-road-classification.ts +1 -0
- package/packages/server/src/known-server-moves.ts +36 -15
- package/packages/server/src/lib/browse-roots.ts +118 -17
- package/packages/server/src/lib/client-dist.ts +36 -21
- package/packages/server/src/lib/dashboard-state-guard.ts +230 -0
- package/packages/server/src/lib/diagram-render.ts +4 -6
- package/packages/server/src/lib/eml.ts +3 -8
- package/packages/server/src/lib/file-cwd-admission.ts +145 -0
- package/packages/server/src/lib/grep-worker.ts +23 -0
- package/packages/server/src/lib/grep.ts +93 -7
- package/packages/server/src/lib/index-html.ts +81 -0
- package/packages/server/src/lib/office-preview.ts +2 -3
- package/packages/server/src/lib/path-containment.ts +7 -0
- package/packages/server/src/lib/resolve-file-mention.ts +11 -9
- package/packages/server/src/lib/route-admission.ts +80 -0
- package/packages/server/src/lib/writable-md-target.ts +4 -0
- package/packages/server/src/lifecycle/recovery-server.ts +65 -18
- package/packages/server/src/live-server/capability-redact.ts +15 -0
- package/packages/server/src/live-server/live-browser-gate.ts +22 -0
- package/packages/server/src/live-server/live-capability.ts +224 -17
- package/packages/server/src/live-server/live-csp-report.ts +63 -0
- package/packages/server/src/live-server/live-csp.ts +93 -0
- package/packages/server/src/live-server/live-egress.ts +435 -0
- package/packages/server/src/live-server/live-exposure.ts +149 -0
- package/packages/server/src/live-server/live-log.ts +21 -0
- package/packages/server/src/live-server/live-origin-scan.ts +298 -0
- package/packages/server/src/live-server/live-server-manager.ts +209 -33
- package/packages/server/src/live-server/live-server-proxy.ts +162 -17
- package/packages/server/src/live-server/live-static.ts +228 -0
- package/packages/server/src/openspec/dependencies-file.ts +122 -0
- package/packages/server/src/openspec/openspec-change-watcher.ts +3 -1
- package/packages/server/src/openspec/openspec-dependency-inputs.ts +281 -0
- package/packages/server/src/openspec/openspec-poll-fs-helpers.ts +72 -26
- package/packages/server/src/openspec/openspec-poll-worker-pool.ts +48 -12
- package/packages/server/src/openspec/openspec-poll-worker.ts +95 -9
- package/packages/server/src/openspec/workflow-schema-status.ts +379 -0
- package/packages/server/src/openspec/workflow-schema.ts +141 -267
- package/packages/server/src/package/npm-search-proxy.ts +5 -2
- package/packages/server/src/package/provider-probe.ts +8 -2
- package/packages/server/src/pairing/browser-gateway.ts +188 -12
- package/packages/server/src/pairing/device-token-services.ts +26 -0
- package/packages/server/src/pairing/paired-devices.ts +335 -22
- package/packages/server/src/pairing/pairing.ts +34 -4
- package/packages/server/src/pairing/socket-locality.ts +26 -0
- package/packages/server/src/persistence/preferences-store.ts +9 -0
- package/packages/server/src/pi/bridge-channel.ts +33 -0
- package/packages/server/src/pi/bridge-upgrade-auth.ts +18 -3
- package/packages/server/src/pi/gateway-listeners.ts +9 -3
- package/packages/server/src/pi/host-project-trust.ts +14 -6
- package/packages/server/src/pi/pi-gateway.ts +191 -21
- package/packages/server/src/pi/resource-toggle-trust.ts +1 -1
- package/packages/server/src/plugin-discovery-wiring.ts +142 -0
- package/packages/server/src/plugin-event-seam.ts +116 -4
- package/packages/server/src/plugin-runtime-clients.ts +89 -0
- package/packages/server/src/routes/access-routes.ts +159 -9
- package/packages/server/src/routes/agent-event-stream-routes.ts +137 -0
- package/packages/server/src/routes/canvas-types-routes.ts +20 -6
- package/packages/server/src/routes/csp-violations-routes.ts +162 -0
- package/packages/server/src/routes/file-routes.ts +329 -209
- package/packages/server/src/routes/file-write-binary-routes.ts +77 -20
- package/packages/server/src/routes/folder-project-routes.ts +18 -12
- package/packages/server/src/routes/git-routes.ts +319 -203
- package/packages/server/src/routes/grep-routes.ts +38 -14
- package/packages/server/src/routes/known-servers-routes.ts +189 -91
- package/packages/server/src/routes/live-server-routes.ts +378 -15
- package/packages/server/src/routes/local-proof-routes.ts +14 -0
- package/packages/server/src/routes/nav-intent-routes.ts +46 -0
- package/packages/server/src/routes/openspec-group-routes.ts +53 -44
- package/packages/server/src/routes/openspec-routes.ts +379 -28
- package/packages/server/src/routes/package-routes.ts +58 -10
- package/packages/server/src/routes/pairing-routes.ts +146 -10
- package/packages/server/src/routes/pi-trust-query-routes.ts +330 -0
- package/packages/server/src/routes/plugin-activation-routes.ts +59 -0
- package/packages/server/src/routes/plugin-runtime-client-routes.ts +149 -0
- package/packages/server/src/routes/provider-auth-routes.ts +15 -2
- package/packages/server/src/routes/resource-activation-routes.ts +18 -4
- package/packages/server/src/routes/session-routes.ts +51 -4
- package/packages/server/src/routes/system-routes.ts +84 -15
- package/packages/server/src/routes/ui-link-base.ts +88 -0
- package/packages/server/src/runtime-overlay/runtime-io.ts +2 -9
- package/packages/server/src/server.ts +648 -137
- package/packages/server/src/session/hydration-state.ts +148 -0
- package/packages/server/src/session/memory-session-manager.ts +7 -0
- package/packages/server/src/session/replay-exit-controller.ts +221 -0
- package/packages/server/src/session/retained-transcript.ts +9 -2
- package/packages/server/src/session/session-load-worker.ts +11 -2
- package/packages/server/src/spawn-process/headless-pid-registry.ts +14 -9
- package/packages/server/src/terminal/terminal-manager.ts +54 -46
- package/packages/server/src/tls/tls-bridge-route.ts +61 -0
- package/packages/server/src/tls/tls-config-validation.ts +2 -0
- package/packages/server/src/vault/device-expiry-sweep.ts +36 -0
- package/packages/server/src/vault/vault-delivery-hub.ts +155 -25
- package/packages/server/src/watch-files-handler.ts +66 -0
- package/packages/shared/package.json +1 -1
- package/packages/shared/src/browser-protocol.ts +148 -2
- package/packages/shared/src/canvas-declare.ts +27 -0
- package/packages/shared/src/config.ts +372 -53
- package/packages/shared/src/containment-guard.ts +35 -0
- package/packages/shared/src/dashboard-plugin/anthropic-peer-names.ts +9 -0
- package/packages/shared/src/dashboard-plugin/event-type-owners.ts +50 -0
- package/packages/shared/src/dashboard-plugin/file-handler.ts +2 -0
- package/packages/shared/src/dashboard-plugin/host-api.ts +61 -0
- package/packages/shared/src/dashboard-plugin/host-fx-classes.ts +23 -0
- package/packages/shared/src/dashboard-plugin/host-import-map.ts +38 -0
- package/packages/shared/src/dashboard-plugin/index.ts +2 -0
- package/packages/shared/src/dashboard-plugin/manifest-types.ts +54 -1
- package/packages/shared/src/dashboard-plugin/plugin-status.ts +54 -0
- package/packages/shared/src/dashboard-plugin/slot-props.ts +45 -3
- package/packages/shared/src/dashboard-plugin/slot-types.ts +8 -0
- package/packages/shared/src/dashboard-plugin/subagent-types.ts +219 -0
- package/packages/shared/src/dashboard-plugin/ui-primitives.ts +28 -0
- package/packages/shared/src/display-prefs.ts +13 -0
- package/packages/shared/src/doctor-core.ts +94 -27
- package/packages/shared/src/live-server.ts +141 -0
- package/packages/shared/src/local-proof-signal.ts +16 -0
- package/packages/shared/src/loopback-host.ts +26 -0
- package/packages/shared/src/mcp/verb-tiers.generated.ts +178 -0
- package/packages/shared/src/mdns-discovery.ts +25 -6
- package/packages/shared/src/nav-intent.ts +29 -0
- package/packages/shared/src/openspec-dependencies.ts +760 -0
- package/packages/shared/src/openspec-poller.ts +3 -2
- package/packages/shared/src/pairing-knock-client.ts +44 -4
- package/packages/shared/src/pi-trust-live-query.ts +93 -0
- package/packages/shared/src/pi-trust-mirror-snapshot.ts +5 -7
- package/packages/shared/src/pi-trust-mirror-types.ts +36 -3
- package/packages/shared/src/pi-trust-mirror.ts +29 -3
- package/packages/shared/src/pi-trust-resource-digest.ts +255 -0
- package/packages/shared/src/platform/ensure-bundled-git.ts +57 -34
- package/packages/shared/src/platform/git-source.ts +88 -26
- package/packages/shared/src/platform/git.ts +14 -8
- package/packages/shared/src/platform/process.ts +48 -4
- package/packages/shared/src/platform/resolve-pi-shell.ts +76 -0
- package/packages/shared/src/platform/select-git-source.ts +7 -0
- package/packages/shared/src/plugin-route-cwd.ts +95 -0
- package/packages/shared/src/preview-egress.ts +138 -0
- package/packages/shared/src/project-root.ts +16 -0
- package/packages/shared/src/protocol.ts +40 -1
- package/packages/shared/src/recommended-extensions.ts +18 -0
- package/packages/shared/src/recovery-timing.ts +27 -0
- package/packages/shared/src/remote-credentials.ts +63 -0
- package/packages/shared/src/rest-api.ts +55 -8
- package/packages/shared/src/route-tiers.ts +55 -1
- package/packages/shared/src/runtime-overlay/archive-safety.d.mts +2 -0
- package/packages/shared/src/runtime-overlay/archive-safety.mjs +33 -0
- package/packages/shared/src/runtime-overlay/manifest.d.mts +7 -0
- package/packages/shared/src/runtime-overlay/manifest.mjs +22 -2
- package/packages/shared/src/safe-local-path.ts +24 -0
- package/packages/shared/src/sanitize-profiles.ts +98 -0
- package/packages/shared/src/server-launcher.ts +9 -1
- package/packages/shared/src/server-pinning.ts +55 -2
- package/packages/shared/src/server-routes.ts +462 -0
- package/packages/shared/src/session-ui-path.ts +11 -0
- package/packages/shared/src/tls-only-token.ts +16 -0
- package/packages/shared/src/tool-registry/definitions.ts +5 -5
- package/packages/shared/src/tool-registry/strategies.ts +12 -11
- package/packages/shared/src/types.ts +66 -0
- package/packages/shared/src/url-policy.ts +96 -0
- package/packages/shared/src/vault-delivery.ts +15 -0
- package/packages/shared/src/ws-message-tiers.ts +1 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subagent wire-contract types + the pure helpers that fold subagent frames
|
|
3
|
+
* into a `SubagentState`. Lives in shared (a non-plugin package) so the core
|
|
4
|
+
* client reducer and the subagents plugin read one definition without a
|
|
5
|
+
* core→plugin import; the plugin re-exports it.
|
|
6
|
+
*
|
|
7
|
+
* Producer of the contract: pi-dashboard-subagents extension
|
|
8
|
+
* (https://github.com/BlackBeltTechnology/pi-dashboard-agents)
|
|
9
|
+
*
|
|
10
|
+
* See change: decouple-plugins-from-core (task 2.7); earlier: add-subagent-inspector.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** A single entry in a subagent's run timeline. */
|
|
14
|
+
export type SubagentTimelineEntry =
|
|
15
|
+
| { kind: "tool"; toolName: string; input: unknown; output?: unknown; isError?: boolean; ts: number }
|
|
16
|
+
| { kind: "text"; text: string; ts: number }
|
|
17
|
+
| { kind: "thinking"; text: string; ts: number }
|
|
18
|
+
| { kind: "error"; text: string; ts: number };
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Bounded tail of a subagent's currently streaming block. `kind: "none"` means
|
|
22
|
+
* nothing is streaming. See change: stream-subagent-reasoning-and-stable-card.
|
|
23
|
+
*/
|
|
24
|
+
export type SubagentLiveTail = { kind: "thinking" | "text" | "none"; text: string };
|
|
25
|
+
|
|
26
|
+
/** In-progress block from the delta stream. See change: add-plugin-bridge-contributions. */
|
|
27
|
+
export type SubagentLiveBlock = {
|
|
28
|
+
blockId: number;
|
|
29
|
+
kind: "thinking" | "text";
|
|
30
|
+
text: string;
|
|
31
|
+
end: number;
|
|
32
|
+
gap: boolean;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/** Per-subagent state held in SessionState.subagents. */
|
|
36
|
+
export interface SubagentState {
|
|
37
|
+
id: string;
|
|
38
|
+
/**
|
|
39
|
+
* Runner session id (v7) minted by the producer for the in-memory subagent
|
|
40
|
+
* session, distinct from the v4 `id` (agentId). Optional: absent with an
|
|
41
|
+
* older producer (< 0.2.3). When present, the reducer dual-indexes the state
|
|
42
|
+
* under both this id and `id`. See change: resolve-subagent-inspector-by-session-id.
|
|
43
|
+
*/
|
|
44
|
+
agentSessionId?: string;
|
|
45
|
+
type: string;
|
|
46
|
+
description: string;
|
|
47
|
+
status: "created" | "running" | "completed" | "failed";
|
|
48
|
+
/**
|
|
49
|
+
* Client-only (never sent by the producer): the heal marker that produced the
|
|
50
|
+
* CURRENT terminal `status` (e.g. `"session_ended"`); absent for a real
|
|
51
|
+
* terminal or a running state. Lets a live tick revive a subagent a
|
|
52
|
+
* fabricated `session_ended` heal failed, without reviving a real failure.
|
|
53
|
+
* See change: fix-replay-fabricates-orphan-end-for-live-calls (D5).
|
|
54
|
+
*/
|
|
55
|
+
healedBy?: string;
|
|
56
|
+
result?: string;
|
|
57
|
+
error?: string;
|
|
58
|
+
durationMs?: number;
|
|
59
|
+
tokens?: { input: number; output: number; total: number };
|
|
60
|
+
toolUses?: number;
|
|
61
|
+
/** Full per-step timeline. Producer: pi-dashboard-subagents extension. */
|
|
62
|
+
entries?: SubagentTimelineEntry[];
|
|
63
|
+
/** Live current-activity string (e.g. "reading src/foo.ts"). */
|
|
64
|
+
activity?: string;
|
|
65
|
+
/** Live tail of the streaming thinking/text block (producer ≥ 0.2.7). */
|
|
66
|
+
liveTail?: SubagentLiveTail;
|
|
67
|
+
/**
|
|
68
|
+
* In-progress block assembled from `subagent_delta` pieces (producer ≥ 0.4.0).
|
|
69
|
+
* `text` is the display text (may carry gap markers); `end` is the LOGICAL
|
|
70
|
+
* block offset reached, so offsets stay exact across gaps. Cleared by the
|
|
71
|
+
* block's `subagent_entry` (same `blockId`) or a terminal state.
|
|
72
|
+
* See change: add-plugin-bridge-contributions (D7).
|
|
73
|
+
*/
|
|
74
|
+
liveBlock?: SubagentLiveBlock;
|
|
75
|
+
/** Highest `blockId` already finished — later pieces of it are ignored (D7 tombstone). */
|
|
76
|
+
closedBlockMax?: number;
|
|
77
|
+
/** Producer step count (`details.entryCount`, ≥ 0.3.0); stream-complete when filled steps reach it. */
|
|
78
|
+
entryCount?: number;
|
|
79
|
+
/** Display name for the agent (e.g. "code-reviewer"). Falls back to `type`. */
|
|
80
|
+
displayName?: string;
|
|
81
|
+
/** Short model name if different from parent. */
|
|
82
|
+
modelName?: string;
|
|
83
|
+
/** Effective thinking level of the child (producer ≥ 0.2.7), e.g. "high". */
|
|
84
|
+
thinkingLevel?: string;
|
|
85
|
+
/** Subagent type (e.g. "general-purpose"). May duplicate `type`. */
|
|
86
|
+
subagentType?: string;
|
|
87
|
+
/** Started-at epoch ms (set on subagent_started). */
|
|
88
|
+
startedAt?: number;
|
|
89
|
+
/**
|
|
90
|
+
* Absolute filesystem path to the agent's `.md` definition file
|
|
91
|
+
* (e.g. `~/.pi/agent/agents/Explore.md`). Producer sets it when the
|
|
92
|
+
* subagent was sourced from a file. Rendered read-only in the inspector
|
|
93
|
+
* header. See change: add-subagent-inspector §15.
|
|
94
|
+
*/
|
|
95
|
+
agentMdPath?: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Max chars of a subagent live tail kept in client state. */
|
|
99
|
+
const LIVE_TAIL_MAX = 280;
|
|
100
|
+
const CLEARED_LIVE_TAIL: SubagentLiveTail = { kind: "none", text: "" };
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Normalize a wire `details.liveTail`, never rejecting. Any plain object
|
|
104
|
+
* overwrites: a valid thinking/text tail is kept (text capped at 280), every
|
|
105
|
+
* other object — sentinel, malformed, future shape — becomes the cleared tail.
|
|
106
|
+
* Non-objects return undefined (key ignored, prior state kept).
|
|
107
|
+
* Also used by `AgentToolRenderer` for its session-less `details.liveTail`
|
|
108
|
+
* fallback, so both paths normalize identically.
|
|
109
|
+
* See change: stream-subagent-reasoning-and-stable-card (D8).
|
|
110
|
+
*/
|
|
111
|
+
export function readLiveTail(raw: unknown): SubagentLiveTail | undefined {
|
|
112
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return undefined;
|
|
113
|
+
const { kind, text } = raw as Record<string, unknown>;
|
|
114
|
+
if ((kind === "thinking" || kind === "text") && typeof text === "string") {
|
|
115
|
+
return { kind, text: text.length > LIVE_TAIL_MAX ? text.slice(-LIVE_TAIL_MAX) : text };
|
|
116
|
+
}
|
|
117
|
+
return CLEARED_LIVE_TAIL;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Pull optional Phase-2 fields (`entries`, `activity`, `displayName`, model,
|
|
122
|
+
* etc.) from a streamed `AgentDetails`-shaped object. Returns a partial that
|
|
123
|
+
* spreads into a `SubagentState`. All fields are optional; absent keys yield
|
|
124
|
+
* `undefined` which leaves any existing value intact when used as a `...spread`.
|
|
125
|
+
*
|
|
126
|
+
* See change: add-subagent-inspector.
|
|
127
|
+
*/
|
|
128
|
+
export function readSubagentDetails(
|
|
129
|
+
details: Record<string, unknown> | undefined,
|
|
130
|
+
): Partial<SubagentState> {
|
|
131
|
+
if (!details) return {};
|
|
132
|
+
const out: Partial<SubagentState> = {};
|
|
133
|
+
// D3 empty-array overwrite guard: only replace `entries` when the incoming
|
|
134
|
+
// array is non-empty. An incoming `[]` (initial subagent_started, or a
|
|
135
|
+
// late/reordered frame) omits the key so the `...spread` merge preserves any
|
|
136
|
+
// already-populated timeline. Entries only ever grow within a run, so a
|
|
137
|
+
// legitimate transition to zero entries never occurs.
|
|
138
|
+
// See change: fix-subagent-live-detail-reliability (D3).
|
|
139
|
+
if (Array.isArray(details.entries) && details.entries.length > 0) {
|
|
140
|
+
out.entries = details.entries as SubagentTimelineEntry[];
|
|
141
|
+
}
|
|
142
|
+
if (typeof details.entryCount === "number" && Number.isSafeInteger(details.entryCount) && details.entryCount >= 0) {
|
|
143
|
+
out.entryCount = details.entryCount;
|
|
144
|
+
}
|
|
145
|
+
if (typeof details.activity === "string") out.activity = details.activity;
|
|
146
|
+
const liveTail = readLiveTail(details.liveTail);
|
|
147
|
+
if (liveTail) out.liveTail = liveTail;
|
|
148
|
+
if (typeof details.displayName === "string") out.displayName = details.displayName;
|
|
149
|
+
if (typeof details.modelName === "string") out.modelName = details.modelName;
|
|
150
|
+
if (typeof details.thinkingLevel === "string" && details.thinkingLevel) out.thinkingLevel = details.thinkingLevel;
|
|
151
|
+
if (typeof details.subagentType === "string") out.subagentType = details.subagentType;
|
|
152
|
+
if (typeof details.toolUses === "number") out.toolUses = details.toolUses;
|
|
153
|
+
if (typeof details.durationMs === "number") out.durationMs = details.durationMs;
|
|
154
|
+
if (typeof details.agentMdPath === "string") out.agentMdPath = details.agentMdPath;
|
|
155
|
+
// Runner session id (v7): when the producer supplies it, persist it so the
|
|
156
|
+
// reducer can dual-index the state under both the agentId and this id.
|
|
157
|
+
// Absent with an older producer (< 0.2.3) → single-key, as today.
|
|
158
|
+
// See change: resolve-subagent-inspector-by-session-id (D1/D2).
|
|
159
|
+
if (typeof details.agentSessionId === "string") out.agentSessionId = details.agentSessionId;
|
|
160
|
+
return out;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** Filled step count of a (possibly sparse) streamed timeline. */
|
|
164
|
+
export function countSteps(entries: SubagentTimelineEntry[] | undefined): number {
|
|
165
|
+
if (!entries) return 0;
|
|
166
|
+
let n = 0;
|
|
167
|
+
for (const e of entries) if (e) n++;
|
|
168
|
+
return n;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** Display marker inserted where a streamed block lost a piece. */
|
|
172
|
+
export const LIVE_BLOCK_GAP_MARKER = " … ";
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Apply one `subagent_delta` piece to the in-progress block (D7): append when
|
|
176
|
+
* contiguous, ignore a fully covered duplicate, append the uncovered tail of a
|
|
177
|
+
* partial overlap, and mark a gap when the piece starts past the logical end.
|
|
178
|
+
* Returns undefined when the piece must be ignored (closed block / stale id).
|
|
179
|
+
*/
|
|
180
|
+
export function applyLiveBlockPiece(
|
|
181
|
+
prev: SubagentState | undefined,
|
|
182
|
+
piece: { blockId: number; kind: "thinking" | "text"; offset: number; text: string },
|
|
183
|
+
): SubagentLiveBlock | undefined {
|
|
184
|
+
if (prev?.status === "completed" || prev?.status === "failed") return undefined;
|
|
185
|
+
if (prev?.closedBlockMax !== undefined && piece.blockId <= prev.closedBlockMax) return undefined;
|
|
186
|
+
let lb = prev?.liveBlock;
|
|
187
|
+
if (lb && piece.blockId < lb.blockId) return undefined;
|
|
188
|
+
if (!lb || lb.blockId !== piece.blockId) lb = { blockId: piece.blockId, kind: piece.kind, text: "", end: 0, gap: false };
|
|
189
|
+
const { offset, text } = piece;
|
|
190
|
+
const pieceEnd = offset + text.length;
|
|
191
|
+
if (pieceEnd <= lb.end) return lb; // covered duplicate
|
|
192
|
+
if (offset > lb.end) {
|
|
193
|
+
return { ...lb, text: lb.text + (lb.text ? LIVE_BLOCK_GAP_MARKER : "") + text, end: pieceEnd, gap: true };
|
|
194
|
+
}
|
|
195
|
+
return { ...lb, text: lb.text + text.slice(lb.end - offset), end: pieceEnd };
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Dual-index a subagent state into the `subagents` map. Always sets the
|
|
200
|
+
* canonical `state.id` (v4 agentId) key; when `state.agentSessionId` (v7) is
|
|
201
|
+
* present, ALSO sets that key to the SAME reference so a lookup by either id
|
|
202
|
+
* resolves the run. Both keys are a PAIR pointing at one object — any future
|
|
203
|
+
* change deleting one on completion MUST delete the other (paired-key
|
|
204
|
+
* invariant, design N1). Do NOT enumerate this map with `.values()/.entries()`
|
|
205
|
+
* without de-duping by `state.id`: a dual-indexed agent appears under two keys.
|
|
206
|
+
* See change: resolve-subagent-inspector-by-session-id (D2).
|
|
207
|
+
*/
|
|
208
|
+
export function setSubagentState(map: Map<string, SubagentState>, state: SubagentState): void {
|
|
209
|
+
// A streamed timeline (subagent_entry) never shrinks: a later tick or terminal
|
|
210
|
+
// frame whose `entries` is empty or holds fewer steps keeps the resident list.
|
|
211
|
+
// A legacy frame with at least as many steps still replaces it.
|
|
212
|
+
// See change: add-plugin-bridge-contributions (D7).
|
|
213
|
+
const prev = map.get(state.id);
|
|
214
|
+
if (prev?.entries && prev.entries !== state.entries && countSteps(state.entries) < countSteps(prev.entries)) {
|
|
215
|
+
state = { ...state, entries: prev.entries };
|
|
216
|
+
}
|
|
217
|
+
map.set(state.id, state);
|
|
218
|
+
if (state.agentSessionId) map.set(state.agentSessionId, state);
|
|
219
|
+
}
|
|
@@ -78,6 +78,13 @@ export const UI_PRIMITIVE_KEYS = {
|
|
|
78
78
|
* (`useUiPrimitiveOrNull`) and hide the affordance when absent.
|
|
79
79
|
* See change: improve-kb-settings-sources-and-search. */
|
|
80
80
|
pathPicker: "ui:path-picker",
|
|
81
|
+
/** Live chat of one session (transcript + composer), host-styled. Self-providing:
|
|
82
|
+
* mounts the chat/session providers it needs, inside the app's registry.
|
|
83
|
+
* See change: decouple-plugins-from-core (D8). */
|
|
84
|
+
chatView: "ui:chat-view",
|
|
85
|
+
/** Small elapsed-time badge: live ticking from `startedAt`, static for `duration`.
|
|
86
|
+
* See change: decouple-plugins-from-core (D8). */
|
|
87
|
+
elapsedBadge: "ui:elapsed-badge",
|
|
81
88
|
} as const;
|
|
82
89
|
|
|
83
90
|
/** Union of all valid UI primitive keys (literal-string narrowed). */
|
|
@@ -412,6 +419,25 @@ export interface UiPathPickerDialogProps {
|
|
|
412
419
|
onCancel: () => void;
|
|
413
420
|
}
|
|
414
421
|
|
|
422
|
+
/**
|
|
423
|
+
* Public prop signature for the chat-view primitive: the live chat of session
|
|
424
|
+
* `sessionId`. `readOnly` hides the prompt composer; `compact` asks for a dense
|
|
425
|
+
* layout. See change: decouple-plugins-from-core (D8).
|
|
426
|
+
*/
|
|
427
|
+
export interface UiChatViewProps {
|
|
428
|
+
sessionId: string;
|
|
429
|
+
readOnly?: boolean;
|
|
430
|
+
compact?: boolean;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/** Public prop signature for the elapsed-badge primitive (the host `ElapsedBadge` props). */
|
|
434
|
+
export interface UiElapsedBadgeProps {
|
|
435
|
+
/** Epoch ms when the operation started (live counter). */
|
|
436
|
+
startedAt?: number;
|
|
437
|
+
/** Duration in ms (static display; wins over the live counter). */
|
|
438
|
+
duration?: number;
|
|
439
|
+
}
|
|
440
|
+
|
|
415
441
|
export interface UiPrimitiveMap {
|
|
416
442
|
"ui:agent-card": ComponentType<UiAgentCardProps>;
|
|
417
443
|
"ui:markdown-content": ComponentType<UiMarkdownContentProps>;
|
|
@@ -432,6 +458,8 @@ export interface UiPrimitiveMap {
|
|
|
432
458
|
"ui:log-block": ComponentType<UiLogBlockProps>;
|
|
433
459
|
"ui:oauth-flow": ComponentType<UiOAuthFlowViewProps>;
|
|
434
460
|
"ui:path-picker": ComponentType<UiPathPickerDialogProps>;
|
|
461
|
+
"ui:chat-view": ComponentType<UiChatViewProps>;
|
|
462
|
+
"ui:elapsed-badge": ComponentType<UiElapsedBadgeProps>;
|
|
435
463
|
}
|
|
436
464
|
|
|
437
465
|
/**
|
|
@@ -209,6 +209,15 @@ export interface DisplayPrefs {
|
|
|
209
209
|
* See change: render-inline-reasoning-and-custom-entries.
|
|
210
210
|
*/
|
|
211
211
|
reasoningInlineFlow: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* When true (default), the live chat transcript plays arrival-driven motion:
|
|
214
|
+
* entry transitions, paced streaming reveal, a soft trailing edge, glide
|
|
215
|
+
* follow-scroll and tool completion cues. When false the transcript behaves
|
|
216
|
+
* exactly as before. `prefers-reduced-motion: reduce` and a hidden document
|
|
217
|
+
* disable it regardless of this value.
|
|
218
|
+
* See change: add-fluid-chat-motion.
|
|
219
|
+
*/
|
|
220
|
+
chatMotion: boolean;
|
|
212
221
|
/**
|
|
213
222
|
* Per-group visibility for custom chat rows, keyed by custom event group id
|
|
214
223
|
* (see `custom-event-groups.ts`). Shallow-merged field-by-field exactly like
|
|
@@ -254,6 +263,7 @@ export const DISPLAY_PRESETS: Record<"simple" | "standard" | "everything", Displ
|
|
|
254
263
|
showOutOfCwdSessionDiffs: false,
|
|
255
264
|
notifyMinLevel: "all",
|
|
256
265
|
reasoningInlineFlow: false,
|
|
266
|
+
chatMotion: true,
|
|
257
267
|
customEventGroups: defaultCustomEventGroupPrefs(),
|
|
258
268
|
},
|
|
259
269
|
standard: {
|
|
@@ -272,6 +282,7 @@ export const DISPLAY_PRESETS: Record<"simple" | "standard" | "everything", Displ
|
|
|
272
282
|
showOutOfCwdSessionDiffs: false,
|
|
273
283
|
notifyMinLevel: "all",
|
|
274
284
|
reasoningInlineFlow: false,
|
|
285
|
+
chatMotion: true,
|
|
275
286
|
customEventGroups: defaultCustomEventGroupPrefs(),
|
|
276
287
|
},
|
|
277
288
|
everything: {
|
|
@@ -290,6 +301,7 @@ export const DISPLAY_PRESETS: Record<"simple" | "standard" | "everything", Displ
|
|
|
290
301
|
showOutOfCwdSessionDiffs: false,
|
|
291
302
|
notifyMinLevel: "all",
|
|
292
303
|
reasoningInlineFlow: false,
|
|
304
|
+
chatMotion: true,
|
|
293
305
|
customEventGroups: defaultCustomEventGroupPrefs(),
|
|
294
306
|
},
|
|
295
307
|
};
|
|
@@ -350,6 +362,7 @@ export function mergeDisplayPrefs(
|
|
|
350
362
|
override.showOutOfCwdSessionDiffs ?? global.showOutOfCwdSessionDiffs,
|
|
351
363
|
notifyMinLevel: override.notifyMinLevel ?? global.notifyMinLevel,
|
|
352
364
|
reasoningInlineFlow: override.reasoningInlineFlow ?? global.reasoningInlineFlow,
|
|
365
|
+
chatMotion: override.chatMotion ?? global.chatMotion,
|
|
353
366
|
customEventGroups: mergeCustomEventGroupPrefs(global.customEventGroups, override.customEventGroups),
|
|
354
367
|
};
|
|
355
368
|
}
|
|
@@ -21,9 +21,9 @@ import { getDashboardConfigDir } from "./dashboard-paths.js";
|
|
|
21
21
|
import type { LegacyManagedDir } from "./legacy-managed-dir.js";
|
|
22
22
|
import { escapeMdTableCell } from "./md-table-cell.js";
|
|
23
23
|
import { isAtOrAboveEnginesCap } from "./node-version.js";
|
|
24
|
-
import { whichSync } from "./platform/binary-lookup.js";
|
|
24
|
+
import { ToolResolver, whichSync } from "./platform/binary-lookup.js";
|
|
25
25
|
import { execSync } from "./platform/exec.js";
|
|
26
|
-
import { getGitSourceReadout } from "./platform/git-source.js";
|
|
26
|
+
import { type GitSourceReadout, getGitSourceReadout } from "./platform/git-source.js";
|
|
27
27
|
import { buildNativeModuleManifest, findAbiMismatches, type probeNativeModuleAbi } from "./platform/native-module-abi.js";
|
|
28
28
|
import { type ResolvedRuntime, resolvedFamilyEntries } from "./platform/spawn-runtime.js";
|
|
29
29
|
import { resolveNativeTsLoader } from "./platform/ts-loader-select.mjs";
|
|
@@ -662,6 +662,26 @@ export interface AttachedServerVersionDeps {
|
|
|
662
662
|
healthFetcher: () => Promise<AttachedHealthLike | null>;
|
|
663
663
|
}
|
|
664
664
|
|
|
665
|
+
/**
|
|
666
|
+
* Launch-source-specific fix text for an attached server whose version differs
|
|
667
|
+
* from the app. Shared by the Doctor row and the Electron attach-time skew
|
|
668
|
+
* notice (`electron-attach-version-skew`, D6) so the wording cannot drift.
|
|
669
|
+
*/
|
|
670
|
+
export function attachedServerVersionSuggestion(ls: string | undefined, appVersion: string): string {
|
|
671
|
+
if (ls === "standalone") {
|
|
672
|
+
return `Run \`npm i -g @blackbelt-technology/pi-dashboard@${appVersion}\` and restart your terminal session.`;
|
|
673
|
+
}
|
|
674
|
+
if (ls === "bridge" || ls === "bridge-orphaned") {
|
|
675
|
+
return "Stop the pi session that started this server (or run `pi-dashboard stop`) and relaunch the app.";
|
|
676
|
+
}
|
|
677
|
+
if (ls === "electron") {
|
|
678
|
+
return "Quit the other Electron instance or use the zombie-adoption prompt to take ownership.";
|
|
679
|
+
}
|
|
680
|
+
// Unknown / missing launchSource (older server, unenumerated launch mode):
|
|
681
|
+
// don't misattribute it to the electron case — give a source-agnostic hint.
|
|
682
|
+
return "The attached server's version differs from this app bundle. Determine how that server was started (npm, a pi session, or another app) and update it from there.";
|
|
683
|
+
}
|
|
684
|
+
|
|
665
685
|
/**
|
|
666
686
|
* Compare the shell's bundled version against the attached server's
|
|
667
687
|
* `/api/health.version`. Electron-arm only — a server comparing its own pkg
|
|
@@ -701,22 +721,7 @@ export async function checkAttachedServerVersion(
|
|
|
701
721
|
};
|
|
702
722
|
}
|
|
703
723
|
const ls = health.launchSource;
|
|
704
|
-
|
|
705
|
-
if (ls === "standalone") {
|
|
706
|
-
suggestion =
|
|
707
|
-
`Run \`npm i -g @blackbelt-technology/pi-dashboard@${deps.appVersion}\` and restart your terminal session.`;
|
|
708
|
-
} else if (ls === "bridge" || ls === "bridge-orphaned") {
|
|
709
|
-
suggestion =
|
|
710
|
-
"Stop the pi session that started this server (or run `pi-dashboard stop`) and relaunch the app.";
|
|
711
|
-
} else if (ls === "electron") {
|
|
712
|
-
suggestion =
|
|
713
|
-
"Quit the other Electron instance or use the zombie-adoption prompt to take ownership.";
|
|
714
|
-
} else {
|
|
715
|
-
// Unknown / missing launchSource (older server, unenumerated launch mode):
|
|
716
|
-
// don't misattribute it to the electron case — give a source-agnostic hint.
|
|
717
|
-
suggestion =
|
|
718
|
-
"The attached server's version differs from this app bundle. Determine how that server was started (npm, a pi session, or another app) and update it from there.";
|
|
719
|
-
}
|
|
724
|
+
const suggestion = attachedServerVersionSuggestion(ls, deps.appVersion);
|
|
720
725
|
return {
|
|
721
726
|
name: "Attached server version",
|
|
722
727
|
section: "setup",
|
|
@@ -900,6 +905,12 @@ export interface SharedChecksDeps {
|
|
|
900
905
|
* hermetically. See change: unify-pi-runtime-identity.
|
|
901
906
|
*/
|
|
902
907
|
detectLegacyManagedDir?: () => LegacyManagedDir;
|
|
908
|
+
/**
|
|
909
|
+
* Test seam for the Windows git/bash source readout. Defaults to the real
|
|
910
|
+
* `getGitSourceReadout`, fed the same spawn env the server builds for real
|
|
911
|
+
* spawns. See change: fix-windows-bundled-bash-exe.
|
|
912
|
+
*/
|
|
913
|
+
gitSourceReadout?: () => GitSourceReadout | null;
|
|
903
914
|
/**
|
|
904
915
|
* The ladder-resolved pi spawn runtime, passed as an INPUT by the host
|
|
905
916
|
* arm (server: `currentSpawnRuntime()`; Electron: live
|
|
@@ -1599,7 +1610,11 @@ export async function runSharedChecks(deps: SharedChecksDeps): Promise<DoctorChe
|
|
|
1599
1610
|
// Windows-only: bundled-vs-host git & shell source. See change:
|
|
1600
1611
|
// embed-git-bash-on-windows.
|
|
1601
1612
|
try {
|
|
1602
|
-
const readout =
|
|
1613
|
+
const readout = deps.gitSourceReadout
|
|
1614
|
+
? deps.gitSourceReadout()
|
|
1615
|
+
: getGitSourceReadout(whichSync, {
|
|
1616
|
+
spawnEnv: () => new ToolResolver({ processExecPath: process.execPath }).buildSpawnEnv(process.env),
|
|
1617
|
+
});
|
|
1603
1618
|
if (readout) {
|
|
1604
1619
|
const tag = `(${readout.source})`;
|
|
1605
1620
|
const wantHostButBundled = readout.setting === "host" && readout.source === "bundled";
|
|
@@ -1616,14 +1631,7 @@ export async function runSharedChecks(deps: SharedChecksDeps): Promise<DoctorChe
|
|
|
1616
1631
|
? "Install Git for Windows, or set windowsGitSource to 'auto' / 'bundled'."
|
|
1617
1632
|
: undefined,
|
|
1618
1633
|
});
|
|
1619
|
-
checks.push(
|
|
1620
|
-
name: "bash source",
|
|
1621
|
-
section: "runtime",
|
|
1622
|
-
status: readout.shellPath ? "ok" : "warning",
|
|
1623
|
-
message: readout.shellPath ? `sh ${tag}` : "no POSIX shell resolved",
|
|
1624
|
-
code: readout.shellPath ? undefined : "doctor.no_posix_shell",
|
|
1625
|
-
detail: readout.shellPath ?? "sh.exe / bash.exe not resolved",
|
|
1626
|
-
});
|
|
1634
|
+
checks.push(bashSourceCheck(readout));
|
|
1627
1635
|
}
|
|
1628
1636
|
} catch {
|
|
1629
1637
|
/* advisory only — never block doctor output */
|
|
@@ -1632,6 +1640,65 @@ export async function runSharedChecks(deps: SharedChecksDeps): Promise<DoctorChe
|
|
|
1632
1640
|
return checks;
|
|
1633
1641
|
}
|
|
1634
1642
|
|
|
1643
|
+
/**
|
|
1644
|
+
* Windows "bash source" row: reports the shell pi-coding-agent will actually
|
|
1645
|
+
* resolve (readout.shellPath), not the shell the dashboard would like. A WSL
|
|
1646
|
+
* launcher is a warning unless the operator chose `windowsBashSource: "host"`.
|
|
1647
|
+
* See change: fix-windows-bundled-bash-exe.
|
|
1648
|
+
*/
|
|
1649
|
+
function bashSourceCheck(readout: GitSourceReadout): DoctorCheck {
|
|
1650
|
+
const base = { name: "bash source", section: "runtime" as const };
|
|
1651
|
+
const { shellPath } = readout;
|
|
1652
|
+
if (!shellPath) {
|
|
1653
|
+
return {
|
|
1654
|
+
...base,
|
|
1655
|
+
status: "warning",
|
|
1656
|
+
message: "no POSIX shell resolved",
|
|
1657
|
+
code: "doctor.no_posix_shell",
|
|
1658
|
+
detail: "pi would find no bash.exe (sh.exe is not used) — agent bash commands fail with 'No bash shell found'",
|
|
1659
|
+
suggestion: "Install Git for Windows, or reinstall the dashboard app so the bundled bash.exe is present.",
|
|
1660
|
+
};
|
|
1661
|
+
}
|
|
1662
|
+
const tag = `(${readout.source})`;
|
|
1663
|
+
if (readout.shellIsWslLauncher) {
|
|
1664
|
+
if (readout.bashSetting === "host") {
|
|
1665
|
+
return {
|
|
1666
|
+
...base,
|
|
1667
|
+
status: "ok",
|
|
1668
|
+
message: `bash ${tag} — WSL`,
|
|
1669
|
+
detail: `${shellPath} — WSL launcher; requires an installed WSL distro`,
|
|
1670
|
+
};
|
|
1671
|
+
}
|
|
1672
|
+
return {
|
|
1673
|
+
...base,
|
|
1674
|
+
status: "warning",
|
|
1675
|
+
message: "pi would use the WSL launcher as its shell",
|
|
1676
|
+
code: "doctor.bash_is_wsl_launcher",
|
|
1677
|
+
detail: `${shellPath} — fails with 'no installed distributions' unless a WSL distro exists`,
|
|
1678
|
+
suggestion:
|
|
1679
|
+
readout.source === "bundled"
|
|
1680
|
+
? "The bundled bash.exe is missing: update or reinstall the dashboard app. To use WSL on purpose, set windowsBashSource to 'host'."
|
|
1681
|
+
: "Agent commands would run inside WSL. To use a Windows bash: install Git for Windows or set windowsGitSource to bundled. To use WSL on purpose, set windowsBashSource to 'host'.",
|
|
1682
|
+
};
|
|
1683
|
+
}
|
|
1684
|
+
// Shell lives inside the bundled git tree? Compare against the git root derived
|
|
1685
|
+
// from gitPath (<root>\cmd\git.exe) so no bundled-path literal is needed here.
|
|
1686
|
+
const gitRoot = readout.gitPath ? path.win32.dirname(path.win32.dirname(readout.gitPath)) : null;
|
|
1687
|
+
const shellIsBundled =
|
|
1688
|
+
readout.source === "bundled" &&
|
|
1689
|
+
gitRoot !== null &&
|
|
1690
|
+
shellPath.toLowerCase().startsWith(`${gitRoot.toLowerCase()}\\`);
|
|
1691
|
+
return {
|
|
1692
|
+
...base,
|
|
1693
|
+
status: "ok",
|
|
1694
|
+
message: `bash ${tag}`,
|
|
1695
|
+
detail:
|
|
1696
|
+
readout.bashSetting === "host" && shellIsBundled
|
|
1697
|
+
? `${shellPath} — host bash requested, none found — using bundled`
|
|
1698
|
+
: shellPath,
|
|
1699
|
+
};
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1635
1702
|
// ─── Stamping helper ──────────────────────────────────────────────────
|
|
1636
1703
|
|
|
1637
1704
|
/**
|
|
@@ -43,11 +43,27 @@ export interface LiveServerTargetInput {
|
|
|
43
43
|
label?: string;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* How a port target came to exist. `user` = added by the operator (persisted);
|
|
48
|
+
* `preset` = agent-declared, in-memory only; `legacy` = persisted before the
|
|
49
|
+
* field existed (origin unknown). See change: improve-canvas-html-and-url-ux.
|
|
50
|
+
*/
|
|
51
|
+
export type LiveTargetAddedBy = "user" | "preset" | "legacy";
|
|
52
|
+
|
|
46
53
|
export interface LiveServerTarget {
|
|
47
54
|
id: string;
|
|
48
55
|
label: string;
|
|
49
56
|
host: string;
|
|
50
57
|
port: number;
|
|
58
|
+
/** Optional on the wire: a missing value reads as `legacy`. */
|
|
59
|
+
addedBy?: LiveTargetAddedBy;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** An in-memory static-file target: a document root served under `/live/<id>/`. */
|
|
63
|
+
export interface StaticTarget {
|
|
64
|
+
id: string;
|
|
65
|
+
cwd: string;
|
|
66
|
+
root: string;
|
|
51
67
|
}
|
|
52
68
|
|
|
53
69
|
export type LiveTargetValidation =
|
|
@@ -84,3 +100,128 @@ export function validateLiveTarget(input: unknown): LiveTargetValidation {
|
|
|
84
100
|
export function liveServerPath(id: string): string {
|
|
85
101
|
return `/live/${id}/`;
|
|
86
102
|
}
|
|
103
|
+
|
|
104
|
+
// ---------------------------------------------------------------------------
|
|
105
|
+
// Static-target helpers (pure, browser-safe).
|
|
106
|
+
// See change: improve-canvas-html-and-url-ux (design D2, D9).
|
|
107
|
+
// ---------------------------------------------------------------------------
|
|
108
|
+
|
|
109
|
+
/** Web asset extensions a static target may serve. No source maps, no `.txt`. */
|
|
110
|
+
export const STATIC_WEB_EXTENSIONS: ReadonlySet<string> = new Set([
|
|
111
|
+
"html", "htm", "css", "js", "mjs", "json", "svg", "png", "jpg", "jpeg",
|
|
112
|
+
"gif", "webp", "avif", "ico", "woff", "woff2", "ttf", "otf", "mp4", "webm",
|
|
113
|
+
"ogg", "mp3", "wav", "m4a",
|
|
114
|
+
]);
|
|
115
|
+
|
|
116
|
+
/** True when `name`'s extension is on the static web-asset allowlist. */
|
|
117
|
+
export function isStaticWebAsset(name: string): boolean {
|
|
118
|
+
const i = name.lastIndexOf(".");
|
|
119
|
+
if (i < 0) return false;
|
|
120
|
+
return STATIC_WEB_EXTENSIONS.has(name.slice(i + 1).toLowerCase());
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Secret-like base names a static target never serves (case-insensitive). */
|
|
124
|
+
const CREDENTIAL_NAME_RES: readonly RegExp[] = [
|
|
125
|
+
/\.(pem|key|p12|pfx|jks|keystore)$/,
|
|
126
|
+
/secret/,
|
|
127
|
+
/credential/,
|
|
128
|
+
/token/,
|
|
129
|
+
/password/,
|
|
130
|
+
/passwd/,
|
|
131
|
+
/private/,
|
|
132
|
+
/^id_rsa/,
|
|
133
|
+
/^auth\.json$/,
|
|
134
|
+
/^service-account.*\.json$/,
|
|
135
|
+
/\.tfstate/,
|
|
136
|
+
];
|
|
137
|
+
|
|
138
|
+
/** True when a single file/dir name looks like a credential (design D2 list). */
|
|
139
|
+
export function isCredentialName(name: string): boolean {
|
|
140
|
+
const n = name.toLowerCase();
|
|
141
|
+
return CREDENTIAL_NAME_RES.some((re) => re.test(n));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const posixDir = (p: string): string => {
|
|
145
|
+
const i = p.lastIndexOf("/");
|
|
146
|
+
return i <= 0 ? "/" : p.slice(0, i);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/** True when `p` is `base` or lies beneath it (component-wise, POSIX paths). */
|
|
150
|
+
function isWithin(p: string, base: string): boolean {
|
|
151
|
+
if (base === "/") return true;
|
|
152
|
+
return p === base || p.startsWith(`${base}/`);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Document root of a static target (design D2).
|
|
157
|
+
*
|
|
158
|
+
* Inside `cwd`: nearest ancestor (inclusive) of the file's directory that holds
|
|
159
|
+
* a marker (`index.html` / `package.json`), searched no higher than `cwd`;
|
|
160
|
+
* none found → the file's own directory (never the whole cwd). Outside `cwd`
|
|
161
|
+
* (a granted file) → the file's own directory.
|
|
162
|
+
*
|
|
163
|
+
* `hasMarker(dir)` answers whether `dir` contains a marker file. POSIX paths.
|
|
164
|
+
*/
|
|
165
|
+
export function resolveStaticRoot(
|
|
166
|
+
cwd: string,
|
|
167
|
+
file: string,
|
|
168
|
+
hasMarker: (dir: string) => boolean,
|
|
169
|
+
): string {
|
|
170
|
+
const fileDir = posixDir(file);
|
|
171
|
+
let base = cwd;
|
|
172
|
+
while (base.length > 1 && base.endsWith("/")) base = base.slice(0, -1);
|
|
173
|
+
if (!isWithin(file, base)) return fileDir;
|
|
174
|
+
let dir = fileDir;
|
|
175
|
+
for (;;) {
|
|
176
|
+
if (hasMarker(dir)) return dir;
|
|
177
|
+
if (dir === base || dir === "/") break;
|
|
178
|
+
dir = posixDir(dir);
|
|
179
|
+
if (!isWithin(dir, base)) break;
|
|
180
|
+
}
|
|
181
|
+
return fileDir;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export type AddressPathResult = { ok: true; path: string } | { ok: false; error: string };
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Validate + encode an address-bar path (design D9). Empty / `/` → root (`""`).
|
|
188
|
+
* One trailing `/` is allowed. Empty, `.`, `..`, backslash and control-char
|
|
189
|
+
* segments are rejected; each segment is percent-encoded. `?query` / `#frag`
|
|
190
|
+
* are preserved verbatim after the path. The result has no leading slash.
|
|
191
|
+
*/
|
|
192
|
+
export function validateAddressPath(input: string): AddressPathResult {
|
|
193
|
+
let rest = typeof input === "string" ? input.trim() : "";
|
|
194
|
+
let suffix = "";
|
|
195
|
+
const cut = rest.search(/[?#]/);
|
|
196
|
+
if (cut >= 0) {
|
|
197
|
+
suffix = rest.slice(cut);
|
|
198
|
+
rest = rest.slice(0, cut);
|
|
199
|
+
}
|
|
200
|
+
if (rest === "" || rest === "/") return { ok: true, path: suffix };
|
|
201
|
+
if (rest.startsWith("/")) rest = rest.slice(1);
|
|
202
|
+
const trailing = rest.endsWith("/");
|
|
203
|
+
if (trailing) rest = rest.slice(0, -1);
|
|
204
|
+
const out: string[] = [];
|
|
205
|
+
for (const seg of rest.split("/")) {
|
|
206
|
+
if (seg === "" || seg === "." || seg === "..") {
|
|
207
|
+
return { ok: false, error: "invalid path segment" };
|
|
208
|
+
}
|
|
209
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: rejecting control chars is the point
|
|
210
|
+
if (seg.includes("\\") || /[\u0000-\u001f\u007f]/.test(seg)) {
|
|
211
|
+
return { ok: false, error: "invalid path segment" };
|
|
212
|
+
}
|
|
213
|
+
// A pre-encoded segment is decoded once and re-checked, then re-encoded.
|
|
214
|
+
let decoded: string;
|
|
215
|
+
try {
|
|
216
|
+
decoded = decodeURIComponent(seg);
|
|
217
|
+
} catch {
|
|
218
|
+
return { ok: false, error: "invalid path encoding" };
|
|
219
|
+
}
|
|
220
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: rejecting control chars is the point
|
|
221
|
+
if (decoded === "." || decoded === ".." || decoded.includes("/") || decoded.includes("\\") || /[\u0000-\u001f\u007f]/.test(decoded)) {
|
|
222
|
+
return { ok: false, error: "invalid path segment" };
|
|
223
|
+
}
|
|
224
|
+
out.push(encodeURIComponent(decoded));
|
|
225
|
+
}
|
|
226
|
+
return { ok: true, path: out.join("/") + (trailing ? "/" : "") + suffix };
|
|
227
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `GET /api/health` carries `localProof: "required"` ONLY for a bare-loopback caller
|
|
3
|
+
* that the strict default (`requireLocalProof`) refuses for want of local proof — the
|
|
4
|
+
* remedy is `pi-dashboard open`. Absent for every other caller.
|
|
5
|
+
*
|
|
6
|
+
* Its own dependency-free module (not `rest-api.ts`) because the browser client reads it too,
|
|
7
|
+
* and a client bundle must not value-import a node-only shared module.
|
|
8
|
+
*
|
|
9
|
+
* See change: close-container-loopback-impersonation (D3).
|
|
10
|
+
*/
|
|
11
|
+
export const LOCAL_PROOF_REQUIRED = "required" as const;
|
|
12
|
+
|
|
13
|
+
/** The additive `/api/health` field described by {@link LOCAL_PROOF_REQUIRED}. */
|
|
14
|
+
export interface HealthLocalProofField {
|
|
15
|
+
localProof?: typeof LOCAL_PROOF_REQUIRED;
|
|
16
|
+
}
|