@hubspot/cli 8.15.0 → 8.16.0-beta.1
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/api/releases.d.ts +4 -1
- package/bin/cli.js +2 -0
- package/commands/account/auth.d.ts +3 -2
- package/commands/account/auth.js +21 -10
- package/commands/app/migrate.js +3 -3
- package/commands/project/add.d.ts +3 -2
- package/commands/project/add.js +10 -8
- package/commands/project/appInstallStatus.d.ts +2 -2
- package/commands/project/appInstallStatus.js +2 -2
- package/commands/project/create.d.ts +4 -2
- package/commands/project/create.js +16 -4
- package/commands/project/deploy.d.ts +2 -2
- package/commands/project/deploy.js +2 -2
- package/commands/project/download.d.ts +2 -2
- package/commands/project/download.js +2 -2
- package/commands/project/info.d.ts +1 -1
- package/commands/project/info.js +1 -1
- package/commands/project/installApp.d.ts +2 -2
- package/commands/project/installApp.js +2 -2
- package/commands/project/listBuilds.d.ts +2 -2
- package/commands/project/listBuilds.js +2 -2
- package/commands/project/migrate.js +4 -4
- package/commands/project/release/create.d.ts +2 -2
- package/commands/project/release/create.js +7 -3
- package/commands/project/release/info.d.ts +2 -2
- package/commands/project/release/info.js +2 -2
- package/commands/project/release/list.d.ts +2 -2
- package/commands/project/release/list.js +2 -2
- package/commands/project/release/preview.d.ts +9 -0
- package/commands/project/release/preview.js +167 -0
- package/commands/project/release.js +7 -1
- package/commands/project/upload.d.ts +2 -2
- package/commands/project/upload.js +2 -2
- package/commands/project/validate.d.ts +2 -2
- package/commands/project/validate.js +2 -2
- package/commands/testAccount/create.d.ts +2 -2
- package/commands/testAccount/create.js +2 -2
- package/lang/en.d.ts +27 -0
- package/lang/en.js +32 -4
- package/lib/accountAuth.d.ts +1 -0
- package/lib/accountAuth.js +8 -0
- package/lib/app/urls.d.ts +0 -1
- package/lib/app/urls.js +0 -4
- package/lib/constants.d.ts +6 -0
- package/lib/constants.js +11 -0
- package/lib/jsonOutput/accountAuth.d.ts +7 -0
- package/lib/jsonOutput/accountAuth.js +6 -0
- package/lib/jsonOutput/projectAdd.d.ts +9 -0
- package/lib/jsonOutput/projectAdd.js +10 -0
- package/lib/jsonOutput/{appInstallStatus.d.ts → projectAppInstallStatus.d.ts} +2 -2
- package/lib/jsonOutput/{appInstallStatus.js → projectAppInstallStatus.js} +1 -1
- package/lib/jsonOutput/projectCreate.d.ts +8 -0
- package/lib/jsonOutput/projectCreate.js +7 -0
- package/lib/jsonOutput/projectDeploy.d.ts +5 -0
- package/lib/jsonOutput/{deploy.js → projectDeploy.js} +1 -1
- package/lib/jsonOutput/projectDownload.d.ts +7 -0
- package/lib/jsonOutput/{download.js → projectDownload.js} +1 -1
- package/lib/jsonOutput/{installApp.d.ts → projectInstallApp.d.ts} +2 -2
- package/lib/jsonOutput/{installApp.js → projectInstallApp.js} +1 -1
- package/lib/jsonOutput/{listBuilds.d.ts → projectListBuilds.d.ts} +2 -2
- package/lib/jsonOutput/{listBuilds.js → projectListBuilds.js} +1 -1
- package/lib/jsonOutput/{release.d.ts → projectRelease.d.ts} +15 -8
- package/lib/jsonOutput/{release.js → projectRelease.js} +11 -4
- package/lib/jsonOutput/{upload.d.ts → projectUpload.d.ts} +2 -2
- package/lib/jsonOutput/{upload.js → projectUpload.js} +1 -1
- package/lib/jsonOutput/{validate.d.ts → projectValidate.d.ts} +2 -2
- package/lib/jsonOutput/{validate.js → projectValidate.js} +1 -1
- package/lib/jsonOutput/{createTestAccount.d.ts → testAccountCreate.d.ts} +2 -2
- package/lib/jsonOutput/{createTestAccount.js → testAccountCreate.js} +1 -1
- package/lib/middleware/deprecationWarningMiddleware.d.ts +1 -0
- package/lib/middleware/deprecationWarningMiddleware.js +57 -0
- package/lib/projects/add/legacyAddComponent.d.ts +2 -1
- package/lib/projects/add/legacyAddComponent.js +3 -0
- package/lib/projects/add/v2AddComponent.d.ts +2 -1
- package/lib/projects/add/v2AddComponent.js +7 -1
- package/lib/projects/localDev/LocalDevWatcher.js +1 -1
- package/lib/projects/release.d.ts +2 -2
- package/lib/projects/validate.d.ts +1 -1
- package/lib/prompts/projectProfilePrompt.d.ts +7 -0
- package/lib/prompts/projectProfilePrompt.js +1 -1
- package/lib/testUtils.d.ts +5 -0
- package/lib/testUtils.js +24 -0
- package/lib/ui/index.js +11 -1
- package/lib/ui/uiMessages.d.ts +1 -0
- package/lib/ui/uiMessages.js +1 -0
- package/mcp-server/Tool.d.ts +6 -1
- package/mcp-server/Tool.js +6 -4
- package/mcp-server/server.js +26 -4
- package/mcp-server/tools/cms/HsCreateFunctionTool.js +1 -1
- package/mcp-server/tools/cms/HsFunctionLogsTool.d.ts +1 -1
- package/mcp-server/tools/cms/HsFunctionLogsTool.js +59 -5
- package/mcp-server/tools/cms/HsListFunctionsTool.js +1 -1
- package/mcp-server/tools/index.js +2 -0
- package/mcp-server/tools/project/AddFeatureToProjectTool.js +31 -31
- package/mcp-server/tools/project/AuthAccountTool.d.ts +1 -0
- package/mcp-server/tools/project/AuthAccountTool.js +36 -5
- package/mcp-server/tools/project/CreateProjectTool.js +13 -3
- package/mcp-server/tools/project/CreateTestAccountTool.js +13 -13
- package/mcp-server/tools/project/DeployProjectTool.d.ts +2 -2
- package/mcp-server/tools/project/DeployProjectTool.js +34 -16
- package/mcp-server/tools/project/DocFetchTool.js +1 -1
- package/mcp-server/tools/project/DocsSearchTool.d.ts +4 -1
- package/mcp-server/tools/project/DocsSearchTool.js +18 -9
- package/mcp-server/tools/project/FindProjectsTool.js +12 -0
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.d.ts +3 -2
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +38 -10
- package/mcp-server/tools/project/GetApplicationInfoTool.d.ts +2 -1
- package/mcp-server/tools/project/GetApplicationInfoTool.js +13 -14
- package/mcp-server/tools/project/GetBuildLogsTool.d.ts +2 -1
- package/mcp-server/tools/project/GetBuildLogsTool.js +12 -9
- package/mcp-server/tools/project/GetBuildStatusTool.d.ts +2 -1
- package/mcp-server/tools/project/GetBuildStatusTool.js +12 -9
- package/mcp-server/tools/project/GetConfigValuesTool.d.ts +2 -1
- package/mcp-server/tools/project/GetConfigValuesTool.js +11 -8
- package/mcp-server/tools/project/KnowledgeSearchTool.d.ts +29 -0
- package/mcp-server/tools/project/KnowledgeSearchTool.js +82 -0
- package/mcp-server/tools/project/UploadProjectTools.d.ts +2 -2
- package/mcp-server/tools/project/UploadProjectTools.js +52 -39
- package/mcp-server/tools/project/ValidateProjectTool.js +23 -7
- package/mcp-server/tools/project/apps.d.ts +8 -0
- package/mcp-server/tools/project/apps.js +7 -0
- package/mcp-server/tools/project/constants.d.ts +3 -0
- package/mcp-server/tools/project/constants.js +11 -1
- package/mcp-server/tools/project/productionConfirmation.d.ts +12 -0
- package/mcp-server/tools/project/productionConfirmation.js +45 -0
- package/mcp-server/tools/project/resolveAccount.d.ts +15 -0
- package/mcp-server/tools/project/resolveAccount.js +60 -0
- package/mcp-server/utils/command.d.ts +1 -0
- package/mcp-server/utils/command.js +8 -0
- package/mcp-server/utils/content.d.ts +1 -0
- package/mcp-server/utils/content.js +5 -0
- package/mcp-server/utils/elicitSelection.d.ts +11 -0
- package/mcp-server/utils/elicitSelection.js +25 -0
- package/mcp-server/utils/elicitation.d.ts +11 -0
- package/mcp-server/utils/elicitation.js +38 -0
- package/package.json +23 -22
- package/ui/components/Table.d.ts +8 -8
- package/lib/jsonOutput/deploy.d.ts +0 -5
- package/lib/jsonOutput/download.d.ts +0 -7
- /package/lib/jsonOutput/{info.d.ts → projectInfo.d.ts} +0 -0
- /package/lib/jsonOutput/{info.js → projectInfo.js} +0 -0
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Tool } from '../../Tool.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { absoluteCurrentWorkingDirectory, absoluteProjectPath, } from './constants.js';
|
|
4
|
-
import { formatTextContents } from '../../utils/content.js';
|
|
4
|
+
import { formatTextContents, formatErrorTextContents, } from '../../utils/content.js';
|
|
5
5
|
import { setupHubSpotConfig } from '../../utils/config.js';
|
|
6
6
|
import { getErrorMessage } from '../../../lib/errorHandlers/index.js';
|
|
7
|
-
import { HubSpotCommand } from '../../utils/command.js';
|
|
7
|
+
import { HubSpotCommand, getCommandResultsFromError, } from '../../utils/command.js';
|
|
8
|
+
import { parseCommandJsonOutput } from '../../utils/json.js';
|
|
9
|
+
import { ProjectValidateSchema } from '../../../lib/jsonOutput/projectValidate.js';
|
|
8
10
|
const inputSchema = {
|
|
9
11
|
absoluteProjectPath,
|
|
10
12
|
absoluteCurrentWorkingDirectory,
|
|
@@ -18,24 +20,38 @@ export class ValidateProjectTool extends Tool {
|
|
|
18
20
|
}
|
|
19
21
|
async handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, }, extra) {
|
|
20
22
|
setupHubSpotConfig(absoluteCurrentWorkingDirectory);
|
|
23
|
+
const command = new HubSpotCommand('project validate', [
|
|
24
|
+
{ name: 'json', value: true },
|
|
25
|
+
]);
|
|
26
|
+
let stdout = '';
|
|
27
|
+
let stderr = '';
|
|
21
28
|
try {
|
|
22
|
-
|
|
23
|
-
const { stdout, stderr } = await this.runCommand(absoluteProjectPath, command, extra);
|
|
24
|
-
return formatTextContents(stdout, stderr);
|
|
29
|
+
({ stdout, stderr } = await this.runCommand(absoluteProjectPath, command, extra));
|
|
25
30
|
}
|
|
26
31
|
catch (error) {
|
|
27
32
|
this.logger.debug(toolName, {
|
|
28
33
|
message: 'Handler caught error',
|
|
29
|
-
error:
|
|
34
|
+
error: getErrorMessage(error),
|
|
30
35
|
});
|
|
31
|
-
|
|
36
|
+
({ stdout, stderr } = getCommandResultsFromError(error));
|
|
37
|
+
if (!stdout) {
|
|
38
|
+
return formatErrorTextContents(getErrorMessage(error));
|
|
39
|
+
}
|
|
32
40
|
}
|
|
41
|
+
const structuredContent = parseCommandJsonOutput(stdout, ProjectValidateSchema, this.logger, toolName);
|
|
42
|
+
if (!structuredContent) {
|
|
43
|
+
return formatErrorTextContents(stdout, stderr);
|
|
44
|
+
}
|
|
45
|
+
const response = await formatTextContents(stdout, stderr);
|
|
46
|
+
response.structuredContent = structuredContent;
|
|
47
|
+
return response;
|
|
33
48
|
}
|
|
34
49
|
register() {
|
|
35
50
|
return this.mcpServer.registerTool(toolName, {
|
|
36
51
|
title: 'Validate HubSpot Project',
|
|
37
52
|
description: 'Validates the HubSpot project and its configuration files. This tool does not need to be ran before uploading the project. If you do not know the project path, use the find-projects tool first to locate HubSpot projects in the workspace.',
|
|
38
53
|
inputSchema,
|
|
54
|
+
outputSchema: ProjectValidateSchema.shape,
|
|
39
55
|
annotations: {
|
|
40
56
|
readOnlyHint: true,
|
|
41
57
|
openWorldHint: false,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
2
|
export declare const absoluteProjectPath: z.ZodString;
|
|
3
3
|
export declare const absoluteCurrentWorkingDirectory: z.ZodString;
|
|
4
|
+
export declare const account: z.ZodOptional<z.ZodString>;
|
|
5
|
+
export declare const confirmProductionAccount: z.ZodOptional<z.ZodBoolean>;
|
|
4
6
|
export declare const features: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
5
7
|
card: "card";
|
|
6
8
|
settings: "settings";
|
|
@@ -17,3 +19,4 @@ export declare const features: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
|
17
19
|
}>>>;
|
|
18
20
|
export declare const docsSearchQuery: z.ZodString;
|
|
19
21
|
export declare const docUrl: z.ZodString;
|
|
22
|
+
export declare const knowledgeSearchQuery: z.ZodString;
|
|
@@ -5,6 +5,13 @@ export const absoluteProjectPath = z
|
|
|
5
5
|
export const absoluteCurrentWorkingDirectory = z
|
|
6
6
|
.string()
|
|
7
7
|
.describe('The absolute path to the current working directory.');
|
|
8
|
+
export const account = z
|
|
9
|
+
.string()
|
|
10
|
+
.optional()
|
|
11
|
+
.describe('Optional: the HubSpot account ID or name to use. If omitted and several accounts are available, you will be asked to choose.');
|
|
12
|
+
export const confirmProductionAccount = z
|
|
13
|
+
.optional(z.boolean())
|
|
14
|
+
.describe('Set to true only after this tool names a production account and the user then explicitly confirms that account in the conversation. NEVER set this on your own. The tool ignores this value when the client can show a confirmation form.');
|
|
8
15
|
export const features = z
|
|
9
16
|
.array(z.enum([
|
|
10
17
|
'card',
|
|
@@ -20,7 +27,7 @@ export const features = z
|
|
|
20
27
|
'page',
|
|
21
28
|
'crm-bulk-action',
|
|
22
29
|
]))
|
|
23
|
-
.describe('The features to include in the project, multiple options can be selected. "app-function" is
|
|
30
|
+
.describe('The features to include in the project, multiple options can be selected. These are features of a developer-platform app, not CMS website assets. "app-function" is a private serverless function that runs inside the app and is not publicly accessible. It is distinct from a CMS serverless function, which is created with create-cms-function. "app-function-endpoint" is an app serverless function that is publicly accessible via an endpoint. "workflow-action" is also known as a custom workflow action. "workflow-action-tool" is also known as agent tools. "crm-bulk-action" is an app actions extension that lets users act on multiple CRM records at once.')
|
|
24
31
|
.optional();
|
|
25
32
|
export const docsSearchQuery = z
|
|
26
33
|
.string()
|
|
@@ -28,3 +35,6 @@ export const docsSearchQuery = z
|
|
|
28
35
|
export const docUrl = z
|
|
29
36
|
.string()
|
|
30
37
|
.describe('The URL of the HubSpot Developer Documentation to fetch.');
|
|
38
|
+
export const knowledgeSearchQuery = z
|
|
39
|
+
.string()
|
|
40
|
+
.describe('The question to search the general HubSpot Knowledge Base for. Use natural language, for example "how do I set up a workflow" or "what is included in the Marketing Hub Professional plan".');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { DiscoverAccountTargetsResult } from '../../../types/AccountTargets.js';
|
|
3
|
+
import { McpToolResponse } from '../../types.js';
|
|
4
|
+
import { HubSpotCommand } from '../../utils/command.js';
|
|
5
|
+
import { McpLogger } from '../../utils/logger.js';
|
|
6
|
+
export declare function setTargetAccount(command: HubSpotCommand, { recommended }: DiscoverAccountTargetsResult, profileName?: string): void;
|
|
7
|
+
export declare function confirmProductionTargets(mcpServer: McpServer, logger: McpLogger, { targets, action, toolName, confirmedInConversation, }: {
|
|
8
|
+
targets: DiscoverAccountTargetsResult;
|
|
9
|
+
action: string;
|
|
10
|
+
toolName: string;
|
|
11
|
+
confirmedInConversation?: boolean;
|
|
12
|
+
}): Promise<McpToolResponse | undefined>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ACCOUNT_TARGET_CATEGORIES, } from '../../../types/AccountTargets.js';
|
|
2
|
+
import { uiAccountDescription } from '../../../lib/ui/index.js';
|
|
3
|
+
import { formatErrorTextContents } from '../../utils/content.js';
|
|
4
|
+
import { canElicit, requestElicitation } from '../../utils/elicitation.js';
|
|
5
|
+
// Sets the command to run against the account that was checked. hs rejects
|
|
6
|
+
// --profile with --account, and a profile already sets the account, so a
|
|
7
|
+
// profile wins.
|
|
8
|
+
export function setTargetAccount(command, { recommended }, profileName) {
|
|
9
|
+
if (profileName) {
|
|
10
|
+
command.addFlag('profile', profileName);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (recommended) {
|
|
14
|
+
command.addFlag('account', recommended.accountId);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
// Without a recommended account the command can act on any candidate, so every
|
|
18
|
+
// production candidate is a possible target.
|
|
19
|
+
function getProductionTargets({ candidates, recommended, }) {
|
|
20
|
+
return (recommended ? [recommended] : candidates).filter(candidate => candidate.category === ACCOUNT_TARGET_CATEGORIES.PRODUCTION_WITH_CARE);
|
|
21
|
+
}
|
|
22
|
+
// Returns an error response when the action must not run, or `undefined` when
|
|
23
|
+
// it can run. `confirmedInConversation` only counts when the client cannot show
|
|
24
|
+
// a confirmation form.
|
|
25
|
+
export async function confirmProductionTargets(mcpServer, logger, { targets, action, toolName, confirmedInConversation, }) {
|
|
26
|
+
const productionTargets = getProductionTargets(targets);
|
|
27
|
+
if (productionTargets.length === 0) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
const accounts = productionTargets
|
|
31
|
+
.map(({ accountId }) => uiAccountDescription(accountId, false))
|
|
32
|
+
.join(' or ');
|
|
33
|
+
if (!canElicit(mcpServer)) {
|
|
34
|
+
return confirmedInConversation
|
|
35
|
+
? undefined
|
|
36
|
+
: formatErrorTextContents(`${action} targets production account ${accounts}, which is not a test account or sandbox. Ask the user to confirm this account. If the user confirms, call ${toolName} again with confirmProductionAccount set to true.`);
|
|
37
|
+
}
|
|
38
|
+
// A failed or timed-out request counts as a decline, so the flag cannot skip
|
|
39
|
+
// the form.
|
|
40
|
+
const elicitation = await requestElicitation(mcpServer, { message: `${action} to production account ${accounts}?`, fields: {} }, logger);
|
|
41
|
+
if (elicitation?.action === 'accept') {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
return formatErrorTextContents(`The user did not confirm production account ${accounts}, so ${toolName} did not run. Tell the user that the action was canceled. Do not ask the user to confirm again, and do not call ${toolName} again unless the user asks.`);
|
|
45
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { McpToolResponse } from '../../types.js';
|
|
3
|
+
import { McpLogger } from '../../utils/logger.js';
|
|
4
|
+
import { DiscoverAccountTargetsOptions } from '../../../types/AccountTargets.js';
|
|
5
|
+
export type ResolveAccountResult = {
|
|
6
|
+
accountId: number;
|
|
7
|
+
} | {
|
|
8
|
+
response: McpToolResponse;
|
|
9
|
+
};
|
|
10
|
+
export declare function resolveAccountId(mcpServer: McpServer, logger: McpLogger, params: {
|
|
11
|
+
toolName: string;
|
|
12
|
+
absoluteCurrentWorkingDirectory?: string;
|
|
13
|
+
account?: string;
|
|
14
|
+
discoverOptions?: DiscoverAccountTargetsOptions;
|
|
15
|
+
}): Promise<ResolveAccountResult>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { formatTextContents } from '../../utils/content.js';
|
|
2
|
+
import { enumField, requestElicitation } from '../../utils/elicitation.js';
|
|
3
|
+
import { discoverAccountTargets } from '../../../lib/accountTargetDiscovery.js';
|
|
4
|
+
function formatAccountChoice(candidate) {
|
|
5
|
+
const name = candidate.accountName || String(candidate.accountId);
|
|
6
|
+
const parts = [`${name} (${candidate.category})`];
|
|
7
|
+
if (candidate.profileName) {
|
|
8
|
+
parts.push(`[profile: ${candidate.profileName}]`);
|
|
9
|
+
}
|
|
10
|
+
return parts.join(' ');
|
|
11
|
+
}
|
|
12
|
+
function fallbackResponse(message, absoluteCurrentWorkingDirectory) {
|
|
13
|
+
return absoluteCurrentWorkingDirectory
|
|
14
|
+
? formatTextContents(absoluteCurrentWorkingDirectory, message)
|
|
15
|
+
: formatTextContents(message);
|
|
16
|
+
}
|
|
17
|
+
// Resolves the HubSpot account a tool should act on. Returns a numeric
|
|
18
|
+
// accountId when one is the obvious choice or the caller supplied a matching
|
|
19
|
+
// `account`. When several accounts are available and none is recommended, it
|
|
20
|
+
// asks the client to pick via elicitation. When the client cannot elicit (or
|
|
21
|
+
// declines), it returns a text response listing the candidates so the caller
|
|
22
|
+
// can return it directly. `toolName` names the tool in that fallback text.
|
|
23
|
+
export async function resolveAccountId(mcpServer, logger, params) {
|
|
24
|
+
const { candidates, recommended } = await discoverAccountTargets({
|
|
25
|
+
...params.discoverOptions,
|
|
26
|
+
explicitAccount: params.account,
|
|
27
|
+
});
|
|
28
|
+
const available = candidates ?? [];
|
|
29
|
+
let accountId = recommended?.accountId;
|
|
30
|
+
if (!accountId && params.account) {
|
|
31
|
+
const match = available.find(candidate => String(candidate.accountId) === params.account ||
|
|
32
|
+
candidate.accountName === params.account);
|
|
33
|
+
accountId = match?.accountId;
|
|
34
|
+
}
|
|
35
|
+
if (!accountId && available.length > 0) {
|
|
36
|
+
const elicitation = await requestElicitation(mcpServer, {
|
|
37
|
+
message: 'Select the HubSpot account to use.',
|
|
38
|
+
fields: {
|
|
39
|
+
account: enumField('HubSpot account', 'The account to use for this request.', available.map(candidate => String(candidate.accountId)), available.map(formatAccountChoice)),
|
|
40
|
+
},
|
|
41
|
+
required: ['account'],
|
|
42
|
+
}, logger);
|
|
43
|
+
if (elicitation?.action === 'accept' && elicitation.content) {
|
|
44
|
+
accountId = Number(elicitation.content.account);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (!accountId) {
|
|
48
|
+
if (available.length > 0) {
|
|
49
|
+
return {
|
|
50
|
+
response: await fallbackResponse(`Several HubSpot accounts are available. Ask the user which to use, then call ${params.toolName} again with the account argument set to one of: ${available
|
|
51
|
+
.map(candidate => `${formatAccountChoice(candidate)} (id ${candidate.accountId})`)
|
|
52
|
+
.join(', ')}.`, params.absoluteCurrentWorkingDirectory),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
response: await fallbackResponse('No account ID found. Call the auth-account tool to authenticate a HubSpot account.', params.absoluteCurrentWorkingDirectory),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return { accountId };
|
|
60
|
+
}
|
|
@@ -28,4 +28,5 @@ export interface CommandResults {
|
|
|
28
28
|
stderr: string;
|
|
29
29
|
stdout: string;
|
|
30
30
|
}
|
|
31
|
+
export declare function getCommandResultsFromError(error: unknown): CommandResults;
|
|
31
32
|
export declare function runCommandInDir(directory: string, command: Command, onData?: (chunk: string, source: 'stdout' | 'stderr') => void): Promise<CommandResults>;
|
|
@@ -38,6 +38,14 @@ export class NpxHubSpotCommand {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
export const execAsync = util.promisify(exec);
|
|
41
|
+
export function getCommandResultsFromError(error) {
|
|
42
|
+
if (typeof error !== 'object' || error === null) {
|
|
43
|
+
return { stdout: '', stderr: '' };
|
|
44
|
+
}
|
|
45
|
+
const stdout = 'stdout' in error && typeof error.stdout === 'string' ? error.stdout : '';
|
|
46
|
+
const stderr = 'stderr' in error && typeof error.stderr === 'string' ? error.stderr : '';
|
|
47
|
+
return { stdout, stderr };
|
|
48
|
+
}
|
|
41
49
|
export async function runCommandInDir(directory, command, onData) {
|
|
42
50
|
if (!fs.existsSync(directory)) {
|
|
43
51
|
fs.mkdirSync(directory);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { TextContent, McpToolResponse } from '../types.js';
|
|
2
2
|
export declare function formatTextContents(...outputs: (string | undefined)[]): Promise<McpToolResponse>;
|
|
3
|
+
export declare function formatErrorTextContents(...outputs: (string | undefined)[]): Promise<McpToolResponse>;
|
|
3
4
|
export declare function formatTextContent(text: string): TextContent;
|
|
@@ -16,6 +16,11 @@ export async function formatTextContents(...outputs) {
|
|
|
16
16
|
content,
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
+
export async function formatErrorTextContents(...outputs) {
|
|
20
|
+
const response = await formatTextContents(...outputs);
|
|
21
|
+
response.isError = true;
|
|
22
|
+
return response;
|
|
23
|
+
}
|
|
19
24
|
export function formatTextContent(text) {
|
|
20
25
|
return {
|
|
21
26
|
type: 'text',
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { McpLogger } from './logger.js';
|
|
3
|
+
export type SelectionOption = {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function elicitSelection(mcpServer: McpServer, logger: McpLogger, params: {
|
|
8
|
+
message: string;
|
|
9
|
+
title: string;
|
|
10
|
+
options: SelectionOption[];
|
|
11
|
+
}): Promise<string | undefined>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { enumField, requestElicitation } from './elicitation.js';
|
|
2
|
+
// Asks the client to pick one option from a runtime-discovered list. Returns
|
|
3
|
+
// the chosen value, or undefined when the list is empty, the client cannot
|
|
4
|
+
// elicit, or the user declines. When exactly one option exists it is returned
|
|
5
|
+
// without prompting.
|
|
6
|
+
export async function elicitSelection(mcpServer, logger, params) {
|
|
7
|
+
if (params.options.length === 0) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
if (params.options.length === 1) {
|
|
11
|
+
return params.options[0].value;
|
|
12
|
+
}
|
|
13
|
+
const elicitation = await requestElicitation(mcpServer, {
|
|
14
|
+
message: params.message,
|
|
15
|
+
fields: {
|
|
16
|
+
selection: enumField(params.title, params.message, params.options.map(option => option.value), params.options.map(option => option.label)),
|
|
17
|
+
},
|
|
18
|
+
required: ['selection'],
|
|
19
|
+
}, logger);
|
|
20
|
+
if (elicitation?.action === 'accept' &&
|
|
21
|
+
typeof elicitation.content?.selection === 'string') {
|
|
22
|
+
return elicitation.content.selection;
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { ElicitResult, PrimitiveSchemaDefinition } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import { McpLogger } from './logger.js';
|
|
4
|
+
export declare function enumField(title: string, description: string, values: string[], names?: string[]): PrimitiveSchemaDefinition;
|
|
5
|
+
export declare function booleanField(title: string, description: string, defaultValue?: boolean): PrimitiveSchemaDefinition;
|
|
6
|
+
export declare function canElicit(mcpServer: McpServer): boolean;
|
|
7
|
+
export declare function requestElicitation(mcpServer: McpServer, params: {
|
|
8
|
+
message: string;
|
|
9
|
+
fields: Record<string, PrimitiveSchemaDefinition>;
|
|
10
|
+
required?: string[];
|
|
11
|
+
}, logger?: McpLogger): Promise<ElicitResult | undefined>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { MCP_ELICITATION_TIMEOUT } from '../../lib/constants.js';
|
|
2
|
+
export function enumField(title, description, values, names) {
|
|
3
|
+
return { type: 'string', title, description, enum: values, enumNames: names };
|
|
4
|
+
}
|
|
5
|
+
export function booleanField(title, description, defaultValue) {
|
|
6
|
+
return { type: 'boolean', title, description, default: defaultValue };
|
|
7
|
+
}
|
|
8
|
+
export function canElicit(mcpServer) {
|
|
9
|
+
return Boolean(mcpServer.server.getClientCapabilities()?.elicitation?.form);
|
|
10
|
+
}
|
|
11
|
+
// Sends a JSON Schema of the required inputs to the client, pauses the tool
|
|
12
|
+
// call, and resumes when the client returns a response that matches the schema.
|
|
13
|
+
// The client collects the values from the user. The SDK checks the returned
|
|
14
|
+
// content against the schema before it resolves.
|
|
15
|
+
//
|
|
16
|
+
// Returns the SDK ElicitResult, or `undefined` when the client cannot elicit
|
|
17
|
+
// (it did not advertise form elicitation, or the request failed). Callers treat
|
|
18
|
+
// `undefined` and any non-`accept` action as "no answer" and fall back to text.
|
|
19
|
+
export async function requestElicitation(mcpServer, params, logger) {
|
|
20
|
+
if (!canElicit(mcpServer)) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
const requestedSchema = {
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: params.fields,
|
|
26
|
+
required: params.required,
|
|
27
|
+
};
|
|
28
|
+
try {
|
|
29
|
+
return await mcpServer.server.elicitInput({ message: params.message, requestedSchema }, { timeout: MCP_ELICITATION_TIMEOUT });
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
logger?.warn('elicitation', {
|
|
33
|
+
message: 'Elicitation request failed',
|
|
34
|
+
error: error instanceof Error ? error.message : String(error),
|
|
35
|
+
});
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cli",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.16.0-beta.1",
|
|
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,35 +10,35 @@
|
|
|
10
10
|
"!**/__tests__/**"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@hubspot/local-dev-lib": "5.
|
|
14
|
-
"@hubspot/project-parsing-lib": "0.23.
|
|
13
|
+
"@hubspot/local-dev-lib": "5.12.0",
|
|
14
|
+
"@hubspot/project-parsing-lib": "0.23.4",
|
|
15
15
|
"@hubspot/ui-extensions-dev-server": "2.2.2",
|
|
16
|
-
"@inquirer/prompts": "7.1
|
|
17
|
-
"@modelcontextprotocol/sdk": "1.
|
|
16
|
+
"@inquirer/prompts": "7.10.1",
|
|
17
|
+
"@modelcontextprotocol/sdk": "1.30.0",
|
|
18
18
|
"archiver": "7.0.1",
|
|
19
|
-
"chalk": "5.
|
|
19
|
+
"chalk": "5.6.2",
|
|
20
20
|
"chokidar": "3.6.0",
|
|
21
21
|
"cli-cursor": "3.1.0",
|
|
22
22
|
"cli-progress": "3.12.0",
|
|
23
|
-
"express": "4.22.
|
|
23
|
+
"express": "4.22.3",
|
|
24
24
|
"findup-sync": "4.0.0",
|
|
25
25
|
"fs-extra": "8.1.0",
|
|
26
|
-
"ink": "6.
|
|
26
|
+
"ink": "6.8.0",
|
|
27
27
|
"ink-spinner": "5.0.0",
|
|
28
28
|
"ink-text-input": "6.0.0",
|
|
29
|
-
"js-yaml": "4.3.
|
|
30
|
-
"minimatch": "10.2.
|
|
31
|
-
"moment": "2.
|
|
29
|
+
"js-yaml": "4.3.2",
|
|
30
|
+
"minimatch": "10.2.6",
|
|
31
|
+
"moment": "2.31.0",
|
|
32
32
|
"open": "7.4.2",
|
|
33
|
-
"p-queue": "8.1.
|
|
34
|
-
"react": "19.
|
|
35
|
-
"semver": "7.
|
|
36
|
-
"strip-ansi": "7.
|
|
33
|
+
"p-queue": "8.1.1",
|
|
34
|
+
"react": "19.3.0",
|
|
35
|
+
"semver": "7.8.5",
|
|
36
|
+
"strip-ansi": "7.2.0",
|
|
37
37
|
"table": "6.9.0",
|
|
38
38
|
"tmp": "0.2.7",
|
|
39
39
|
"update-notifier": "7.3.1",
|
|
40
|
-
"ws": "8.21.
|
|
41
|
-
"yargs": "17.7.
|
|
40
|
+
"ws": "8.21.3",
|
|
41
|
+
"yargs": "17.7.3",
|
|
42
42
|
"yargs-parser": "21.1.1",
|
|
43
43
|
"zod": "^4.4.3"
|
|
44
44
|
},
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@types/fs-extra": "^11.0.4",
|
|
52
52
|
"@types/js-yaml": "^4.0.9",
|
|
53
53
|
"@types/node": "^24.1.0",
|
|
54
|
-
"@types/react": "^
|
|
54
|
+
"@types/react": "^19.3.0",
|
|
55
55
|
"@types/semver": "^7.5.8",
|
|
56
56
|
"@types/tmp": "^0.2.6",
|
|
57
57
|
"@types/update-notifier": "^6.0.8",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"@types/yargs": "^17.0.33",
|
|
60
60
|
"@typescript-eslint/eslint-plugin": "^8.30.1",
|
|
61
61
|
"@typescript-eslint/parser": "^8.11.0",
|
|
62
|
-
"@vitest/coverage-v8": "^
|
|
63
|
-
"axios": "1.
|
|
62
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
63
|
+
"axios": "1.20.0",
|
|
64
64
|
"eslint": "^8.56.0",
|
|
65
65
|
"eslint-plugin-import": "^2.31.0",
|
|
66
66
|
"husky": "^4.3.8",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"ts-node": "^10.9.2",
|
|
72
72
|
"tsx": "^4.20.3",
|
|
73
73
|
"typescript": "^5.6.2",
|
|
74
|
-
"vitest": "^
|
|
74
|
+
"vitest": "^4.1.11"
|
|
75
75
|
},
|
|
76
76
|
"scripts": {
|
|
77
77
|
"build": "tsx ./scripts/build.ts",
|
|
@@ -126,6 +126,7 @@
|
|
|
126
126
|
"eslint-visitor-keys": "4.2.0",
|
|
127
127
|
"@eslint-community/eslint-utils": "4.9.0",
|
|
128
128
|
"@opentelemetry/core": "2.10.0",
|
|
129
|
-
"axios": "1.
|
|
129
|
+
"axios": "1.20.0",
|
|
130
|
+
"vite": "6.4.3"
|
|
130
131
|
}
|
|
131
132
|
}
|
package/ui/components/Table.d.ts
CHANGED
|
@@ -23,15 +23,15 @@ export type TableProps<T extends ScalarDict> = {
|
|
|
23
23
|
/**
|
|
24
24
|
* Header component.
|
|
25
25
|
*/
|
|
26
|
-
header: (props: React.PropsWithChildren<object>) => JSX.Element;
|
|
26
|
+
header: (props: React.PropsWithChildren<object>) => React.JSX.Element;
|
|
27
27
|
/**
|
|
28
28
|
* Component used to render a cell in the table.
|
|
29
29
|
*/
|
|
30
|
-
cell: (props: CellProps) => JSX.Element;
|
|
30
|
+
cell: (props: CellProps) => React.JSX.Element;
|
|
31
31
|
/**
|
|
32
32
|
* Component used to render the skeleton of the table.
|
|
33
33
|
*/
|
|
34
|
-
skeleton: (props: React.PropsWithChildren<object>) => JSX.Element;
|
|
34
|
+
skeleton: (props: React.PropsWithChildren<object>) => React.JSX.Element;
|
|
35
35
|
/**
|
|
36
36
|
* Whether to render without borders.
|
|
37
37
|
*/
|
|
@@ -57,11 +57,11 @@ export default class Table<T extends ScalarDict> extends React.Component<Pick<Ta
|
|
|
57
57
|
* Returns a (data) row representing the headings.
|
|
58
58
|
*/
|
|
59
59
|
getHeadings(): Partial<T>;
|
|
60
|
-
getHeaderRow(): (props: RowProps<T>) => JSX.Element;
|
|
61
|
-
getHeadingRow(): (props: RowProps<T>) => JSX.Element;
|
|
62
|
-
getSeparatorRow(): (props: RowProps<T>) => JSX.Element;
|
|
63
|
-
getDataRow(): (props: RowProps<T>) => JSX.Element;
|
|
64
|
-
getFooterRow(): (props: RowProps<T>) => JSX.Element;
|
|
60
|
+
getHeaderRow(): (props: RowProps<T>) => React.JSX.Element;
|
|
61
|
+
getHeadingRow(): (props: RowProps<T>) => React.JSX.Element;
|
|
62
|
+
getSeparatorRow(): (props: RowProps<T>) => React.JSX.Element;
|
|
63
|
+
getDataRow(): (props: RowProps<T>) => React.JSX.Element;
|
|
64
|
+
getFooterRow(): (props: RowProps<T>) => React.JSX.Element;
|
|
65
65
|
render(): React.JSX.Element;
|
|
66
66
|
}
|
|
67
67
|
type RowProps<T extends ScalarDict> = {
|
|
File without changes
|
|
File without changes
|