@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,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Preview-egress origin helpers — pure, browser-safe.
|
|
3
|
+
*
|
|
4
|
+
* `canonicalHttpsOrigin` is the single canonical subject form of the
|
|
5
|
+
* `preview-egress` access plane; `isUngrantableEgressOrigin` decides which
|
|
6
|
+
* origins can NEVER be granted (loopback / private / LAN / wildcard-DNS names
|
|
7
|
+
* and the dashboard's own origins). Origin semantics — deliberately separate
|
|
8
|
+
* from the path-oriented `forbidden-subjects`.
|
|
9
|
+
*
|
|
10
|
+
* See change: improve-canvas-html-and-url-ux (design D7).
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* WHATWG-canonical `https` origin: lowercase, punycode, trailing-dot stripped,
|
|
15
|
+
* default port elided. `null` for a non-https scheme, userinfo, or a
|
|
16
|
+
* non-parseable input.
|
|
17
|
+
*/
|
|
18
|
+
export function canonicalHttpsOrigin(input: string): string | null {
|
|
19
|
+
let u: URL;
|
|
20
|
+
try {
|
|
21
|
+
u = new URL(input);
|
|
22
|
+
} catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
if (u.protocol !== "https:") return null;
|
|
26
|
+
if (u.username || u.password) return null;
|
|
27
|
+
const host = u.hostname.replace(/\.+$/, "");
|
|
28
|
+
if (!host) return null;
|
|
29
|
+
return `https://${host}${u.port ? `:${u.port}` : ""}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Parse an IPv6 literal (no brackets) into 8 16-bit groups; null when malformed. */
|
|
33
|
+
function parseIpv6(addr: string): number[] | null {
|
|
34
|
+
let a = addr.toLowerCase();
|
|
35
|
+
const zone = a.indexOf("%");
|
|
36
|
+
if (zone >= 0) a = a.slice(0, zone);
|
|
37
|
+
// Trailing dotted-quad (IPv4-mapped / compatible forms).
|
|
38
|
+
const quad = a.match(/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);
|
|
39
|
+
if (quad) {
|
|
40
|
+
const o = quad.slice(1, 5).map(Number);
|
|
41
|
+
if (o.some((n) => n > 255)) return null;
|
|
42
|
+
a = `${a.slice(0, quad.index)}${((o[0] << 8) | o[1]).toString(16)}:${((o[2] << 8) | o[3]).toString(16)}`;
|
|
43
|
+
}
|
|
44
|
+
const halves = a.split("::");
|
|
45
|
+
if (halves.length > 2) return null;
|
|
46
|
+
const head = halves[0] ? halves[0].split(":") : [];
|
|
47
|
+
const tail = halves.length === 2 && halves[1] ? halves[1].split(":") : [];
|
|
48
|
+
const fill = 8 - head.length - tail.length;
|
|
49
|
+
if (halves.length === 1 ? head.length !== 8 : fill < 1) return null;
|
|
50
|
+
const groups = [...head, ...Array(halves.length === 2 ? fill : 0).fill("0"), ...tail];
|
|
51
|
+
if (groups.length !== 8) return null;
|
|
52
|
+
const out: number[] = [];
|
|
53
|
+
for (const g of groups) {
|
|
54
|
+
if (!/^[0-9a-f]{1,4}$/.test(g)) return null;
|
|
55
|
+
out.push(Number.parseInt(g, 16));
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** True for loopback / unspecified / private / link-local / CGNAT IPv4. */
|
|
61
|
+
function isPrivateIpv4(o: readonly number[]): boolean {
|
|
62
|
+
const [a, b] = o;
|
|
63
|
+
return (
|
|
64
|
+
a === 0 ||
|
|
65
|
+
a === 10 ||
|
|
66
|
+
a === 127 ||
|
|
67
|
+
(a === 100 && b >= 64 && b <= 127) ||
|
|
68
|
+
(a === 169 && b === 254) ||
|
|
69
|
+
(a === 172 && b >= 16 && b <= 31) ||
|
|
70
|
+
(a === 192 && b === 168) ||
|
|
71
|
+
(a === 192 && b === 0) ||
|
|
72
|
+
a >= 224 // multicast / reserved / broadcast
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function isPrivateIpv6(g: readonly number[]): boolean {
|
|
77
|
+
if (g.every((x) => x === 0)) return true; // ::
|
|
78
|
+
if (g.slice(0, 7).every((x) => x === 0) && g[7] === 1) return true; // ::1
|
|
79
|
+
if ((g[0] & 0xfe00) === 0xfc00) return true; // fc00::/7 ULA
|
|
80
|
+
if ((g[0] & 0xffc0) === 0xfe80) return true; // fe80::/10 link-local
|
|
81
|
+
// IPv4-mapped (::ffff:a.b.c.d) / IPv4-compatible (::a.b.c.d)
|
|
82
|
+
if (g.slice(0, 5).every((x) => x === 0) && (g[5] === 0xffff || g[5] === 0)) {
|
|
83
|
+
return isPrivateIpv4([g[6] >> 8, g[6] & 0xff, g[7] >> 8, g[7] & 0xff]);
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const INTERNAL_SUFFIXES = [".local", ".internal", ".lan", ".home.arpa", ".localhost"];
|
|
89
|
+
|
|
90
|
+
/** Hostname embeds an IPv4 pattern (`10.0.0.5.example.io`, `127-0-0-1.example.io`). */
|
|
91
|
+
function embedsIpv4(host: string): boolean {
|
|
92
|
+
return (
|
|
93
|
+
/(^|\.)\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(\.|$)/.test(host) ||
|
|
94
|
+
/(^|[.-])\d{1,3}-\d{1,3}-\d{1,3}-\d{1,3}($|[.-])/.test(host)
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* True when `origin` must never be granted as a preview egress origin: not a
|
|
100
|
+
* canonical https origin; `localhost` / `*.localhost`; a loopback / private /
|
|
101
|
+
* link-local / CGNAT / ULA IP literal in any parsed form; a single-label host;
|
|
102
|
+
* an internal suffix; a host embedding an IPv4 pattern (structurally covers
|
|
103
|
+
* wildcard-DNS services); or one of the dashboard's own origins.
|
|
104
|
+
*/
|
|
105
|
+
export function isUngrantableEgressOrigin(
|
|
106
|
+
origin: string,
|
|
107
|
+
ownOrigins: Iterable<string> = [],
|
|
108
|
+
): boolean {
|
|
109
|
+
const canon = canonicalHttpsOrigin(origin);
|
|
110
|
+
if (!canon) return true;
|
|
111
|
+
const u = new URL(canon);
|
|
112
|
+
const host = u.hostname;
|
|
113
|
+
if (host === "localhost" || host.endsWith(".localhost")) return true;
|
|
114
|
+
|
|
115
|
+
if (host.startsWith("[")) {
|
|
116
|
+
const g = parseIpv6(host.slice(1, -1));
|
|
117
|
+
if (!g || isPrivateIpv6(g)) return true;
|
|
118
|
+
} else if (/^\d+(\.\d+){0,3}$/.test(host) || /^0x/i.test(host)) {
|
|
119
|
+
// WHATWG already normalised any numeric form to dotted-quad.
|
|
120
|
+
const o = host.split(".").map(Number);
|
|
121
|
+
if (o.length !== 4 || o.some((n) => !Number.isInteger(n) || n > 255) || isPrivateIpv4(o)) {
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
if (!host.includes(".")) return true; // single-label
|
|
126
|
+
if (INTERNAL_SUFFIXES.some((s) => host.endsWith(s))) return true;
|
|
127
|
+
if (embedsIpv4(host)) return true;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
for (const own of ownOrigins) {
|
|
131
|
+
try {
|
|
132
|
+
if (new URL(own).origin === u.origin) return true;
|
|
133
|
+
} catch {
|
|
134
|
+
/* ignore malformed own origin */
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ONE `.git`/`.pi` project-root test (change: add-access-provisioning, D8).
|
|
3
|
+
* A directory is a project root when it holds an entry named `.git` (directory
|
|
4
|
+
* or worktree file) or `.pi`. Node-only (`node:fs`); the browser client MUST NOT import it.
|
|
5
|
+
*/
|
|
6
|
+
import * as fs from "node:fs";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
|
|
9
|
+
/** True when `dir` holds an entry named `.git` or `.pi`. Never throws. */
|
|
10
|
+
export function hasProjectRootMarker(dir: string): boolean {
|
|
11
|
+
try {
|
|
12
|
+
return fs.existsSync(path.join(dir, ".git")) || fs.existsSync(path.join(dir, ".pi"));
|
|
13
|
+
} catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -148,6 +148,12 @@ export interface SessionRegisterMessage {
|
|
|
148
148
|
cwd: string;
|
|
149
149
|
name?: string;
|
|
150
150
|
source: SessionSource;
|
|
151
|
+
/**
|
|
152
|
+
* Declared by a bridge that enforced TLS certificate validation on this (TLS)
|
|
153
|
+
* connection. Absent on plain `ws`, the local socket and old bridges.
|
|
154
|
+
* See change: prove-vault-bridge-tls (D7).
|
|
155
|
+
*/
|
|
156
|
+
certValidation?: "enforced";
|
|
151
157
|
/** Bridge extension identity (D8). Absent on pre-overlay bridges. */
|
|
152
158
|
extensionIdentity?: BridgeExtensionIdentity;
|
|
153
159
|
model?: string;
|
|
@@ -159,6 +165,22 @@ export interface SessionRegisterMessage {
|
|
|
159
165
|
isNew?: boolean;
|
|
160
166
|
/** Number of conversation entries — used by server to skip event wipe on reconnect */
|
|
161
167
|
eventCount?: number;
|
|
168
|
+
/**
|
|
169
|
+
* Id of the last entry of the branch `eventCount` counts. With `eventCount`
|
|
170
|
+
* it lets the server prove a stored/hydrated transcript is the same branch
|
|
171
|
+
* and skip the wipe. Sent only by a bridge that also marks replayed events
|
|
172
|
+
* (`EventForwardMessage.replay`). Absent ⇒ the server always wipes.
|
|
173
|
+
* See change: fix-large-session-resume-replay (D5, D7).
|
|
174
|
+
*/
|
|
175
|
+
leafEntryId?: string;
|
|
176
|
+
/**
|
|
177
|
+
* True when a turn is in progress (the same value the bridge uses for its
|
|
178
|
+
* own replay's `liveTailOpen`). A hydration-learned skip requires `false`:
|
|
179
|
+
* cold hydration closes open tool calls the live replay keeps open.
|
|
180
|
+
* Absent ⇒ no hydration-learned skip.
|
|
181
|
+
* See change: fix-large-session-resume-replay (D5, D7).
|
|
182
|
+
*/
|
|
183
|
+
liveTailOpen?: boolean;
|
|
162
184
|
/** OS process ID of the pi agent — used for force-kill escalation */
|
|
163
185
|
pid?: number;
|
|
164
186
|
/**
|
|
@@ -392,6 +414,14 @@ export interface EventForwardMessage {
|
|
|
392
414
|
type: "event_forward";
|
|
393
415
|
sessionId: string;
|
|
394
416
|
event: DashboardEvent;
|
|
417
|
+
/**
|
|
418
|
+
* `true` on every event of a history replay (register / reconnect / session
|
|
419
|
+
* switch / ACP event-log replay); never set on a live forward. The server
|
|
420
|
+
* handles a marked event as replayed whatever its replay timers say. Absent
|
|
421
|
+
* ⇒ the server falls back to its idle/cap replay-mode timers.
|
|
422
|
+
* See change: fix-large-session-resume-replay (D1).
|
|
423
|
+
*/
|
|
424
|
+
replay?: true;
|
|
395
425
|
}
|
|
396
426
|
|
|
397
427
|
/**
|
|
@@ -874,10 +904,17 @@ export interface VaultSyncRequestMessage {
|
|
|
874
904
|
type: "vault_sync_request";
|
|
875
905
|
sessionId: string;
|
|
876
906
|
cwd?: string;
|
|
877
|
-
/**
|
|
907
|
+
/**
|
|
908
|
+
* `git remote get-url origin` of `cwd` in its RAW shape (never normalised), with URL userinfo
|
|
909
|
+
* stripped by the bridge (`http(s)`: all userinfo; `ssh://`: password only). Absent when there is no
|
|
910
|
+
* readable origin, or the remote carries userinfo but cannot be parsed. The hub strips again on
|
|
911
|
+
* receipt (old bridges) and normalises it once. See change: harden-bridge-inbound-and-discovery (D18).
|
|
912
|
+
*/
|
|
878
913
|
origin?: string;
|
|
879
914
|
tracked: string[];
|
|
880
915
|
reason: "connect" | "startup" | "reload" | "new" | "resume" | "fork";
|
|
916
|
+
/** See `SessionRegisterMessage.certValidation`. See change: prove-vault-bridge-tls (D7). */
|
|
917
|
+
certValidation?: "enforced";
|
|
881
918
|
}
|
|
882
919
|
|
|
883
920
|
/**
|
|
@@ -894,6 +931,8 @@ export interface VaultSnapshotMessage {
|
|
|
894
931
|
/** Present only when `status === "ok"`. */
|
|
895
932
|
entries: Array<{ name: string; value: string }>;
|
|
896
933
|
graceHours: number;
|
|
934
|
+
/** Which proof a refused (`denied`) session is missing; never a value. See change: prove-vault-bridge-tls (D8). */
|
|
935
|
+
trustDetail?: import("./vault-delivery.js").VaultTrustDetail;
|
|
897
936
|
}
|
|
898
937
|
|
|
899
938
|
/** Bridge → server: how each granted name was applied (names and outcomes only). */
|
|
@@ -636,6 +636,24 @@ export const RECOMMENDED_EXTENSIONS: readonly RecommendedExtension[] = [
|
|
|
636
636
|
"pi-photocraft CLI (compatibility alias; replace-region)",
|
|
637
637
|
],
|
|
638
638
|
},
|
|
639
|
+
{
|
|
640
|
+
id: "@blackbelt-technology/pi-dashboard-blender",
|
|
641
|
+
source: "npm:@blackbelt-technology/pi-dashboard-blender",
|
|
642
|
+
displayName: "pi-dashboard-blender",
|
|
643
|
+
fallbackDescription:
|
|
644
|
+
"Headless Blender for pi agents without a native install: runs the " +
|
|
645
|
+
"published Blender WebAssembly build inside Node (Node 24+, ~1.2 GB per " +
|
|
646
|
+
"session), provisions one integrity-pinned runtime on first use and " +
|
|
647
|
+
"exposes it as a sandboxed stdio MCP server (blender-wasm) with a " +
|
|
648
|
+
"project-root-confined file workflow for 3D modelling and GLB export. " +
|
|
649
|
+
"Exposes the pi-blender CLI.",
|
|
650
|
+
status: "optional",
|
|
651
|
+
unlocks: [
|
|
652
|
+
"blender skill (headless 3D modelling with bpy, GLB-first export)",
|
|
653
|
+
"pi-blender CLI (ensure, status, mcp, mcp --register)",
|
|
654
|
+
"blender-wasm MCP server (blender_scene, blender_python, blender_import, blender_export, blender_reset)",
|
|
655
|
+
],
|
|
656
|
+
},
|
|
639
657
|
{
|
|
640
658
|
id: "@blackbelt-technology/pi-untrusted-content-guard",
|
|
641
659
|
source: "npm:@blackbelt-technology/pi-untrusted-content-guard",
|
|
@@ -22,6 +22,33 @@
|
|
|
22
22
|
*/
|
|
23
23
|
export const RESTART_QUIESCE_MS = 5000;
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Shutdown quiesce window announced by the shutdown route (host going down;
|
|
27
|
+
* the orchestrator may take longer to bring a server back than a restart).
|
|
28
|
+
*/
|
|
29
|
+
export const SHUTDOWN_QUIESCE_MS = 60_000;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Hard upper bound on any auto-start pause a bridge honours, whoever asked
|
|
33
|
+
* (`server_restarting` frame, direct `pauseAutoStart` call). A rogue or buggy
|
|
34
|
+
* server cannot hold a bridge's spawn step off indefinitely. Must stay >= 2x
|
|
35
|
+
* the largest value the server itself sends. See change:
|
|
36
|
+
* harden-bridge-inbound-and-discovery (D17).
|
|
37
|
+
*/
|
|
38
|
+
export const MAX_QUIESCE_MS = 120_000;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Normalize an untrusted quiesce duration into the pause a bridge applies.
|
|
42
|
+
* Returns `undefined` (ignore, no pause) for non-numbers, `NaN` and values
|
|
43
|
+
* <= 0. Otherwise rounds a non-integer UP (the window is "at least"
|
|
44
|
+
* `quiesceMs`), then clamps to `MAX_QUIESCE_MS` (`Infinity` included).
|
|
45
|
+
*/
|
|
46
|
+
export function normalizeQuiesceMs(value: unknown): number | undefined {
|
|
47
|
+
if (typeof value !== "number" || Number.isNaN(value) || value <= 0) return undefined;
|
|
48
|
+
if (value === Infinity) return MAX_QUIESCE_MS;
|
|
49
|
+
return Math.min(Math.ceil(value), MAX_QUIESCE_MS);
|
|
50
|
+
}
|
|
51
|
+
|
|
25
52
|
/**
|
|
26
53
|
* Slack added on top of the quiesce window to cover mDNS re-discovery plus
|
|
27
54
|
* WebSocket reconnect latency once a bridge is allowed to come back.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Credential stripping for git remote URLs.
|
|
3
|
+
*
|
|
4
|
+
* A remote such as `https://user:token@github.com/o/r` carries a secret in its
|
|
5
|
+
* userinfo. Anything that builds a link from a remote, or sends a remote off
|
|
6
|
+
* the bridge (vault sync origin), goes through `stripRemoteCredentials` first.
|
|
7
|
+
*
|
|
8
|
+
* Rules (scheme, host, port, path are kept verbatim — never re-serialised, so
|
|
9
|
+
* IPv6 brackets and percent-escapes survive):
|
|
10
|
+
* - every scheme EXCEPT the ssh family (`http(s)`, `git+https`, `ftps`, `git`, …)
|
|
11
|
+
* → ALL userinfo removed (there the user part is the token);
|
|
12
|
+
* - the ssh family (`ssh`, `git+ssh`, `ssh+git`) → the PASSWORD is removed, the
|
|
13
|
+
* user is kept (`ssh://git:secret@h/o/r` → `ssh://git@h/o/r`: `git` is not a secret);
|
|
14
|
+
* - scp form `git@host:owner/repo` carries no password → returned unchanged;
|
|
15
|
+
* - no userinfo → returned unchanged (byte-identical);
|
|
16
|
+
* - userinfo present but the remainder is not a usable URL (no host) →
|
|
17
|
+
* `undefined`: the caller sends no origin and builds no links rather than
|
|
18
|
+
* risk leaking what it could not parse.
|
|
19
|
+
*
|
|
20
|
+
* The output is the RAW shape, never `normalizeOrigin`'s `host/path` form
|
|
21
|
+
* (that is not idempotent: it has no scheme, so re-parsing it yields nothing).
|
|
22
|
+
*
|
|
23
|
+
* See change: harden-bridge-inbound-and-discovery (D18).
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
const SSH_FAMILY = /^(ssh|git\+ssh|ssh\+git)$/i;
|
|
27
|
+
const SCHEMED = /^([a-z][a-z0-9+.-]*):\/\/([^/?#]*)(.*)$/is;
|
|
28
|
+
/** `host` or `[ipv6]`, optional `:port`. */
|
|
29
|
+
const HOST_PORT = /^(\[[^\]\s]+\]|[^:@\s[\]]+)(?::\d+)?$/;
|
|
30
|
+
|
|
31
|
+
export function stripRemoteCredentials(raw: string): string | undefined {
|
|
32
|
+
const m = SCHEMED.exec(raw);
|
|
33
|
+
if (!m) return raw; // scp form, local path, or garbage with no `scheme://`: no URL userinfo to strip
|
|
34
|
+
const [, scheme, authority, rest] = m;
|
|
35
|
+
const at = authority.lastIndexOf("@"); // last: a password may itself contain `@`
|
|
36
|
+
if (at === -1) {
|
|
37
|
+
// A literal `#` / `?` inside a password ends `authority` early, hiding the `@`.
|
|
38
|
+
// If an `@` still sits before the first `/`, we cannot tell where the host starts: fail closed.
|
|
39
|
+
const afterScheme = raw.slice(scheme.length + 3);
|
|
40
|
+
const slash = afterScheme.indexOf("/");
|
|
41
|
+
if ((slash === -1 ? afterScheme : afterScheme.slice(0, slash)).includes("@")) return undefined;
|
|
42
|
+
return raw;
|
|
43
|
+
}
|
|
44
|
+
const userinfo = authority.slice(0, at);
|
|
45
|
+
const hostPort = authority.slice(at + 1);
|
|
46
|
+
if (!HOST_PORT.test(hostPort)) return undefined;
|
|
47
|
+
if (!SSH_FAMILY.test(scheme)) return `${scheme}://${hostPort}${rest}`;
|
|
48
|
+
const colon = userinfo.indexOf(":");
|
|
49
|
+
const user = colon === -1 ? userinfo : userinfo.slice(0, colon);
|
|
50
|
+
return user ? `${scheme}://${user}@${hostPort}${rest}` : `${scheme}://${hostPort}${rest}`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The remote as it may LEAVE the bridge (or be stored by the hub): credentials
|
|
55
|
+
* stripped, and for a URL form also any `?query` / `#fragment` (a token riding
|
|
56
|
+
* in `?access_token=…` is as much a secret as userinfo, and is never part of the
|
|
57
|
+
* repository path). scp and other non-URL forms pass through untouched.
|
|
58
|
+
*/
|
|
59
|
+
export function remoteForWire(raw: string): string | undefined {
|
|
60
|
+
const stripped = stripRemoteCredentials(raw);
|
|
61
|
+
if (stripped === undefined || !SCHEMED.test(stripped)) return stripped;
|
|
62
|
+
return stripped.replace(/[?#].*$/s, "");
|
|
63
|
+
}
|
|
@@ -81,7 +81,12 @@ export interface ListSessionsQuery {
|
|
|
81
81
|
status?: "active" | "ended";
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
/** A `GET /api/sessions` row: the session plus absolute browser links built
|
|
85
|
+
* from the origin the caller used. Never stored, never sent over the WebSocket.
|
|
86
|
+
* See change: add-session-ui-deep-links-for-agents. */
|
|
87
|
+
export type SessionListItem = DashboardSession & { uiUrl: string; diffUrl: string };
|
|
88
|
+
|
|
89
|
+
export type ListSessionsResponse = ApiResponse<SessionListItem[]>;
|
|
85
90
|
|
|
86
91
|
// ── Events ──────────────────────────────────────────────────────────
|
|
87
92
|
|
|
@@ -402,6 +407,11 @@ export interface BrowseResult {
|
|
|
402
407
|
entries: BrowseEntry[];
|
|
403
408
|
parent: string | null;
|
|
404
409
|
current: string;
|
|
410
|
+
/**
|
|
411
|
+
* True when the request was confined to the shared-root set (a non-local
|
|
412
|
+
* caller); absent for local callers. See change: harden-server-capability-bounds.
|
|
413
|
+
*/
|
|
414
|
+
confined?: boolean;
|
|
405
415
|
/**
|
|
406
416
|
* The server's `process.platform` — lets the client use OS-correct path
|
|
407
417
|
* handling (separator, case-sensitivity, drive-letter rules) without
|
|
@@ -1121,9 +1131,16 @@ export type PiCoreUpdateApiResponse = ApiResponse<PiCoreUpdateResponse>;
|
|
|
1121
1131
|
// ── Known Servers ─────────────────────────────────────────────
|
|
1122
1132
|
|
|
1123
1133
|
import type { KnownServer } from "./config.js";
|
|
1134
|
+
import type { RouteScheme } from "./server-routes.js";
|
|
1124
1135
|
|
|
1125
|
-
/**
|
|
1126
|
-
|
|
1136
|
+
/**
|
|
1137
|
+
* A known server as listed: one entry per identity with its `routes`, and its
|
|
1138
|
+
* verified move suggestion (for the primary route) when one exists.
|
|
1139
|
+
* A server older than `group-servers-by-identity` lists entries WITHOUT `routes`;
|
|
1140
|
+
* clients treat that as "pre-routes" (no https add offered).
|
|
1141
|
+
*/
|
|
1142
|
+
export interface KnownServerListEntry extends Omit<KnownServer, "routes"> {
|
|
1143
|
+
routes?: KnownServer["routes"];
|
|
1127
1144
|
/** Verified new address of the same identity (never persisted). */
|
|
1128
1145
|
movedTo?: { host: string; port: number };
|
|
1129
1146
|
}
|
|
@@ -1136,19 +1153,24 @@ export type KnownServersListResponse = ApiResponse<KnownServerListEntry[]> & {
|
|
|
1136
1153
|
export interface AddKnownServerRequest {
|
|
1137
1154
|
host: string;
|
|
1138
1155
|
port: number;
|
|
1156
|
+
/** Route scheme; default `http`. Only `http` / `https` are accepted (`400 invalid_scheme` otherwise). */
|
|
1157
|
+
scheme?: RouteScheme;
|
|
1139
1158
|
label?: string;
|
|
1140
1159
|
/** Hint only — persisted solely when the identity challenge proves it. */
|
|
1141
1160
|
fingerprint?: string;
|
|
1142
1161
|
}
|
|
1143
1162
|
|
|
1144
|
-
/**
|
|
1163
|
+
/**
|
|
1164
|
+
* `POST /api/known-servers` success data. `updated` is true exactly when the add
|
|
1165
|
+
* attached a route that was not stored before to an existing entry.
|
|
1166
|
+
*/
|
|
1145
1167
|
export interface AddKnownServerResult {
|
|
1146
1168
|
updated?: boolean;
|
|
1147
1169
|
}
|
|
1148
1170
|
|
|
1149
1171
|
/** `POST /api/known-servers/accept-move` body. */
|
|
1150
1172
|
export interface AcceptKnownServerMoveRequest {
|
|
1151
|
-
/** Current stored address of the entry. */
|
|
1173
|
+
/** Current stored address of the entry (its primary route). */
|
|
1152
1174
|
host: string;
|
|
1153
1175
|
port: number;
|
|
1154
1176
|
}
|
|
@@ -1156,15 +1178,40 @@ export interface AcceptKnownServerMoveRequest {
|
|
|
1156
1178
|
/** Server-side reachability of a known server (operator-only probe). */
|
|
1157
1179
|
export type KnownServerProbeStatus = "reachable" | "name-not-resolved" | "refused" | "timeout" | "error";
|
|
1158
1180
|
|
|
1181
|
+
export interface KnownServerProbeRequest {
|
|
1182
|
+
host: string;
|
|
1183
|
+
port: number;
|
|
1184
|
+
/** Must still match a stored route; default `http`. */
|
|
1185
|
+
scheme?: RouteScheme;
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1159
1188
|
export interface KnownServerProbeResult {
|
|
1160
1189
|
status: KnownServerProbeStatus;
|
|
1190
|
+
/** Scheme the probe used (that of the stored route). */
|
|
1191
|
+
scheme?: RouteScheme;
|
|
1192
|
+
/** Present when the dashboard server's own identity challenge proved a fingerprint at the route. */
|
|
1193
|
+
fingerprint?: string;
|
|
1161
1194
|
}
|
|
1162
1195
|
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1196
|
+
/** `DELETE /api/known-servers`: one route (and the entry when it was the last), or a whole entry by fingerprint. */
|
|
1197
|
+
export type RemoveKnownServerRequest = { host: string; port: number; scheme?: RouteScheme } | { fingerprint: string };
|
|
1198
|
+
|
|
1199
|
+
/**
|
|
1200
|
+
* `data` of an `approved` `POST /api/pair/poll` answer (the one answer that
|
|
1201
|
+
* carries the token). `routes` are the server's reachable `https` origins; a
|
|
1202
|
+
* device validates them (`validateDeliveredRoutes`) before it stores any.
|
|
1203
|
+
* Absent on pending / rejected / unknown answers and on servers that predate it.
|
|
1204
|
+
*/
|
|
1205
|
+
export interface PairPollApproved {
|
|
1206
|
+
status: "approved";
|
|
1207
|
+
token: string;
|
|
1208
|
+
/** Epoch ms the bearer expires; present only when the pairing declared `holder:"browser"`. */
|
|
1209
|
+
expiresAt?: number;
|
|
1210
|
+
routes?: string[];
|
|
1166
1211
|
}
|
|
1167
1212
|
|
|
1213
|
+
export type PairPollData = { status: "pending" | "rejected" | "unknown" } | PairPollApproved;
|
|
1214
|
+
|
|
1168
1215
|
export interface DiscoveredServerInfo {
|
|
1169
1216
|
host: string;
|
|
1170
1217
|
port: number;
|