@hubspot/cli 8.17.0 → 8.18.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.
@@ -0,0 +1,10 @@
1
+ import { HubSpotPromise } from '@hubspot/local-dev-lib/types/Http';
2
+ export declare const FEEDBACK_SOURCES: readonly ["user", "agent"];
3
+ export type FeedbackSource = (typeof FEEDBACK_SOURCES)[number];
4
+ type FeedbackRequest = {
5
+ feedback: string;
6
+ source: FeedbackSource;
7
+ cliVersion: string;
8
+ };
9
+ export declare function sendFeedback(accountId: number, request: FeedbackRequest): HubSpotPromise<void>;
10
+ export {};
@@ -0,0 +1,9 @@
1
+ import { http } from '@hubspot/local-dev-lib/http';
2
+ const FEEDBACK_API_PATH = 'local/dev/tools/proxy/v1/feedback';
3
+ export const FEEDBACK_SOURCES = ['user', 'agent'];
4
+ export function sendFeedback(accountId, request) {
5
+ return http.post(accountId, {
6
+ url: FEEDBACK_API_PATH,
7
+ data: request,
8
+ });
9
+ }
@@ -1,4 +1,8 @@
1
- import { CommonArgs, YargsCommandModule } from '../types/Yargs.js';
2
- type FeedbackArgs = CommonArgs;
1
+ import { AccountArgs, CommonArgs, ConfigArgs, EnvironmentArgs, YargsCommandModule } from '../types/Yargs.js';
2
+ import { FeedbackSource } from '../api/feedback.js';
3
+ type FeedbackArgs = CommonArgs & ConfigArgs & AccountArgs & EnvironmentArgs & {
4
+ message?: string;
5
+ source: FeedbackSource;
6
+ };
3
7
  declare const feedbackCommand: YargsCommandModule<unknown, FeedbackArgs>;
4
8
  export default feedbackCommand;
@@ -5,25 +5,99 @@ import { makeYargsBuilder } from '../lib/yargsUtils.js';
5
5
  import { EXIT_CODES } from '../lib/enums/exitCodes.js';
6
6
  import { commands } from '../lang/en.js';
7
7
  import { uiLogger } from '../lib/ui/logger.js';
8
- import { FEEDBACK_URL } from '../lib/constants.js';
8
+ import { ApiErrorContext, logError } from '../lib/errorHandlers/index.js';
9
+ import { FEEDBACK_SOURCE_ENV_VAR, FEEDBACK_URL, MAX_FEEDBACK_LENGTH, } from '../lib/constants.js';
10
+ import { FEEDBACK_SOURCES } from '../api/feedback.js';
11
+ import { containsAccountCredentials, submitFeedback } from '../lib/feedback.js';
9
12
  const command = 'feedback';
10
13
  const describe = commands.project.feedback.describe;
