@wonderwhy-er/desktop-commander 0.2.45 → 0.2.46
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/dist/config-manager.js +11 -1
- package/dist/server.js +13 -7
- package/dist/tools/fuzzySearchAlgorithm.d.ts +34 -0
- package/dist/tools/fuzzySearchAlgorithm.js +85 -0
- package/dist/utils/default-editor.d.ts +4 -0
- package/dist/utils/default-editor.js +36 -0
- package/dist/utils/install-source.d.ts +15 -0
- package/dist/utils/install-source.js +23 -0
- package/dist/utils/posthog.d.ts +17 -0
- package/dist/utils/posthog.js +94 -0
- package/dist/utils/welcome-onboarding.d.ts +2 -0
- package/dist/utils/welcome-onboarding.js +36 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/config-manager.js
CHANGED
|
@@ -56,6 +56,15 @@ class ConfigManager {
|
|
|
56
56
|
const configData = await fs.readFile(this.configPath, 'utf8');
|
|
57
57
|
this.config = JSON.parse(configData);
|
|
58
58
|
this._isFirstRun = false;
|
|
59
|
+
// Configs created before this marker existed must not receive the
|
|
60
|
+
// welcome page retroactively when client eligibility changes later.
|
|
61
|
+
// New configs get this field from getDefaultConfig() and remain
|
|
62
|
+
// eligible across restarts until their first initialization.
|
|
63
|
+
if (this.config['welcomeOnboardingEligible'] === undefined) {
|
|
64
|
+
this.config['welcomeOnboardingEligible'] = false;
|
|
65
|
+
this.config['pendingWelcomeOnboarding'] = false;
|
|
66
|
+
await this.saveConfig();
|
|
67
|
+
}
|
|
59
68
|
}
|
|
60
69
|
catch (error) {
|
|
61
70
|
// Config file doesn't exist, create default
|
|
@@ -140,7 +149,8 @@ class ConfigManager {
|
|
|
140
149
|
telemetryEnabled: true, // Default to opt-out approach (telemetry on by default)
|
|
141
150
|
fileWriteLineLimit: 50, // Default line limit for file write operations (changed from 100)
|
|
142
151
|
fileReadLineLimit: 1000, // Default line limit for file read operations (changed from character-based)
|
|
143
|
-
pendingWelcomeOnboarding: true // New install flag - triggers A/B test for welcome page
|
|
152
|
+
pendingWelcomeOnboarding: true, // New install flag - triggers A/B test for welcome page
|
|
153
|
+
welcomeOnboardingEligible: true // Distinguishes new installs from migrated legacy configs
|
|
144
154
|
};
|
|
145
155
|
}
|
|
146
156
|
/**
|
package/dist/server.js
CHANGED
|
@@ -19,7 +19,7 @@ import { trackToolCall } from './utils/trackTools.js';
|
|
|
19
19
|
import { usageTracker } from './utils/usageTracker.js';
|
|
20
20
|
import { processDockerPrompt } from './utils/dockerPrompt.js';
|
|
21
21
|
import { toolHistory } from './utils/toolHistory.js';
|
|
22
|
-
import { handleWelcomePageOnboarding } from './utils/welcome-onboarding.js';
|
|
22
|
+
import { handleWelcomePageOnboarding, skipWelcomePageOnboarding } from './utils/welcome-onboarding.js';
|
|
23
23
|
import { VERSION } from './version.js';
|
|
24
24
|
import { capture, capture_call_tool, runInUiOriginCallContext } from "./utils/capture.js";
|
|
25
25
|
import { logToStderr, logger } from './utils/logger.js';
|
|
@@ -139,16 +139,22 @@ server.setRequestHandler(InitializeRequestSchema, async (request) => {
|
|
|
139
139
|
if (clientInfo) {
|
|
140
140
|
await updateCurrentClient(clientInfo);
|
|
141
141
|
// Welcome page for new users (A/B test controlled) — all clients except
|
|
142
|
-
// the Desktop Commander app
|
|
143
|
-
//
|
|
144
|
-
//
|
|
145
|
-
|
|
142
|
+
// the Desktop Commander app and remote contexts. Further exclusions are
|
|
143
|
+
// flag-served via welcome_page_excluded_clients (e.g. claude-code, which
|
|
144
|
+
// covers Claude Code and Cowork plugin sessions — both identify as
|
|
145
|
+
// `claude-code` and provide their own onboarding surface).
|
|
146
|
+
const isWelcomePageEligibleClient = currentClient.name !== 'desktop-commander-app'
|
|
146
147
|
&& currentClient.name !== 'desktop-commander'
|
|
147
148
|
&& !isRemoteClientContext(currentClient.name)
|
|
148
|
-
&&
|
|
149
|
-
|
|
149
|
+
&& !global.disableOnboarding;
|
|
150
|
+
if (isWelcomePageEligibleClient) {
|
|
150
151
|
await handleWelcomePageOnboarding(currentClient.name);
|
|
151
152
|
}
|
|
153
|
+
else {
|
|
154
|
+
// Do not carry a first-run page over to a client that is made
|
|
155
|
+
// eligible in a later release.
|
|
156
|
+
await skipWelcomePageOnboarding();
|
|
157
|
+
}
|
|
152
158
|
}
|
|
153
159
|
// Raw host environment signals (no PII, undefined when absent). Some
|
|
154
160
|
// hosts share a clientInfo name — Claude Code CLI, Claude Code inside
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure fuzzy-search algorithm, shared by the main thread (fuzzySearch.ts)
|
|
3
|
+
* and the worker thread (fuzzySearchWorker.ts). This is the single source
|
|
4
|
+
* of truth for the algorithm — do not fork it.
|
|
5
|
+
*
|
|
6
|
+
* Must stay side-effect free with no imports beyond fastest-levenshtein:
|
|
7
|
+
* telemetry lives in the caller (metrics are returned, not captured here),
|
|
8
|
+
* and a small module graph keeps worker spawn cheap.
|
|
9
|
+
*/
|
|
10
|
+
export interface FuzzyMatch {
|
|
11
|
+
start: number;
|
|
12
|
+
end: number;
|
|
13
|
+
value: string;
|
|
14
|
+
distance: number;
|
|
15
|
+
}
|
|
16
|
+
export interface FuzzySearchMetrics {
|
|
17
|
+
/** Total wall time of the search in ms */
|
|
18
|
+
executionTimeMs: number;
|
|
19
|
+
/** Wall time of the final iterative refinement phase in ms */
|
|
20
|
+
iterativeTimeMs: number;
|
|
21
|
+
/** Iterations spent in the iterative refinement phase */
|
|
22
|
+
iterations: number;
|
|
23
|
+
/** Length of the segment handed to iterative refinement */
|
|
24
|
+
segmentLength: number;
|
|
25
|
+
}
|
|
26
|
+
export interface FuzzySearchResult {
|
|
27
|
+
match: FuzzyMatch;
|
|
28
|
+
metrics: FuzzySearchMetrics;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Finds the closest match to a query string within text using fuzzy matching.
|
|
32
|
+
* Returns the match plus timing/iteration metrics for the caller to report.
|
|
33
|
+
*/
|
|
34
|
+
export declare function fuzzyIndexOf(text: string, query: string): FuzzySearchResult;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure fuzzy-search algorithm, shared by the main thread (fuzzySearch.ts)
|
|
3
|
+
* and the worker thread (fuzzySearchWorker.ts). This is the single source
|
|
4
|
+
* of truth for the algorithm — do not fork it.
|
|
5
|
+
*
|
|
6
|
+
* Must stay side-effect free with no imports beyond fastest-levenshtein:
|
|
7
|
+
* telemetry lives in the caller (metrics are returned, not captured here),
|
|
8
|
+
* and a small module graph keeps worker spawn cheap.
|
|
9
|
+
*/
|
|
10
|
+
import { distance } from 'fastest-levenshtein';
|
|
11
|
+
/**
|
|
12
|
+
* Finds the closest match to a query string within text using fuzzy matching.
|
|
13
|
+
* Returns the match plus timing/iteration metrics for the caller to report.
|
|
14
|
+
*/
|
|
15
|
+
export function fuzzyIndexOf(text, query) {
|
|
16
|
+
const startTime = performance.now();
|
|
17
|
+
const metrics = { iterativeTimeMs: 0, iterations: 0, segmentLength: 0 };
|
|
18
|
+
const match = recursiveFuzzyIndexOf(text, query, 0, text.length, Infinity, metrics);
|
|
19
|
+
return {
|
|
20
|
+
match,
|
|
21
|
+
metrics: { ...metrics, executionTimeMs: performance.now() - startTime }
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Recursively narrows the search to the half of the text with the better
|
|
26
|
+
* Levenshtein distance, falling back to iterative refinement when the
|
|
27
|
+
* segment is small or no longer improving.
|
|
28
|
+
*/
|
|
29
|
+
function recursiveFuzzyIndexOf(text, query, start, end, parentDistance, metrics) {
|
|
30
|
+
// For small text segments, use iterative approach
|
|
31
|
+
if (end - start <= 2 * query.length) {
|
|
32
|
+
return iterativeReduction(text, query, start, end, parentDistance, metrics);
|
|
33
|
+
}
|
|
34
|
+
let midPoint = start + Math.floor((end - start) / 2);
|
|
35
|
+
let leftEnd = Math.min(end, midPoint + query.length); // Include query length to cover overlaps
|
|
36
|
+
let rightStart = Math.max(start, midPoint - query.length); // Include query length to cover overlaps
|
|
37
|
+
let leftDistance = distance(text.substring(start, leftEnd), query);
|
|
38
|
+
let rightDistance = distance(text.substring(rightStart, end), query);
|
|
39
|
+
let bestDistance = Math.min(leftDistance, parentDistance, rightDistance);
|
|
40
|
+
// If parent distance is already the best, use iterative approach
|
|
41
|
+
if (parentDistance === bestDistance) {
|
|
42
|
+
return iterativeReduction(text, query, start, end, parentDistance, metrics);
|
|
43
|
+
}
|
|
44
|
+
// Recursively search the better half
|
|
45
|
+
if (leftDistance < rightDistance) {
|
|
46
|
+
return recursiveFuzzyIndexOf(text, query, start, leftEnd, bestDistance, metrics);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return recursiveFuzzyIndexOf(text, query, rightStart, end, bestDistance, metrics);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Iteratively refines the best match by shrinking the segment from both ends
|
|
54
|
+
* while the Levenshtein distance keeps improving.
|
|
55
|
+
*/
|
|
56
|
+
function iterativeReduction(text, query, start, end, parentDistance, metrics) {
|
|
57
|
+
const startTime = performance.now();
|
|
58
|
+
let bestDistance = parentDistance;
|
|
59
|
+
let bestStart = start;
|
|
60
|
+
let bestEnd = end;
|
|
61
|
+
// Improve start position
|
|
62
|
+
let nextDistance = distance(text.substring(bestStart + 1, bestEnd), query);
|
|
63
|
+
while (nextDistance < bestDistance) {
|
|
64
|
+
bestDistance = nextDistance;
|
|
65
|
+
bestStart++;
|
|
66
|
+
nextDistance = distance(text.substring(bestStart + 1, bestEnd), query);
|
|
67
|
+
metrics.iterations++;
|
|
68
|
+
}
|
|
69
|
+
// Improve end position
|
|
70
|
+
nextDistance = distance(text.substring(bestStart, bestEnd - 1), query);
|
|
71
|
+
while (nextDistance < bestDistance) {
|
|
72
|
+
bestDistance = nextDistance;
|
|
73
|
+
bestEnd--;
|
|
74
|
+
nextDistance = distance(text.substring(bestStart, bestEnd - 1), query);
|
|
75
|
+
metrics.iterations++;
|
|
76
|
+
}
|
|
77
|
+
metrics.iterativeTimeMs = performance.now() - startTime;
|
|
78
|
+
metrics.segmentLength = end - start;
|
|
79
|
+
return {
|
|
80
|
+
start: bestStart,
|
|
81
|
+
end: bestEnd,
|
|
82
|
+
value: text.substring(bestStart, bestEnd),
|
|
83
|
+
distance: bestDistance
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { execFile } from 'child_process';
|
|
2
|
+
import os from 'os';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { promisify } from 'util';
|
|
5
|
+
const execFileAsync = promisify(execFile);
|
|
6
|
+
const defaultEditorCache = new Map();
|
|
7
|
+
function escapeAppleScriptString(value) {
|
|
8
|
+
return value.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
9
|
+
}
|
|
10
|
+
export async function getDefaultEditorMetadata(filePath) {
|
|
11
|
+
if (os.platform() !== 'darwin') {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
const extension = path.extname(filePath).toLowerCase();
|
|
15
|
+
const cacheKey = extension || path.basename(filePath).toLowerCase();
|
|
16
|
+
const cached = defaultEditorCache.get(cacheKey);
|
|
17
|
+
if (cached) {
|
|
18
|
+
return cached;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const script = `set appAlias to default application of (info for POSIX file "${escapeAppleScriptString(filePath)}")\nreturn (name of (info for appAlias)) & linefeed & POSIX path of appAlias`;
|
|
22
|
+
const { stdout } = await execFileAsync('osascript', ['-e', script], { timeout: 12000 });
|
|
23
|
+
const lines = stdout.split('\n').map((line) => line.trim()).filter(Boolean);
|
|
24
|
+
const defaultEditorName = lines[lines.length - 2]?.replace(/\.app$/i, '') ?? '';
|
|
25
|
+
const defaultEditorPath = lines[lines.length - 1] ?? '';
|
|
26
|
+
if (defaultEditorName && defaultEditorPath.startsWith('/')) {
|
|
27
|
+
const metadata = { defaultEditorName, defaultEditorPath };
|
|
28
|
+
defaultEditorCache.set(cacheKey, metadata);
|
|
29
|
+
return metadata;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// Generic UI fallback is good enough if detection fails.
|
|
34
|
+
}
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detect how this server instance was installed/launched, beyond what the
|
|
3
|
+
* MCP client reports in clientInfo. A plugin is not a separate MCP client —
|
|
4
|
+
* the host connects under its own name (e.g. the Claude Code plugin still
|
|
5
|
+
* reports 'claude-code'), so the environment is the only place this signal
|
|
6
|
+
* exists.
|
|
7
|
+
*
|
|
8
|
+
* Checked in priority order:
|
|
9
|
+
* 1. DC_INSTALL_SOURCE — explicit marker set by our own packaging
|
|
10
|
+
* (e.g. the Claude Code plugin manifest, or future Cowork/host configs).
|
|
11
|
+
* 2. CLAUDE_PLUGIN_ROOT / CLAUDE_PLUGIN_DATA — set by Claude Code itself
|
|
12
|
+
* when it spawns a plugin's MCP server, so this also covers plugin
|
|
13
|
+
* versions installed before the explicit marker existed.
|
|
14
|
+
*/
|
|
15
|
+
export declare function detectInstallSource(): string | undefined;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detect how this server instance was installed/launched, beyond what the
|
|
3
|
+
* MCP client reports in clientInfo. A plugin is not a separate MCP client —
|
|
4
|
+
* the host connects under its own name (e.g. the Claude Code plugin still
|
|
5
|
+
* reports 'claude-code'), so the environment is the only place this signal
|
|
6
|
+
* exists.
|
|
7
|
+
*
|
|
8
|
+
* Checked in priority order:
|
|
9
|
+
* 1. DC_INSTALL_SOURCE — explicit marker set by our own packaging
|
|
10
|
+
* (e.g. the Claude Code plugin manifest, or future Cowork/host configs).
|
|
11
|
+
* 2. CLAUDE_PLUGIN_ROOT / CLAUDE_PLUGIN_DATA — set by Claude Code itself
|
|
12
|
+
* when it spawns a plugin's MCP server, so this also covers plugin
|
|
13
|
+
* versions installed before the explicit marker existed.
|
|
14
|
+
*/
|
|
15
|
+
export function detectInstallSource() {
|
|
16
|
+
if (process.env.DC_INSTALL_SOURCE) {
|
|
17
|
+
return process.env.DC_INSTALL_SOURCE;
|
|
18
|
+
}
|
|
19
|
+
if (process.env.CLAUDE_PLUGIN_ROOT || process.env.CLAUDE_PLUGIN_DATA) {
|
|
20
|
+
return 'claude-code-plugin';
|
|
21
|
+
}
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture a PostHog event. Silently no-ops if POSTHOG_API_KEY is not set
|
|
3
|
+
* or if telemetry has been disabled by the user.
|
|
4
|
+
*/
|
|
5
|
+
export declare function capturePostHog(distinctId: string, event: string, properties?: Record<string, any>): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Identify a user by their distinct ID and set person properties.
|
|
8
|
+
*/
|
|
9
|
+
export declare function identifyPostHog(distinctId: string, properties?: Record<string, any>): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Capture an exception via PostHog error tracking.
|
|
12
|
+
*/
|
|
13
|
+
export declare function captureExceptionPostHog(error: unknown, distinctId?: string, additionalProperties?: Record<string, any>): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Flush all pending PostHog events. Call before process exit.
|
|
16
|
+
*/
|
|
17
|
+
export declare function shutdownPostHog(): Promise<void>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { PostHog } from 'posthog-node';
|
|
2
|
+
import { platform } from 'os';
|
|
3
|
+
let _client = null;
|
|
4
|
+
function getClient() {
|
|
5
|
+
if (!_client) {
|
|
6
|
+
_client = new PostHog(process.env.POSTHOG_API_KEY ?? '', {
|
|
7
|
+
host: process.env.POSTHOG_HOST,
|
|
8
|
+
enableExceptionAutocapture: true,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
return _client;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Capture a PostHog event. Silently no-ops if POSTHOG_API_KEY is not set
|
|
15
|
+
* or if telemetry has been disabled by the user.
|
|
16
|
+
*/
|
|
17
|
+
export async function capturePostHog(distinctId, event, properties) {
|
|
18
|
+
if (!process.env.POSTHOG_API_KEY)
|
|
19
|
+
return;
|
|
20
|
+
try {
|
|
21
|
+
// Respect the user's telemetry preference
|
|
22
|
+
const { configManager, isTelemetryDisabledValue } = await import('../config-manager.js');
|
|
23
|
+
const telemetryEnabled = await configManager.getValue('telemetryEnabled');
|
|
24
|
+
if (isTelemetryDisabledValue(telemetryEnabled))
|
|
25
|
+
return;
|
|
26
|
+
let VERSION = 'unknown';
|
|
27
|
+
try {
|
|
28
|
+
const { VERSION: v } = await import('../version.js');
|
|
29
|
+
VERSION = v;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// Continue without version
|
|
33
|
+
}
|
|
34
|
+
getClient().capture({
|
|
35
|
+
distinctId,
|
|
36
|
+
event,
|
|
37
|
+
properties: {
|
|
38
|
+
platform: platform(),
|
|
39
|
+
app_version: VERSION,
|
|
40
|
+
...properties,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// Silently fail — analytics must never break functionality
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Identify a user by their distinct ID and set person properties.
|
|
50
|
+
*/
|
|
51
|
+
export async function identifyPostHog(distinctId, properties) {
|
|
52
|
+
if (!process.env.POSTHOG_API_KEY)
|
|
53
|
+
return;
|
|
54
|
+
try {
|
|
55
|
+
const { configManager, isTelemetryDisabledValue } = await import('../config-manager.js');
|
|
56
|
+
const telemetryEnabled = await configManager.getValue('telemetryEnabled');
|
|
57
|
+
if (isTelemetryDisabledValue(telemetryEnabled))
|
|
58
|
+
return;
|
|
59
|
+
getClient().identify({ distinctId, properties });
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// Silently fail
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Capture an exception via PostHog error tracking.
|
|
67
|
+
*/
|
|
68
|
+
export async function captureExceptionPostHog(error, distinctId, additionalProperties) {
|
|
69
|
+
if (!process.env.POSTHOG_API_KEY)
|
|
70
|
+
return;
|
|
71
|
+
try {
|
|
72
|
+
const { configManager, isTelemetryDisabledValue } = await import('../config-manager.js');
|
|
73
|
+
const telemetryEnabled = await configManager.getValue('telemetryEnabled');
|
|
74
|
+
if (isTelemetryDisabledValue(telemetryEnabled))
|
|
75
|
+
return;
|
|
76
|
+
getClient().captureException(error, distinctId, additionalProperties);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
// Silently fail
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Flush all pending PostHog events. Call before process exit.
|
|
84
|
+
*/
|
|
85
|
+
export async function shutdownPostHog() {
|
|
86
|
+
if (_client) {
|
|
87
|
+
try {
|
|
88
|
+
await _client.shutdown();
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
// Silently fail
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -4,6 +4,24 @@ import { featureFlagManager } from './feature-flags.js';
|
|
|
4
4
|
import { openWelcomePage } from './open-browser.js';
|
|
5
5
|
import { logToStderr } from './logger.js';
|
|
6
6
|
import { capture } from './capture.js';
|
|
7
|
+
/** Consume a pending welcome page when this client must never receive it. */
|
|
8
|
+
export async function skipWelcomePageOnboarding() {
|
|
9
|
+
const pending = await configManager.getValue('pendingWelcomeOnboarding');
|
|
10
|
+
if (!pending) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
await configManager.setValue('pendingWelcomeOnboarding', false);
|
|
14
|
+
logToStderr('debug', 'Welcome page skipped');
|
|
15
|
+
}
|
|
16
|
+
function isWelcomePageClientExcluded(clientName) {
|
|
17
|
+
const configuredClients = featureFlagManager.get('welcome_page_excluded_clients', []);
|
|
18
|
+
if (!Array.isArray(configuredClients) || !clientName) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const normalizedClientName = clientName.trim().toLowerCase();
|
|
22
|
+
return configuredClients.some((configuredClient) => typeof configuredClient === 'string'
|
|
23
|
+
&& configuredClient.trim().toLowerCase() === normalizedClientName);
|
|
24
|
+
}
|
|
7
25
|
/**
|
|
8
26
|
* Handle welcome page display for new users (A/B test controlled)
|
|
9
27
|
*
|
|
@@ -13,6 +31,12 @@ import { capture } from './capture.js';
|
|
|
13
31
|
* 3. Haven't seen it yet
|
|
14
32
|
*/
|
|
15
33
|
export async function handleWelcomePageOnboarding(clientName) {
|
|
34
|
+
// Existing configs are migrated to false. Only configs created with the
|
|
35
|
+
// eligibility marker may receive this welcome-page campaign.
|
|
36
|
+
const eligible = await configManager.getValue('welcomeOnboardingEligible');
|
|
37
|
+
if (!eligible) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
16
40
|
// Check if this is a new install pending A/B decision
|
|
17
41
|
// This flag is set when config is first created and survives process restarts
|
|
18
42
|
const pending = await configManager.getValue('pendingWelcomeOnboarding');
|
|
@@ -28,6 +52,18 @@ export async function handleWelcomePageOnboarding(clientName) {
|
|
|
28
52
|
logToStderr('debug', 'Waiting for feature flags to load...');
|
|
29
53
|
await featureFlagManager.waitForFreshFlags();
|
|
30
54
|
}
|
|
55
|
+
// Keep an MCP release compatible with an older flag document: only an
|
|
56
|
+
// explicit false disables. Absent or malformed values fail open so a flag
|
|
57
|
+
// file typo cannot permanently consume pending onboarding for new installs.
|
|
58
|
+
const enabled = featureFlagManager.get('welcome_page_enabled', true) !== false;
|
|
59
|
+
if (!enabled) {
|
|
60
|
+
await skipWelcomePageOnboarding();
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (isWelcomePageClientExcluded(clientName)) {
|
|
64
|
+
await skipWelcomePageOnboarding();
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
31
67
|
// Check A/B test assignment
|
|
32
68
|
const shouldShow = await hasFeature('showOnboardingPage');
|
|
33
69
|
// Track the A/B decision
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.2.
|
|
1
|
+
export declare const VERSION = "0.2.46";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.2.
|
|
1
|
+
export const VERSION = '0.2.46';
|
package/package.json
CHANGED