@blackbelt-technology/pi-dashboard-extension 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.pi/skills/browser/SKILL.md +84 -29
- package/.pi/skills/browser/UPSTREAM.md +13 -1
- package/.pi/skills/browser/references/challenge.md +183 -0
- package/.pi/skills/browser/references/dashboard-relay.md +150 -0
- package/.pi/skills/browser/references/electron.agent.md +57 -0
- package/.pi/skills/browser/references/own-browser.md +305 -0
- package/.pi/skills/browser/references/web.agent.md +323 -0
- package/.pi/skills/browser/scripts/check-panerelay.sh +157 -0
- package/.pi/skills/doctor/SKILL.md +4 -9
- package/.pi/skills/doctor/_lib/checks.ts +133 -54
- package/.pi/skills/doctor/_lib/derive-tokens.ts +5 -0
- package/.pi/skills/doctor/modules/apple-tools.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/apple-tools.md +52 -0
- package/.pi/skills/doctor/modules/mcp-builtin.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/mcp-builtin.md +61 -0
- package/.pi/skills/doctor/modules/oauth-redirect-base.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/oauth-redirect-base.md +71 -0
- package/.pi/skills/doctor/modules/pi-resolution.knowledge.hash +1 -1
- package/.pi/skills/doctor/modules/pi-resolution.md +21 -1
- package/.pi/skills/doctor/modules/plugins-bridges.md +14 -1
- package/.pi/skills/pi-dashboard/SKILL.md +10 -3
- package/.pi/skills/pi-dashboard/references/api-reference.agent.md +69 -0
- package/.pi/skills/pi-dashboard/scripts/dashboard-bus.ts +4 -4
- package/.pi/skills/project-init/SKILL.md +41 -34
- package/.pi/skills/project-init/profiles/coding/AGENTS.md.tmpl +0 -23
- package/.pi/skills/project-init/profiles/docs/profile.json +1 -1
- package/README.md +19 -0
- package/agents/DoxTriage.md +80 -0
- package/package.json +30 -16
- package/src/ask-user-tool.ts +4 -0
- package/src/auto-session-namer.ts +486 -70
- package/src/autostart-guard.ts +99 -0
- package/src/autostart-lock.ts +258 -0
- package/src/bridge-activation.ts +26 -0
- package/src/bridge-context.ts +106 -23
- package/src/bridge-default-model-gate.ts +38 -0
- package/src/bridge-polling.ts +148 -0
- package/src/bridge-ticket-client.ts +105 -0
- package/src/bridge.ts +1760 -350
- package/src/canvas-tool.ts +5 -0
- package/src/command-handler.ts +392 -71
- package/src/connect-target.ts +130 -0
- package/src/connection.ts +846 -17
- package/src/custom-entry-forward.ts +92 -0
- package/src/endpoint-resolution.ts +253 -0
- package/src/event-forwarder.ts +42 -0
- package/src/extension-identity.ts +59 -0
- package/src/flow-event-wiring.ts +125 -3
- package/src/followup-buffer.ts +217 -0
- package/src/git-dir-watcher.ts +79 -0
- package/src/git-poll.ts +45 -12
- package/src/git-probe-scheduler.ts +119 -0
- package/src/git-tracker.ts +284 -0
- package/src/instance-verification.ts +156 -0
- package/src/local-token-header.ts +44 -0
- package/src/mcp-token-delivery.ts +147 -0
- package/src/message-update-coalescer.ts +340 -0
- package/src/model-refresh.ts +95 -0
- package/src/model-tracker.ts +118 -35
- package/src/notify-proxy.ts +36 -0
- package/src/path-gate/decide.ts +149 -0
- package/src/path-gate/grant-cache.ts +71 -0
- package/src/path-gate/grant-link.ts +108 -0
- package/src/path-gate/handler.ts +307 -0
- package/src/path-gate/index.ts +155 -0
- package/src/path-gate/resolve.ts +126 -0
- package/src/path-gate/roots.ts +137 -0
- package/src/path-gate/suppression.ts +27 -0
- package/src/pending-prompt-emitter.ts +59 -0
- package/src/pi-env.d.ts +6 -10
- package/src/pi-retry-settings.ts +91 -0
- package/src/plugin-request-client.ts +114 -0
- package/src/poll-cost.ts +40 -0
- package/src/pr-status.ts +338 -0
- package/src/process-metrics.ts +77 -1
- package/src/process-scan-scheduler.ts +137 -0
- package/src/process-scanner.ts +226 -247
- package/src/project-init/dox-kb-config.ts +3 -0
- package/src/project-init/scaffold.ts +1 -4
- package/src/project-init/seed-doctrine.ts +23 -60
- package/src/prompt-bus.ts +13 -0
- package/src/provider-register.ts +92 -21
- package/src/remote-registration-gate.ts +102 -0
- package/src/retry-tracker.ts +258 -86
- package/src/role-manager.ts +38 -91
- package/src/role-model-tools.ts +44 -3
- package/src/server-auto-start.ts +331 -20
- package/src/server-launcher.ts +70 -34
- package/src/server-pin-store.ts +92 -0
- package/src/session-move.ts +275 -0
- package/src/session-sync.ts +75 -20
- package/src/slash-dispatch.ts +66 -81
- package/src/subagent-fanout-admission.ts +234 -0
- package/src/subagent-forward-sites.ts +69 -0
- package/src/subagent-frame-buffer.ts +24 -3
- package/src/subagent-frame-strip.ts +109 -0
- package/src/subagent-saturation.ts +196 -0
- package/src/subagent-tick-throttle.ts +250 -0
- package/src/terminal-reload.ts +298 -0
- package/src/transcript-backfill.ts +151 -0
- package/src/transport-diagnostics.ts +76 -0
- package/src/tui-prompt-adapter.ts +13 -1
- package/src/turn-actionability.ts +20 -0
- package/src/ui-stale-guard.ts +58 -0
- package/src/usage-drain.ts +167 -0
- package/src/vcs-info.ts +261 -63
- package/.pi/skills/doctor/AGENTS.md +0 -27
- package/.pi/skills/project-init/dox-doctrine.md +0 -104
- package/src/AGENTS.md +0 -57
- package/src/__tests__/abort-latch.test.ts +0 -97
- package/src/__tests__/agent-settled.test.ts +0 -82
- package/src/__tests__/artifact-roots.test.ts +0 -83
- package/src/__tests__/ask-user-attachments.test.ts +0 -106
- package/src/__tests__/ask-user-schema-discriminator.test.ts +0 -141
- package/src/__tests__/ask-user-tool.test.ts +0 -571
- package/src/__tests__/auto-session-namer.test.ts +0 -339
- package/src/__tests__/bridge-default-model-apply.test.ts +0 -242
- package/src/__tests__/bridge-default-model-gate.test.ts +0 -50
- package/src/__tests__/bridge-entry-id-pi-070.test.ts +0 -174
- package/src/__tests__/bridge-followup-chat-order.test.ts +0 -215
- package/src/__tests__/bridge-followup-multi-entry.test.ts +0 -202
- package/src/__tests__/bridge-followup-mutation.test.ts +0 -217
- package/src/__tests__/bridge-followup-queue-drain.test.ts +0 -266
- package/src/__tests__/bridge-hasui-flip.test.ts +0 -109
- package/src/__tests__/bridge-no-queue-mutation.test.ts +0 -112
- package/src/__tests__/bridge-plugin-emit-event.test.ts +0 -44
- package/src/__tests__/bridge-queue-update-forward.test.ts +0 -77
- package/src/__tests__/bridge-resume-disconnect.test.ts +0 -333
- package/src/__tests__/bridge-shadow-queue-gate.test.ts +0 -299
- package/src/__tests__/bridge-shutdown-reset.test.ts +0 -159
- package/src/__tests__/bridge-slash-command-routing.test.ts +0 -458
- package/src/__tests__/bridge-stop-after-turn.test.ts +0 -72
- package/src/__tests__/bridge-system-followup.test.ts +0 -163
- package/src/__tests__/bridge-thinking-level-select.test.ts +0 -68
- package/src/__tests__/browser-skill-registered.test.ts +0 -84
- package/src/__tests__/build-provider-catalogue.test.ts +0 -210
- package/src/__tests__/command-handler.test.ts +0 -1180
- package/src/__tests__/commit-draft.test.ts +0 -100
- package/src/__tests__/connection-dropped-frames.test.ts +0 -78
- package/src/__tests__/connection-suppress-auto-start.test.ts +0 -97
- package/src/__tests__/connection.test.ts +0 -344
- package/src/__tests__/credentials-updated.test.ts +0 -26
- package/src/__tests__/custom-provider-apikey-roundtrip.test.ts +0 -128
- package/src/__tests__/cwd-missing-probe.test.ts +0 -82
- package/src/__tests__/dashboard-commands-shipped.test.ts +0 -53
- package/src/__tests__/dashboard-context-injector.test.ts +0 -190
- package/src/__tests__/dashboard-default-adapter.test.ts +0 -77
- package/src/__tests__/dev-build.test.ts +0 -79
- package/src/__tests__/doctor/checks.test.ts +0 -121
- package/src/__tests__/doctor/modules.test.ts +0 -64
- package/src/__tests__/doctor/provenance-hash.test.ts +0 -94
- package/src/__tests__/doctor/router.test.ts +0 -143
- package/src/__tests__/empty-actionable-guard-config.test.ts +0 -32
- package/src/__tests__/empty-actionable-guard.test.ts +0 -73
- package/src/__tests__/enrich-model-metadata.test.ts +0 -222
- package/src/__tests__/event-forwarder.test.ts +0 -119
- package/src/__tests__/extension-slash-command-detection.test.ts +0 -143
- package/src/__tests__/filter-enabled-models.test.ts +0 -151
- package/src/__tests__/fixtures/turn-actionability-fixtures.ts +0 -69
- package/src/__tests__/fork-entryid-timing.test.ts +0 -88
- package/src/__tests__/git-info-status.test.ts +0 -73
- package/src/__tests__/git-link-builder.test.ts +0 -102
- package/src/__tests__/git-poll.test.ts +0 -69
- package/src/__tests__/markdown-image-inliner.test.ts +0 -392
- package/src/__tests__/model-resolve.test.ts +0 -379
- package/src/__tests__/multiselect-dashboard-routing.test.ts +0 -203
- package/src/__tests__/multiselect-list.test.ts +0 -137
- package/src/__tests__/multiselect-polyfill.test.ts +0 -92
- package/src/__tests__/no-session-replacement-calls.test.ts +0 -99
- package/src/__tests__/no-tui-multiselect-arm-regression.test.ts +0 -81
- package/src/__tests__/openspec-activity-detector.test.ts +0 -337
- package/src/__tests__/openspec-cli-shim.test.ts +0 -145
- package/src/__tests__/openspec-poller.test.ts +0 -124
- package/src/__tests__/pi-version-tracker.test.ts +0 -109
- package/src/__tests__/process-metrics.test.ts +0 -47
- package/src/__tests__/process-scanner-kill.test.ts +0 -61
- package/src/__tests__/process-scanner.test.ts +0 -292
- package/src/__tests__/project-init-detect-stack.test.ts +0 -61
- package/src/__tests__/project-init-dox-kb-config.test.ts +0 -53
- package/src/__tests__/project-init-profiles.test.ts +0 -84
- package/src/__tests__/project-init-scaffold.test.ts +0 -139
- package/src/__tests__/project-init-seed-doctrine.test.ts +0 -100
- package/src/__tests__/project-trust.test.ts +0 -92
- package/src/__tests__/prompt-bus-wiring.test.ts +0 -791
- package/src/__tests__/prompt-bus.test.ts +0 -513
- package/src/__tests__/prompt-expander.test.ts +0 -398
- package/src/__tests__/provider-register-native-models.test.ts +0 -182
- package/src/__tests__/provider-register-reload.test.ts +0 -498
- package/src/__tests__/provider-register-thinking-levels.test.ts +0 -104
- package/src/__tests__/retry-tracker.test.ts +0 -152
- package/src/__tests__/role-manager.test.ts +0 -585
- package/src/__tests__/role-model-tools-registry-readiness.test.ts +0 -114
- package/src/__tests__/role-model-tools.test.ts +0 -229
- package/src/__tests__/search-files-completeness.test.ts +0 -111
- package/src/__tests__/search-files-ranking.test.ts +0 -168
- package/src/__tests__/server-auto-start.test.ts +0 -375
- package/src/__tests__/server-launcher-launch.test.ts +0 -96
- package/src/__tests__/server-launcher.test.ts +0 -101
- package/src/__tests__/server-probe.test.ts +0 -25
- package/src/__tests__/session-switch.test.ts +0 -139
- package/src/__tests__/session-sync.test.ts +0 -243
- package/src/__tests__/single-derivation-guard.test.ts +0 -39
- package/src/__tests__/source-detector.test.ts +0 -88
- package/src/__tests__/stats-extractor.test.ts +0 -92
- package/src/__tests__/subagent-frame-buffer.test.ts +0 -239
- package/src/__tests__/tool-result-image-inliner.test.ts +0 -206
- package/src/__tests__/tui-prompt-adapter.test.ts +0 -213
- package/src/__tests__/turn-actionability.test.ts +0 -86
- package/src/__tests__/ui-decorators.test.ts +0 -309
- package/src/__tests__/ui-modules.test.ts +0 -293
- package/src/__tests__/vcs-info.test.ts +0 -265
- package/src/__tests__/visibility-intent.test.ts +0 -43
- package/src/__tests__/watchdog.test.ts +0 -161
- package/src/abort-latch.ts.AGENTS.md +0 -3
- package/src/agent-settled.ts +0 -72
- package/src/agent-settled.ts.AGENTS.md +0 -3
- package/src/artifact-roots.ts.AGENTS.md +0 -3
- package/src/ask-user-attachments.ts.AGENTS.md +0 -3
- package/src/ask-user-tool.ts.AGENTS.md +0 -3
- package/src/auto-session-namer.ts.AGENTS.md +0 -3
- package/src/bridge-context.ts.AGENTS.md +0 -3
- package/src/bridge-default-model-gate.ts.AGENTS.md +0 -3
- package/src/bridge.ts.AGENTS.md +0 -3
- package/src/command-handler.ts.AGENTS.md +0 -3
- package/src/commit-draft-agent.ts.AGENTS.md +0 -3
- package/src/commit-draft.ts.AGENTS.md +0 -3
- package/src/connection.ts.AGENTS.md +0 -3
- package/src/dashboard-context-injector.ts.AGENTS.md +0 -3
- package/src/dashboard-default-adapter.ts.AGENTS.md +0 -3
- package/src/dev-build.ts.AGENTS.md +0 -3
- package/src/empty-actionable-guard-config.ts.AGENTS.md +0 -3
- package/src/empty-actionable-guard.ts.AGENTS.md +0 -3
- package/src/event-forwarder.ts.AGENTS.md +0 -3
- package/src/flow-event-wiring.ts.AGENTS.md +0 -3
- package/src/git-link-builder.ts.AGENTS.md +0 -3
- package/src/git-poll.ts.AGENTS.md +0 -3
- package/src/hasui-flip.ts.AGENTS.md +0 -3
- package/src/markdown-image-inliner.ts.AGENTS.md +0 -3
- package/src/model-tracker.ts.AGENTS.md +0 -3
- package/src/multiselect-decode.ts.AGENTS.md +0 -3
- package/src/multiselect-list.ts.AGENTS.md +0 -3
- package/src/multiselect-polyfill.ts.AGENTS.md +0 -3
- package/src/openspec-cli-shim.ts.AGENTS.md +0 -7
- package/src/process-metrics.ts.AGENTS.md +0 -3
- package/src/process-scanner.ts.AGENTS.md +0 -3
- package/src/project-init/AGENTS.md +0 -12
- package/src/project-trust.ts.AGENTS.md +0 -3
- package/src/prompt-bus.ts.AGENTS.md +0 -3
- package/src/prompt-expander.ts.AGENTS.md +0 -3
- package/src/provider-register.ts.AGENTS.md +0 -3
- package/src/retry-tracker.ts.AGENTS.md +0 -3
- package/src/role-manager.ts.AGENTS.md +0 -3
- package/src/role-model-tools.ts.AGENTS.md +0 -3
- package/src/server-auto-start.ts.AGENTS.md +0 -3
- package/src/server-launcher.ts.AGENTS.md +0 -3
- package/src/session-sync.ts.AGENTS.md +0 -3
- package/src/slash-dispatch.ts.AGENTS.md +0 -3
- package/src/source-detector.ts.AGENTS.md +0 -3
- package/src/subagent-frame-buffer.ts.AGENTS.md +0 -3
- package/src/tool-result-image-inliner.ts.AGENTS.md +0 -3
- package/src/tui-prompt-adapter.ts.AGENTS.md +0 -3
- package/src/turn-actionability.ts.AGENTS.md +0 -3
- package/src/ui-modules.ts.AGENTS.md +0 -3
- package/src/vcs-info.ts.AGENTS.md +0 -3
- package/src/visibility-intent.ts.AGENTS.md +0 -3
|
@@ -1,375 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, afterEach } from "vitest";
|
|
2
|
-
import { getDashboardServerLogPath } from "@blackbelt-technology/pi-dashboard-shared/dashboard-paths.js";
|
|
3
|
-
import { autoStartServer, type AutoStartDeps, type DiscoveredServer } from "../server-auto-start.js";
|
|
4
|
-
|
|
5
|
-
function makeDeps(overrides: Partial<AutoStartDeps> = {}): AutoStartDeps {
|
|
6
|
-
return {
|
|
7
|
-
discoverDashboard: vi.fn().mockResolvedValue([]),
|
|
8
|
-
isDashboardRunning: vi.fn().mockResolvedValue({ running: false }),
|
|
9
|
-
launchServer: vi.fn().mockResolvedValue({ success: true, message: "Server started" }),
|
|
10
|
-
notify: vi.fn(),
|
|
11
|
-
...overrides,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const baseConfig = { piPort: 9999, port: 8000, autoStart: true };
|
|
16
|
-
|
|
17
|
-
describe("autoStartServer", () => {
|
|
18
|
-
it("returns server from mDNS when local server is discovered", async () => {
|
|
19
|
-
const localServer: DiscoveredServer = {
|
|
20
|
-
host: "myhost.local", port: 8000, piPort: 9999,
|
|
21
|
-
isLocal: true, source: "mdns",
|
|
22
|
-
};
|
|
23
|
-
const deps = makeDeps({
|
|
24
|
-
discoverDashboard: vi.fn().mockResolvedValue([localServer]),
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
const result = await autoStartServer(baseConfig, deps);
|
|
28
|
-
|
|
29
|
-
expect(result.server).toEqual({ host: "myhost.local", port: 8000, piPort: 9999 });
|
|
30
|
-
expect(deps.isDashboardRunning).not.toHaveBeenCalled();
|
|
31
|
-
expect(deps.launchServer).not.toHaveBeenCalled();
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("falls back to health check when mDNS finds no local server", async () => {
|
|
35
|
-
const deps = makeDeps({
|
|
36
|
-
discoverDashboard: vi.fn().mockResolvedValue([]),
|
|
37
|
-
isDashboardRunning: vi.fn().mockResolvedValue({ running: true }),
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const result = await autoStartServer(baseConfig, deps);
|
|
41
|
-
|
|
42
|
-
expect(result.server).toEqual({ host: "localhost", port: 8000, piPort: 9999 });
|
|
43
|
-
expect(deps.launchServer).not.toHaveBeenCalled();
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("falls back to health check when mDNS throws", async () => {
|
|
47
|
-
const deps = makeDeps({
|
|
48
|
-
discoverDashboard: vi.fn().mockRejectedValue(new Error("mDNS failed")),
|
|
49
|
-
isDashboardRunning: vi.fn().mockResolvedValue({ running: true }),
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
const result = await autoStartServer(baseConfig, deps);
|
|
53
|
-
|
|
54
|
-
expect(result.server).toEqual({ host: "localhost", port: 8000, piPort: 9999 });
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("auto-starts server and returns config defaults when mDNS fails after launch", async () => {
|
|
58
|
-
const deps = makeDeps({
|
|
59
|
-
discoverDashboard: vi.fn().mockResolvedValue([]),
|
|
60
|
-
isDashboardRunning: vi.fn().mockResolvedValue({ running: false }),
|
|
61
|
-
launchServer: vi.fn().mockResolvedValue({ success: true, message: "ok" }),
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
const result = await autoStartServer(baseConfig, deps);
|
|
65
|
-
|
|
66
|
-
expect(deps.launchServer).toHaveBeenCalled();
|
|
67
|
-
expect(deps.notify).toHaveBeenCalledWith(
|
|
68
|
-
"🌐 Dashboard started at http://localhost:8000",
|
|
69
|
-
"info",
|
|
70
|
-
);
|
|
71
|
-
expect(result.server).toEqual({ host: "localhost", port: 8000, piPort: 9999 });
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("uses mDNS-discovered piPort after auto-start", async () => {
|
|
75
|
-
const localServer: DiscoveredServer = {
|
|
76
|
-
host: "myhost.local", port: 8000, piPort: 9998,
|
|
77
|
-
isLocal: true, source: "mdns",
|
|
78
|
-
};
|
|
79
|
-
const deps = makeDeps({
|
|
80
|
-
discoverDashboard: vi.fn()
|
|
81
|
-
.mockResolvedValueOnce([]) // First call: nothing found
|
|
82
|
-
.mockResolvedValueOnce([localServer]), // After launch: found
|
|
83
|
-
isDashboardRunning: vi.fn().mockResolvedValue({ running: false }),
|
|
84
|
-
launchServer: vi.fn().mockResolvedValue({ success: true, message: "ok" }),
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
const result = await autoStartServer(baseConfig, deps);
|
|
88
|
-
|
|
89
|
-
expect(result.server).toEqual({ host: "myhost.local", port: 8000, piPort: 9998 });
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it("suppresses warning when launch fails but health check succeeds on recheck", async () => {
|
|
93
|
-
const deps = makeDeps({
|
|
94
|
-
discoverDashboard: vi.fn().mockResolvedValue([]),
|
|
95
|
-
isDashboardRunning: vi.fn()
|
|
96
|
-
.mockResolvedValueOnce({ running: false }) // initial check
|
|
97
|
-
.mockResolvedValueOnce({ running: true }), // recheck after failure
|
|
98
|
-
launchServer: vi.fn().mockResolvedValue({ success: false, message: "exited" }),
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
const result = await autoStartServer(baseConfig, deps);
|
|
102
|
-
|
|
103
|
-
expect(deps.notify).not.toHaveBeenCalled();
|
|
104
|
-
expect(result.server).toEqual({ host: "localhost", port: 8000, piPort: 9999 });
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("shows warning when launch fails and recheck also fails", async () => {
|
|
108
|
-
const deps = makeDeps({
|
|
109
|
-
discoverDashboard: vi.fn().mockResolvedValue([]),
|
|
110
|
-
isDashboardRunning: vi.fn().mockResolvedValue({ running: false }),
|
|
111
|
-
launchServer: vi.fn().mockResolvedValue({ success: false, message: "exited" }),
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
const result = await autoStartServer(baseConfig, deps);
|
|
115
|
-
|
|
116
|
-
expect(deps.notify).toHaveBeenCalledTimes(1);
|
|
117
|
-
const [msg, level] = (deps.notify as any).mock.calls[0];
|
|
118
|
-
expect(msg).toMatch(/Dashboard server failed to start: exited/);
|
|
119
|
-
// Spec requirement (fix-windows-server-parity + fix-bridge-server-start-
|
|
120
|
-
// diagnostics): failure notification MUST include the absolute path
|
|
121
|
-
// returned by getDashboardServerLogPath() — the same file the bridge
|
|
122
|
-
// auto-spawn now writes — not a hardcoded string.
|
|
123
|
-
expect(msg).toContain(getDashboardServerLogPath());
|
|
124
|
-
expect(level).toBe("warning");
|
|
125
|
-
expect(result.server).toBeUndefined();
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
// fix-bridge-server-start-diagnostics (CodeRabbit #3): the "See log:" suffix
|
|
129
|
-
// must only appear when the spawn actually owned/opened the log file. A
|
|
130
|
-
// JitiNotFoundError is thrown BEFORE launchDashboardServer opens the logFile
|
|
131
|
-
// fd, so no server.log exists — pointing the user at it resurfaces issue #99.
|
|
132
|
-
// launchServer signals this via logOwned:false.
|
|
133
|
-
it("omits the 'See log' suffix when the failure never owned a log (logOwned:false)", async () => {
|
|
134
|
-
const deps = makeDeps({
|
|
135
|
-
discoverDashboard: vi.fn().mockResolvedValue([]),
|
|
136
|
-
isDashboardRunning: vi.fn().mockResolvedValue({ running: false }),
|
|
137
|
-
launchServer: vi.fn().mockResolvedValue({ success: false, message: "loader missing", logOwned: false }),
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
await autoStartServer(baseConfig, deps);
|
|
141
|
-
|
|
142
|
-
expect(deps.notify).toHaveBeenCalledTimes(1);
|
|
143
|
-
const [msg, level] = (deps.notify as any).mock.calls[0];
|
|
144
|
-
expect(msg).toMatch(/Dashboard server failed to start: loader missing/);
|
|
145
|
-
expect(msg).not.toMatch(/See log/);
|
|
146
|
-
expect(msg).not.toContain(getDashboardServerLogPath());
|
|
147
|
-
expect(level).toBe("warning");
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it("does nothing when autoStart is disabled and no server found", async () => {
|
|
151
|
-
const deps = makeDeps({
|
|
152
|
-
discoverDashboard: vi.fn().mockResolvedValue([]),
|
|
153
|
-
isDashboardRunning: vi.fn().mockResolvedValue({ running: false }),
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
const result = await autoStartServer({ ...baseConfig, autoStart: false }, deps);
|
|
157
|
-
|
|
158
|
-
expect(deps.launchServer).not.toHaveBeenCalled();
|
|
159
|
-
expect(result.server).toBeUndefined();
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it("shows port conflict warning when port is occupied by another service", async () => {
|
|
163
|
-
const deps = makeDeps({
|
|
164
|
-
discoverDashboard: vi.fn().mockResolvedValue([]),
|
|
165
|
-
isDashboardRunning: vi.fn().mockResolvedValue({ running: false, portConflict: true }),
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
const result = await autoStartServer(baseConfig, deps);
|
|
169
|
-
|
|
170
|
-
expect(deps.launchServer).not.toHaveBeenCalled();
|
|
171
|
-
expect(deps.notify).toHaveBeenCalledWith(
|
|
172
|
-
"Port 8000 is occupied by another service",
|
|
173
|
-
"warning",
|
|
174
|
-
);
|
|
175
|
-
expect(result.server).toBeUndefined();
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
it("prefers local server over remote when both discovered via mDNS", async () => {
|
|
179
|
-
const remote: DiscoveredServer = {
|
|
180
|
-
host: "remote.local", port: 8000, piPort: 9999,
|
|
181
|
-
isLocal: false, source: "mdns",
|
|
182
|
-
};
|
|
183
|
-
const local: DiscoveredServer = {
|
|
184
|
-
host: "myhost.local", port: 8000, piPort: 9999,
|
|
185
|
-
isLocal: true, source: "mdns",
|
|
186
|
-
};
|
|
187
|
-
const deps = makeDeps({
|
|
188
|
-
discoverDashboard: vi.fn().mockResolvedValue([remote, local]),
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
const result = await autoStartServer(baseConfig, deps);
|
|
192
|
-
|
|
193
|
-
expect(result.server).toEqual({ host: "myhost.local", port: 8000, piPort: 9999 });
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
// Change: resolve-global-prompt-templates-from-dashboard — bridge-side
|
|
197
|
-
// PI_DASHBOARD_NO_MDNS opt-out (mirrors the server's gate). Required for
|
|
198
|
-
// isolated runs: otherwise the bridge discovers a co-located real dashboard
|
|
199
|
-
// via mDNS and hijacks its connection off the explicit PI_DASHBOARD_URL.
|
|
200
|
-
describe("PI_DASHBOARD_NO_MDNS opt-out", () => {
|
|
201
|
-
afterEach(() => {
|
|
202
|
-
delete process.env.PI_DASHBOARD_NO_MDNS;
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
it("skips mDNS discovery and uses health-check fallback when NO_MDNS=1", async () => {
|
|
206
|
-
process.env.PI_DASHBOARD_NO_MDNS = "1";
|
|
207
|
-
// A local server IS discoverable via mDNS, but the gate must ignore it.
|
|
208
|
-
const otherServer: DiscoveredServer = {
|
|
209
|
-
host: "realhost.local", port: 8000, piPort: 9999,
|
|
210
|
-
isLocal: true, source: "mdns",
|
|
211
|
-
};
|
|
212
|
-
const deps = makeDeps({
|
|
213
|
-
discoverDashboard: vi.fn().mockResolvedValue([otherServer]),
|
|
214
|
-
isDashboardRunning: vi.fn().mockResolvedValue({ running: true }),
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
const result = await autoStartServer({ piPort: 9123, port: 8123, autoStart: true }, deps);
|
|
218
|
-
|
|
219
|
-
// mDNS never consulted; connection stays on the configured iso port.
|
|
220
|
-
expect(deps.discoverDashboard).not.toHaveBeenCalled();
|
|
221
|
-
expect(result.server).toEqual({ host: "localhost", port: 8123, piPort: 9123 });
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
it("with NO_MDNS, after auto-start returns config ports without re-discovering", async () => {
|
|
225
|
-
process.env.PI_DASHBOARD_NO_MDNS = "true";
|
|
226
|
-
const deps = makeDeps({
|
|
227
|
-
discoverDashboard: vi.fn().mockResolvedValue([]),
|
|
228
|
-
isDashboardRunning: vi.fn().mockResolvedValue({ running: false }),
|
|
229
|
-
launchServer: vi.fn().mockResolvedValue({ success: true, message: "ok" }),
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
const result = await autoStartServer({ piPort: 9123, port: 8123, autoStart: true }, deps);
|
|
233
|
-
|
|
234
|
-
expect(deps.launchServer).toHaveBeenCalled();
|
|
235
|
-
expect(deps.discoverDashboard).not.toHaveBeenCalled();
|
|
236
|
-
expect(result.server).toEqual({ host: "localhost", port: 8123, piPort: 9123 });
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
it("skips mDNS when NO_MDNS=yes (server-compatible truthy value)", async () => {
|
|
240
|
-
process.env.PI_DASHBOARD_NO_MDNS = "yes";
|
|
241
|
-
const deps = makeDeps({
|
|
242
|
-
discoverDashboard: vi.fn().mockResolvedValue([]),
|
|
243
|
-
isDashboardRunning: vi.fn().mockResolvedValue({ running: true }),
|
|
244
|
-
});
|
|
245
|
-
const result = await autoStartServer({ piPort: 9123, port: 8123, autoStart: true }, deps);
|
|
246
|
-
expect(deps.discoverDashboard).not.toHaveBeenCalled();
|
|
247
|
-
expect(result.server).toEqual({ host: "localhost", port: 8123, piPort: 9123 });
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
it("normalizes NO_MDNS values via trim + lowercase (' TRUE ')", async () => {
|
|
251
|
-
process.env.PI_DASHBOARD_NO_MDNS = " TRUE ";
|
|
252
|
-
const deps = makeDeps({
|
|
253
|
-
discoverDashboard: vi.fn().mockResolvedValue([]),
|
|
254
|
-
isDashboardRunning: vi.fn().mockResolvedValue({ running: true }),
|
|
255
|
-
});
|
|
256
|
-
await autoStartServer({ piPort: 9123, port: 8123, autoStart: true }, deps);
|
|
257
|
-
expect(deps.discoverDashboard).not.toHaveBeenCalled();
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
it("treats an unrelated NO_MDNS value as NOT disabled (mDNS still runs)", async () => {
|
|
261
|
-
process.env.PI_DASHBOARD_NO_MDNS = "0";
|
|
262
|
-
const local: DiscoveredServer = {
|
|
263
|
-
host: "myhost.local", port: 8000, piPort: 9999,
|
|
264
|
-
isLocal: true, source: "mdns",
|
|
265
|
-
};
|
|
266
|
-
const deps = makeDeps({ discoverDashboard: vi.fn().mockResolvedValue([local]) });
|
|
267
|
-
const result = await autoStartServer(baseConfig, deps);
|
|
268
|
-
expect(deps.discoverDashboard).toHaveBeenCalled();
|
|
269
|
-
expect(result.server).toEqual({ host: "myhost.local", port: 8000, piPort: 9999 });
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
it("still uses mDNS when NO_MDNS is unset (default behavior preserved)", async () => {
|
|
273
|
-
const local: DiscoveredServer = {
|
|
274
|
-
host: "myhost.local", port: 8000, piPort: 9999,
|
|
275
|
-
isLocal: true, source: "mdns",
|
|
276
|
-
};
|
|
277
|
-
const deps = makeDeps({
|
|
278
|
-
discoverDashboard: vi.fn().mockResolvedValue([local]),
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
const result = await autoStartServer(baseConfig, deps);
|
|
282
|
-
|
|
283
|
-
expect(deps.discoverDashboard).toHaveBeenCalled();
|
|
284
|
-
expect(result.server).toEqual({ host: "myhost.local", port: 8000, piPort: 9999 });
|
|
285
|
-
});
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
describe("onLaunchStart / onLaunchEnd callbacks", () => {
|
|
289
|
-
it("fires onLaunchStart then onLaunchEnd(true) when launch succeeds", async () => {
|
|
290
|
-
const onLaunchStart = vi.fn();
|
|
291
|
-
const onLaunchEnd = vi.fn();
|
|
292
|
-
const deps = makeDeps({
|
|
293
|
-
launchServer: vi.fn().mockResolvedValue({ success: true, message: "ok" }),
|
|
294
|
-
onLaunchStart,
|
|
295
|
-
onLaunchEnd,
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
await autoStartServer(baseConfig, deps);
|
|
299
|
-
|
|
300
|
-
expect(onLaunchStart).toHaveBeenCalledTimes(1);
|
|
301
|
-
expect(onLaunchEnd).toHaveBeenCalledTimes(1);
|
|
302
|
-
expect(onLaunchEnd).toHaveBeenCalledWith(true);
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
it("fires onLaunchStart then onLaunchEnd(false) when launch fails", async () => {
|
|
306
|
-
const onLaunchStart = vi.fn();
|
|
307
|
-
const onLaunchEnd = vi.fn();
|
|
308
|
-
const deps = makeDeps({
|
|
309
|
-
launchServer: vi.fn().mockResolvedValue({ success: false, message: "boom" }),
|
|
310
|
-
isDashboardRunning: vi.fn().mockResolvedValue({ running: false }),
|
|
311
|
-
onLaunchStart,
|
|
312
|
-
onLaunchEnd,
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
await autoStartServer(baseConfig, deps);
|
|
316
|
-
|
|
317
|
-
expect(onLaunchStart).toHaveBeenCalledTimes(1);
|
|
318
|
-
expect(onLaunchEnd).toHaveBeenCalledTimes(1);
|
|
319
|
-
expect(onLaunchEnd).toHaveBeenCalledWith(false);
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
it("fires onLaunchEnd(true) when launch fails but recheck finds running server", async () => {
|
|
323
|
-
// Race scenario: another agent started the server during our launch attempt.
|
|
324
|
-
const onLaunchStart = vi.fn();
|
|
325
|
-
const onLaunchEnd = vi.fn();
|
|
326
|
-
const deps = makeDeps({
|
|
327
|
-
launchServer: vi.fn().mockResolvedValue({ success: false, message: "EADDRINUSE" }),
|
|
328
|
-
isDashboardRunning: vi.fn()
|
|
329
|
-
.mockResolvedValueOnce({ running: false }) // before launch
|
|
330
|
-
.mockResolvedValueOnce({ running: true }), // after launch (recheck)
|
|
331
|
-
onLaunchStart,
|
|
332
|
-
onLaunchEnd,
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
await autoStartServer(baseConfig, deps);
|
|
336
|
-
|
|
337
|
-
expect(onLaunchStart).toHaveBeenCalledTimes(1);
|
|
338
|
-
expect(onLaunchEnd).toHaveBeenCalledWith(true);
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
it("does NOT fire onLaunchStart when mDNS finds a local server (no launch happens)", async () => {
|
|
342
|
-
const onLaunchStart = vi.fn();
|
|
343
|
-
const onLaunchEnd = vi.fn();
|
|
344
|
-
const local: DiscoveredServer = {
|
|
345
|
-
host: "localhost", port: 8000, piPort: 9999,
|
|
346
|
-
isLocal: true, source: "mdns",
|
|
347
|
-
};
|
|
348
|
-
const deps = makeDeps({
|
|
349
|
-
discoverDashboard: vi.fn().mockResolvedValue([local]),
|
|
350
|
-
onLaunchStart,
|
|
351
|
-
onLaunchEnd,
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
await autoStartServer(baseConfig, deps);
|
|
355
|
-
|
|
356
|
-
expect(onLaunchStart).not.toHaveBeenCalled();
|
|
357
|
-
expect(onLaunchEnd).not.toHaveBeenCalled();
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
it("does NOT fire onLaunchStart when health check finds an already-running server", async () => {
|
|
361
|
-
const onLaunchStart = vi.fn();
|
|
362
|
-
const onLaunchEnd = vi.fn();
|
|
363
|
-
const deps = makeDeps({
|
|
364
|
-
isDashboardRunning: vi.fn().mockResolvedValue({ running: true }),
|
|
365
|
-
onLaunchStart,
|
|
366
|
-
onLaunchEnd,
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
await autoStartServer(baseConfig, deps);
|
|
370
|
-
|
|
371
|
-
expect(onLaunchStart).not.toHaveBeenCalled();
|
|
372
|
-
expect(onLaunchEnd).not.toHaveBeenCalled();
|
|
373
|
-
});
|
|
374
|
-
});
|
|
375
|
-
});
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pins the Bridge → `launchDashboardServer` forwarding contract: the
|
|
3
|
-
* extension's `launchServer` must always pass `starter: "Bridge"`,
|
|
4
|
-
* `stdio: { logFile: getDashboardServerLogPath() }`, and
|
|
5
|
-
* `healthTimeoutMs: 10_000`. The shared launcher is mocked so this test
|
|
6
|
-
* never spawns a real server.
|
|
7
|
-
*
|
|
8
|
-
* See change: unify-server-launch-ts-loader (§3.1.2),
|
|
9
|
-
* fix-bridge-server-start-diagnostics (bridge now owns the server log
|
|
10
|
-
* and uses a 10 s cold-start window).
|
|
11
|
-
*/
|
|
12
|
-
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
13
|
-
import type { launchDashboardServer } from "@blackbelt-technology/pi-dashboard-shared/server-launcher.js";
|
|
14
|
-
import { getDashboardServerLogPath } from "@blackbelt-technology/pi-dashboard-shared/dashboard-paths.js";
|
|
15
|
-
|
|
16
|
-
const { launchSpy } = vi.hoisted(() => ({
|
|
17
|
-
launchSpy: vi.fn<typeof launchDashboardServer>(async () => ({ childPid: 1, reportedPid: 1, healthOk: true as const })),
|
|
18
|
-
}));
|
|
19
|
-
|
|
20
|
-
vi.mock("@blackbelt-technology/pi-dashboard-shared/server-launcher.js", () => ({
|
|
21
|
-
launchDashboardServer: launchSpy,
|
|
22
|
-
JitiNotFoundError: class JitiNotFoundError extends Error {},
|
|
23
|
-
PortConflictError: class PortConflictError extends Error {},
|
|
24
|
-
EarlyExitError: class EarlyExitError extends Error { code: number | null = null; },
|
|
25
|
-
}));
|
|
26
|
-
|
|
27
|
-
import { launchServer } from "../server-launcher.js";
|
|
28
|
-
|
|
29
|
-
const cfg = {
|
|
30
|
-
port: 3000,
|
|
31
|
-
piPort: 4000,
|
|
32
|
-
autoStart: true,
|
|
33
|
-
autoShutdown: true,
|
|
34
|
-
shutdownIdleSeconds: 300,
|
|
35
|
-
spawnStrategy: "tmux" as const,
|
|
36
|
-
tunnel: { enabled: true },
|
|
37
|
-
devBuildOnReload: false,
|
|
38
|
-
memoryLimits: { maxEventsPerSession: 5000, maxStringFieldSize: 0, maxWsBufferBytes: 4194304 },
|
|
39
|
-
editor: { idleTimeoutMinutes: 10, maxInstances: 3 },
|
|
40
|
-
defaultModel: "",
|
|
41
|
-
trustedNetworks: [],
|
|
42
|
-
resolvedTrustedNetworks: [],
|
|
43
|
-
cors: { allowedOrigins: [] },
|
|
44
|
-
electronMode: false,
|
|
45
|
-
} as any;
|
|
46
|
-
|
|
47
|
-
beforeEach(() => {
|
|
48
|
-
launchSpy.mockClear();
|
|
49
|
-
launchSpy.mockResolvedValue({ childPid: 1, reportedPid: 1, healthOk: true } as any);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
describe("Bridge launchServer → launchDashboardServer forwarding", () => {
|
|
53
|
-
it("passes starter:Bridge + stdio:{logFile} + 10s health timeout + port", async () => {
|
|
54
|
-
const r = await launchServer(cfg);
|
|
55
|
-
expect(r.success).toBe(true);
|
|
56
|
-
expect(launchSpy).toHaveBeenCalledOnce();
|
|
57
|
-
const opts = launchSpy.mock.calls[0]![0]!;
|
|
58
|
-
expect(opts.starter).toBe("Bridge");
|
|
59
|
-
expect(opts.stdio).toEqual({ logFile: getDashboardServerLogPath() });
|
|
60
|
-
expect(opts.healthTimeoutMs).toBe(10000);
|
|
61
|
-
expect(opts.port).toBe(3000);
|
|
62
|
-
expect(opts.extraArgs).toEqual(["--port", "3000", "--pi-port", "4000"]);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("maps JitiNotFoundError to a failed LaunchResult (no throw)", async () => {
|
|
66
|
-
const { JitiNotFoundError } = await import("@blackbelt-technology/pi-dashboard-shared/server-launcher.js");
|
|
67
|
-
launchSpy.mockRejectedValueOnce(new JitiNotFoundError("loader missing"));
|
|
68
|
-
const r = await launchServer(cfg);
|
|
69
|
-
expect(r.success).toBe(false);
|
|
70
|
-
expect(r.message).toContain("loader missing");
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("maps EarlyExitError to a failed LaunchResult mentioning the exit code", async () => {
|
|
74
|
-
const { EarlyExitError } = await import("@blackbelt-technology/pi-dashboard-shared/server-launcher.js");
|
|
75
|
-
const err = new (EarlyExitError as unknown as new (...args: unknown[]) => Error & { code: number })();
|
|
76
|
-
err.code = 17;
|
|
77
|
-
launchSpy.mockRejectedValueOnce(err);
|
|
78
|
-
const r = await launchServer(cfg);
|
|
79
|
-
expect(r.success).toBe(false);
|
|
80
|
-
expect(r.message).toMatch(/code=17/);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
// fix-bridge-server-start-diagnostics: the EarlyExitError copy must point
|
|
84
|
-
// at the path the bridge spawn actually writes (getDashboardServerLogPath),
|
|
85
|
-
// not a hardcoded "~/.pi/dashboard/server.log" string.
|
|
86
|
-
it("EarlyExitError message references getDashboardServerLogPath(), not a hardcoded path", async () => {
|
|
87
|
-
const { EarlyExitError } = await import("@blackbelt-technology/pi-dashboard-shared/server-launcher.js");
|
|
88
|
-
const err = new (EarlyExitError as unknown as new (...args: unknown[]) => Error & { code: number })();
|
|
89
|
-
err.code = 1;
|
|
90
|
-
launchSpy.mockRejectedValueOnce(err);
|
|
91
|
-
const r = await launchServer(cfg);
|
|
92
|
-
expect(r.success).toBe(false);
|
|
93
|
-
expect(r.message).toContain(getDashboardServerLogPath());
|
|
94
|
-
expect(r.message).not.toContain("~/.pi/dashboard/server.log");
|
|
95
|
-
});
|
|
96
|
-
});
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { describe, expect, it } from "vitest";
|
|
4
|
-
import { buildSpawnArgs, buildSpawnEnv, resolveServerCliPath } from "../server-launcher.js";
|
|
5
|
-
|
|
6
|
-
describe("server-launcher", () => {
|
|
7
|
-
describe("resolveServerCliPath", () => {
|
|
8
|
-
it("should return an absolute path", () => {
|
|
9
|
-
expect(path.isAbsolute(resolveServerCliPath())).toBe(true);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it("should point to packages/server/src/cli.ts", () => {
|
|
13
|
-
const cliPath = resolveServerCliPath();
|
|
14
|
-
expect(cliPath).toContain(path.join("packages", "server", "src", "cli.ts"));
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("should point to a file that actually exists on disk", () => {
|
|
18
|
-
expect(existsSync(resolveServerCliPath())).toBe(true);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("uses require.resolve so it adapts to installed layout", () => {
|
|
22
|
-
// Regression: the monorepo-relative path math
|
|
23
|
-
// (`<extension>/../../server/src/cli.ts`) produced
|
|
24
|
-
// `<scope>/server/src/cli.ts` instead of
|
|
25
|
-
// `<scope>/pi-dashboard-server/src/cli.ts` when the extension
|
|
26
|
-
// was installed into `node_modules/@blackbelt-technology/`. The
|
|
27
|
-
// resolver must locate the server via package name, not sibling
|
|
28
|
-
// path arithmetic.
|
|
29
|
-
const cliPath = resolveServerCliPath();
|
|
30
|
-
// Either layout is fine; we just must NOT produce the broken
|
|
31
|
-
// `@blackbelt-technology/server/src/cli.ts` shape.
|
|
32
|
-
expect(cliPath).not.toMatch(/@blackbelt-technology[\\/]+server[\\/]+src[\\/]+cli\.ts$/);
|
|
33
|
-
// And must land on pi-dashboard-server (installed) or packages/server (dev).
|
|
34
|
-
expect(cliPath).toMatch(/(pi-dashboard-server|packages[\\/]+server)[\\/]+src[\\/]+cli\.ts$/);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe("buildSpawnArgs", () => {
|
|
39
|
-
it("should include port and pi-port flags", () => {
|
|
40
|
-
const args = buildSpawnArgs({
|
|
41
|
-
port: 3000,
|
|
42
|
-
piPort: 4000,
|
|
43
|
-
autoStart: true,
|
|
44
|
-
autoShutdown: true,
|
|
45
|
-
shutdownIdleSeconds: 300,
|
|
46
|
-
spawnStrategy: "tmux",
|
|
47
|
-
tunnel: { enabled: true },
|
|
48
|
-
devBuildOnReload: false,
|
|
49
|
-
memoryLimits: { maxEventsPerSession: 5000, maxStringFieldSize: 0, maxWsBufferBytes: 4194304 },
|
|
50
|
-
editor: { idleTimeoutMinutes: 10, maxInstances: 3 },
|
|
51
|
-
defaultModel: "",
|
|
52
|
-
trustedNetworks: [],
|
|
53
|
-
resolvedTrustedNetworks: [],
|
|
54
|
-
cors: { allowedOrigins: [] },
|
|
55
|
-
electronMode: false,
|
|
56
|
-
} as any);
|
|
57
|
-
|
|
58
|
-
expect(args).toEqual(["--port", "3000", "--pi-port", "4000"]);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
describe("buildSpawnEnv", () => {
|
|
63
|
-
it("always includes DASHBOARD_STARTER=Bridge", () => {
|
|
64
|
-
const env = buildSpawnEnv({});
|
|
65
|
-
expect(env["DASHBOARD_STARTER"]).toBe("Bridge");
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it("overrides any existing DASHBOARD_STARTER in baseEnv", () => {
|
|
69
|
-
const env = buildSpawnEnv({ DASHBOARD_STARTER: "Standalone" });
|
|
70
|
-
expect(env["DASHBOARD_STARTER"]).toBe("Bridge");
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("preserves other env vars from baseEnv", () => {
|
|
74
|
-
const env = buildSpawnEnv({ MY_VAR: "hello" });
|
|
75
|
-
expect(env["MY_VAR"]).toBe("hello");
|
|
76
|
-
expect(env["DASHBOARD_STARTER"]).toBe("Bridge");
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it("filters out undefined values from baseEnv", () => {
|
|
80
|
-
const env = buildSpawnEnv({ DEFINED: "yes", UNDEF: undefined });
|
|
81
|
-
expect(Object.keys(env)).not.toContain("UNDEF");
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("adds --max-old-space-size to NODE_OPTIONS by default", () => {
|
|
85
|
-
const env = buildSpawnEnv({});
|
|
86
|
-
expect(env["NODE_OPTIONS"]).toContain("--max-old-space-size=8192");
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it("appends the flag to an existing NODE_OPTIONS without a heap limit", () => {
|
|
90
|
-
const env = buildSpawnEnv({ NODE_OPTIONS: "--enable-source-maps" });
|
|
91
|
-
expect(env["NODE_OPTIONS"]).toBe(
|
|
92
|
-
"--enable-source-maps --max-old-space-size=8192",
|
|
93
|
-
);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it("never overrides a user-supplied --max-old-space-size", () => {
|
|
97
|
-
const env = buildSpawnEnv({ NODE_OPTIONS: "--max-old-space-size=2048" });
|
|
98
|
-
expect(env["NODE_OPTIONS"]).toBe("--max-old-space-size=2048");
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { isPortOpen } from "../server-probe.js";
|
|
3
|
-
import net from "node:net";
|
|
4
|
-
|
|
5
|
-
describe("isPortOpen", () => {
|
|
6
|
-
it("should return true when a server is listening", async () => {
|
|
7
|
-
// Start a temporary server
|
|
8
|
-
const server = net.createServer();
|
|
9
|
-
await new Promise<void>((resolve) => server.listen(0, resolve));
|
|
10
|
-
const port = (server.address() as net.AddressInfo).port;
|
|
11
|
-
|
|
12
|
-
try {
|
|
13
|
-
const result = await isPortOpen(port);
|
|
14
|
-
expect(result).toBe(true);
|
|
15
|
-
} finally {
|
|
16
|
-
server.close();
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("should return false when no server is listening", async () => {
|
|
21
|
-
// Use a port that's almost certainly not in use
|
|
22
|
-
const result = await isPortOpen(59321);
|
|
23
|
-
expect(result).toBe(false);
|
|
24
|
-
});
|
|
25
|
-
});
|