@hubspot/cli 8.18.0-beta.0 → 8.19.0-beta.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/commands/account/auth.js +2 -2
- package/commands/account/createOverride.js +2 -0
- package/commands/account/removeOverride.js +2 -0
- package/commands/app/secret/add.js +1 -1
- package/commands/app/secret/delete.js +1 -1
- package/commands/app/secret/list.js +1 -1
- package/commands/app/secret/update.js +1 -1
- package/commands/app/secret.js +1 -1
- package/commands/auth.js +3 -2
- package/commands/cms/function/create.js +5 -37
- package/commands/cms/function/deploy.js +8 -1
- package/commands/cms/function/list.js +4 -0
- package/commands/cms/function/logs.js +2 -0
- package/commands/cms/function/server.js +6 -0
- package/commands/cms/upload.js +6 -0
- package/commands/cms/watch.js +2 -0
- package/commands/cms/webpack/create.js +5 -32
- package/commands/customObject.js +2 -2
- package/commands/getStarted.js +4 -4
- package/commands/hubdb/list.js +2 -2
- package/commands/init.js +3 -2
- package/commands/mcp/setup.js +3 -2
- package/commands/project/dev/index.js +2 -2
- package/commands/project/logs.js +2 -2
- package/commands/project/upload.js +6 -2
- package/commands/project/watch.js +2 -2
- package/commands/sandbox/create.js +3 -3
- package/commands/sandbox/delete.js +1 -1
- package/commands/sandbox.js +1 -1
- package/lang/en.d.ts +26 -0
- package/lang/en.js +85 -43
- package/lib/accountAuth.js +12 -0
- package/lib/accountCredentials.d.ts +1 -0
- package/lib/accountCredentials.js +25 -0
- package/lib/app/logSystemTypes.d.ts +4 -0
- package/lib/app/logSystemTypes.js +17 -0
- package/lib/app/logs.d.ts +2 -4
- package/lib/app/logs.js +2 -17
- package/lib/app/migrate.js +3 -3
- package/lib/constants.d.ts +2 -0
- package/lib/constants.js +4 -0
- package/lib/crossPlatformSpawn/escape.d.ts +2 -0
- package/lib/crossPlatformSpawn/escape.js +38 -0
- package/lib/crossPlatformSpawn/index.d.ts +7 -0
- package/lib/crossPlatformSpawn/index.js +43 -0
- package/lib/crossPlatformSpawn/resolveCommand.d.ts +1 -0
- package/lib/crossPlatformSpawn/resolveCommand.js +69 -0
- package/lib/errorHandlers/suppressError.js +3 -3
- package/lib/feedback.js +2 -18
- package/lib/hints/hints.d.ts +9 -0
- package/lib/hints/hints.js +30 -0
- package/lib/hints/throttle.d.ts +4 -0
- package/lib/hints/throttle.js +9 -0
- package/lib/jsonOutput/projectUpload.d.ts +1 -0
- package/lib/jsonOutput/projectUpload.js +1 -0
- package/lib/mcp/promotion.js +15 -30
- package/lib/mcp/setup.d.ts +6 -1
- package/lib/mcp/setup.js +1 -1
- package/lib/middleware/deprecationWarningMiddleware.js +4 -9
- package/lib/projects/localDev/AppDevModeInterface.js +3 -3
- package/lib/projects/localDev/LocalDevLogger.js +5 -5
- package/lib/projects/localDev/helpers/project.js +3 -3
- package/lib/projects/pollProjectBuildAndDeploy.js +4 -4
- package/lib/projects/projectInfo.js +4 -4
- package/lib/projects/projectProfiles.js +3 -3
- package/lib/projects/ui.js +3 -3
- package/lib/projects/upload.d.ts +3 -1
- package/lib/projects/upload.js +23 -6
- package/lib/projects/watch.js +4 -2
- package/lib/projects/workspaces.js +4 -4
- package/lib/prompts/personalAccessKeyPrompt.js +2 -2
- package/lib/prompts/selectPublicAppForMigrationPrompt.js +3 -3
- package/lib/serverlessSunset.d.ts +6 -0
- package/lib/serverlessSunset.js +32 -0
- package/lib/testUtils.d.ts +5 -1
- package/lib/testUtils.js +2 -2
- package/lib/ui/appLogs.js +4 -4
- package/lib/ui/formatting.d.ts +13 -0
- package/lib/ui/formatting.js +39 -0
- package/lib/ui/git.js +3 -3
- package/lib/ui/index.d.ts +9 -23
- package/lib/ui/index.js +36 -69
- package/lib/ui/logger.d.ts +1 -0
- package/lib/ui/logger.js +2 -1
- package/lib/ui/uiMessages.js +1 -1
- package/mcp-server/server.js +13 -5
- package/mcp-server/tools/cms/HsFunctionLogsTool.js +2 -2
- package/mcp-server/tools/cms/HsListFunctionsTool.js +1 -1
- package/mcp-server/tools/cms/HsListTool.js +4 -1
- package/mcp-server/tools/index.js +0 -2
- package/mcp-server/tools/project/DocFetchTool.js +2 -6
- package/mcp-server/tools/project/DocsSearchTool.js +2 -7
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +2 -7
- package/mcp-server/tools/project/GetApplicationInfoTool.js +2 -7
- package/mcp-server/tools/project/GetBuildLogsTool.js +2 -12
- package/mcp-server/tools/project/GetBuildStatusTool.js +2 -12
- package/mcp-server/tools/project/KnowledgeSearchTool.js +2 -5
- package/mcp-server/tools/project/SubmitFeedbackTool.js +2 -1
- package/mcp-server/utils/command.js +16 -5
- package/mcp-server/utils/errors.d.ts +1 -0
- package/mcp-server/utils/errors.js +9 -0
- package/package.json +9 -9
- package/mcp-server/tools/cms/HsCreateFunctionTool.d.ts +0 -26
- package/mcp-server/tools/cms/HsCreateFunctionTool.js +0 -100
package/mcp-server/server.js
CHANGED
|
@@ -45,13 +45,17 @@ REQUIRED WORKFLOWS
|
|
|
45
45
|
5. Debugging a failed build: start with \`get-build-status\` to surface
|
|
46
46
|
error messages, and only reach for \`get-build-logs\` for deeper
|
|
47
47
|
troubleshooting or warnings.
|
|
48
|
-
6. Reading serverless function logs
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
6. Reading serverless function logs (deprecated, CMS serverless functions
|
|
49
|
+
are being sunset: editing ends on November 17, 2026 and existing
|
|
50
|
+
functions stop running on February 1, 2027): call
|
|
51
|
+
\`list-cms-serverless-functions\` first to discover the endpoint path,
|
|
52
|
+
then \`get-cms-serverless-function-logs\`.
|
|
51
53
|
7. Serverless functions come in two distinct kinds. CMS serverless
|
|
52
54
|
functions are website endpoints served at \`/hs/serverless/<path>\`.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
They can no longer be created and editing ends on November 17, 2026,
|
|
56
|
+
so build new serverless functions in a Developer Project instead with
|
|
57
|
+
\`add-feature-to-project\`.
|
|
58
|
+
Manage existing ones with \`list-cms-serverless-functions\` and
|
|
55
59
|
\`get-cms-serverless-function-logs\`. App functions are serverless
|
|
56
60
|
functions built inside a developer-platform app, either private
|
|
57
61
|
(the \`app-function\` feature) or publicly accessible via an endpoint
|
|
@@ -63,6 +67,10 @@ REQUIRED WORKFLOWS
|
|
|
63
67
|
9. Feedback: when you hit a bug, an error you cannot explain, a confusing
|
|
64
68
|
result, or a request these tools cannot do, call \`submit-feedback\`
|
|
65
69
|
with one short message. Then continue with the task.
|
|
70
|
+
10. Long-running commands: never run \`hs project dev\`,
|
|
71
|
+
\`hs project watch\`, or \`hs cms watch\` from a shell, even if
|
|
72
|
+
asked. Ask the user to run it in a separate terminal window. To
|
|
73
|
+
watch a project, give them \`hs project dev --auto-upload\`.
|
|
66
74
|
|
|
67
75
|
OUTPUT
|
|
68
76
|
Tool results contain the relevant \`hs\` stdout/stderr or structured data.
|
|
@@ -91,7 +91,7 @@ export class HsFunctionLogsTool extends Tool {
|
|
|
91
91
|
const normalizedEndpoint = resolvedEndpoint.startsWith('/')
|
|
92
92
|
? resolvedEndpoint.slice(1)
|
|
93
93
|
: resolvedEndpoint;
|
|
94
|
-
const command = new HubSpotCommand(
|
|
94
|
+
const command = new HubSpotCommand('cms function logs').addArg(normalizedEndpoint);
|
|
95
95
|
if (latest) {
|
|
96
96
|
command.addFlag('latest', latest);
|
|
97
97
|
}
|
|
@@ -119,7 +119,7 @@ export class HsFunctionLogsTool extends Tool {
|
|
|
119
119
|
register() {
|
|
120
120
|
return this.mcpServer.registerTool(toolName, {
|
|
121
121
|
title: 'Get HubSpot CMS serverless function logs for an endpoint',
|
|
122
|
-
description: 'Retrieve logs for HubSpot CMS serverless functions. These are CMS/website functions, not developer-platform app functions (the private app-function feature or the public app-function-endpoint feature). Use this tool to help debug issues with serverless functions by reading the production logs. Supports various options like latest, compact, and limiting results. Use after listing functions with list-cms-serverless-functions to get the endpoint path.',
|
|
122
|
+
description: 'DEPRECATED: CMS serverless functions are being sunset: creating them has ended, editing ends on November 17, 2026, and existing functions stop running on February 1, 2027. Retrieve logs for HubSpot CMS serverless functions. These are CMS/website functions, not developer-platform app functions (the private app-function feature or the public app-function-endpoint feature). Use this tool to help debug issues with serverless functions by reading the production logs. Supports various options like latest, compact, and limiting results. Use after listing functions with list-cms-serverless-functions to get the endpoint path.',
|
|
123
123
|
inputSchema,
|
|
124
124
|
annotations: {
|
|
125
125
|
readOnlyHint: true,
|
|
@@ -54,7 +54,7 @@ export class HsListFunctionsTool extends Tool {
|
|
|
54
54
|
register() {
|
|
55
55
|
return this.mcpServer.registerTool(toolName, {
|
|
56
56
|
title: 'List HubSpot CMS Serverless Functions',
|
|
57
|
-
description: 'Lists CMS serverless functions deployed in a HubSpot account. CMS serverless functions are website endpoints served at /hs/serverless/<path>. This does NOT list developer-platform app functions (the private app-function feature or the public app-function-endpoint feature). Shows function routes, HTTP methods, secrets, and timestamps.',
|
|
57
|
+
description: 'DEPRECATED: CMS serverless functions are being sunset: creating them has ended, editing ends on November 17, 2026, and existing functions stop running on February 1, 2027. Lists CMS serverless functions deployed in a HubSpot account. CMS serverless functions are website endpoints served at /hs/serverless/<path>. This does NOT list developer-platform app functions (the private app-function feature or the public app-function-endpoint feature). Shows function routes, HTTP methods, secrets, and timestamps.',
|
|
58
58
|
inputSchema,
|
|
59
59
|
annotations: {
|
|
60
60
|
readOnlyHint: true,
|
|
@@ -25,7 +25,10 @@ export class HsListTool extends Tool {
|
|
|
25
25
|
}
|
|
26
26
|
async handler({ path, account, absoluteCurrentWorkingDirectory }, extra) {
|
|
27
27
|
setupHubSpotConfig(absoluteCurrentWorkingDirectory);
|
|
28
|
-
const command = new HubSpotCommand(
|
|
28
|
+
const command = new HubSpotCommand('cms list');
|
|
29
|
+
if (path) {
|
|
30
|
+
command.addArg(path);
|
|
31
|
+
}
|
|
29
32
|
if (account) {
|
|
30
33
|
command.addFlag('account', account);
|
|
31
34
|
}
|
|
@@ -15,7 +15,6 @@ import { GetBuildStatusTool } from './project/GetBuildStatusTool.js';
|
|
|
15
15
|
import { HsListTool } from './cms/HsListTool.js';
|
|
16
16
|
import { HsCreateModuleTool } from './cms/HsCreateModuleTool.js';
|
|
17
17
|
import { HsCreateTemplateTool } from './cms/HsCreateTemplateTool.js';
|
|
18
|
-
import { HsCreateFunctionTool } from './cms/HsCreateFunctionTool.js';
|
|
19
18
|
import { HsListFunctionsTool } from './cms/HsListFunctionsTool.js';
|
|
20
19
|
import { HsFunctionLogsTool } from './cms/HsFunctionLogsTool.js';
|
|
21
20
|
import { CreateTestAccountTool } from './project/CreateTestAccountTool.js';
|
|
@@ -49,7 +48,6 @@ export function registerCmsTools(mcpServer, logger) {
|
|
|
49
48
|
new HsListTool(mcpServer, logger).register(),
|
|
50
49
|
new HsCreateModuleTool(mcpServer, logger).register(),
|
|
51
50
|
new HsCreateTemplateTool(mcpServer, logger).register(),
|
|
52
|
-
new HsCreateFunctionTool(mcpServer, logger).register(),
|
|
53
51
|
new HsListFunctionsTool(mcpServer, logger).register(),
|
|
54
52
|
new HsFunctionLogsTool(mcpServer, logger).register(),
|
|
55
53
|
];
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
2
|
import { Tool } from '../../Tool.js';
|
|
3
3
|
import { formatErrorTextContents, formatTextContents, } from '../../utils/content.js';
|
|
4
|
+
import { getToolErrorMessage } from '../../utils/errors.js';
|
|
4
5
|
import { absoluteCurrentWorkingDirectory, docUrl } from './constants.js';
|
|
5
6
|
import { http } from '@hubspot/local-dev-lib/http/unauthed';
|
|
6
|
-
import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
|
|
7
7
|
import { setupHubSpotConfig } from '../../utils/config.js';
|
|
8
|
-
import { getErrorMessage } from '../../../lib/errorHandlers/index.js';
|
|
9
8
|
const offset = z
|
|
10
9
|
.number()
|
|
11
10
|
.int()
|
|
@@ -82,10 +81,7 @@ export class DocFetchTool extends Tool {
|
|
|
82
81
|
message: 'Handler caught error',
|
|
83
82
|
error: error instanceof Error ? error.message : String(error),
|
|
84
83
|
});
|
|
85
|
-
|
|
86
|
-
return formatErrorTextContents(error.toString());
|
|
87
|
-
}
|
|
88
|
-
const errorMessage = `Error fetching documentation: ${getErrorMessage(error)}`;
|
|
84
|
+
const errorMessage = `Error fetching documentation: ${getToolErrorMessage(error)}`;
|
|
89
85
|
return formatErrorTextContents(errorMessage);
|
|
90
86
|
}
|
|
91
87
|
}
|
|
@@ -2,11 +2,10 @@ import { http } from '@hubspot/local-dev-lib/http';
|
|
|
2
2
|
import z from 'zod';
|
|
3
3
|
import { Tool } from '../../Tool.js';
|
|
4
4
|
import { formatTextContents } from '../../utils/content.js';
|
|
5
|
+
import { getToolErrorMessage } from '../../utils/errors.js';
|
|
5
6
|
import { absoluteCurrentWorkingDirectory, account, docsSearchQuery, } from './constants.js';
|
|
6
|
-
import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
|
|
7
7
|
import { setupHubSpotConfig } from '../../utils/config.js';
|
|
8
8
|
import { resolveAccountId } from './resolveAccount.js';
|
|
9
|
-
import { getErrorMessage } from '../../../lib/errorHandlers/index.js';
|
|
10
9
|
const docsSearchLimit = z
|
|
11
10
|
.number()
|
|
12
11
|
.int()
|
|
@@ -80,11 +79,7 @@ export class DocsSearchTool extends Tool {
|
|
|
80
79
|
message: 'Handler caught error',
|
|
81
80
|
error: error instanceof Error ? error.message : String(error),
|
|
82
81
|
});
|
|
83
|
-
|
|
84
|
-
// Handle different status codes
|
|
85
|
-
return formatTextContents(error.toString());
|
|
86
|
-
}
|
|
87
|
-
const errorMessage = `Error searching documentation: ${getErrorMessage(error)}`;
|
|
82
|
+
const errorMessage = `Error searching documentation: ${getToolErrorMessage(error)}`;
|
|
88
83
|
return formatTextContents(errorMessage);
|
|
89
84
|
}
|
|
90
85
|
}
|
|
@@ -2,11 +2,10 @@ import { Tool } from '../../Tool.js';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { http } from '@hubspot/local-dev-lib/http';
|
|
4
4
|
import { formatTextContents } from '../../utils/content.js';
|
|
5
|
-
import {
|
|
5
|
+
import { getToolErrorMessage } from '../../utils/errors.js';
|
|
6
6
|
import { absoluteCurrentWorkingDirectory, absoluteProjectPath, account, } from './constants.js';
|
|
7
7
|
import { setupHubSpotConfig } from '../../utils/config.js';
|
|
8
8
|
import { resolveAccountId } from './resolveAccount.js';
|
|
9
|
-
import { getErrorMessage } from '../../../lib/errorHandlers/index.js';
|
|
10
9
|
import { elicitSelection } from '../../utils/elicitSelection.js';
|
|
11
10
|
import { getApps } from './apps.js';
|
|
12
11
|
const inputSchema = {
|
|
@@ -83,11 +82,7 @@ export class GetApiUsagePatternsByAppIdTool extends Tool {
|
|
|
83
82
|
message: 'Handler caught error',
|
|
84
83
|
error: error instanceof Error ? error.message : String(error),
|
|
85
84
|
});
|
|
86
|
-
|
|
87
|
-
// Handle HubSpot-specific HTTP errors
|
|
88
|
-
return formatTextContents(error.toString());
|
|
89
|
-
}
|
|
90
|
-
return formatTextContents(getErrorMessage(error));
|
|
85
|
+
return formatTextContents(getToolErrorMessage(error));
|
|
91
86
|
}
|
|
92
87
|
}
|
|
93
88
|
register() {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { Tool } from '../../Tool.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { formatTextContents } from '../../utils/content.js';
|
|
4
|
-
import {
|
|
4
|
+
import { getToolErrorMessage } from '../../utils/errors.js';
|
|
5
5
|
import { absoluteCurrentWorkingDirectory, absoluteProjectPath, account, } from './constants.js';
|
|
6
6
|
import { setupHubSpotConfig } from '../../utils/config.js';
|
|
7
7
|
import { resolveAccountId } from './resolveAccount.js';
|
|
8
|
-
import { getErrorMessage } from '../../../lib/errorHandlers/index.js';
|
|
9
8
|
import { getApps } from './apps.js';
|
|
10
9
|
const inputSchema = {
|
|
11
10
|
absoluteCurrentWorkingDirectory,
|
|
@@ -39,11 +38,7 @@ export class GetApplicationInfoTool extends Tool {
|
|
|
39
38
|
message: 'Handler caught error',
|
|
40
39
|
error: error instanceof Error ? error.message : String(error),
|
|
41
40
|
});
|
|
42
|
-
|
|
43
|
-
// Handle HubSpot-specific HTTP errors
|
|
44
|
-
return formatTextContents(error.toString());
|
|
45
|
-
}
|
|
46
|
-
return formatTextContents(getErrorMessage(error));
|
|
41
|
+
return formatTextContents(getToolErrorMessage(error));
|
|
47
42
|
}
|
|
48
43
|
}
|
|
49
44
|
register() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Tool } from '../../Tool.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { formatTextContents } from '../../utils/content.js';
|
|
4
|
-
import {
|
|
4
|
+
import { getToolErrorMessage } from '../../utils/errors.js';
|
|
5
5
|
import { http } from '@hubspot/local-dev-lib/http';
|
|
6
6
|
import { getProjectConfig } from '../../../lib/projects/config.js';
|
|
7
7
|
import { absoluteCurrentWorkingDirectory, absoluteProjectPath, account, } from './constants.js';
|
|
@@ -104,17 +104,7 @@ export class GetBuildLogsTool extends Tool {
|
|
|
104
104
|
message: 'Handler caught error',
|
|
105
105
|
error: error instanceof Error ? error.message : String(error),
|
|
106
106
|
});
|
|
107
|
-
|
|
108
|
-
if (isHubSpotHttpError(error)) {
|
|
109
|
-
errorMessage = error.toString();
|
|
110
|
-
}
|
|
111
|
-
else if (error instanceof Error) {
|
|
112
|
-
errorMessage = error.message;
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
errorMessage = String(error);
|
|
116
|
-
}
|
|
117
|
-
return formatTextContents(absoluteCurrentWorkingDirectory, errorMessage);
|
|
107
|
+
return formatTextContents(absoluteCurrentWorkingDirectory, getToolErrorMessage(error));
|
|
118
108
|
}
|
|
119
109
|
}
|
|
120
110
|
register() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Tool } from '../../Tool.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { formatTextContents } from '../../utils/content.js';
|
|
4
|
-
import {
|
|
4
|
+
import { getToolErrorMessage } from '../../utils/errors.js';
|
|
5
5
|
import { fetchProjectBuilds, getBuildStatus, } from '@hubspot/local-dev-lib/api/projects';
|
|
6
6
|
import { getProjectConfig } from '../../../lib/projects/config.js';
|
|
7
7
|
import moment from 'moment';
|
|
@@ -145,17 +145,7 @@ export class GetBuildStatusTool extends Tool {
|
|
|
145
145
|
message: 'Handler caught error',
|
|
146
146
|
error: error instanceof Error ? error.message : String(error),
|
|
147
147
|
});
|
|
148
|
-
|
|
149
|
-
if (isHubSpotHttpError(error)) {
|
|
150
|
-
errorMessage = error.toString();
|
|
151
|
-
}
|
|
152
|
-
else if (error instanceof Error) {
|
|
153
|
-
errorMessage = error.message;
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
errorMessage = String(error);
|
|
157
|
-
}
|
|
158
|
-
return formatTextContents(absoluteCurrentWorkingDirectory, errorMessage);
|
|
148
|
+
return formatTextContents(absoluteCurrentWorkingDirectory, getToolErrorMessage(error));
|
|
159
149
|
}
|
|
160
150
|
}
|
|
161
151
|
register() {
|
|
@@ -2,8 +2,8 @@ import { http } from '@hubspot/local-dev-lib/http/unauthed';
|
|
|
2
2
|
import z from 'zod';
|
|
3
3
|
import { Tool } from '../../Tool.js';
|
|
4
4
|
import { formatTextContents } from '../../utils/content.js';
|
|
5
|
+
import { getToolErrorMessage } from '../../utils/errors.js';
|
|
5
6
|
import { absoluteCurrentWorkingDirectory, knowledgeSearchQuery, } from './constants.js';
|
|
6
|
-
import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
|
|
7
7
|
import { setupHubSpotConfig } from '../../utils/config.js';
|
|
8
8
|
import { getErrorMessage } from '../../../lib/errorHandlers/index.js';
|
|
9
9
|
const knowledgeSearchLimit = z
|
|
@@ -61,10 +61,7 @@ export class KnowledgeSearchTool extends Tool {
|
|
|
61
61
|
message: 'Handler caught error',
|
|
62
62
|
error: getErrorMessage(error),
|
|
63
63
|
});
|
|
64
|
-
|
|
65
|
-
return formatTextContents(error.toString());
|
|
66
|
-
}
|
|
67
|
-
const errorMessage = `Error searching the knowledge base: ${getErrorMessage(error)}`;
|
|
64
|
+
const errorMessage = `Error searching the knowledge base: ${getToolErrorMessage(error)}`;
|
|
68
65
|
return formatTextContents(errorMessage);
|
|
69
66
|
}
|
|
70
67
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
2
|
import { Tool } from '../../Tool.js';
|
|
3
3
|
import { formatTextContents } from '../../utils/content.js';
|
|
4
|
+
import { getToolErrorMessage } from '../../utils/errors.js';
|
|
4
5
|
import { setupHubSpotConfig } from '../../utils/config.js';
|
|
5
6
|
import { absoluteCurrentWorkingDirectory, account } from './constants.js';
|
|
6
7
|
import { resolveAccountId } from './resolveAccount.js';
|
|
@@ -53,7 +54,7 @@ export class SubmitFeedbackTool extends Tool {
|
|
|
53
54
|
message: 'Handler caught error',
|
|
54
55
|
error: getErrorMessage(error),
|
|
55
56
|
});
|
|
56
|
-
return formatTextContents(`Error sending feedback: ${
|
|
57
|
+
return formatTextContents(`Error sending feedback: ${getToolErrorMessage(error)}`);
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
register() {
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import util from 'util';
|
|
4
|
-
import { exec
|
|
4
|
+
import { exec } from 'node:child_process';
|
|
5
|
+
import { crossPlatformSpawn } from '../../lib/crossPlatformSpawn/index.js';
|
|
6
|
+
import { lib } from '../../lang/en.js';
|
|
7
|
+
function formatFlag({ name, value }) {
|
|
8
|
+
const flag = `--${name}`;
|
|
9
|
+
const values = (Array.isArray(value) ? value : [value]).map(String);
|
|
10
|
+
if (values.some(item => item.startsWith('-'))) {
|
|
11
|
+
return values.map(item => `${flag}=${item}`);
|
|
12
|
+
}
|
|
13
|
+
return [flag, ...values];
|
|
14
|
+
}
|
|
5
15
|
export class HubSpotCommand {
|
|
6
16
|
executable = 'hs';
|
|
7
17
|
subcommandArgs;
|
|
@@ -13,6 +23,9 @@ export class HubSpotCommand {
|
|
|
13
23
|
this.flags = [...flags];
|
|
14
24
|
}
|
|
15
25
|
addArg(value) {
|
|
26
|
+
if (value.startsWith('-')) {
|
|
27
|
+
throw new Error(lib.hubSpotCommand.argStartsWithDash(value));
|
|
28
|
+
}
|
|
16
29
|
this.positionalArgs.push(value);
|
|
17
30
|
return this;
|
|
18
31
|
}
|
|
@@ -24,9 +37,7 @@ export class HubSpotCommand {
|
|
|
24
37
|
return [
|
|
25
38
|
...this.subcommandArgs,
|
|
26
39
|
...this.positionalArgs,
|
|
27
|
-
...this.flags.flatMap(
|
|
28
|
-
? [`--${name}`, ...value.map(String)]
|
|
29
|
-
: [`--${name}`, String(value)]),
|
|
40
|
+
...this.flags.flatMap(formatFlag),
|
|
30
41
|
];
|
|
31
42
|
}
|
|
32
43
|
}
|
|
@@ -64,7 +75,7 @@ export async function runCommandInDir(directory, command, onData) {
|
|
|
64
75
|
return new Promise((resolve, reject) => {
|
|
65
76
|
const stdoutChunks = [];
|
|
66
77
|
const stderrChunks = [];
|
|
67
|
-
const child =
|
|
78
|
+
const child = crossPlatformSpawn(finalCommand.executable, finalCommand.args, {
|
|
68
79
|
cwd: resolvedDir,
|
|
69
80
|
env: { ...process.env, INIT_CWD: resolvedDir },
|
|
70
81
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getToolErrorMessage(error: unknown): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
|
|
2
|
+
import { getErrorMessage } from '../../lib/errorHandlers/index.js';
|
|
3
|
+
import { getConfigCredentials } from '../../lib/accountCredentials.js';
|
|
4
|
+
export function getToolErrorMessage(error) {
|
|
5
|
+
const message = isHubSpotHttpError(error)
|
|
6
|
+
? error.toString()
|
|
7
|
+
: getErrorMessage(error);
|
|
8
|
+
return getConfigCredentials().reduce((redactedMessage, credential) => redactedMessage.replaceAll(credential, '[redacted]'), message);
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cli",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.19.0-beta.0",
|
|
4
4
|
"description": "The official CLI for developing on HubSpot",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": "https://github.com/HubSpot/hubspot-cli",
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
"!**/__tests__/**"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@hubspot/local-dev-lib": "5.14.
|
|
13
|
+
"@hubspot/local-dev-lib": "5.14.1",
|
|
14
14
|
"@hubspot/project-parsing-lib": "0.23.7",
|
|
15
15
|
"@hubspot/ui-extensions-dev-server": "2.2.5",
|
|
16
16
|
"@inquirer/prompts": "7.10.1",
|
|
17
|
-
"@modelcontextprotocol/sdk": "1.32.
|
|
17
|
+
"@modelcontextprotocol/sdk": "1.32.2",
|
|
18
18
|
"archiver": "7.0.1",
|
|
19
19
|
"chalk": "5.6.2",
|
|
20
20
|
"chokidar": "4.0.3",
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
"moment": "2.31.0",
|
|
31
31
|
"open": "7.4.2",
|
|
32
32
|
"p-queue": "8.1.1",
|
|
33
|
-
"react": "19.3.
|
|
34
|
-
"semver": "7.8.
|
|
33
|
+
"react": "19.3.1",
|
|
34
|
+
"semver": "7.8.6",
|
|
35
35
|
"strip-ansi": "7.2.0",
|
|
36
|
-
"table": "6.
|
|
36
|
+
"table": "6.10.1",
|
|
37
37
|
"tmp": "0.2.7",
|
|
38
38
|
"update-notifier": "7.3.1",
|
|
39
|
-
"ws": "8.22.
|
|
39
|
+
"ws": "8.22.2",
|
|
40
40
|
"yargs": "17.7.3",
|
|
41
41
|
"yargs-parser": "21.1.1",
|
|
42
42
|
"zod": "^4.4.3"
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@typescript-eslint/eslint-plugin": "^8.30.1",
|
|
59
59
|
"@typescript-eslint/parser": "^8.11.0",
|
|
60
60
|
"@vitest/coverage-v8": "^4.1.11",
|
|
61
|
-
"axios": "1.
|
|
61
|
+
"axios": "1.21.1",
|
|
62
62
|
"eslint": "^8.56.0",
|
|
63
63
|
"eslint-plugin-import": "^2.31.0",
|
|
64
64
|
"husky": "^4.3.8",
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
"eslint-visitor-keys": "4.2.0",
|
|
125
125
|
"@eslint-community/eslint-utils": "4.9.0",
|
|
126
126
|
"@opentelemetry/core": "2.10.0",
|
|
127
|
-
"axios": "1.
|
|
127
|
+
"axios": "1.21.1",
|
|
128
128
|
"vite": "6.4.3"
|
|
129
129
|
}
|
|
130
130
|
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { McpToolResponse } from '../../types.js';
|
|
2
|
-
import { Tool, ToolExtra } from '../../Tool.js';
|
|
3
|
-
import { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
|
-
import { McpLogger } from '../../utils/logger.js';
|
|
5
|
-
import { z } from 'zod';
|
|
6
|
-
declare const inputSchemaZodObject: z.ZodObject<{
|
|
7
|
-
absoluteCurrentWorkingDirectory: z.ZodString;
|
|
8
|
-
dest: z.ZodOptional<z.ZodString>;
|
|
9
|
-
functionsFolder: z.ZodOptional<z.ZodString>;
|
|
10
|
-
filename: z.ZodOptional<z.ZodString>;
|
|
11
|
-
endpointMethod: z.ZodOptional<z.ZodEnum<{
|
|
12
|
-
GET: "GET";
|
|
13
|
-
DELETE: "DELETE";
|
|
14
|
-
POST: "POST";
|
|
15
|
-
PUT: "PUT";
|
|
16
|
-
PATCH: "PATCH";
|
|
17
|
-
}>>;
|
|
18
|
-
endpointPath: z.ZodOptional<z.ZodString>;
|
|
19
|
-
}, z.core.$strip>;
|
|
20
|
-
export type HsCreateFunctionInputSchema = z.infer<typeof inputSchemaZodObject>;
|
|
21
|
-
export declare class HsCreateFunctionTool extends Tool<HsCreateFunctionInputSchema> {
|
|
22
|
-
constructor(mcpServer: McpServer, logger: McpLogger);
|
|
23
|
-
handler({ dest, functionsFolder, filename, endpointMethod, endpointPath, absoluteCurrentWorkingDirectory, }: HsCreateFunctionInputSchema, extra?: ToolExtra): Promise<McpToolResponse>;
|
|
24
|
-
register(): RegisteredTool;
|
|
25
|
-
}
|
|
26
|
-
export {};
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { Tool } from '../../Tool.js';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { absoluteCurrentWorkingDirectory } from '../project/constants.js';
|
|
4
|
-
import { formatTextContents, formatTextContent } from '../../utils/content.js';
|
|
5
|
-
import { HTTP_METHODS } from '../../../types/Cms.js';
|
|
6
|
-
import { HubSpotCommand } from '../../utils/command.js';
|
|
7
|
-
import { setupHubSpotConfig } from '../../utils/config.js';
|
|
8
|
-
import { getErrorMessage } from '../../../lib/errorHandlers/index.js';
|
|
9
|
-
const inputSchema = {
|
|
10
|
-
absoluteCurrentWorkingDirectory,
|
|
11
|
-
dest: z
|
|
12
|
-
.string()
|
|
13
|
-
.describe('The destination path where the function should be created on the current computer.')
|
|
14
|
-
.optional(),
|
|
15
|
-
functionsFolder: z
|
|
16
|
-
.string()
|
|
17
|
-
.describe('Folder name for function creation. Required for non-interactive function creation. If the user has not specified the folder name, ask them to provide it.')
|
|
18
|
-
.optional(),
|
|
19
|
-
filename: z
|
|
20
|
-
.string()
|
|
21
|
-
.describe('Function filename. Required for non-interactive function creation. If the user has not specified the filename, ask them to provide it.')
|
|
22
|
-
.optional(),
|
|
23
|
-
endpointMethod: z
|
|
24
|
-
.enum(HTTP_METHODS)
|
|
25
|
-
.describe(`HTTP method for the function endpoint. Must be one of: ${HTTP_METHODS.join(', ')}. Defaults to GET.`)
|
|
26
|
-
.optional(),
|
|
27
|
-
endpointPath: z
|
|
28
|
-
.string()
|
|
29
|
-
.describe('API endpoint path for the function. Required for non-interactive function creation. If the user has not specified the endpoint path, ask them to provide it.')
|
|
30
|
-
.optional(),
|
|
31
|
-
};
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
33
|
-
const inputSchemaZodObject = z.object({ ...inputSchema });
|
|
34
|
-
const toolName = 'create-cms-function';
|
|
35
|
-
export class HsCreateFunctionTool extends Tool {
|
|
36
|
-
constructor(mcpServer, logger) {
|
|
37
|
-
super(mcpServer, logger, toolName);
|
|
38
|
-
}
|
|
39
|
-
async handler({ dest, functionsFolder, filename, endpointMethod, endpointPath, absoluteCurrentWorkingDirectory, }, extra) {
|
|
40
|
-
setupHubSpotConfig(absoluteCurrentWorkingDirectory);
|
|
41
|
-
const content = [];
|
|
42
|
-
// Require functions folder
|
|
43
|
-
if (!functionsFolder) {
|
|
44
|
-
content.push(formatTextContent(`Ask the user to provide the folder name for the function.`));
|
|
45
|
-
}
|
|
46
|
-
// Require filename
|
|
47
|
-
if (!filename) {
|
|
48
|
-
content.push(formatTextContent(`Ask the user to provide the filename for the function.`));
|
|
49
|
-
}
|
|
50
|
-
// Require endpoint path
|
|
51
|
-
if (!endpointPath) {
|
|
52
|
-
content.push(formatTextContent(`Ask the user to provide the API endpoint path for the function.`));
|
|
53
|
-
}
|
|
54
|
-
// If we have missing required information, return the prompts
|
|
55
|
-
if (content.length > 0) {
|
|
56
|
-
return {
|
|
57
|
-
content,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
// Build the command
|
|
61
|
-
const command = new HubSpotCommand('cms function create');
|
|
62
|
-
if (dest) {
|
|
63
|
-
command.addArg(dest);
|
|
64
|
-
}
|
|
65
|
-
if (functionsFolder) {
|
|
66
|
-
command.addFlag('functions-folder', functionsFolder);
|
|
67
|
-
}
|
|
68
|
-
if (filename) {
|
|
69
|
-
command.addFlag('filename', filename);
|
|
70
|
-
}
|
|
71
|
-
command.addFlag('endpoint-method', endpointMethod ?? 'GET');
|
|
72
|
-
if (endpointPath) {
|
|
73
|
-
command.addFlag('endpoint-path', endpointPath);
|
|
74
|
-
}
|
|
75
|
-
try {
|
|
76
|
-
const { stdout, stderr } = await this.runCommand(absoluteCurrentWorkingDirectory, command, extra);
|
|
77
|
-
return formatTextContents(stdout, stderr);
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
this.logger.debug(toolName, {
|
|
81
|
-
message: 'Handler caught error',
|
|
82
|
-
error: error instanceof Error ? error.message : String(error),
|
|
83
|
-
});
|
|
84
|
-
return formatTextContents(getErrorMessage(error));
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
register() {
|
|
88
|
-
return this.mcpServer.registerTool(toolName, {
|
|
89
|
-
title: 'Create HubSpot CMS Serverless Function',
|
|
90
|
-
description: `Creates a new HubSpot CMS serverless function using the hs cms function create command. This is for CMS/website projects, served at /hs/serverless/<path>. Do NOT use this for developer-platform app functions (the private app-function feature or the public app-function-endpoint feature). For those, use add-feature-to-project. Functions can be created non-interactively by specifying functionsFolder, filename, and endpointPath. Supports all HTTP methods (${HTTP_METHODS.join(', ')}).`,
|
|
91
|
-
inputSchema,
|
|
92
|
-
annotations: {
|
|
93
|
-
readOnlyHint: false,
|
|
94
|
-
destructiveHint: false,
|
|
95
|
-
idempotentHint: false,
|
|
96
|
-
openWorldHint: false,
|
|
97
|
-
},
|
|
98
|
-
}, (input, extra) => this.wrappedHandler(input, extra));
|
|
99
|
-
}
|
|
100
|
-
}
|