11
14
  async function handler(args) {
12
- const { exit } = args;
13
- const shouldOpen = await confirmPrompt(commands.project.feedback.openPrompt);
14
- if (!shouldOpen) {
15
- uiLogger.log(commands.project.feedback.error(FEEDBACK_URL));
15
+ const { message, source, derivedAccountId, addUsageMetadata, exit } = args;
16
+ if (message === undefined) {
17
+ if (!process.stdin.isTTY) {
18
+ uiLogger.log(commands.project.feedback.nonInteractive(FEEDBACK_URL));
19
+ return exit(EXIT_CODES.SUCCESS);
20
+ }
21
+ const shouldOpen = await confirmPrompt(commands.project.feedback.openPrompt);
22
+ if (!shouldOpen) {
23
+ uiLogger.log(commands.project.feedback.error(FEEDBACK_URL));
24
+ return exit(EXIT_CODES.SUCCESS);
25
+ }
26
+ addUsageMetadata({ action: 'open-form' });
27
+ open(FEEDBACK_URL, { url: true });
28
+ uiLogger.success(commands.project.feedback.success(FEEDBACK_URL));
16
29
  return exit(EXIT_CODES.SUCCESS);
17
30
  }
18
- open(FEEDBACK_URL, { url: true });
19
- uiLogger.success(commands.project.feedback.success(FEEDBACK_URL));
31
+ addUsageMetadata({ action: 'submit', type: source });
32
+ const feedback = message.trim();
33
+ if (!feedback) {
34
+ uiLogger.error(commands.project.feedback.errors.blankMessage);
35
+ return exit(EXIT_CODES.ERROR);
36
+ }
37
+ if (feedback.length > MAX_FEEDBACK_LENGTH) {
38
+ uiLogger.error(commands.project.feedback.errors.messageTooLong(feedback.length));
39
+ return exit(EXIT_CODES.ERROR);
40
+ }
41
+ if (!derivedAccountId) {
42
+ uiLogger.error(commands.project.feedback.errors.noAccount);
43
+ return exit(EXIT_CODES.ERROR);
44
+ }
45
+ if (containsAccountCredentials(feedback)) {
46
+ uiLogger.error(commands.project.feedback.errors.containsCredentials);
47
+ return exit(EXIT_CODES.ERROR);
48
+ }
49
+ try {
50
+ await submitFeedback(derivedAccountId, feedback, source);
51
+ }
52
+ catch (error) {
53
+ uiLogger.error(commands.project.feedback.errors.submitFailed);
54
+ logError(error, new ApiErrorContext({
55
+ accountId: derivedAccountId,
56
+ request: 'submit feedback',
57
+ }));
58
+ return exit(EXIT_CODES.ERROR);
59
+ }
60
+ uiLogger.success(commands.project.feedback.submitSuccess);
20
61
  return exit(EXIT_CODES.SUCCESS);
21
62
  }
22
63
  function feedbackBuilder(yargs) {
64
+ yargs.options({
65
+ message: {
66
+ alias: 'm',
67
+ describe: commands.project.feedback.options.message.describe,
68
+ type: 'string',
69
+ },
70
+ source: {
71
+ describe: commands.project.feedback.options.source.describe,
72
+ type: 'string',
73
+ choices: FEEDBACK_SOURCES,
74
+ default: process.env[FEEDBACK_SOURCE_ENV_VAR]?.trim().toLowerCase() || undefined,
75
+ },
76
+ });
77
+ yargs.check(argv => {
78
+ if (argv.message !== undefined && !argv.source) {
79
+ throw new Error(commands.project.feedback.errors.sourceRequired);
80
+ }
81
+ return true;
82
+ });
83
+ yargs.example([
84
+ ['$0 feedback', commands.project.feedback.examples.openForm],
85
+ [
86
+ '$0 feedback --message "<message>" --source=user',
87
+ commands.project.feedback.examples.submit,
88
+ ],
89
+ [
90
+ '$0 feedback --message "<message>" --source=agent',
91
+ commands.project.feedback.examples.submitAsAgent,
92
+ ],
93
+ ]);
23
94
  return yargs;
24
95
  }
25
- const builder = makeYargsBuilder(feedbackBuilder, command, describe, {
96
+ const builder = makeYargsBuilder(feedbackBuilder, command, commands.project.feedback.verboseDescribe, {
26
97
  useGlobalOptions: true,
98
+ useConfigOptions: true,
99
+ useAccountOptions: true,
100
+ useEnvironmentOptions: true,
27
101
  });
28
102
  const feedbackCommand = {
29
103
  command,
package/lang/en.d.ts CHANGED
@@ -2071,9 +2071,33 @@ export declare const commands: {
2071
2071
  };
2072
2072
  feedback: {
2073
2073
  describe: string;
2074
+ verboseDescribe: string;
2075
+ options: {
2076
+ message: {
2077
+ describe: string;
2078
+ };
2079
+ source: {
2080
+ describe: string;
2081
+ };
2082
+ };
2083
+ examples: {
2084
+ openForm: string;
2085
+ submit: string;
2086
+ submitAsAgent: string;
2087
+ };
2074
2088
  openPrompt: string;
2075
2089
  success: (url: string) => string;
2076
2090
  error: (url: string) => string;
2091
+ nonInteractive: (url: string) => string;
2092
+ submitSuccess: string;
2093
+ errors: {
2094
+ blankMessage: string;
2095
+ messageTooLong: (length: number) => string;
2096
+ containsCredentials: string;
2097
+ sourceRequired: string;
2098
+ noAccount: string;
2099
+ submitFailed: string;
2100
+ };
2077
2101
  };
2078
2102
  installDeps: {
2079
2103
  help: {
package/lang/en.js CHANGED
@@ -2,7 +2,7 @@ import chalk from 'chalk';
2
2
  import { mapToUserFriendlyName } from '@hubspot/project-parsing-lib/transform';
3
3
  import { PLATFORM_VERSIONS } from '@hubspot/project-parsing-lib/constants';
4
4
  import { PERSONAL_ACCESS_KEY_AUTH_METHOD } from '@hubspot/local-dev-lib/constants/auth';
5
- import { APP_AUTH_TYPES, APP_DISTRIBUTION_TYPES, CLI_SUPPORT_GUIDELINES_URL, LEGACY_PUBLIC_APP_FILE, LOCAL_DEV_DEFAULT_PORT, PROJECT_CONFIG_FILE, PROJECT_WITH_APP, } from '../lib/constants.js';
5
+ import { APP_AUTH_TYPES, APP_DISTRIBUTION_TYPES, CLI_SUPPORT_GUIDELINES_URL, FEEDBACK_SOURCE_ENV_VAR, LEGACY_PUBLIC_APP_FILE, LOCAL_DEV_DEFAULT_PORT, MAX_FEEDBACK_LENGTH, PROJECT_CONFIG_FILE, PROJECT_WITH_APP, } from '../lib/constants.js';
6
6
  import { ARCHIVED_HUBSPOT_CONFIG_YAML_FILE_NAME, DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME, GLOBAL_CONFIG_PATH, } from '@hubspot/local-dev-lib/constants/config';
7
7
  import { indent, UI_COLORS, uiAccountDescription, uiAuthCommandReference, uiBetaTag, uiCommandReference, uiDeprecatedTag, uiLink, } from '../lib/ui/index.js';
8
8
  import { getLocalDevUiUrl, getProjectDetailUrl, getProjectSettingsUrl, } from '../lib/projects/urls.js';
@@ -1952,7 +1952,7 @@ export const commands = {
1952
1952
  runCommand: (command) => `Run \`${uiCommandReference(command)}\``,
1953
1953
  autoDeployDisabled: (deployCommand) => `Automatic deploys are disabled for this project. Run ${uiCommandReference(deployCommand)} to deploy this build.`,
1954
1954
  autoDeploySkipped: (deployCommand) => `Auto-deploy was skipped for this build. Run ${uiCommandReference(deployCommand)} to deploy this build.`,
1955
- releaseManagementRequired: (releaseCommand) => `This build is not live yet. Run ${uiCommandReference(releaseCommand)} to make it live.`,
1955
+ releaseManagementRequired: (releaseCommand) => `This build is not live yet. Run ${uiCommandReference(releaseCommand)} to release it. Apps then go live when you roll the release out in the projects UI.`,
1956
1956
  uploadingWithProfile: (profileName, accountId) => `Initializing project upload with ${chalk.bold(profileName)} profile: ${uiAccountDescription(accountId)}`,
1957
1957
  uploadingToAccount: (accountId) => `Initializing project upload to account ${uiAccountDescription(accountId)}`,
1958
1958
  uploadedToAccount: (accountId) => `Project uploaded to ${uiAccountDescription(accountId)}`,
@@ -2098,9 +2098,33 @@ export const commands = {
2098
2098
  },
2099
2099
  feedback: {
2100
2100
  describe: 'Leave feedback or file a bug report.',
2101
+ verboseDescribe: `Leave feedback or file a bug report.\n\nPass ${uiCommandReference('--message')} to send feedback from the terminal. Run ${uiCommandReference('hs feedback')} without it to open the feedback form in your browser instead.\n\nThe feedback includes your account ID, your user ID, and the CLI version.`,
2102
+ options: {
2103
+ message: {
2104
+ describe: 'Feedback to send. If omitted, opens the feedback form in your browser.',
2105
+ },
2106
+ source: {
2107
+ describe: `Who is sending the feedback. Required with ${uiCommandReference('--message')} unless the ${FEEDBACK_SOURCE_ENV_VAR} environment variable is set.`,
2108
+ },
2109
+ },
2110
+ examples: {
2111
+ openForm: 'Open the feedback form in your browser',
2112
+ submit: 'Send feedback from the terminal',
2113
+ submitAsAgent: 'Send feedback on behalf of an AI agent',
2114
+ },
2101
2115
  openPrompt: 'Open the feedback form in your browser?',
2102
2116
  success: (url) => `We opened ${uiLink('the developer feedback form', url)} in your browser.`,
2103
2117
  error: (url) => `Navigate to ${uiLink('the developer feedback form', url)} to leave feedback.`,
2118
+ nonInteractive: (url) => `To send feedback from the terminal, run ${uiCommandReference('hs feedback --message "<message>" --source <user|agent>')}. To use the browser instead, navigate to ${uiLink('the developer feedback form', url)}.`,
2119
+ submitSuccess: 'Your feedback has been successfully submitted. Thank you.',
2120
+ errors: {
2121
+ blankMessage: `Feedback cannot be blank. Pass your feedback with ${uiCommandReference('hs feedback --message "<message>" --source <user|agent>')}.`,
2122
+ messageTooLong: (length) => `Feedback must be ${MAX_FEEDBACK_LENGTH} characters or fewer. Your message has ${length} characters.`,
2123
+ containsCredentials: 'Feedback cannot contain an access key, token, or secret from your HubSpot config. Remove it, then try again.',
2124
+ sourceRequired: `${uiCommandReference('--message')} requires ${uiCommandReference('--source')}. Pass ${uiCommandReference('--source user')} if you are a person, or ${uiCommandReference('--source agent')} if you are an AI agent.`,
2125
+ noAccount: `To send feedback from the terminal, authenticate an account with ${uiCommandReference('hs account auth')}. To use the feedback form instead, run ${uiCommandReference('hs feedback')} without ${uiCommandReference('--message')}.`,
2126
+ submitFailed: `Could not send your feedback. To use the feedback form instead, run ${uiCommandReference('hs feedback')} without ${uiCommandReference('--message')}.`,
2127
+ },
2104
2128
  },
2105
2129
  installDeps: {
2106
2130
  help: {
@@ -3465,6 +3489,7 @@ export const lib = {
3465
3489
  'Color: To remove color from the output, pass `--no-color` or set `NO_COLOR`.',
3466
3490
  'Debug logs: To print debug logs, pass `--debug`.',
3467
3491
  'MCP server: To connect the HubSpot Dev MCP server to an AI coding tool, run `hs mcp setup`.',
3492
+ 'Feedback: To send feedback about the CLI, run `hs feedback --message "<message>" --source agent`. Send one short line about a bug, a missing command or flag, or anything that confused the user. Keep it about the CLI. Do not include secrets, access keys, file contents, or personal data. Then continue with the task.',
3468
3493
  ],
3469
3494
  jsonOutput: {
3470
3495
  schema: 'With `--json`, the command prints one JSON object to stdout. The object matches this JSON Schema:',
@@ -0,0 +1 @@
1
+ export declare function getConfigCredentials(): string[];
@@ -0,0 +1,25 @@
1
+ import { getAllConfigAccounts } from '@hubspot/local-dev-lib/config';
2
+ import { API_KEY_AUTH_METHOD, OAUTH_AUTH_METHOD, PERSONAL_ACCESS_KEY_AUTH_METHOD, } from '@hubspot/local-dev-lib/constants/auth';
3
+ function getAccountCredentials(account) {
4
+ if (account.authType === API_KEY_AUTH_METHOD.value) {
5
+ return [account.apiKey];
6
+ }
7
+ const { accessToken, refreshToken } = account.auth?.tokenInfo ?? {};
8
+ if (account.authType === PERSONAL_ACCESS_KEY_AUTH_METHOD.value) {
9
+ return [account.personalAccessKey, accessToken, refreshToken];
10
+ }
11
+ if (account.authType === OAUTH_AUTH_METHOD.value) {
12
+ return [account.auth.clientSecret, accessToken, refreshToken];
13
+ }
14
+ return [accessToken, refreshToken];
15
+ }
16
+ export function getConfigCredentials() {
17
+ try {
18
+ return getAllConfigAccounts()
19
+ .flatMap(getAccountCredentials)
20
+ .filter((credential) => Boolean(credential));
21
+ }
22
+ catch {
23
+ return [];
24
+ }
25
+ }
@@ -160,4 +160,6 @@ export declare const ACCOUNT_LEVELS: {
160
160
  };
161
161
  export declare const ACCOUNT_LEVEL_CHOICES: readonly ["FREE", "STARTER", "PROFESSIONAL", "ENTERPRISE"];
162
162
  export declare const FEEDBACK_URL = "https://developers.hubspot.com/feedback";
163
+ export declare const FEEDBACK_SOURCE_ENV_VAR = "HUBSPOT_FEEDBACK_SOURCE";
164
+ export declare const MAX_FEEDBACK_LENGTH = 5000;
163
165
  export declare const LOCAL_DEV_DEFAULT_PORT = 4828;
package/lib/constants.js CHANGED
@@ -166,6 +166,8 @@ export const ACCOUNT_LEVEL_CHOICES = [
166
166
  ACCOUNT_LEVELS.ENTERPRISE,
167
167
  ];
168
168
  export const FEEDBACK_URL = 'https://developers.hubspot.com/feedback';
169
+ export const FEEDBACK_SOURCE_ENV_VAR = 'HUBSPOT_FEEDBACK_SOURCE';
170
+ export const MAX_FEEDBACK_LENGTH = 5000;
169
171
  // TODO: remove this constant and use PORT_MANAGER_SERVER_PORT from
170
172
  // @hubspot/local-dev-lib once LDL changes its default to 4828.
171
173
  export const LOCAL_DEV_DEFAULT_PORT = 4828;
@@ -0,0 +1,3 @@
1
+ import { FeedbackSource } from '../api/feedback.js';
2
+ export declare function containsAccountCredentials(feedback: string): boolean;
3
+ export declare function submitFeedback(accountId: number, feedback: string, source: FeedbackSource): Promise<void>;
@@ -0,0 +1,13 @@
1
+ import { sendFeedback } from '../api/feedback.js';
2
+ import { getConfigCredentials } from './accountCredentials.js';
3
+ import { pkg } from './jsonLoader.js';
4
+ export function containsAccountCredentials(feedback) {
5
+ return getConfigCredentials().some(credential => feedback.includes(credential));
6
+ }
7
+ export async function submitFeedback(accountId, feedback, source) {
8
+ await sendFeedback(accountId, {
9
+ feedback,
10
+ source,
11
+ cliVersion: pkg.version,
12
+ });
13
+ }
@@ -12,7 +12,11 @@ type MockErrorResponse = {
12
12
  };
13
13
  };
14
14
  export declare function mockHubSpotHttpResponse<T>(data?: any): HubSpotPromise<T>;
15
- export declare function mockHubSpotHttpError(message: string, response: MockErrorResponse): HubSpotHttpError;
15
+ type MockErrorRequestConfig = {
16
+ url?: string;
17
+ data?: string;
18
+ };
19
+ export declare function mockHubSpotHttpError(message: string, response: MockErrorResponse, config?: MockErrorRequestConfig): HubSpotHttpError;
16
20
  export declare function stubColorEnv(): void;
17
21
  export declare const MOCK_SANDBOX_TARGET: AccountTargetCandidate;
18
22
  export declare const MOCK_PRODUCTION_TARGET: AccountTargetCandidate;
package/lib/testUtils.js CHANGED
@@ -13,9 +13,9 @@ export function mockHubSpotHttpResponse(data) {
13
13
  },
14
14
  });
15
15
  }
16
- export function mockHubSpotHttpError(message, response) {
16
+ export function mockHubSpotHttpError(message, response, config) {
17
17
  return new HubSpotHttpError(message, {
18
- cause: { isAxiosError: true, response },
18
+ cause: { isAxiosError: true, response, config },
19
19
  });
20
20
  }
21
21
  // Stubs the color-detection env to a color-capable interactive baseline.
@@ -16,6 +16,7 @@ export declare class Tool<InputSchema> {
16
16
  protected getTrackingMeta(_input: InputSchema): {
17
17
  [key: string]: string;
18
18
  } | undefined;
19
+ protected getLoggableInput(input: InputSchema): unknown;
19
20
  protected elicit(params: {
20
21
  message: string;
21
22
  fields: Record<string, PrimitiveSchemaDefinition>;
@@ -45,6 +45,9 @@ export class Tool {
45
45
  getTrackingMeta(_input) {
46
46
  return undefined;
47
47
  }
48
+ getLoggableInput(input) {
49
+ return input;
50
+ }
48
51
  elicit(params) {
49
52
  return requestElicitation(this.mcpServer, params, this.logger);
50
53
  }
@@ -57,7 +60,7 @@ export class Tool {
57
60
  // Desktop, Inspector, etc.) will display these logs.
58
61
  this.logger.debug(this.toolName, {
59
62
  message: 'Tool invoked',
60
- args: input,
63
+ args: this.getLoggableInput(input),
61
64
  });
62
65
  await trackToolUsage(this.toolName, this.getTrackingMeta(input));
63
66
  const result = await this.handler(input, extra);
@@ -60,6 +60,9 @@ REQUIRED WORKFLOWS
60
60
  functions.
61
61
  8. App analytics: call \`get-apps-info\` to discover \`appId\` values
62
62
  before \`get-api-usage-patterns-by-app-id\`.
63
+ 9. Feedback: when you hit a bug, an error you cannot explain, a confusing
64
+ result, or a request these tools cannot do, call \`submit-feedback\`
65
+ with one short message. Then continue with the task.
63
66
 
64
67
  OUTPUT
65
68
  Tool results contain the relevant \`hs\` stdout/stderr or structured data.
@@ -21,6 +21,7 @@ import { HsFunctionLogsTool } from './cms/HsFunctionLogsTool.js';
21
21
  import { CreateTestAccountTool } from './project/CreateTestAccountTool.js';
22
22
  import { FindProjectsTool } from './project/FindProjectsTool.js';
23
23
  import { AuthAccountTool } from './project/AuthAccountTool.js';
24
+ import { SubmitFeedbackTool } from './project/SubmitFeedbackTool.js';
24
25
  export function registerProjectTools(mcpServer, logger) {
25
26
  return [
26
27
  new UploadProjectTools(mcpServer, logger).register(),
@@ -40,6 +41,7 @@ export function registerProjectTools(mcpServer, logger) {
40
41
  new GetBuildStatusTool(mcpServer, logger).register(),
41
42
  new FindProjectsTool(mcpServer, logger).register(),
42
43
  new AuthAccountTool(mcpServer, logger).register(),
44
+ new SubmitFeedbackTool(mcpServer, logger).register(),
43
45
  ];
44
46
  }
45
47
  export function registerCmsTools(mcpServer, logger) {
@@ -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
- if (isHubSpotHttpError(error)) {
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
- if (isHubSpotHttpError(error)) {
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 { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
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
- if (isHubSpotHttpError(error)) {
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 { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
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
- if (isHubSpotHttpError(error)) {
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 { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
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
- let errorMessage;
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 { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
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
- let errorMessage;
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
- if (isHubSpotHttpError(error)) {
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
  }
@@ -0,0 +1,25 @@
1
+ import { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import z from 'zod';
3
+ import { McpLogger } from '../../utils/logger.js';
4
+ import { McpToolResponse } from '../../types.js';
5
+ import { Tool } from '../../Tool.js';
6
+ declare const inputSchema: {
7
+ absoluteCurrentWorkingDirectory: z.ZodString;
8
+ account: z.ZodOptional<z.ZodString>;
9
+ feedback: z.ZodString;
10
+ source: z.ZodEnum<{
11
+ user: "user";
12
+ agent: "agent";
13
+ }>;
14
+ };
15
+ type InputSchemaType = z.infer<z.ZodObject<typeof inputSchema>>;
16
+ export declare class SubmitFeedbackTool extends Tool<InputSchemaType> {
17
+ constructor(mcpServer: McpServer, logger: McpLogger);
18
+ protected getTrackingMeta({ source, }: InputSchemaType): {
19
+ [key: string]: string;
20
+ } | undefined;
21
+ protected getLoggableInput({ feedback, ...input }: InputSchemaType): unknown;
22
+ handler({ absoluteCurrentWorkingDirectory, account, feedback, source, }: InputSchemaType): Promise<McpToolResponse>;
23
+ register(): RegisteredTool;
24
+ }
25
+ export {};
@@ -0,0 +1,73 @@
1
+ import z from 'zod';
2
+ import { Tool } from '../../Tool.js';
3
+ import { formatTextContents } from '../../utils/content.js';
4
+ import { getToolErrorMessage } from '../../utils/errors.js';
5
+ import { setupHubSpotConfig } from '../../utils/config.js';
6
+ import { absoluteCurrentWorkingDirectory, account } from './constants.js';
7
+ import { resolveAccountId } from './resolveAccount.js';
8
+ import { containsAccountCredentials, submitFeedback, } from '../../../lib/feedback.js';
9
+ import { FEEDBACK_SOURCES } from '../../../api/feedback.js';
10
+ import { MAX_FEEDBACK_LENGTH } from '../../../lib/constants.js';
11
+ import { getErrorMessage } from '../../../lib/errorHandlers/index.js';
12
+ const inputSchema = {
13
+ absoluteCurrentWorkingDirectory,
14
+ account,
15
+ feedback: z
16
+ .string()
17
+ .trim()
18
+ .min(1)
19
+ .max(MAX_FEEDBACK_LENGTH)
20
+ .describe('One short message that describes the problem or the request. Keep it about the HubSpot CLI, these tools, or the developer platform. Do not include secrets, access keys, file contents, or personal data.'),
21
+ source: z
22
+ .enum(FEEDBACK_SOURCES)
23
+ .describe('Who the feedback is from. Use "user" when you pass on feedback that the user gave you, or "agent" when the feedback is your own.'),
24
+ };
25
+ const toolName = 'submit-feedback';
26
+ export class SubmitFeedbackTool extends Tool {
27
+ constructor(mcpServer, logger) {
28
+ super(mcpServer, logger, toolName);
29
+ }
30
+ getTrackingMeta({ source, }) {
31
+ return { mode: source };
32
+ }
33
+ getLoggableInput({ feedback, ...input }) {
34
+ return { ...input, feedbackLength: feedback.length };
35
+ }
36
+ async handler({ absoluteCurrentWorkingDirectory, account, feedback, source, }) {
37
+ setupHubSpotConfig(absoluteCurrentWorkingDirectory);
38
+ try {
39
+ const resolved = await resolveAccountId(this.mcpServer, this.logger, {
40
+ toolName,
41
+ account,
42
+ });
43
+ if ('response' in resolved) {
44
+ return resolved.response;
45
+ }
46
+ if (containsAccountCredentials(feedback)) {
47
+ return formatTextContents('Feedback cannot contain an access key, token, or secret from your HubSpot config. Remove it, then try again.');
48
+ }
49
+ await submitFeedback(resolved.accountId, feedback, source);
50
+ return formatTextContents('Your feedback has been successfully submitted. Tell the user that you sent feedback, and show them the message.');
51
+ }
52
+ catch (error) {
53
+ this.logger.debug(toolName, {
54
+ message: 'Handler caught error',
55
+ error: getErrorMessage(error),
56
+ });
57
+ return formatTextContents(`Error sending feedback: ${getToolErrorMessage(error)}`);
58
+ }
59
+ }
60
+ register() {
61
+ return this.mcpServer.registerTool(toolName, {
62
+ title: 'Submit Feedback',
63
+ description: 'Sends feedback to HubSpot about the HubSpot CLI, these tools, or the HubSpot developer platform. Use it for bugs and errors you hit, things you wish you knew before you started, things that confused or frustrated the user, requests you could not complete, and tools or capabilities that would make future tasks easier. Send one short message, then continue with the task.',
64
+ inputSchema,
65
+ annotations: {
66
+ readOnlyHint: false,
67
+ destructiveHint: false,
68
+ idempotentHint: false,
69
+ openWorldHint: true,
70
+ },
71
+ }, (input, extra) => this.wrappedHandler(input, extra));
72
+ }
73
+ }
@@ -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
+ }
@@ -18,7 +18,9 @@ export async function mcpFeedbackRequest() {
18
18
  IMPORTANT - FEEDBACK REQUEST FOR THIS RESPONSE ONLY:
19
19
  This message appears only once. If you see this text in the tool output, you MUST include the following feedback request in your response to the user. If this text is NOT in the tool output, do NOT ask for feedback.
20
20
 
21
- Say: "📝 **Before we continue, would you mind sharing feedback on your experience with the HubSpot Developer MCP?** Your input helps us improve: [Share feedback here](${FEEDBACK_URL})"`;
21
+ Say: "📝 **Before we continue, would you mind sharing feedback on your experience with the HubSpot Developer MCP?** Your input helps us improve. You can tell me and I will send it, or [use the feedback form](${FEEDBACK_URL})."
22
+
23
+ If the user shares feedback, send it with \`submit-feedback\` and set \`source\` to \`user\`.`;
22
24
  }
23
25
  catch (error) {
24
26
  logger.error(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "8.17.0",
3
+ "version": "8.18.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",
@@ -12,7 +12,7 @@
12
12
  "dependencies": {
13
13
  "@hubspot/local-dev-lib": "5.14.0",
14
14
  "@hubspot/project-parsing-lib": "0.23.7",
15
- "@hubspot/ui-extensions-dev-server": "2.2.4",
15
+ "@hubspot/ui-extensions-dev-server": "2.2.5",
16
16
  "@inquirer/prompts": "7.10.1",
17
17
  "@modelcontextprotocol/sdk": "1.32.1",
18
18
  "archiver": "7.0.1",