@xmemo/client 0.4.156 → 0.4.157
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/README.md +37 -7
- package/package.json +2 -1
- package/plugins/kiro/.kiro-plugin/power.json +35 -0
- package/plugins/kiro/CHANGELOG.md +9 -0
- package/plugins/kiro/LICENSE +7 -0
- package/plugins/kiro/POWER.md +147 -0
- package/plugins/kiro/README.md +31 -0
- package/plugins/kiro/SETUP.md +234 -0
- package/plugins/kiro/assets/logo.svg +27 -0
- package/plugins/kiro/mcp.json +7 -0
- package/plugins/kiro/steering/xmemo-memory.md +32 -0
- package/src/cli.js +5 -5
- package/src/commands/auth.js +9 -8
- package/src/commands/diagnostics.js +10 -9
- package/src/commands/mcp.js +12 -11
- package/src/commands/profile.js +7 -6
- package/src/commands/setup.js +13 -12
- package/src/commands/update.js +6 -5
- package/src/{env.js → config/env.js} +7 -6
- package/src/{path-config.js → config/paths.js} +2 -1
- package/src/{profile.js → config/profile.js} +5 -4
- package/src/mcp/{detect.js → clients/detect.js} +3 -2
- package/src/mcp/{registry.js → clients/registry.js} +2 -1
- package/src/mcp/clients.js +6 -5
- package/src/mcp/{names.js → core/names.js} +2 -1
- package/src/mcp/{templates.js → core/templates.js} +4 -3
- package/src/mcp/{json-clients.js → formats/json.js} +6 -5
- package/src/mcp/{codex.js → formats/toml.js} +5 -4
- package/src/mcp/{hermes.js → formats/yaml.js} +5 -4
- package/src/mcp/{identity.js → identity/device.js} +28 -12
- package/src/mcp/{paths.js → identity/paths.js} +1 -0
- package/src/mcp/{copilot-proxy.js → proxy/copilot.js} +6 -5
- package/src/mcp/{proxy.js → proxy/server.js} +8 -7
- package/src/{auth.js → network/auth.js} +5 -4
- package/src/{base-url.js → network/base-url.js} +3 -2
- package/src/{discovery.js → network/discovery.js} +5 -4
- package/src/{http.js → network/http.js} +3 -2
- package/src/{help.js → ui/help.js} +3 -2
- package/src/{setup.js → ui/setup.js} +9 -8
- /package/src/{args.js → core/args.js} +0 -0
- /package/src/{constants.js → core/constants.js} +0 -0
- /package/src/{errors.js → core/errors.js} +0 -0
- /package/src/{io.js → core/io.js} +0 -0
- /package/src/{runtime.js → core/runtime.js} +0 -0
- /package/src/{version.js → core/version.js} +0 -0
package/src/commands/auth.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { hasFlag, optionValue, parsePositiveInteger } from '../args.js';
|
|
1
|
+
import { hasFlag, optionValue, parsePositiveInteger } from '../core/args.js';
|
|
2
2
|
import {
|
|
3
3
|
formatAccount,
|
|
4
4
|
pollDeviceLogin,
|
|
@@ -8,18 +8,18 @@ import {
|
|
|
8
8
|
storeTokenFromStdin,
|
|
9
9
|
storeTokenValue,
|
|
10
10
|
validateToken
|
|
11
|
-
} from '../auth.js';
|
|
12
|
-
import { baseUrlOption } from '../base-url.js';
|
|
11
|
+
} from '../network/auth.js';
|
|
12
|
+
import { baseUrlOption } from '../network/base-url.js';
|
|
13
13
|
import {
|
|
14
14
|
COMMAND_NAME,
|
|
15
15
|
LEGACY_TOKEN_ENV_VAR,
|
|
16
16
|
PRODUCT_NAME,
|
|
17
17
|
TOKEN_ENV_VAR
|
|
18
|
-
} from '../constants.js';
|
|
19
|
-
import { UsageError } from '../errors.js';
|
|
20
|
-
import { normalizeBaseUrl, verifyTokenWithMcp } from '../http.js';
|
|
21
|
-
import { writeLine } from '../io.js';
|
|
22
|
-
import { readAll } from '../runtime.js';
|
|
18
|
+
} from '../core/constants.js';
|
|
19
|
+
import { UsageError } from '../core/errors.js';
|
|
20
|
+
import { normalizeBaseUrl, verifyTokenWithMcp } from '../network/http.js';
|
|
21
|
+
import { writeLine } from '../core/io.js';
|
|
22
|
+
import { readAll } from '../core/runtime.js';
|
|
23
23
|
|
|
24
24
|
export async function loginCommand(args, io) {
|
|
25
25
|
const outputJson = hasFlag(args, '--json');
|
|
@@ -227,3 +227,4 @@ function writeCredentialStatus(report, io, { mode }) {
|
|
|
227
227
|
}
|
|
228
228
|
writeLine(io.stdout, report.loggedIn ? 'Credential is ready; token value remains hidden.' : `Run \`${COMMAND_NAME} login\` to sign in.`);
|
|
229
229
|
}
|
|
230
|
+
|
|
@@ -5,30 +5,30 @@ import {
|
|
|
5
5
|
parsePositiveInteger,
|
|
6
6
|
sameMajorMinor,
|
|
7
7
|
stringValue
|
|
8
|
-
} from '../args.js';
|
|
9
|
-
import { baseUrlOption } from '../base-url.js';
|
|
8
|
+
} from '../core/args.js';
|
|
9
|
+
import { baseUrlOption } from '../network/base-url.js';
|
|
10
10
|
import {
|
|
11
11
|
CLI_VERSION,
|
|
12
12
|
COMMAND_NAME,
|
|
13
13
|
PACKAGE_NAME,
|
|
14
14
|
PRODUCT_NAME
|
|
15
|
-
} from '../constants.js';
|
|
16
|
-
import { UsageError } from '../errors.js';
|
|
15
|
+
} from '../core/constants.js';
|
|
16
|
+
import { UsageError } from '../core/errors.js';
|
|
17
17
|
import {
|
|
18
18
|
agentDiscoveryClientIds,
|
|
19
19
|
bestEffortRootVersion,
|
|
20
20
|
discoveryMcpUrl,
|
|
21
21
|
ensureDiscoveryService
|
|
22
|
-
} from '../discovery.js';
|
|
22
|
+
} from '../network/discovery.js';
|
|
23
23
|
import {
|
|
24
24
|
endpointUrl,
|
|
25
25
|
fetchJson,
|
|
26
26
|
normalizeBaseUrl,
|
|
27
27
|
probe
|
|
28
|
-
} from '../http.js';
|
|
29
|
-
import { writeLine } from '../io.js';
|
|
30
|
-
import { codexSmokeReport } from '../mcp/
|
|
31
|
-
import { defaultCodexConfigPath } from '../
|
|
28
|
+
} from '../network/http.js';
|
|
29
|
+
import { writeLine } from '../core/io.js';
|
|
30
|
+
import { codexSmokeReport } from '../mcp/formats/toml.js';
|
|
31
|
+
import { defaultCodexConfigPath } from '../config/paths.js';
|
|
32
32
|
|
|
33
33
|
export async function doctorCommand(args, io) {
|
|
34
34
|
const baseUrl = normalizeBaseUrl(baseUrlOption(args, io.env));
|
|
@@ -194,3 +194,4 @@ export async function smokeCommand(args, io) {
|
|
|
194
194
|
}
|
|
195
195
|
return report.ok ? 0 : 1;
|
|
196
196
|
}
|
|
197
|
+
|
package/src/commands/mcp.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { hasFlag, optionValue, parsePositiveInteger } from '../args.js';
|
|
2
|
-
import { baseUrlOption } from '../base-url.js';
|
|
1
|
+
import { hasFlag, optionValue, parsePositiveInteger } from '../core/args.js';
|
|
2
|
+
import { baseUrlOption } from '../network/base-url.js';
|
|
3
3
|
import {
|
|
4
4
|
AGENT_INSTANCE_ENV_VAR,
|
|
5
5
|
COMMAND_NAME,
|
|
@@ -8,30 +8,30 @@ import {
|
|
|
8
8
|
MCP_SERVER_NAME,
|
|
9
9
|
PRODUCT_NAME,
|
|
10
10
|
TOKEN_ENV_VAR
|
|
11
|
-
} from '../constants.js';
|
|
12
|
-
import { UsageError } from '../errors.js';
|
|
13
|
-
import { endpointUrl, normalizeBaseUrl } from '../http.js';
|
|
14
|
-
import { writeLine } from '../io.js';
|
|
11
|
+
} from '../core/constants.js';
|
|
12
|
+
import { UsageError } from '../core/errors.js';
|
|
13
|
+
import { endpointUrl, normalizeBaseUrl } from '../network/http.js';
|
|
14
|
+
import { writeLine } from '../core/io.js';
|
|
15
15
|
import {
|
|
16
16
|
MCP_CLIENTS,
|
|
17
17
|
supportedMcpClientIds,
|
|
18
18
|
supportedMcpClients
|
|
19
19
|
} from '../mcp/clients.js';
|
|
20
|
-
import { mcpProxyCommand } from '../mcp/copilot
|
|
20
|
+
import { mcpProxyCommand } from '../mcp/proxy/copilot.js';
|
|
21
21
|
import {
|
|
22
22
|
agentIdentity,
|
|
23
23
|
envReferenceIdentity
|
|
24
|
-
} from '../mcp/identity.js';
|
|
24
|
+
} from '../mcp/identity/device.js';
|
|
25
25
|
import {
|
|
26
26
|
agentInstanceGenerationPolicy,
|
|
27
27
|
mcpConfigTemplate,
|
|
28
28
|
mcpLocalProxyTemplate
|
|
29
|
-
} from '../mcp/templates.js';
|
|
30
|
-
import { usesClientOAuth } from '../mcp/registry.js';
|
|
29
|
+
} from '../mcp/core/templates.js';
|
|
30
|
+
import { usesClientOAuth } from '../mcp/clients/registry.js';
|
|
31
31
|
import {
|
|
32
32
|
codexMemoryProfile,
|
|
33
33
|
writeCodexMemoryProfile
|
|
34
|
-
} from '../profile.js';
|
|
34
|
+
} from '../config/profile.js';
|
|
35
35
|
|
|
36
36
|
export async function mcpCommand(args, io) {
|
|
37
37
|
const subcommand = args[0] ?? 'help';
|
|
@@ -185,3 +185,4 @@ export async function mcpCommand(args, io) {
|
|
|
185
185
|
writeLine(io.stdout, `${AGENT_INSTANCE_ENV_VAR} must be stable per local ${client.label} install; run ${COMMAND_NAME} mcp add ${target} --write to generate it automatically.`);
|
|
186
186
|
return 0;
|
|
187
187
|
}
|
|
188
|
+
|
package/src/commands/profile.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { hasFlag, optionValue } from '../args.js';
|
|
2
|
-
import { COMMAND_NAME } from '../constants.js';
|
|
3
|
-
import { UsageError } from '../errors.js';
|
|
4
|
-
import { writeLine } from '../io.js';
|
|
1
|
+
import { hasFlag, optionValue } from '../core/args.js';
|
|
2
|
+
import { COMMAND_NAME } from '../core/constants.js';
|
|
3
|
+
import { UsageError } from '../core/errors.js';
|
|
4
|
+
import { writeLine } from '../core/io.js';
|
|
5
5
|
import { MCP_CLIENTS } from '../mcp/clients.js';
|
|
6
6
|
import {
|
|
7
7
|
defaultProfileTarget,
|
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
profileUninstallResult,
|
|
12
12
|
supportedProfileClientIds,
|
|
13
13
|
writeProfileResult
|
|
14
|
-
} from '../profile.js';
|
|
15
|
-
import { normalizeSetupClientId } from '../setup.js';
|
|
14
|
+
} from '../config/profile.js';
|
|
15
|
+
import { normalizeSetupClientId } from '../ui/setup.js';
|
|
16
16
|
|
|
17
17
|
export async function profileCommand(args, io) {
|
|
18
18
|
const subcommand = args[0] ?? 'help';
|
|
@@ -54,3 +54,4 @@ export async function profileCommand(args, io) {
|
|
|
54
54
|
writeProfileResult(subcommand, result, io);
|
|
55
55
|
return 0;
|
|
56
56
|
}
|
|
57
|
+
|
package/src/commands/setup.js
CHANGED
|
@@ -3,38 +3,38 @@ import {
|
|
|
3
3
|
optionValue,
|
|
4
4
|
parsePositiveInteger,
|
|
5
5
|
stringValue
|
|
6
|
-
} from '../args.js';
|
|
7
|
-
import { baseUrlOption } from '../base-url.js';
|
|
6
|
+
} from '../core/args.js';
|
|
7
|
+
import { baseUrlOption } from '../network/base-url.js';
|
|
8
8
|
import {
|
|
9
9
|
DEFAULT_PROXY_PORT
|
|
10
|
-
} from '../constants.js';
|
|
10
|
+
} from '../core/constants.js';
|
|
11
11
|
import {
|
|
12
12
|
buildSetupPlan,
|
|
13
13
|
ensureDiscoveryService
|
|
14
|
-
} from '../discovery.js';
|
|
15
|
-
import { UsageError } from '../errors.js';
|
|
14
|
+
} from '../network/discovery.js';
|
|
15
|
+
import { UsageError } from '../core/errors.js';
|
|
16
16
|
import {
|
|
17
17
|
endpointUrl,
|
|
18
18
|
fetchJson,
|
|
19
19
|
normalizeBaseUrl
|
|
20
|
-
} from '../http.js';
|
|
21
|
-
import { writeLine } from '../io.js';
|
|
20
|
+
} from '../network/http.js';
|
|
21
|
+
import { writeLine } from '../core/io.js';
|
|
22
22
|
import {
|
|
23
23
|
MCP_CLIENTS,
|
|
24
24
|
supportedMcpClients
|
|
25
25
|
} from '../mcp/clients.js';
|
|
26
|
-
import { mergeCopilotMcpConfig } from '../mcp/copilot
|
|
27
|
-
import { detectClient } from '../mcp/detect.js';
|
|
26
|
+
import { mergeCopilotMcpConfig } from '../mcp/proxy/copilot.js';
|
|
27
|
+
import { detectClient } from '../mcp/clients/detect.js';
|
|
28
28
|
import {
|
|
29
29
|
agentIdentity,
|
|
30
30
|
envReferenceIdentity
|
|
31
|
-
} from '../mcp/identity.js';
|
|
31
|
+
} from '../mcp/identity/device.js';
|
|
32
32
|
import {
|
|
33
33
|
confirmProfileInstall,
|
|
34
34
|
defaultProfileTarget,
|
|
35
35
|
profileClientConfig,
|
|
36
36
|
profileInstallResult
|
|
37
|
-
} from '../profile.js';
|
|
37
|
+
} from '../config/profile.js';
|
|
38
38
|
import {
|
|
39
39
|
clientSetupPlan,
|
|
40
40
|
copilotSetupPlan,
|
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
positionalClientArg,
|
|
43
43
|
supportedSetupClientIds,
|
|
44
44
|
writeSetupSummary
|
|
45
|
-
} from '../setup.js';
|
|
45
|
+
} from '../ui/setup.js';
|
|
46
46
|
|
|
47
47
|
export async function setupCommand(args, io) {
|
|
48
48
|
const positionalClientId = positionalClientArg(args, MCP_CLIENTS);
|
|
@@ -188,3 +188,4 @@ export async function setupCommand(args, io) {
|
|
|
188
188
|
writeSetupSummary(setupPlan, io);
|
|
189
189
|
return 0;
|
|
190
190
|
}
|
|
191
|
+
|
package/src/commands/update.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { hasFlag } from '../args.js';
|
|
1
|
+
import { hasFlag } from '../core/args.js';
|
|
2
2
|
import {
|
|
3
3
|
COMMAND_NAME,
|
|
4
4
|
PACKAGE_NAME
|
|
5
|
-
} from '../constants.js';
|
|
6
|
-
import { UsageError } from '../errors.js';
|
|
7
|
-
import { writeLine } from '../io.js';
|
|
5
|
+
} from '../core/constants.js';
|
|
6
|
+
import { UsageError } from '../core/errors.js';
|
|
7
|
+
import { writeLine } from '../core/io.js';
|
|
8
8
|
import {
|
|
9
9
|
npmExecutable,
|
|
10
10
|
runProcess
|
|
11
|
-
} from '../runtime.js';
|
|
11
|
+
} from '../core/runtime.js';
|
|
12
12
|
|
|
13
13
|
export async function updateCommand(args, io) {
|
|
14
14
|
const outputJson = hasFlag(args, '--json');
|
|
@@ -55,3 +55,4 @@ export async function updateCommand(args, io) {
|
|
|
55
55
|
}
|
|
56
56
|
return 0;
|
|
57
57
|
}
|
|
58
|
+
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { hasFlag, optionValue } from '
|
|
2
|
-
import { baseUrlOption } from '
|
|
1
|
+
import { hasFlag, optionValue } from '../core/args.js';
|
|
2
|
+
import { baseUrlOption } from '../network/base-url.js';
|
|
3
3
|
import {
|
|
4
4
|
AGENT_ID_ENV_VAR,
|
|
5
5
|
AGENT_INSTANCE_ENV_VAR,
|
|
6
6
|
COMMAND_NAME,
|
|
7
7
|
PRODUCT_NAME,
|
|
8
8
|
TOKEN_ENV_VAR
|
|
9
|
-
} from '
|
|
10
|
-
import { UsageError } from '
|
|
11
|
-
import { normalizeBaseUrl } from '
|
|
12
|
-
import { writeLine } from '
|
|
9
|
+
} from '../core/constants.js';
|
|
10
|
+
import { UsageError } from '../core/errors.js';
|
|
11
|
+
import { normalizeBaseUrl } from '../network/http.js';
|
|
12
|
+
import { writeLine } from '../core/io.js';
|
|
13
13
|
|
|
14
14
|
export function envCommand(args, io) {
|
|
15
15
|
const subcommand = args[0] ?? 'help';
|
|
@@ -79,3 +79,4 @@ export function writePrivacy(io) {
|
|
|
79
79
|
writeLine(io.stdout, '- Legacy `token set` plaintext storage requires explicit --allow-plaintext.');
|
|
80
80
|
writeLine(io.stdout, '- npm publishing is restricted by package.json files whitelist.');
|
|
81
81
|
}
|
|
82
|
+
|
|
@@ -12,10 +12,10 @@ import {
|
|
|
12
12
|
PRODUCT_NAME,
|
|
13
13
|
PROFILE_MARKER_PREFIX,
|
|
14
14
|
TOKEN_ENV_VAR
|
|
15
|
-
} from '
|
|
16
|
-
import { UsageError } from '
|
|
17
|
-
import { writeLine } from '
|
|
18
|
-
import { readTextIfExists } from '
|
|
15
|
+
} from '../core/constants.js';
|
|
16
|
+
import { UsageError } from '../core/errors.js';
|
|
17
|
+
import { writeLine } from '../core/io.js';
|
|
18
|
+
import { readTextIfExists } from '../core/runtime.js';
|
|
19
19
|
|
|
20
20
|
export function codexMemoryProfile() {
|
|
21
21
|
return memoryBehaviorProfile('codex');
|
|
@@ -530,3 +530,4 @@ export function writeProfileResult(action, result, io) {
|
|
|
530
530
|
}
|
|
531
531
|
writeLine(io.stdout, ' Token value embedded: false');
|
|
532
532
|
}
|
|
533
|
+
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import os from 'node:os';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
|
|
4
|
-
import { fileExists } from '
|
|
5
|
-
import { defaultCopilotConfigPath } from '
|
|
4
|
+
import { fileExists } from '../../core/runtime.js';
|
|
5
|
+
import { defaultCopilotConfigPath } from '../identity/paths.js';
|
|
6
6
|
|
|
7
7
|
export async function detectClient(clientId, env, mcpClients) {
|
|
8
8
|
let filePaths = [];
|
|
@@ -48,3 +48,4 @@ export async function detectClient(clientId, env, mcpClients) {
|
|
|
48
48
|
|
|
49
49
|
return { detected: false };
|
|
50
50
|
}
|
|
51
|
+
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JSON_MCP_CLIENT_DEFINITIONS } from '
|
|
1
|
+
import { JSON_MCP_CLIENT_DEFINITIONS } from '../formats/json.js';
|
|
2
2
|
|
|
3
3
|
export function createMcpClients(deps) {
|
|
4
4
|
const clients = new Map();
|
|
@@ -65,3 +65,4 @@ export function usesClientOAuth(clientId) {
|
|
|
65
65
|
(definition) => definition.id === clientId && definition.authentication === 'oauth'
|
|
66
66
|
);
|
|
67
67
|
}
|
|
68
|
+
|
package/src/mcp/clients.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
appendTomlServerConfig,
|
|
3
3
|
codexTomlSnippet
|
|
4
|
-
} from './
|
|
4
|
+
} from './formats/toml.js';
|
|
5
5
|
import {
|
|
6
6
|
hermesYamlSnippet,
|
|
7
7
|
mergeHermesMcpConfig
|
|
8
|
-
} from './
|
|
8
|
+
} from './formats/yaml.js';
|
|
9
9
|
import {
|
|
10
10
|
JSON_MCP_CLIENT_DEFINITIONS,
|
|
11
11
|
jsonClientSnippet,
|
|
12
12
|
mergeJsonClientMcpConfig
|
|
13
|
-
} from './json
|
|
13
|
+
} from './formats/json.js';
|
|
14
14
|
import {
|
|
15
15
|
defaultAntigravity2ConfigPath,
|
|
16
16
|
defaultAntigravityCliConfigPath,
|
|
@@ -33,12 +33,12 @@ import {
|
|
|
33
33
|
defaultTraeSoloConfigPath,
|
|
34
34
|
defaultWindsurfConfigPath,
|
|
35
35
|
defaultZedConfigPath
|
|
36
|
-
} from '../
|
|
36
|
+
} from '../config/paths.js';
|
|
37
37
|
import {
|
|
38
38
|
createMcpClients,
|
|
39
39
|
supportedMcpClientIds as registrySupportedMcpClientIds,
|
|
40
40
|
supportedMcpClients as registrySupportedMcpClients
|
|
41
|
-
} from './registry.js';
|
|
41
|
+
} from './clients/registry.js';
|
|
42
42
|
|
|
43
43
|
export const MCP_CLIENTS = createMcpClients({
|
|
44
44
|
JSON_MCP_CLIENT_DEFINITIONS,
|
|
@@ -78,3 +78,4 @@ export function supportedMcpClients() {
|
|
|
78
78
|
export function supportedMcpClientIds() {
|
|
79
79
|
return registrySupportedMcpClientIds(MCP_CLIENTS);
|
|
80
80
|
}
|
|
81
|
+
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LEGACY_MCP_SERVER_NAMES,
|
|
3
3
|
MCP_SERVER_NAME
|
|
4
|
-
} from '
|
|
4
|
+
} from '../../core/constants.js';
|
|
5
5
|
|
|
6
6
|
export function knownMcpServerNames() {
|
|
7
7
|
return [MCP_SERVER_NAME, ...LEGACY_MCP_SERVER_NAMES];
|
|
@@ -10,3 +10,4 @@ export function knownMcpServerNames() {
|
|
|
10
10
|
export function existingJsonMcpServerName(mcpServers) {
|
|
11
11
|
return knownMcpServerNames().find((name) => mcpServers[name]);
|
|
12
12
|
}
|
|
13
|
+
|
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
DEFAULT_PROXY_PORT,
|
|
7
7
|
MCP_SERVER_NAME,
|
|
8
8
|
TOKEN_ENV_VAR
|
|
9
|
-
} from '
|
|
10
|
-
import { codexTomlSnippet } from '
|
|
9
|
+
} from '../../core/constants.js';
|
|
10
|
+
import { codexTomlSnippet } from '../formats/toml.js';
|
|
11
11
|
import {
|
|
12
12
|
jsonClientConfig,
|
|
13
13
|
jsonMcpClientDefinition
|
|
14
|
-
} from '
|
|
14
|
+
} from '../formats/json.js';
|
|
15
15
|
|
|
16
16
|
export function mcpConfigTemplate(clientId, mcpUrl, options = {}) {
|
|
17
17
|
if (clientId === 'codex') {
|
|
@@ -153,3 +153,4 @@ function oauthJsonMcpTemplate(clientId, mcpUrl, snippet, options) {
|
|
|
153
153
|
writesTokenValue: false
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
|
+
|
|
@@ -7,16 +7,16 @@ import {
|
|
|
7
7
|
AGENT_INSTANCE_HEADER,
|
|
8
8
|
MCP_SERVER_NAME,
|
|
9
9
|
TOKEN_ENV_VAR
|
|
10
|
-
} from '
|
|
11
|
-
import { UsageError } from '
|
|
10
|
+
} from '../../core/constants.js';
|
|
11
|
+
import { UsageError } from '../../core/errors.js';
|
|
12
12
|
import {
|
|
13
13
|
bestEffortChmod,
|
|
14
14
|
isPlainObject,
|
|
15
15
|
parseJsonConfig,
|
|
16
16
|
readTextIfExists
|
|
17
|
-
} from '
|
|
18
|
-
import { envReferenceIdentity } from '
|
|
19
|
-
import { existingJsonMcpServerName } from '
|
|
17
|
+
} from '../../core/runtime.js';
|
|
18
|
+
import { envReferenceIdentity } from '../identity/device.js';
|
|
19
|
+
import { existingJsonMcpServerName } from '../core/names.js';
|
|
20
20
|
|
|
21
21
|
export const JSON_MCP_CLIENT_DEFINITIONS = Object.freeze([
|
|
22
22
|
httpClientDefinition('cursor', 'Cursor', 'defaultCursorConfigPath', { urlKey: 'url', authentication: 'env-bearer' }),
|
|
@@ -352,3 +352,4 @@ export const claudecodeJsonConfig = (mcpUrl, identity = envReferenceIdentity('cl
|
|
|
352
352
|
export const claudecodeJsonSnippet = (mcpUrl, identity = envReferenceIdentity('claude-code')) => jsonClientSnippet('claude-code', mcpUrl, identity);
|
|
353
353
|
export const claudecodeJsonServerConfig = (mcpUrl, identity = envReferenceIdentity('claude-code')) => jsonClientServerConfig('claude-code', mcpUrl, identity);
|
|
354
354
|
export const mergeClaudecodeMcpConfig = (configPath, mcpUrl, identity) => mergeJsonClientMcpConfig('claude-code', configPath, mcpUrl, identity);
|
|
355
|
+
|
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
LEGACY_MCP_SERVER_NAMES,
|
|
7
7
|
MCP_SERVER_NAME,
|
|
8
8
|
TOKEN_ENV_VAR
|
|
9
|
-
} from '
|
|
10
|
-
import { UsageError } from '
|
|
9
|
+
} from '../../core/constants.js';
|
|
10
|
+
import { UsageError } from '../../core/errors.js';
|
|
11
11
|
import {
|
|
12
12
|
bestEffortChmod,
|
|
13
13
|
escapeRegExp,
|
|
@@ -15,8 +15,8 @@ import {
|
|
|
15
15
|
fileExists,
|
|
16
16
|
readTextIfExists,
|
|
17
17
|
unescapeTomlString
|
|
18
|
-
} from '
|
|
19
|
-
import { agentInstanceIdentityPath } from '
|
|
18
|
+
} from '../../core/runtime.js';
|
|
19
|
+
import { agentInstanceIdentityPath } from '../identity/device.js';
|
|
20
20
|
|
|
21
21
|
export function codexTomlSnippet(mcpUrl) {
|
|
22
22
|
return `[mcp_servers.${MCP_SERVER_NAME}]
|
|
@@ -145,3 +145,4 @@ function tomlStringValue(block, key) {
|
|
|
145
145
|
const match = block.match(pattern);
|
|
146
146
|
return match ? unescapeTomlString(match[1]) : null;
|
|
147
147
|
}
|
|
148
|
+
|
|
@@ -5,13 +5,13 @@ import {
|
|
|
5
5
|
AGENT_INSTANCE_ENV_VAR,
|
|
6
6
|
MCP_SERVER_NAME,
|
|
7
7
|
TOKEN_ENV_VAR
|
|
8
|
-
} from '
|
|
9
|
-
import { UsageError } from '
|
|
8
|
+
} from '../../core/constants.js';
|
|
9
|
+
import { UsageError } from '../../core/errors.js';
|
|
10
10
|
import {
|
|
11
11
|
bestEffortChmod,
|
|
12
12
|
readTextIfExists
|
|
13
|
-
} from '
|
|
14
|
-
import { envReferenceIdentity } from '
|
|
13
|
+
} from '../../core/runtime.js';
|
|
14
|
+
import { envReferenceIdentity } from '../identity/device.js';
|
|
15
15
|
|
|
16
16
|
export function hermesYamlSnippet(mcpUrl, identity = envReferenceIdentity('hermes')) {
|
|
17
17
|
return `mcp_servers:
|
|
@@ -69,3 +69,4 @@ export async function mergeHermesMcpConfig(configPath, mcpUrl, identity) {
|
|
|
69
69
|
}
|
|
70
70
|
await bestEffortChmod(configPath, 0o600);
|
|
71
71
|
}
|
|
72
|
+
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
|
+
import os from 'node:os';
|
|
2
3
|
import path from 'node:path';
|
|
3
|
-
import { randomUUID } from 'node:crypto';
|
|
4
4
|
|
|
5
|
-
import { AGENT_INSTANCE_ENV_VAR } from '
|
|
6
|
-
import { bestEffortChmod, parseJsonConfig, readTextIfExists } from '
|
|
7
|
-
import { stringValue } from '
|
|
5
|
+
import { AGENT_INSTANCE_ENV_VAR } from '../../core/constants.js';
|
|
6
|
+
import { bestEffortChmod, parseJsonConfig, readTextIfExists } from '../../core/runtime.js';
|
|
7
|
+
import { stringValue } from '../../core/args.js';
|
|
8
8
|
import { configRoot } from './paths.js';
|
|
9
9
|
|
|
10
10
|
function identityClientId(clientId) {
|
|
@@ -24,32 +24,47 @@ export async function agentIdentity(clientId, env) {
|
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
const identityPath =
|
|
28
|
-
const existing = await
|
|
27
|
+
const identityPath = deviceInstanceIdentityPath(env);
|
|
28
|
+
const existing = await readDeviceInstanceIdentity(identityPath);
|
|
29
29
|
if (existing) {
|
|
30
30
|
return { agentId: targetClientId, agentInstanceId: existing, path: identityPath };
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
const
|
|
33
|
+
const hostname = os.hostname().toLowerCase().replace(/[^a-z0-9-]/g, '-').substring(0, 32);
|
|
34
|
+
const generated = `xmemo-${hostname}`;
|
|
35
|
+
|
|
34
36
|
await fs.mkdir(path.dirname(identityPath), { recursive: true, mode: 0o700 });
|
|
35
37
|
await bestEffortChmod(path.dirname(identityPath), 0o700);
|
|
36
|
-
await fs.writeFile(identityPath, `${JSON.stringify({
|
|
38
|
+
await fs.writeFile(identityPath, `${JSON.stringify({
|
|
39
|
+
version: 1,
|
|
40
|
+
deviceInstanceId: generated,
|
|
41
|
+
hostname: os.hostname(),
|
|
42
|
+
createdAt: new Date().toISOString()
|
|
43
|
+
}, null, 2)}\n`, { mode: 0o600 });
|
|
37
44
|
await bestEffortChmod(identityPath, 0o600);
|
|
38
45
|
return { agentId: targetClientId, agentInstanceId: generated, path: identityPath };
|
|
39
46
|
}
|
|
40
47
|
|
|
41
|
-
export async function
|
|
48
|
+
export async function readDeviceInstanceIdentity(identityPath) {
|
|
42
49
|
const existing = await readTextIfExists(identityPath);
|
|
43
50
|
if (!existing.trim()) {
|
|
44
51
|
return null;
|
|
45
52
|
}
|
|
46
53
|
const parsed = parseJsonConfig(existing, identityPath);
|
|
47
|
-
const value = stringValue(parsed, ['agentInstanceId']);
|
|
54
|
+
const value = stringValue(parsed, ['deviceInstanceId']) || stringValue(parsed, ['agentInstanceId']);
|
|
48
55
|
return value || null;
|
|
49
56
|
}
|
|
50
57
|
|
|
51
|
-
export function
|
|
52
|
-
return path.join(configRoot(env), '
|
|
58
|
+
export function deviceInstanceIdentityPath(env) {
|
|
59
|
+
return path.join(configRoot(env), 'device-instance.json');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export async function readAgentInstanceIdentity(identityPath) {
|
|
63
|
+
return readDeviceInstanceIdentity(identityPath);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function agentInstanceIdentityPath(env) {
|
|
67
|
+
return deviceInstanceIdentityPath(env);
|
|
53
68
|
}
|
|
54
69
|
|
|
55
70
|
export function envReferenceIdentity(clientId) {
|
|
@@ -60,3 +75,4 @@ export function envReferenceIdentity(clientId) {
|
|
|
60
75
|
path: `${AGENT_INSTANCE_ENV_VAR} environment variable`
|
|
61
76
|
};
|
|
62
77
|
}
|
|
78
|
+
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
|
|
4
|
-
import { MCP_SERVER_NAME } from '
|
|
5
|
-
import { UsageError } from '
|
|
4
|
+
import { MCP_SERVER_NAME } from '../../core/constants.js';
|
|
5
|
+
import { UsageError } from '../../core/errors.js';
|
|
6
6
|
import {
|
|
7
7
|
bestEffortChmod,
|
|
8
8
|
isPlainObject,
|
|
9
9
|
parseJsonConfig,
|
|
10
10
|
readTextIfExists
|
|
11
|
-
} from '
|
|
12
|
-
import { existingJsonMcpServerName } from '
|
|
13
|
-
export { mcpProxyCommand } from './
|
|
11
|
+
} from '../../core/runtime.js';
|
|
12
|
+
import { existingJsonMcpServerName } from '../core/names.js';
|
|
13
|
+
export { mcpProxyCommand } from './server.js';
|
|
14
14
|
|
|
15
15
|
export async function mergeCopilotMcpConfig(configPath, proxyUrl) {
|
|
16
16
|
const existing = await readTextIfExists(configPath);
|
|
@@ -41,3 +41,4 @@ export function copilotLocalProxyServerConfig(proxyUrl) {
|
|
|
41
41
|
url: proxyUrl
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import http from 'node:http';
|
|
2
2
|
|
|
3
|
-
import { optionValue, parsePositiveInteger } from '
|
|
3
|
+
import { optionValue, parsePositiveInteger } from '../../core/args.js';
|
|
4
4
|
import {
|
|
5
5
|
AGENT_ID_HEADER,
|
|
6
6
|
AGENT_INSTANCE_HEADER,
|
|
@@ -11,12 +11,12 @@ import {
|
|
|
11
11
|
DEFAULT_PROXY_PORT,
|
|
12
12
|
PRODUCT_NAME,
|
|
13
13
|
TOKEN_ENV_VAR
|
|
14
|
-
} from '
|
|
15
|
-
import { credentialsPath, resolveCredentialToken, validateToken } from '
|
|
16
|
-
import { endpointUrl, normalizeBaseUrl } from '
|
|
17
|
-
import { UsageError } from '
|
|
18
|
-
import { writeLine } from '
|
|
19
|
-
import { closeServer, readAll, waitForShutdown } from '
|
|
14
|
+
} from '../../core/constants.js';
|
|
15
|
+
import { credentialsPath, resolveCredentialToken, validateToken } from '../../network/auth.js';
|
|
16
|
+
import { endpointUrl, normalizeBaseUrl } from '../../network/http.js';
|
|
17
|
+
import { UsageError } from '../../core/errors.js';
|
|
18
|
+
import { writeLine } from '../../core/io.js';
|
|
19
|
+
import { closeServer, readAll, waitForShutdown } from '../../core/runtime.js';
|
|
20
20
|
|
|
21
21
|
export async function mcpProxyCommand(args, io, { agentIdentity }) {
|
|
22
22
|
const baseUrl = normalizeBaseUrl(baseUrlOption(args, io.env));
|
|
@@ -109,3 +109,4 @@ function baseUrlOption(args, env) {
|
|
|
109
109
|
?? env.MEMORY_OS_BASE_URL
|
|
110
110
|
?? DEFAULT_SERVICE_URL;
|
|
111
111
|
}
|
|
112
|
+
|