@blackbelt-technology/pi-agent-dashboard 0.11.0 → 0.12.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 -0
- package/README.md +17 -12
- package/docs/architecture.md +973 -224
- package/package.json +29 -18
- package/packages/extension/package.json +16 -9
- package/packages/extension/src/bridge-context.ts +6 -0
- package/packages/extension/src/bridge-handlers/dispatch.ts +54 -69
- package/packages/extension/src/bridge-handlers/forwarders.ts +19 -42
- package/packages/extension/src/bridge-handlers/instance.ts +21 -12
- package/packages/extension/src/bridge-handlers/lifecycle.ts +84 -40
- package/packages/extension/src/bridge-shutdown.ts +44 -0
- package/packages/extension/src/bridge.ts +272 -260
- package/packages/extension/src/command-handler.ts +26 -31
- package/packages/extension/src/connection.ts +123 -31
- package/packages/extension/src/credential-guard.ts +300 -0
- package/packages/extension/src/custom-entry-forward.ts +27 -18
- package/packages/extension/src/default-model-apply.ts +83 -0
- package/packages/extension/src/flow-event-wiring.ts +19 -95
- package/packages/extension/src/followup-drain.ts +19 -5
- package/packages/extension/src/path-gate/decide.ts +68 -5
- package/packages/extension/src/path-gate/handler.ts +16 -8
- package/packages/extension/src/path-gate/index.ts +2 -2
- package/packages/extension/src/path-gate/roots.ts +15 -3
- package/packages/extension/src/path-gate/suppression.ts +3 -0
- package/packages/extension/src/pi-env.d.ts +8 -1
- package/packages/extension/src/pi-retry-settings.ts +11 -2
- package/packages/extension/src/plugin-event-forward-registry.ts +90 -14
- package/packages/extension/src/preview-path-link.ts +151 -0
- package/packages/extension/src/project-init/scaffold.ts +98 -35
- package/packages/extension/src/project-trust.ts +24 -15
- package/packages/extension/src/provider-model-cache.ts +118 -0
- package/packages/extension/src/provider-register.ts +428 -28
- package/packages/extension/src/retry-tracker.ts +90 -7
- package/packages/extension/src/role-manager.ts +4 -2
- package/packages/extension/src/role-model-tools.ts +21 -4
- package/packages/extension/src/server-auto-start.ts +68 -2
- package/packages/extension/src/server-launcher.ts +26 -8
- package/packages/extension/src/session-sync.ts +11 -12
- package/packages/extension/src/spawn-new-session.ts +22 -0
- package/packages/extension/src/steer-buffer.ts +164 -0
- package/packages/extension/src/stream-forward-buffer.ts +64 -15
- package/packages/extension/src/sudo-askpass/config-reader.ts +32 -0
- package/packages/extension/src/sudo-askpass/controller.ts +405 -0
- package/packages/extension/src/sudo-askpass/helper-script.ts +69 -0
- package/packages/extension/src/sudo-askpass/in-flight.ts +79 -0
- package/packages/extension/src/sudo-askpass/index.ts +11 -0
- package/packages/extension/src/sudo-askpass/install.ts +143 -0
- package/packages/extension/src/sudo-askpass/password-cache.ts +118 -0
- package/packages/extension/src/sudo-askpass/prompt-text.ts +55 -0
- package/packages/extension/src/sudo-askpass/protocol.ts +18 -0
- package/packages/extension/src/sudo-askpass/sudo-mask-registry.ts +52 -0
- package/packages/extension/src/terminal-reload.ts +19 -5
- package/packages/extension/src/tool-update-filter-registry.ts +210 -0
- package/packages/extension/src/vault-redaction.ts +4 -3
- package/packages/server/package.json +17 -14
- package/packages/server/src/access/access-denials.ts +8 -0
- package/packages/server/src/access/access-grants.ts +244 -58
- package/packages/server/src/access/access-plane.ts +7 -0
- package/packages/server/src/access/containment-gate.ts +66 -21
- package/packages/server/src/access/denial-hold.ts +3 -0
- package/packages/server/src/access/grant-coordinator.ts +17 -1
- package/packages/server/src/access/named-grant.ts +3 -0
- package/packages/server/src/access/pending-grant-registry.ts +32 -5
- package/packages/server/src/access/pi-trust-mirror-service.ts +7 -1
- package/packages/server/src/access/planes.ts +1 -0
- package/packages/server/src/access/verified-read.ts +24 -7
- package/packages/server/src/acp-bridge/acp-session-adapter.ts +10 -2
- package/packages/server/src/acp-bridge/server-requests.ts +10 -4
- package/packages/server/src/agent-events/agent-event-hub.ts +1 -1
- package/packages/server/src/auth/audit-log.ts +28 -0
- package/packages/server/src/auth/auth-plugin.ts +188 -15
- package/packages/server/src/auth/auth.ts +80 -0
- package/packages/server/src/auth/bridge-ticket-eligibility.ts +53 -10
- package/packages/server/src/auth/cors-origin.ts +14 -1
- package/packages/server/src/auth/credential-envelope.ts +233 -0
- package/packages/server/src/auth/credential-key-worker.d.mts +16 -0
- package/packages/server/src/auth/credential-key-worker.mjs +108 -0
- package/packages/server/src/auth/credential-key.ts +479 -0
- package/packages/server/src/auth/credential-migration.ts +162 -0
- package/packages/server/src/auth/csp-report-paths.ts +0 -5
- package/packages/server/src/auth/csp.ts +74 -36
- package/packages/server/src/auth/device-proof.ts +202 -0
- package/packages/server/src/auth/duplicate-cookie-gate.ts +271 -0
- package/packages/server/src/auth/host-admission.ts +7 -0
- package/packages/server/src/auth/host-gate.ts +13 -2
- package/packages/server/src/auth/localhost-guard.ts +50 -23
- package/packages/server/src/auth/locked-json-file.ts +68 -6
- package/packages/server/src/auth/models-json-store.ts +269 -0
- package/packages/server/src/auth/mutation-origin-gate.ts +5 -2
- package/packages/server/src/auth/node-guard.ts +36 -49
- package/packages/server/src/auth/plugin-credential-store.ts +81 -10
- package/packages/server/src/auth/provider-auth-storage.ts +208 -11
- package/packages/server/src/auth/provider-block-checks.ts +321 -0
- package/packages/server/src/auth/provider-host-detect.ts +151 -0
- package/packages/server/src/auth/provider-key-file.ts +71 -0
- package/packages/server/src/auth/provider-readiness.ts +91 -0
- package/packages/server/src/auth/route-tier-gate.ts +3 -2
- package/packages/server/src/auth/vertex-key-check.ts +140 -0
- package/packages/server/src/auth/ws-ticket.ts +1 -1
- package/packages/server/src/browse.ts +73 -20
- package/packages/server/src/browser-handlers/acp-guard.ts +1 -4
- package/packages/server/src/browser-handlers/directory-handler.ts +11 -24
- package/packages/server/src/browser-handlers/session-action-handler.ts +158 -62
- package/packages/server/src/browser-handlers/spawn-choice.ts +138 -1
- package/packages/server/src/browser-handlers/subscription-handler.ts +46 -1
- package/packages/server/src/build-plugin-send-prompt.ts +18 -0
- package/packages/server/src/cli/credentials-command.ts +555 -0
- package/packages/server/src/cli.ts +21 -16
- package/packages/server/src/config-api.ts +34 -38
- package/packages/server/src/config-snapshot.ts +149 -0
- package/packages/server/src/directory-service.ts +33 -14
- package/packages/server/src/embed-lifecycle/idle-reaper.ts +13 -3
- package/packages/server/src/event-wiring.ts +181 -101
- package/packages/server/src/git-worktree/ensure-worktree.ts +185 -0
- package/packages/server/src/git-worktree/git-operations.ts +1 -1
- package/packages/server/src/git-worktree/repo-lock.ts +42 -0
- package/packages/server/src/git-worktree/start-worktree-init.ts +151 -0
- package/packages/server/src/git-worktree/worktree-init.ts +5 -1
- package/packages/server/src/identity/http-road-classification.ts +5 -1
- package/packages/server/src/identity/identity-floor.ts +5 -2
- package/packages/server/src/identity/ws-message-scope.ts +10 -3
- package/packages/server/src/identity/ws-road-classification.ts +2 -1
- package/packages/server/src/lib/browse-roots.ts +13 -2
- package/packages/server/src/lib/content-disposition.ts +20 -0
- package/packages/server/src/lib/dashboard-state-guard.ts +304 -21
- package/packages/server/src/lib/eml.ts +2 -2
- package/packages/server/src/lib/frame-policy-probe.ts +308 -0
- package/packages/server/src/lib/frame-policy-test-seam.ts +99 -0
- package/packages/server/src/lib/frame-policy-verdict.ts +125 -0
- package/packages/server/src/lib/grep.ts +4 -1
- package/packages/server/src/lib/index-html.ts +2 -2
- package/packages/server/src/lib/mention-fuzzy-index.ts +263 -0
- package/packages/server/src/lib/office-preview.ts +47 -10
- package/packages/server/src/lib/path-containment.ts +45 -12
- package/packages/server/src/lib/resolve-file-mention.ts +230 -38
- package/packages/server/src/lib/resolve-mentions-batch.ts +143 -0
- package/packages/server/src/lib/writable-handler-target.ts +4 -0
- package/packages/server/src/lib/writable-md-target.ts +22 -0
- package/packages/server/src/lifecycle/boot-parent-liveness.ts +10 -25
- package/packages/server/src/lifecycle/credential-exit-barrier.ts +207 -0
- package/packages/server/src/lifecycle/exit-signal.ts +43 -0
- package/packages/server/src/live-server/capability-redact.ts +21 -5
- package/packages/server/src/live-server/live-capability.ts +416 -52
- package/packages/server/src/live-server/live-csp-report.ts +1 -1
- package/packages/server/src/live-server/live-csp.ts +64 -16
- package/packages/server/src/live-server/live-log.ts +5 -1
- package/packages/server/src/live-server/live-server-manager.ts +11 -0
- package/packages/server/src/live-server/live-server-proxy.ts +268 -52
- package/packages/server/src/live-server/live-static.ts +4 -1
- package/packages/server/src/live-server/preview-dispatch.ts +286 -0
- package/packages/server/src/live-server/preview-observe.ts +53 -0
- package/packages/server/src/live-server/preview-origin.ts +182 -0
- package/packages/server/src/live-server/preview-path-bridge.ts +70 -0
- package/packages/server/src/live-server/preview-path-store.ts +420 -0
- package/packages/server/src/live-server/preview-path.ts +40 -0
- package/packages/server/src/live-server/preview-pool.ts +385 -0
- package/packages/server/src/live-server/preview-preflight.ts +41 -0
- package/packages/server/src/live-server/preview-reserve.ts +44 -0
- package/packages/server/src/live-server/preview-tier.ts +217 -0
- package/packages/server/src/live-server/preview-viewers.ts +54 -0
- package/packages/server/src/live-server/preview-ws-registry.ts +43 -0
- package/packages/server/src/model-proxy/custom-provider-discovery.ts +4 -2
- package/packages/server/src/model-proxy/internal-auth-storage.ts +5 -1
- package/packages/server/src/model-proxy/internal-registry.ts +283 -21
- package/packages/server/src/model-proxy/models-block-apply.ts +291 -0
- package/packages/server/src/model-proxy/pi-models-validator.ts +164 -0
- package/packages/server/src/model-proxy/registry-singleton.ts +44 -9
- package/packages/server/src/model-proxy/server-model-runtime.ts +17 -0
- package/packages/server/src/openspec/readiness.ts +1 -1
- package/packages/server/src/package/provider-probe.ts +194 -5
- package/packages/server/src/pairing/browser-gateway.ts +140 -42
- package/packages/server/src/pairing/device-key-intake.ts +120 -0
- package/packages/server/src/pairing/paired-devices.ts +370 -8
- package/packages/server/src/pairing/pairing.ts +69 -7
- package/packages/server/src/pairing/{subagent-resync-routing.ts → resync-requester-registry.ts} +6 -10
- package/packages/server/src/pairing/ws-tier-gate.ts +74 -0
- package/packages/server/src/pending/pending-attach-registry.ts +15 -0
- package/packages/server/src/pending/pending-initial-prompt-registry.ts +15 -0
- package/packages/server/src/persistence/memory-event-store.ts +251 -296
- package/packages/server/src/persistence/preferences-store.ts +52 -2
- package/packages/server/src/pi/bridge-contention.ts +84 -2
- package/packages/server/src/pi/host-project-trust.ts +15 -9
- package/packages/server/src/pi/pi-gateway.ts +208 -21
- package/packages/server/src/pi/provisional-registration.ts +4 -1
- package/packages/server/src/pi/resource-toggle-trust.ts +17 -6
- package/packages/server/src/pi-agent-settings.ts +95 -301
- package/packages/server/src/pi-default-remirror.ts +89 -0
- package/packages/server/src/plugin-append-event.ts +35 -0
- package/packages/server/src/plugin-entry-stats.ts +61 -0
- package/packages/server/src/plugin-local-request.ts +207 -0
- package/packages/server/src/plugin-ownership.ts +111 -0
- package/packages/server/src/plugin-policy-registry.ts +297 -0
- package/packages/server/src/plugin-request-lane.ts +92 -16
- package/packages/server/src/preferences-relay.ts +20 -0
- package/packages/server/src/project-seed.ts +347 -0
- package/packages/server/src/push/push-transports/webhook-url.ts +8 -5
- package/packages/server/src/questions/question-store.ts +3 -2
- package/packages/server/src/routes/access-routes.ts +23 -6
- package/packages/server/src/routes/acme-routes.ts +14 -4
- package/packages/server/src/routes/agent-event-stream-routes.ts +1 -1
- package/packages/server/src/routes/file-routes.ts +327 -86
- package/packages/server/src/routes/file-write-binary-routes.ts +20 -4
- package/packages/server/src/routes/frame-policy-routes.ts +215 -0
- package/packages/server/src/routes/git-routes.ts +29 -78
- package/packages/server/src/routes/grep-routes.ts +26 -0
- package/packages/server/src/routes/live-server-routes.ts +198 -4
- package/packages/server/src/routes/models-introspection-routes.ts +1 -1
- package/packages/server/src/routes/openspec-routes.ts +17 -3
- package/packages/server/src/routes/pairing-routes.ts +200 -11
- package/packages/server/src/routes/pi-settings-routes.ts +2 -0
- package/packages/server/src/routes/preferences-auto-name-routes.ts +5 -2
- package/packages/server/src/routes/preferences-claude-compat-routes.ts +49 -0
- package/packages/server/src/routes/provider-auth-routes.ts +167 -9
- package/packages/server/src/routes/provider-override-routes.ts +158 -0
- package/packages/server/src/routes/provider-routes.ts +348 -86
- package/packages/server/src/routes/session-routes.ts +25 -22
- package/packages/server/src/routes/system-routes.ts +87 -39
- package/packages/server/src/rpc-keeper/keeper-manager.ts +196 -25
- package/packages/server/src/rpc-keeper/keeper.cjs +37 -23
- package/packages/server/src/runtime-overlay/extension-reload.ts +16 -10
- package/packages/server/src/runtime-overlay/runtime-stager.ts +4 -2
- package/packages/server/src/server.ts +512 -175
- package/packages/server/src/services/cli-service.ts +59 -10
- package/packages/server/src/services/secrets-resolver.ts +46 -30
- package/packages/server/src/session/custom-event-group-annotation.ts +3 -3
- package/packages/server/src/session/custom-event-group-resolver.ts +10 -5
- package/packages/server/src/session/death-reason.ts +11 -7
- package/packages/server/src/session/event-status-extraction.ts +5 -1
- package/packages/server/src/session/memory-session-manager.ts +24 -2
- package/packages/server/src/session/open-tool-calls.ts +81 -47
- package/packages/server/src/session/pid-target.ts +127 -0
- package/packages/server/src/session/replay-compaction.ts +18 -5
- package/packages/server/src/session/seed-discovered-history.ts +85 -0
- package/packages/server/src/session/server-pid-context.ts +14 -0
- package/packages/server/src/session/session-api.ts +78 -29
- package/packages/server/src/session/session-archive.ts +7 -0
- package/packages/server/src/session/session-bootstrap.ts +9 -54
- package/packages/server/src/session/session-load-worker-pool.ts +11 -1
- package/packages/server/src/session/session-load-worker.ts +22 -3
- package/packages/server/src/spawn-process/abort-spawned-run.ts +28 -9
- package/packages/server/src/spawn-process/acp-spawn.ts +8 -2
- package/packages/server/src/spawn-process/headless-pid-registry.ts +383 -72
- package/packages/server/src/spawn-process/link-register.ts +42 -0
- package/packages/server/src/spawn-process/plugin-spawn-choice.ts +48 -0
- package/packages/server/src/spawn-process/plugin-spawn-worktree.ts +290 -0
- package/packages/server/src/spawn-process/process-classifier.ts +8 -3
- package/packages/server/src/spawn-process/process-manager.ts +61 -6
- package/packages/server/src/spawn-process/restored-identity.ts +112 -0
- package/packages/server/src/spawn-process/session-terminator.ts +179 -18
- package/packages/server/src/spawn-process/spawn-env-contributors.ts +2 -1
- package/packages/server/src/spawn-process/spawn-failure-log.ts +9 -0
- package/packages/server/src/spawn-process/spawn-register-watchdog.ts +44 -19
- package/packages/server/src/sudo-credential/relay.ts +337 -0
- package/packages/server/src/terminal/terminal-gateway.ts +10 -0
- package/packages/server/src/tls/sources/acme/credentials.ts +3 -2
- package/packages/server/src/tls/sources/acme/runtime.ts +2 -1
- package/packages/server/src/vault/vault-delivery-hub.ts +17 -1
- package/packages/server/src/vault/vault-routes.ts +9 -2
- package/packages/server/src/vault/vault-store.ts +87 -24
- package/packages/server/vendor/xlsx/LICENSE +201 -0
- package/packages/server/vendor/xlsx/PROVENANCE.json +13 -0
- package/packages/server/vendor/xlsx/xlsx.d.mts +1065 -0
- package/packages/server/vendor/xlsx/xlsx.mjs +28228 -0
- package/packages/shared/package.json +4 -2
- package/packages/shared/src/agent-credential-files.ts +32 -0
- package/packages/shared/src/browser-protocol.ts +137 -57
- package/packages/shared/src/canvas-detect.ts +1 -1
- package/packages/shared/src/canvas-types.ts +2 -2
- package/packages/shared/src/config.ts +73 -136
- package/packages/shared/src/containment-guard.ts +14 -4
- package/packages/shared/src/credential-encryption.ts +87 -0
- package/packages/shared/src/custom-event-groups.ts +2 -0
- package/packages/shared/src/dashboard-plugin/claude-compat.ts +159 -0
- package/packages/shared/src/dashboard-plugin/host-api.ts +1 -1
- package/packages/shared/src/dashboard-plugin/manifest-types.ts +46 -0
- package/packages/shared/src/dashboard-plugin/plugin-status.ts +4 -3
- package/packages/shared/src/dashboard-plugin/replay-entry-types.ts +46 -0
- package/packages/shared/src/dashboard-plugin/slot-props.ts +2 -0
- package/packages/shared/src/dashboard-plugin/slot-types.ts +1 -1
- package/packages/shared/src/dashboard-plugin/ui-primitives.ts +11 -3
- package/packages/shared/src/device-key-proof.ts +309 -0
- package/packages/shared/src/event-forward-declaration.ts +85 -12
- package/packages/shared/src/forbidden-subjects.ts +126 -14
- package/packages/shared/src/heap-limits.ts +0 -30
- package/packages/shared/src/host-admission.ts +2 -1
- package/packages/shared/src/index.ts +7 -6
- package/packages/shared/src/live-server.ts +20 -0
- package/packages/shared/src/mcp/verb-tiers.generated.ts +1 -3
- package/packages/shared/src/models-json-reader.ts +41 -0
- package/packages/shared/src/network-denial-signal.ts +15 -0
- package/packages/shared/src/node-version.ts +63 -60
- package/packages/shared/src/pairing-knock-client.ts +92 -8
- package/packages/shared/src/pi-agent-settings-lock.ts +311 -0
- package/packages/shared/src/pi-path-compare.ts +31 -0
- package/packages/shared/src/pi-settings-schema.ts +52 -9
- package/packages/shared/src/pi-trust-mirror-snapshot.ts +16 -4
- package/packages/shared/src/pi-trust-mirror-types.ts +2 -0
- package/packages/shared/src/pi-trust-mirror.ts +18 -8
- package/packages/shared/src/pi-trust-resource-digest.ts +18 -12
- package/packages/shared/src/pid-namespace.ts +86 -0
- package/packages/shared/src/platform/native-ts-register.mjs +1 -1
- package/packages/shared/src/platform/process.ts +404 -1
- package/packages/shared/src/platform/resolve-pi-shell.ts +38 -9
- package/packages/shared/src/platform/spawn-runtime.ts +193 -7
- package/packages/shared/src/preview-egress.ts +56 -2
- package/packages/shared/src/preview-origins.ts +398 -0
- package/packages/shared/src/prompt-answer.ts +9 -5
- package/packages/shared/src/protocol.ts +147 -85
- package/packages/shared/src/provider-env-catalog.ts +413 -0
- package/packages/shared/src/provider-overrides.ts +112 -0
- package/packages/shared/src/question-types.ts +6 -0
- package/packages/shared/src/recommended-extensions.ts +79 -26
- package/packages/shared/src/renderer-by-ext.ts +5 -2
- package/packages/shared/src/rest-api.ts +93 -3
- package/packages/shared/src/role-schema.ts +24 -0
- package/packages/shared/src/route-tiers.ts +94 -3
- package/packages/shared/src/runtime-overlay/compat.ts +70 -6
- package/packages/shared/src/secret-patterns.ts +49 -0
- package/packages/shared/src/source-matching.ts +2 -2
- package/packages/shared/src/state-replay.ts +40 -24
- package/packages/shared/src/sudo-credential.ts +71 -0
- package/packages/shared/src/tool-path-resolve.ts +16 -1
- package/packages/shared/src/tool-registry/strategies.ts +1 -1
- package/packages/shared/src/tool-workdir.ts +56 -0
- package/packages/shared/src/trusted-types-mode.ts +72 -0
- package/packages/shared/src/types.ts +68 -109
- package/packages/shared/src/vertex-regions.ts +81 -0
- package/packages/shared/src/ws-message-tiers.ts +10 -3
- package/packages/extension/src/subagent-fanout-admission.ts +0 -234
- package/packages/extension/src/subagent-forward-sites.ts +0 -69
- package/packages/extension/src/subagent-frame-buffer.ts +0 -245
- package/packages/extension/src/subagent-frame-strip.ts +0 -109
- package/packages/extension/src/subagent-saturation.ts +0 -196
- package/packages/extension/src/subagent-tick-throttle.ts +0 -252
- package/packages/shared/src/anthropic-messages-source.ts +0 -8
- package/packages/shared/src/dashboard-plugin/anthropic-peer-names.ts +0 -9
- package/packages/shared/src/dashboard-plugin/subagent-types.ts +0 -219
|
@@ -226,6 +226,37 @@ export interface PluginClaim {
|
|
|
226
226
|
* See change: decouple-plugins-from-core (design D5 item 7).
|
|
227
227
|
*/
|
|
228
228
|
resultPending?: string;
|
|
229
|
+
/**
|
|
230
|
+
* `tool-renderer` claims only: exported sync predicate name
|
|
231
|
+
* `(toolDetails, session) => boolean`. True = a COMPLETE row opens expanded
|
|
232
|
+
* (mount seed, and on each running→complete transition until the user toggles).
|
|
233
|
+
* A throw or non-boolean counts as false. MUST be synchronous.
|
|
234
|
+
* See change: add-agent-control-renderer (design D3).
|
|
235
|
+
*/
|
|
236
|
+
expandWhenComplete?: string;
|
|
237
|
+
/**
|
|
238
|
+
* `tool-renderer` claims only: exported sync fn name
|
|
239
|
+
* `(toolDetails, session) => { state: "queued" | "stopped"; label?: string } | undefined`.
|
|
240
|
+
* `queued` replaces the spinner/elapsed badge of a RUNNING row with a static
|
|
241
|
+
* clock + label; `stopped` replaces the success check of a non-error terminal
|
|
242
|
+
* row with a neutral stop glyph. Error and elided rows are never overridden.
|
|
243
|
+
* MUST be synchronous. See change: subagent-queue-visibility (design D2).
|
|
244
|
+
*/
|
|
245
|
+
rowStatus?: string;
|
|
246
|
+
/**
|
|
247
|
+
* `tool-renderer` claims only: exported fn name
|
|
248
|
+
* `({ sessionId, toolCallId, toolDetails }) => boolean` consulted BEFORE the
|
|
249
|
+
* row's own abort and before an enclosing burst-group stop controller.
|
|
250
|
+
* `true` consumes the click; otherwise the existing stop path runs.
|
|
251
|
+
* See change: subagent-queue-visibility (design D2).
|
|
252
|
+
*/
|
|
253
|
+
stop?: string;
|
|
254
|
+
/**
|
|
255
|
+
* `tool-renderer` claims only: exported fn name
|
|
256
|
+
* `(toolDetails) => string | undefined` supplying the row stop's accessible
|
|
257
|
+
* label. See change: subagent-queue-visibility (design D2).
|
|
258
|
+
*/
|
|
259
|
+
stopLabel?: string;
|
|
229
260
|
}
|
|
230
261
|
|
|
231
262
|
/**
|
|
@@ -243,6 +274,13 @@ export interface PluginRequirements {
|
|
|
243
274
|
/** pi extension package identifiers (matched via the same logic
|
|
244
275
|
RECOMMENDED_EXTENSIONS uses: name / id / source / displayName). */
|
|
245
276
|
piExtensions?: string[];
|
|
277
|
+
/**
|
|
278
|
+
* Minimum installed version per pi extension package name (semver range,
|
|
279
|
+
* e.g. `">=0.7.0"`). An unmet range is listed in `missingRequirements` as
|
|
280
|
+
* `<name> <range>`. A git/local install without a valid version counts as
|
|
281
|
+
* satisfied (warning in plugin status). See change: move-subagents-to-plugin (D9).
|
|
282
|
+
*/
|
|
283
|
+
piExtensionVersions?: Record<string, string>;
|
|
246
284
|
/** Binaries that must resolve on PATH via the tool-registry. */
|
|
247
285
|
binaries?: string[];
|
|
248
286
|
/** Named service probes (closed built-in registry; "model-proxy" only in V1). */
|
|
@@ -392,6 +430,14 @@ export interface PluginManifest {
|
|
|
392
430
|
* See change: harden-git-terminal-plugin-boundaries (D16).
|
|
393
431
|
*/
|
|
394
432
|
emits?: string[];
|
|
433
|
+
/**
|
|
434
|
+
* Persisted `type: "custom"` entry types this plugin owns (e.g. flows:
|
|
435
|
+
* `["flow-event"]`). An enabled plugin's types replay as their recorded
|
|
436
|
+
* `{ seq, eventType, data }` protocol events; every declared type is kept out
|
|
437
|
+
* of the generic custom-entry rendering. Malformed values contribute nothing.
|
|
438
|
+
* See change: update-flows-plugin (D3).
|
|
439
|
+
*/
|
|
440
|
+
replayEntryTypes?: string[];
|
|
395
441
|
/**
|
|
396
442
|
* Host API range this plugin was built against: `^MAJOR.MINOR[.PATCH]` or an
|
|
397
443
|
* exact `MAJOR.MINOR.PATCH`. Evaluated at discovery against
|
|
@@ -20,7 +20,8 @@ export type BridgeLoadSource = "packages[]" | "dashboardPluginBridges" | "none";
|
|
|
20
20
|
* See change: add-plugin-activation-ui (Layer 1.5).
|
|
21
21
|
*/
|
|
22
22
|
export interface PluginRequirementReport {
|
|
23
|
-
|
|
23
|
+
/** `warning`: satisfied without a verifiable version (git/local install). See change: move-subagents-to-plugin. */
|
|
24
|
+
piExtensions: { name: string; satisfied: boolean; warning?: string }[];
|
|
24
25
|
binaries: { name: string; satisfied: boolean; resolvedPath?: string }[];
|
|
25
26
|
services: { name: string; satisfied: boolean; error?: string }[];
|
|
26
27
|
/**
|
|
@@ -34,12 +35,12 @@ export interface PluginRequirementReport {
|
|
|
34
35
|
|
|
35
36
|
/**
|
|
36
37
|
* Latest bridge-status probe forwarded from the pi-side extension (for
|
|
37
|
-
* status-emitting bridges
|
|
38
|
+
* status-emitting bridges). Omitted when the
|
|
38
39
|
* plugin has no bridge or hasn't reported yet.
|
|
39
40
|
*/
|
|
40
41
|
export interface BridgeProbeSnapshot {
|
|
41
42
|
status: "probing" | "waiting_peers" | "active" | "degraded";
|
|
42
|
-
/** Per-peer probe results keyed by the peer spec (e.g. "
|
|
43
|
+
/** Per-peer probe results keyed by the peer spec (e.g. "pi-flows"). */
|
|
43
44
|
peers: Record<string, { ok: boolean; reason?: string }>;
|
|
44
45
|
/** Unix-ms timestamp when the bridge emitted this snapshot. */
|
|
45
46
|
at: number;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin-owned persisted custom-entry types (`pi-dashboard-plugin.replayEntryTypes`).
|
|
3
|
+
*
|
|
4
|
+
* A plugin declares the `type: "custom"` entry `customType` values it owns.
|
|
5
|
+
* Core replays an ENABLED plugin's types as their recorded protocol events
|
|
6
|
+
* (`state-replay.ts`) and keeps EVERY declared type — enabled or not — out of
|
|
7
|
+
* the generic custom-entry paths (a disabled plugin's entries stay hidden).
|
|
8
|
+
* Core never names a plugin entry type. See change: update-flows-plugin (D3, G5, G6).
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** Same shape as a custom entry type: printable, no whitespace, ≤ 128 chars. */
|
|
12
|
+
const ENTRY_TYPE_RE = /^[A-Za-z0-9][A-Za-z0-9:._-]{0,127}$/;
|
|
13
|
+
/** Max declared entry types per plugin. */
|
|
14
|
+
export const MAX_REPLAY_ENTRY_TYPES = 16;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Lenient parse of an untrusted manifest value: an array of valid type names,
|
|
18
|
+
* else `[]` (a malformed value contributes nothing and never throws — G6).
|
|
19
|
+
*/
|
|
20
|
+
export function normalizeReplayEntryTypes(value: unknown): string[] {
|
|
21
|
+
if (!Array.isArray(value) || value.length > MAX_REPLAY_ENTRY_TYPES) return [];
|
|
22
|
+
if (!value.every((t) => typeof t === "string" && ENTRY_TYPE_RE.test(t))) return [];
|
|
23
|
+
return [...new Set(value as string[])];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface ReplayEntryTypeSets {
|
|
27
|
+
/** Types replayed as recorded protocol events (enabled plugins only). */
|
|
28
|
+
replay: string[];
|
|
29
|
+
/** Types kept out of the generic custom-entry paths (every declaring plugin). */
|
|
30
|
+
hidden: string[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Compute both sets from discovered plugins and their enabled state. */
|
|
34
|
+
export function computeReplayEntryTypes(
|
|
35
|
+
plugins: ReadonlyArray<{ replayEntryTypes?: unknown; enabled: boolean }>,
|
|
36
|
+
): ReplayEntryTypeSets {
|
|
37
|
+
const replay = new Set<string>();
|
|
38
|
+
const hidden = new Set<string>();
|
|
39
|
+
for (const p of plugins) {
|
|
40
|
+
for (const t of normalizeReplayEntryTypes(p.replayEntryTypes)) {
|
|
41
|
+
hidden.add(t);
|
|
42
|
+
if (p.enabled) replay.add(t);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return { replay: [...replay], hidden: [...hidden] };
|
|
46
|
+
}
|
|
@@ -327,6 +327,8 @@ export interface SlotPropsMap {
|
|
|
327
327
|
toolDetails?: Record<string, unknown>;
|
|
328
328
|
images?: ToolRendererImage[];
|
|
329
329
|
context?: ToolRendererContext;
|
|
330
|
+
/** Epoch ms when the tool row started; lets a running card show a live budget. See change: add-agent-control-renderer (D4). */
|
|
331
|
+
startedAt?: number;
|
|
330
332
|
};
|
|
331
333
|
"custom-entry-renderer": CustomEntryRendererProps;
|
|
332
334
|
"automation-action-editor": {
|
|
@@ -169,7 +169,7 @@ export const SLOT_DEFINITIONS: Record<SlotId, SlotDefinition> = {
|
|
|
169
169
|
multiplicity: "many",
|
|
170
170
|
payloadTier: "react-only",
|
|
171
171
|
description:
|
|
172
|
-
"Custom React payload editor for a specific automation action id (keyed by config.actionId). Rendered by the
|
|
172
|
+
"Custom React payload editor for a specific automation action id (keyed by config.actionId). Rendered by the inline automation editor additively below the generic ActionPayloadForm; receives { payload, onChange, cwd }.",
|
|
173
173
|
},
|
|
174
174
|
"editor-pane-tab": {
|
|
175
175
|
multiplicity: "many",
|
|
@@ -106,6 +106,9 @@ export interface UiAgentCardProps {
|
|
|
106
106
|
stats?: ReactNode;
|
|
107
107
|
onClick?: () => void;
|
|
108
108
|
selected?: boolean;
|
|
109
|
+
/** Border accent replacing the status accent (`question`: an open flow
|
|
110
|
+
* question). Selection still wins. See change: adopt-flow-parent-mailbox. */
|
|
111
|
+
accent?: "question";
|
|
109
112
|
children?: ReactNode;
|
|
110
113
|
}
|
|
111
114
|
|
|
@@ -407,14 +410,19 @@ export interface UiOAuthFlowViewProps {
|
|
|
407
410
|
|
|
408
411
|
/**
|
|
409
412
|
* Public prop signature for the path-picker primitive: a modal that confirms ONE
|
|
410
|
-
* existing
|
|
411
|
-
* verified
|
|
412
|
-
* never reaches `onSelect`.
|
|
413
|
+
* existing path. `onSelect` receives an absolute path that the host has verified:
|
|
414
|
+
* a verified directory, or in file mode a verified file; anything else shows an
|
|
415
|
+
* inline error and never reaches `onSelect`.
|
|
416
|
+
* See change: improve-kb-settings-sources-and-search, add-provider-env-config.
|
|
413
417
|
*/
|
|
414
418
|
export interface UiPathPickerDialogProps {
|
|
415
419
|
open: boolean;
|
|
416
420
|
initialPath?: string;
|
|
417
421
|
title?: string;
|
|
422
|
+
/** `"file"` confirms a file instead of a directory. Default `"directory"`. */
|
|
423
|
+
mode?: "directory" | "file";
|
|
424
|
+
/** File mode: extensions offered behind the picker's filter toggle (e.g. `[".json"]`). */
|
|
425
|
+
accept?: string[];
|
|
418
426
|
onSelect: (absPath: string) => void;
|
|
419
427
|
onCancel: () => void;
|
|
420
428
|
}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device-key proof helpers shared by the server, the browser client, the
|
|
3
|
+
* Electron main process and the mobile shell.
|
|
4
|
+
*
|
|
5
|
+
* Pure: string builders, validators, the companion fragment codec, the short
|
|
6
|
+
* key id and the row-state derivation. No `node:crypto` import — the browser
|
|
7
|
+
* bundles this file. Signing/verifying lives with each runtime (WebCrypto in
|
|
8
|
+
* the browser, `node:crypto` on the server and in Electron).
|
|
9
|
+
*
|
|
10
|
+
* Signed texts are LF-joined with no trailing LF, version-prefixed, and
|
|
11
|
+
* carry the server fingerprint, so a signature for one server or one purpose
|
|
12
|
+
* never verifies as another (design D1).
|
|
13
|
+
*
|
|
14
|
+
* See change: device-key-mutual-check (D1, D3, D5, D9).
|
|
15
|
+
*/
|
|
16
|
+
import { INVISIBLE_OR_SEPARATOR } from "./terminal-safe.js";
|
|
17
|
+
|
|
18
|
+
export const DEVCHECK_PREFIX = "pi-devcheck/v2";
|
|
19
|
+
export const DEVBIND_PREFIX = "pi-devbind/v1";
|
|
20
|
+
export const COMPANION_PREFIX = "pi-companion/v1";
|
|
21
|
+
|
|
22
|
+
/** Server nonce lifetime and client re-challenge threshold. */
|
|
23
|
+
export const DEVICE_NONCE_TTL_MS = 60_000;
|
|
24
|
+
export const DEVICE_NONCE_REUSE_MS = 30_000;
|
|
25
|
+
export const COMPANION_TS_WINDOW_S = 300;
|
|
26
|
+
export const COMPANION_FRAGMENT_MAX = 512;
|
|
27
|
+
export const COMPANION_ORIGIN_MAX_BYTES = 255;
|
|
28
|
+
export const MAX_COMPANIONS = 4;
|
|
29
|
+
|
|
30
|
+
export function devcheckMessage(fingerprint: string, deviceNonce: string): string {
|
|
31
|
+
return `${DEVCHECK_PREFIX}\n${fingerprint}\n${deviceNonce}`;
|
|
32
|
+
}
|
|
33
|
+
export function devbindMessage(fingerprint: string, deviceNonce: string): string {
|
|
34
|
+
return `${DEVBIND_PREFIX}\n${fingerprint}\n${deviceNonce}`;
|
|
35
|
+
}
|
|
36
|
+
export function companionMessage(fingerprint: string, origin: string, ts: number): string {
|
|
37
|
+
return `${COMPANION_PREFIX}\n${fingerprint}\n${origin}\n${ts}`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 32 bytes → 43 chars, last char carries 2 zero pad bits; 64 bytes → 86 chars, 4 zero bits.
|
|
41
|
+
const PUB_RE = /^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$/;
|
|
42
|
+
const SIG_RE = /^[A-Za-z0-9_-]{85}[AQgw]$/;
|
|
43
|
+
|
|
44
|
+
export function isDevicePub(v: unknown): v is string {
|
|
45
|
+
return typeof v === "string" && PUB_RE.test(v);
|
|
46
|
+
}
|
|
47
|
+
export function isDeviceSig(v: unknown): v is string {
|
|
48
|
+
return typeof v === "string" && SIG_RE.test(v);
|
|
49
|
+
}
|
|
50
|
+
/** Server-issued: 32 random bytes, base64url, 43 chars. */
|
|
51
|
+
export function isDeviceNonce(v: unknown): v is string {
|
|
52
|
+
return typeof v === "string" && PUB_RE.test(v);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface DeviceProof {
|
|
56
|
+
deviceNonce: string;
|
|
57
|
+
pub: string;
|
|
58
|
+
sig: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** `{deviceNonce, pub, sig}` with every field shape-checked, else `null`. */
|
|
62
|
+
export function parseDeviceProof(v: unknown): DeviceProof | null {
|
|
63
|
+
if (!v || typeof v !== "object") return null;
|
|
64
|
+
const o = v as Record<string, unknown>;
|
|
65
|
+
if (!isDeviceNonce(o.deviceNonce) || !isDevicePub(o.pub) || !isDeviceSig(o.sig)) return null;
|
|
66
|
+
return { deviceNonce: o.deviceNonce, pub: o.pub, sig: o.sig };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Integer seconds, from a number or a decimal-digit string; else `null`. */
|
|
70
|
+
export function parseCompanionTs(v: unknown): number | null {
|
|
71
|
+
if (typeof v === "number") return Number.isSafeInteger(v) ? v : null;
|
|
72
|
+
if (typeof v === "string" && /^-?\d{1,15}$/.test(v)) return Number(v);
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function isCompanionTsFresh(ts: number, nowMs: number): boolean {
|
|
77
|
+
return Math.abs(nowMs / 1000 - ts) <= COMPANION_TS_WINDOW_S;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function utf8Bytes(s: string): number {
|
|
81
|
+
return new TextEncoder().encode(s).length;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* `http(s)://host[:port]` only — no userinfo, path, query or fragment,
|
|
86
|
+
* at most 255 UTF-8 bytes. Parsed as sent; control/format characters are
|
|
87
|
+
* allowed here (the signature covers them) and stripped only for storage.
|
|
88
|
+
*/
|
|
89
|
+
export function validCompanionOrigin(v: unknown): v is string {
|
|
90
|
+
if (typeof v !== "string" || utf8Bytes(v) > COMPANION_ORIGIN_MAX_BYTES) return false;
|
|
91
|
+
const m = /^https?:\/\/(\[[0-9A-Fa-f:.]+\]|[^\s/?#@\\:[\]]+)(?::(\d{1,5}))?$/.exec(v);
|
|
92
|
+
if (!m) return false;
|
|
93
|
+
if (m[2] !== undefined) {
|
|
94
|
+
const port = Number(m[2]);
|
|
95
|
+
if (port < 1 || port > 65535) return false;
|
|
96
|
+
}
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Stored / displayed form: control and format characters removed. */
|
|
101
|
+
export function storedCompanionOrigin(origin: string): string {
|
|
102
|
+
return origin.replace(INVISIBLE_OR_SEPARATOR, "").replace(/\p{Cc}/gu, "");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface CompanionClaim {
|
|
106
|
+
pub: string;
|
|
107
|
+
ts: number;
|
|
108
|
+
sig: string;
|
|
109
|
+
origin: string;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function encodeCompanionFragment(c: CompanionClaim): string {
|
|
113
|
+
return `companion=${c.pub}.${c.ts}.${c.sig}&from=${encodeURIComponent(c.origin)}`;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Structural parse of a `companion=` fragment (leading `#` optional): at most
|
|
118
|
+
* 512 chars, exactly three dot parts of the right shapes, a `from` value.
|
|
119
|
+
* Origin validity is the receiving server's call (`validCompanionOrigin`).
|
|
120
|
+
*/
|
|
121
|
+
export function parseCompanionFragment(hash: string): CompanionClaim | null {
|
|
122
|
+
const frag = hash.startsWith("#") ? hash.slice(1) : hash;
|
|
123
|
+
if (frag.length > COMPANION_FRAGMENT_MAX) return null;
|
|
124
|
+
const m = /^companion=([^&]*)&from=([^&]*)$/.exec(frag);
|
|
125
|
+
if (!m) return null;
|
|
126
|
+
const parts = m[1].split(".");
|
|
127
|
+
if (parts.length !== 3) return null;
|
|
128
|
+
const [pub, tsRaw, sig] = parts;
|
|
129
|
+
const ts = parseCompanionTs(tsRaw);
|
|
130
|
+
if (!isDevicePub(pub) || !isDeviceSig(sig) || ts === null) return null;
|
|
131
|
+
let origin: string;
|
|
132
|
+
try {
|
|
133
|
+
origin = decodeURIComponent(m[2]);
|
|
134
|
+
} catch {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
if (origin.length === 0) return null;
|
|
138
|
+
return { pub, ts, sig, origin };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Raw 32-byte Ed25519 key → SPKI DER (fixed 12-byte prefix). */
|
|
142
|
+
const SPKI_ED25519_PREFIX = Uint8Array.from([
|
|
143
|
+
0x30, 0x2a, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x70, 0x03, 0x21, 0x00,
|
|
144
|
+
]);
|
|
145
|
+
export function rawEd25519PubToSpki(raw: Uint8Array): Uint8Array {
|
|
146
|
+
const out = new Uint8Array(SPKI_ED25519_PREFIX.length + raw.length);
|
|
147
|
+
out.set(SPKI_ED25519_PREFIX, 0);
|
|
148
|
+
out.set(raw, SPKI_ED25519_PREFIX.length);
|
|
149
|
+
return out;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const B64URL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
153
|
+
export function bytesToBase64url(bytes: Uint8Array): string {
|
|
154
|
+
let out = "";
|
|
155
|
+
let i = 0;
|
|
156
|
+
for (; i + 2 < bytes.length; i += 3) {
|
|
157
|
+
const n = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2];
|
|
158
|
+
out += B64URL[(n >> 18) & 63] + B64URL[(n >> 12) & 63] + B64URL[(n >> 6) & 63] + B64URL[n & 63];
|
|
159
|
+
}
|
|
160
|
+
if (i < bytes.length) {
|
|
161
|
+
const n = (bytes[i] << 16) | ((bytes[i + 1] ?? 0) << 8);
|
|
162
|
+
out += B64URL[(n >> 18) & 63] + B64URL[(n >> 12) & 63];
|
|
163
|
+
if (i + 1 < bytes.length) out += B64URL[(n >> 6) & 63];
|
|
164
|
+
}
|
|
165
|
+
return out;
|
|
166
|
+
}
|
|
167
|
+
export function base64urlToBytes(s: string): Uint8Array {
|
|
168
|
+
const out: number[] = [];
|
|
169
|
+
let buf = 0;
|
|
170
|
+
let bits = 0;
|
|
171
|
+
for (const ch of s) {
|
|
172
|
+
const v = B64URL.indexOf(ch);
|
|
173
|
+
if (v < 0) throw new Error("bad base64url");
|
|
174
|
+
buf = (buf << 6) | v;
|
|
175
|
+
bits += 6;
|
|
176
|
+
if (bits >= 8) {
|
|
177
|
+
bits -= 8;
|
|
178
|
+
out.push((buf >> bits) & 0xff);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return Uint8Array.from(out);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** `dk:` + first 12 base64url chars of SHA-256 over the raw public key. */
|
|
185
|
+
export function shortKeyIdFromDigest(digest: Uint8Array): string {
|
|
186
|
+
return `dk:${bytesToBase64url(digest).slice(0, 12)}`;
|
|
187
|
+
}
|
|
188
|
+
export async function shortKeyId(pub: string): Promise<string> {
|
|
189
|
+
const raw = base64urlToBytes(pub);
|
|
190
|
+
const digest = await globalThis.crypto.subtle.digest("SHA-256", raw as BufferSource);
|
|
191
|
+
return shortKeyIdFromDigest(new Uint8Array(digest));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// ── Device-status reply + row state (D9) ─────────────────────────────
|
|
195
|
+
|
|
196
|
+
export type DeviceTier = "observe" | "control" | "operate";
|
|
197
|
+
export type DeviceStatus = "paired" | "expired" | "unknown" | "revoked" | "unverified";
|
|
198
|
+
|
|
199
|
+
/** Wire body of `POST /api/pair/device-status`. */
|
|
200
|
+
export interface DeviceStatusReply {
|
|
201
|
+
status: DeviceStatus;
|
|
202
|
+
tier?: DeviceTier;
|
|
203
|
+
scope?: "full" | "status-only";
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** Narrow an untrusted reply body; anything unrecognised is `unverified`. */
|
|
207
|
+
export function parseDeviceStatusReply(v: unknown): DeviceStatusReply {
|
|
208
|
+
if (!v || typeof v !== "object") return { status: "unverified" };
|
|
209
|
+
const o = v as Record<string, unknown>;
|
|
210
|
+
switch (o.status) {
|
|
211
|
+
case "paired": {
|
|
212
|
+
if (o.scope === "status-only") return { status: "paired", scope: "status-only" };
|
|
213
|
+
const tier = o.tier === "observe" || o.tier === "control" || o.tier === "operate" ? o.tier : undefined;
|
|
214
|
+
return tier ? { status: "paired", scope: "full", tier } : { status: "unverified" };
|
|
215
|
+
}
|
|
216
|
+
case "expired":
|
|
217
|
+
case "unknown":
|
|
218
|
+
case "revoked":
|
|
219
|
+
return { status: o.status };
|
|
220
|
+
default:
|
|
221
|
+
return { status: "unverified" };
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** What the client learnt from the two-step check. */
|
|
226
|
+
export type DeviceCheckReply =
|
|
227
|
+
| ({ kind: "answer" } & DeviceStatusReply)
|
|
228
|
+
/** The challenge reply carried no `deviceNonce` (older server). */
|
|
229
|
+
| { kind: "no-nonce" }
|
|
230
|
+
/** Timeout, transport error, or no check was run. */
|
|
231
|
+
| { kind: "no-answer" };
|
|
232
|
+
|
|
233
|
+
/** `unknowable`: a browser tab cannot see another origin's credential. */
|
|
234
|
+
export type DeviceRowCredential = "held" | "none" | "unknowable";
|
|
235
|
+
|
|
236
|
+
export type DeviceRowStateId =
|
|
237
|
+
| "paired"
|
|
238
|
+
| "paired-status-only"
|
|
239
|
+
| "access-removed"
|
|
240
|
+
| "access-expired"
|
|
241
|
+
| "not-paired"
|
|
242
|
+
| "key-pending"
|
|
243
|
+
| "status-unknown";
|
|
244
|
+
|
|
245
|
+
export interface DeviceRowState {
|
|
246
|
+
state: DeviceRowStateId;
|
|
247
|
+
tier?: DeviceTier;
|
|
248
|
+
label: string;
|
|
249
|
+
action?: "pair" | "pair-again";
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export const TIER_LABELS: Record<DeviceTier, string> = {
|
|
253
|
+
observe: "Observe",
|
|
254
|
+
control: "Control",
|
|
255
|
+
operate: "Operate",
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
export const DEVICE_ROW_LABELS: Record<Exclude<DeviceRowStateId, "paired">, string> = {
|
|
259
|
+
"paired-status-only": "Paired · status only",
|
|
260
|
+
"access-removed": "Access removed",
|
|
261
|
+
"access-expired": "Access expired",
|
|
262
|
+
"not-paired": "Not paired",
|
|
263
|
+
"key-pending": "Paired · key pending",
|
|
264
|
+
"status-unknown": "Status unknown",
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
function row(state: Exclude<DeviceRowStateId, "paired">, action?: DeviceRowState["action"]): DeviceRowState {
|
|
268
|
+
return action ? { state, label: DEVICE_ROW_LABELS[state], action } : { state, label: DEVICE_ROW_LABELS[state] };
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Pure `(credential, keyHeld, reply) → row state`. Never returns a discard
|
|
273
|
+
* instruction: only a refused credential at a proven route discards (D9).
|
|
274
|
+
* `credentialAccepted` is the outcome of the verifying authenticated call
|
|
275
|
+
* after an `unknown` answer (undefined while it is in flight).
|
|
276
|
+
*/
|
|
277
|
+
export function deviceRowState(input: {
|
|
278
|
+
credential: DeviceRowCredential;
|
|
279
|
+
keyHeld: boolean;
|
|
280
|
+
reply: DeviceCheckReply;
|
|
281
|
+
credentialAccepted?: boolean;
|
|
282
|
+
}): DeviceRowState {
|
|
283
|
+
const { credential, keyHeld, reply, credentialAccepted } = input;
|
|
284
|
+
if (!keyHeld) {
|
|
285
|
+
if (credential === "held") return row("key-pending");
|
|
286
|
+
if (credential === "none") return row("not-paired", "pair");
|
|
287
|
+
return row("status-unknown");
|
|
288
|
+
}
|
|
289
|
+
if (reply.kind !== "answer") return row("status-unknown");
|
|
290
|
+
switch (reply.status) {
|
|
291
|
+
case "paired":
|
|
292
|
+
if (reply.scope === "status-only") return row("paired-status-only");
|
|
293
|
+
if (reply.tier) return { state: "paired", tier: reply.tier, label: `Paired · ${TIER_LABELS[reply.tier]}` };
|
|
294
|
+
return row("status-unknown");
|
|
295
|
+
case "revoked":
|
|
296
|
+
return row("access-removed", "pair-again");
|
|
297
|
+
case "expired":
|
|
298
|
+
return row("access-expired", "pair-again");
|
|
299
|
+
case "unknown":
|
|
300
|
+
if (credential === "none") return row("not-paired", "pair");
|
|
301
|
+
if (credential === "held") {
|
|
302
|
+
if (credentialAccepted === true) return row("key-pending");
|
|
303
|
+
if (credentialAccepted === false) return row("not-paired", "pair");
|
|
304
|
+
}
|
|
305
|
+
return row("status-unknown");
|
|
306
|
+
default:
|
|
307
|
+
return row("status-unknown");
|
|
308
|
+
}
|
|
309
|
+
}
|
|
@@ -14,6 +14,28 @@
|
|
|
14
14
|
|
|
15
15
|
export const REGISTER_EVENT_FORWARD_CHANNEL = "dashboard:register-event-forward";
|
|
16
16
|
export const BRIDGE_READY_CHANNEL = "dashboard:bridge-ready";
|
|
17
|
+
/**
|
|
18
|
+
* A plugin bridge emits this with a {@link ToolUpdateFilterDeclaration} to drop
|
|
19
|
+
* data paths from `tool_execution_update` frames of a tool its manifest claims.
|
|
20
|
+
* See change: move-subagents-to-plugin (D5).
|
|
21
|
+
*/
|
|
22
|
+
export const REGISTER_TOOL_UPDATE_FILTER_CHANNEL = "dashboard:register-tool-update-filter";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Ownership table the server derives from loaded plugin manifests and sends to
|
|
26
|
+
* each bridge (`plugin_ownership`): manifest `eventTypes` pattern → pluginId and
|
|
27
|
+
* tool-renderer claim toolName → pluginId. The bridge reads no manifests.
|
|
28
|
+
* See change: move-subagents-to-plugin (D1).
|
|
29
|
+
*/
|
|
30
|
+
export interface PluginOwnershipTable {
|
|
31
|
+
eventTypes: Record<string, string>;
|
|
32
|
+
toolClaims: Record<string, string>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Bare signal any plugin bridge emits to make the core bridge resend
|
|
36
|
+
* `commands_list` (payload ignored). See change: update-flows-plugin (D4).
|
|
37
|
+
*/
|
|
38
|
+
export const COMMANDS_CHANGED_CHANNEL = "dashboard:commands-changed";
|
|
17
39
|
|
|
18
40
|
export type EventForwardDelivery = "live" | "latest" | "stream";
|
|
19
41
|
|
|
@@ -23,11 +45,28 @@ export interface EventForwardChannelSpec {
|
|
|
23
45
|
delivery: EventForwardDelivery;
|
|
24
46
|
/** Top-level payload field grouping retained messages (latest/stream). */
|
|
25
47
|
key?: string;
|
|
48
|
+
/**
|
|
49
|
+
* `latest` only: channels of one plugin naming the same group share ONE
|
|
50
|
+
* retained slot per key (the newest across the group's channels).
|
|
51
|
+
*/
|
|
52
|
+
group?: string;
|
|
26
53
|
}
|
|
27
54
|
|
|
28
55
|
export interface EventForwardDeclaration {
|
|
29
56
|
pluginId: string;
|
|
30
57
|
channels: Record<string, EventForwardChannelSpec>;
|
|
58
|
+
/**
|
|
59
|
+
* Retention key budget for this plugin (default 64, ceiling 256). A larger
|
|
60
|
+
* value is clamped to 256 and counted as a rejection.
|
|
61
|
+
*/
|
|
62
|
+
maxKeys?: number;
|
|
63
|
+
/**
|
|
64
|
+
* Persisted custom-entry types this plugin owns (its manifest
|
|
65
|
+
* `replayEntryTypes`). The live bridge replays them as recorded protocol
|
|
66
|
+
* events and never forwards them as generic `custom_entry` rows. Malformed
|
|
67
|
+
* values contribute nothing. See change: update-flows-plugin (D3).
|
|
68
|
+
*/
|
|
69
|
+
replayEntryTypes?: string[];
|
|
31
70
|
}
|
|
32
71
|
|
|
33
72
|
/** Normalized accepted channel (as resolved, delivery, key). */
|
|
@@ -36,8 +75,11 @@ export interface AcceptedChannelSpec {
|
|
|
36
75
|
as: string;
|
|
37
76
|
delivery: EventForwardDelivery;
|
|
38
77
|
key?: string;
|
|
78
|
+
group?: string;
|
|
39
79
|
}
|
|
40
80
|
|
|
81
|
+
export const DEFAULT_PLUGIN_MAX_KEYS = 64;
|
|
82
|
+
export const MAX_PLUGIN_MAX_KEYS = 256;
|
|
41
83
|
export const MAX_CHANNELS_PER_PLUGIN = 32;
|
|
42
84
|
export const MAX_PLUGIN_CHANNELS_TOTAL = 256;
|
|
43
85
|
|
|
@@ -47,9 +89,10 @@ const AS_RE = /^[a-z0-9_]{1,64}$/;
|
|
|
47
89
|
const KEY_RE = /^[A-Za-z][A-Za-z0-9_]{0,31}$/;
|
|
48
90
|
|
|
49
91
|
/**
|
|
50
|
-
* Event types a plugin channel may NOT forward as: pi core event types
|
|
51
|
-
*
|
|
52
|
-
*
|
|
92
|
+
* Event types a plugin channel may NOT forward as: pi core event types and
|
|
93
|
+
* bridge↔server control message types. A plugin hijacking one would inject
|
|
94
|
+
* frames the reducer trusts. Plugin-owned types are NOT listed here: ownership
|
|
95
|
+
* comes from the manifest `eventTypes` via the server's `plugin_ownership` table.
|
|
53
96
|
*/
|
|
54
97
|
export const RESERVED_EVENT_TYPES: ReadonlySet<string> = new Set([
|
|
55
98
|
// pi core session events
|
|
@@ -61,18 +104,12 @@ export const RESERVED_EVENT_TYPES: ReadonlySet<string> = new Set([
|
|
|
61
104
|
"session_before_compact", "session_before_switch", "session_before_fork", "session_tree",
|
|
62
105
|
"model_select", "user_bash", "auto_compaction_start", "auto_compaction_end",
|
|
63
106
|
"auto_retry_start", "auto_retry_end", "compaction_start", "compaction_end",
|
|
64
|
-
// core-mapped bus channels
|
|
65
|
-
"flow_started", "flow_agent_started", "flow_agent_complete", "flow_agent_error",
|
|
66
|
-
"flow_tool_call", "flow_tool_result", "flow_assistant_text", "flow_thinking_text",
|
|
67
|
-
"flow_loop_iteration", "flow_auto_decision", "flow_complete", "flow_summary_started",
|
|
68
|
-
"flow_summary_ready", "flow_summary_dismissed", "flow_autonomous_changed",
|
|
69
|
-
"subagent_created", "subagent_started", "subagent_completed", "subagent_failed",
|
|
70
107
|
// bridge control / protocol message types
|
|
71
108
|
"event_forward", "entry_persisted", "session_register", "session_unregister",
|
|
72
|
-
"session_heartbeat", "replay_complete", "commands_list",
|
|
109
|
+
"session_heartbeat", "replay_complete", "commands_list",
|
|
73
110
|
"extension_ui_request", "usage_recorded", "prompt_request", "prompt_dismiss",
|
|
74
111
|
"prompt_cancel", "notify", "plugin_pi_message", "plugin_request", "queue_update",
|
|
75
|
-
"bridge_diagnostic",
|
|
112
|
+
"bridge_diagnostic", "plugin_ownership",
|
|
76
113
|
]);
|
|
77
114
|
|
|
78
115
|
export type RejectionReason =
|
|
@@ -82,6 +119,7 @@ export type RejectionReason =
|
|
|
82
119
|
| "reserved-as"
|
|
83
120
|
| "delivery"
|
|
84
121
|
| "key"
|
|
122
|
+
| "group"
|
|
85
123
|
| "per-plugin-cap"
|
|
86
124
|
| "total-cap"
|
|
87
125
|
| "spec-shape";
|
|
@@ -92,6 +130,10 @@ export interface ValidationResult {
|
|
|
92
130
|
pluginId?: string;
|
|
93
131
|
accepted: AcceptedChannelSpec[];
|
|
94
132
|
rejected: Array<{ channel: string; reason: RejectionReason }>;
|
|
133
|
+
/** Validated `maxKeys` (clamped to the ceiling); absent when not declared / invalid. */
|
|
134
|
+
maxKeys?: number;
|
|
135
|
+
/** True when `maxKeys` was invalid or clamped (counted by the registry). */
|
|
136
|
+
maxKeysRejected?: boolean;
|
|
95
137
|
}
|
|
96
138
|
|
|
97
139
|
function own(obj: object, k: string): unknown {
|
|
@@ -122,7 +164,15 @@ function checkChannelSpec(channel: string, spec: unknown): AcceptedChannelSpec |
|
|
|
122
164
|
if (RESERVED_EVENT_TYPES.has(as)) return "reserved-as";
|
|
123
165
|
const key = optionalMatch(own(spec, "key"), KEY_RE);
|
|
124
166
|
if (key === false || (delivery !== "live" && key === undefined)) return "key";
|
|
125
|
-
|
|
167
|
+
const group = optionalMatch(own(spec, "group"), KEY_RE);
|
|
168
|
+
if (group === false || (group !== undefined && delivery !== "latest")) return "group";
|
|
169
|
+
return {
|
|
170
|
+
channel,
|
|
171
|
+
as,
|
|
172
|
+
delivery,
|
|
173
|
+
...(key !== undefined ? { key } : {}),
|
|
174
|
+
...(group !== undefined ? { group } : {}),
|
|
175
|
+
};
|
|
126
176
|
}
|
|
127
177
|
|
|
128
178
|
/** Parse the declaration header; `undefined` when the envelope is malformed. */
|
|
@@ -154,6 +204,15 @@ export function validateDeclaration(
|
|
|
154
204
|
if (!header) return result;
|
|
155
205
|
result.ok = true;
|
|
156
206
|
result.pluginId = header.pluginId;
|
|
207
|
+
const rawMax = own(raw as object, "maxKeys");
|
|
208
|
+
if (rawMax !== undefined) {
|
|
209
|
+
if (typeof rawMax === "number" && Number.isInteger(rawMax) && rawMax >= 1) {
|
|
210
|
+
result.maxKeys = Math.min(rawMax, MAX_PLUGIN_MAX_KEYS);
|
|
211
|
+
if (rawMax > MAX_PLUGIN_MAX_KEYS) result.maxKeysRejected = true;
|
|
212
|
+
} else {
|
|
213
|
+
result.maxKeysRejected = true;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
157
216
|
|
|
158
217
|
let perPlugin = opts.existingForPlugin ?? 0;
|
|
159
218
|
let total = opts.existingTotal ?? 0;
|
|
@@ -185,3 +244,17 @@ export function isValidKeyValue(v: unknown): v is string | number {
|
|
|
185
244
|
if (typeof v === "number") return Number.isFinite(v) && String(v).length <= 128;
|
|
186
245
|
return false;
|
|
187
246
|
}
|
|
247
|
+
|
|
248
|
+
export interface ToolUpdateFilterCondition {
|
|
249
|
+
/** Dot path of a string value; read as a sibling of each drop path first, else absolute. */
|
|
250
|
+
path: string;
|
|
251
|
+
in: string[];
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** Data-only `tool_execution_update` filter declaration (D5). */
|
|
255
|
+
export interface ToolUpdateFilterDeclaration {
|
|
256
|
+
pluginId: string;
|
|
257
|
+
toolName: string;
|
|
258
|
+
dropPaths: string[];
|
|
259
|
+
when?: ToolUpdateFilterCondition;
|
|
260
|
+
}
|