@salesforce/agents 0.1.2
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/LICENSE.txt +12 -0
- package/README.md +13 -0
- package/lib/agent.d.ts +18 -0
- package/lib/agent.js +105 -0
- package/lib/agent.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +12 -0
- package/lib/index.js.map +1 -0
- package/lib/mockDir.d.ts +9 -0
- package/lib/mockDir.js +48 -0
- package/lib/mockDir.js.map +1 -0
- package/lib/types.d.ts +51 -0
- package/lib/types.js +9 -0
- package/lib/types.js.map +1 -0
- package/messages/agents.md +0 -0
- package/package.json +171 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Copyright (c) 2024, Salesforce.com, Inc.
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
5
|
+
|
|
6
|
+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
7
|
+
|
|
8
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
9
|
+
|
|
10
|
+
* Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
11
|
+
|
|
12
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Salesforce Agents - UNDER DEVELOPMENT
|
|
2
|
+
|
|
3
|
+
### THIS LIBRARY IS UNDER DEVELOPMENT AND IS NOT MEANT FOR PRODUCTION USAGE.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@salesforce/agents) [](https://npmjs.org/package/@salesforce/agents) [](https://raw.githubusercontent.com/forcedotcom/agents/main/LICENSE.txt)
|
|
6
|
+
|
|
7
|
+
## Description
|
|
8
|
+
|
|
9
|
+
A TypeScript library for working with Salesforce Agents.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
TBD
|
package/lib/agent.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Connection, SfProject } from '@salesforce/core';
|
|
2
|
+
import { type SfAgent, type AgentCreateConfig, type AgentCreateResponse, type AgentJobSpec, type AgentJobSpecCreateConfig } from './types.js';
|
|
3
|
+
export declare class Agent implements SfAgent {
|
|
4
|
+
private connection;
|
|
5
|
+
private project;
|
|
6
|
+
private logger;
|
|
7
|
+
private mockDir?;
|
|
8
|
+
constructor(connection: Connection, project: SfProject);
|
|
9
|
+
create(config: AgentCreateConfig): Promise<AgentCreateResponse>;
|
|
10
|
+
/**
|
|
11
|
+
* Create an agent spec from provided data.
|
|
12
|
+
*
|
|
13
|
+
* @param config The configuration used to generate an agent spec.
|
|
14
|
+
*/
|
|
15
|
+
createSpec(config: AgentJobSpecCreateConfig): Promise<AgentJobSpec>;
|
|
16
|
+
private verifyAgentSpecConfig;
|
|
17
|
+
private buildAgentJobSpecUrl;
|
|
18
|
+
}
|
package/lib/agent.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.Agent = void 0;
|
|
10
|
+
const node_path_1 = require("node:path");
|
|
11
|
+
const node_fs_1 = require("node:fs");
|
|
12
|
+
const node_util_1 = require("node:util");
|
|
13
|
+
const core_1 = require("@salesforce/core");
|
|
14
|
+
const kit_1 = require("@salesforce/kit");
|
|
15
|
+
const mockDir_1 = require("./mockDir");
|
|
16
|
+
class Agent {
|
|
17
|
+
connection;
|
|
18
|
+
project;
|
|
19
|
+
logger;
|
|
20
|
+
mockDir;
|
|
21
|
+
constructor(connection, project) {
|
|
22
|
+
this.connection = connection;
|
|
23
|
+
this.project = project;
|
|
24
|
+
this.logger = core_1.Logger.childFromRoot(this.constructor.name);
|
|
25
|
+
this.mockDir = (0, mockDir_1.getMockDir)();
|
|
26
|
+
}
|
|
27
|
+
async create(config) {
|
|
28
|
+
this.logger.debug(`Creating Agent using config: ${(0, node_util_1.inspect)(config)} in project: ${this.project.getPath()}`);
|
|
29
|
+
// Generate a GenAiPlanner in the local project and deploy
|
|
30
|
+
// make API request to /services/data/{api-version}/connect/attach-agent-topics
|
|
31
|
+
await (0, kit_1.sleep)(kit_1.Duration.seconds(3));
|
|
32
|
+
// on success, retrieve all Agent metadata
|
|
33
|
+
return { isSuccess: true };
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Create an agent spec from provided data.
|
|
37
|
+
*
|
|
38
|
+
* @param config The configuration used to generate an agent spec.
|
|
39
|
+
*/
|
|
40
|
+
async createSpec(config) {
|
|
41
|
+
this.verifyAgentSpecConfig(config);
|
|
42
|
+
let agentSpec;
|
|
43
|
+
if (this.mockDir) {
|
|
44
|
+
const specFileName = `${config.name}Spec.json`;
|
|
45
|
+
const specFilePath = (0, node_path_1.join)(this.mockDir, `${specFileName}`);
|
|
46
|
+
try {
|
|
47
|
+
this.logger.debug(`Using mock directory: ${this.mockDir} for agent job spec creation`);
|
|
48
|
+
(0, node_fs_1.statSync)(specFilePath);
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
throw core_1.SfError.create({
|
|
52
|
+
name: 'MissingMockFile',
|
|
53
|
+
message: `SF_MOCK_DIR [${this.mockDir}] must contain a spec file with name ${specFileName}`,
|
|
54
|
+
cause: err,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
this.logger.debug(`Returning mock agent spec file: ${specFilePath}`);
|
|
59
|
+
agentSpec = JSON.parse((0, node_fs_1.readFileSync)(specFilePath, 'utf8'));
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
throw core_1.SfError.create({
|
|
63
|
+
name: 'InvalidMockFile',
|
|
64
|
+
message: `SF_MOCK_DIR [${this.mockDir}] must contain a valid spec file with name ${specFileName}`,
|
|
65
|
+
cause: err,
|
|
66
|
+
actions: [
|
|
67
|
+
'Check that the file is readable',
|
|
68
|
+
'Check that the file is a valid JSON array of jobTitle and jobDescription objects',
|
|
69
|
+
],
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
// TODO: We'll probably want to wrap this for better error handling but let's see
|
|
75
|
+
// what it looks like first.
|
|
76
|
+
const response = await this.connection.requestGet(this.buildAgentJobSpecUrl(config), {
|
|
77
|
+
retry: { maxRetries: 3 },
|
|
78
|
+
});
|
|
79
|
+
if (response.isSuccess) {
|
|
80
|
+
agentSpec = response?.jobSpecs;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
throw core_1.SfError.create({
|
|
84
|
+
name: 'AgentJobSpecCreateError',
|
|
85
|
+
message: response.errorMessage ?? 'unknown',
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return agentSpec;
|
|
90
|
+
}
|
|
91
|
+
// eslint-disable-next-line class-methods-use-this
|
|
92
|
+
verifyAgentSpecConfig(config) {
|
|
93
|
+
// TBD: for now just return. At some point verify all required config values.
|
|
94
|
+
if (config)
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
// eslint-disable-next-line class-methods-use-this
|
|
98
|
+
buildAgentJobSpecUrl(config) {
|
|
99
|
+
const { type, role, companyName, companyDescription, companyWebsite } = config;
|
|
100
|
+
const website = companyWebsite ? `&companyWebsite=${companyWebsite}` : '';
|
|
101
|
+
return `/connect/agent-job-spec?agentType=${type}&role=${role}&companyName=${companyName}&companyDescription=${companyDescription}${website}`;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.Agent = Agent;
|
|
105
|
+
//# sourceMappingURL=agent.js.map
|
package/lib/agent.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,yCAAiC;AACjC,qCAAiD;AACjD,yCAAoC;AACpC,2CAA0E;AAC1E,yCAAkD;AAClD,uCAAuC;AAUvC,MAAa,KAAK;IAIW;IAAgC;IAHnD,MAAM,CAAS;IACf,OAAO,CAAU;IAEzB,YAA2B,UAAsB,EAAU,OAAkB;QAAlD,eAAU,GAAV,UAAU,CAAY;QAAU,YAAO,GAAP,OAAO,CAAW;QAC3E,IAAI,CAAC,MAAM,GAAG,aAAM,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAC1D,IAAI,CAAC,OAAO,GAAG,IAAA,oBAAU,GAAE,CAAC;IAC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AAqC,IAAI,SAAS,IAAI,gBAAgB,WAAW,uBAAuB,kBAAkB,GAAG,OAAO,EAAE,CAAC;IAChJ,CAAC;CACF;AAzFD,sBAyFC"}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.Agent = void 0;
|
|
10
|
+
var agent_1 = require("./agent");
|
|
11
|
+
Object.defineProperty(exports, "Agent", { enumerable: true, get: function () { return agent_1.Agent; } });
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAUH,iCAAgC;AAAvB,8FAAA,KAAK,OAAA"}
|
package/lib/mockDir.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* If the `SF_MOCK_DIR` environment variable is set, resolve to an absolue path
|
|
3
|
+
* and ensure the directory exits, then return the path.
|
|
4
|
+
*
|
|
5
|
+
* NOTE: THIS SHOULD BE MOVED TO SOME OTHER LIBRARY LIKE `@salesforce/kit`.
|
|
6
|
+
*
|
|
7
|
+
* @returns the absolute path to an existing directory used for mocking behavior
|
|
8
|
+
*/
|
|
9
|
+
export declare const getMockDir: () => string | undefined;
|
package/lib/mockDir.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.getMockDir = void 0;
|
|
10
|
+
const node_path_1 = require("node:path");
|
|
11
|
+
const node_fs_1 = require("node:fs");
|
|
12
|
+
const core_1 = require("@salesforce/core");
|
|
13
|
+
const kit_1 = require("@salesforce/kit");
|
|
14
|
+
/**
|
|
15
|
+
* If the `SF_MOCK_DIR` environment variable is set, resolve to an absolue path
|
|
16
|
+
* and ensure the directory exits, then return the path.
|
|
17
|
+
*
|
|
18
|
+
* NOTE: THIS SHOULD BE MOVED TO SOME OTHER LIBRARY LIKE `@salesforce/kit`.
|
|
19
|
+
*
|
|
20
|
+
* @returns the absolute path to an existing directory used for mocking behavior
|
|
21
|
+
*/
|
|
22
|
+
const getMockDir = () => {
|
|
23
|
+
const mockDir = kit_1.env.getString('SF_MOCK_DIR');
|
|
24
|
+
if (mockDir) {
|
|
25
|
+
let mockDirStat;
|
|
26
|
+
try {
|
|
27
|
+
mockDirStat = (0, node_fs_1.statSync)((0, node_path_1.resolve)(mockDir));
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
throw core_1.SfError.create({
|
|
31
|
+
name: 'InvalidMockDir',
|
|
32
|
+
message: `SF_MOCK_DIR [${mockDir}] not found`,
|
|
33
|
+
cause: err,
|
|
34
|
+
actions: ['If you\'re trying to mock agent behavior you must create the mock directory and add expected mock files to it.']
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (!mockDirStat.isDirectory()) {
|
|
38
|
+
throw core_1.SfError.create({
|
|
39
|
+
name: 'InvalidMockDir',
|
|
40
|
+
message: `SF_MOCK_DIR [${mockDir}] is not a directory`,
|
|
41
|
+
actions: ['If you\'re trying to mock agent behavior you must create the mock directory and add expected mock files to it.']
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return mockDir;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
exports.getMockDir = getMockDir;
|
|
48
|
+
//# sourceMappingURL=mockDir.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mockDir.js","sourceRoot":"","sources":["../src/mockDir.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,yCAAoC;AACpC,qCAA+C;AAC/C,2CAA2C;AAC3C,yCAAsC;AAEtC;;;;;;;GAOG;AACI,MAAM,UAAU,GAAG,GAAuB,EAAE;IACjD,MAAM,OAAO,GAAG,SAAG,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IAC7C,IAAI,OAAO,EAAE,CAAC;QACZ,IAAI,WAAkB,CAAC;QACvB,IAAI,CAAC;YACH,WAAW,GAAG,IAAA,kBAAQ,EAAC,IAAA,mBAAO,EAAC,OAAO,CAAC,CAAC,CAAC;QAC3C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,cAAO,CAAC,MAAM,CAAC;gBACnB,IAAI,EAAE,gBAAgB;gBACtB,OAAO,EAAE,gBAAgB,OAAO,aAAa;gBAC7C,KAAK,EAAE,GAAG;gBACV,OAAO,EAAE,CAAC,gHAAgH,CAAC;aAC5H,CAAC,CAAC;QACL,CAAC;QAED,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,EAAE,CAAC;YAC/B,MAAM,cAAO,CAAC,MAAM,CAAC;gBACnB,IAAI,EAAE,gBAAgB;gBACtB,OAAO,EAAE,gBAAgB,OAAO,sBAAsB;gBACtD,OAAO,EAAE,CAAC,gHAAgH,CAAC;aAC5H,CAAC,CAAC;QACL,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC,CAAA;AAxBY,QAAA,UAAU,cAwBtB"}
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An agent job spec is a list of job titles and descriptions
|
|
3
|
+
* to be performed by the agent.
|
|
4
|
+
*/
|
|
5
|
+
export type AgentJobSpec = [
|
|
6
|
+
{
|
|
7
|
+
jobTitle: string;
|
|
8
|
+
jobDescription: string;
|
|
9
|
+
}
|
|
10
|
+
];
|
|
11
|
+
/**
|
|
12
|
+
* The parameters used to generate an agent spec.
|
|
13
|
+
*/
|
|
14
|
+
export type AgentJobSpecCreateConfig = {
|
|
15
|
+
name: string;
|
|
16
|
+
type: 'customer_facing' | 'employee_facing';
|
|
17
|
+
role: string;
|
|
18
|
+
companyName: string;
|
|
19
|
+
companyDescription: string;
|
|
20
|
+
companyWebsite?: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The parameters used to generate an agent in an org.
|
|
24
|
+
*
|
|
25
|
+
* NOTE: This is likely to change with planned serverside APIs.
|
|
26
|
+
*/
|
|
27
|
+
export type AgentCreateConfig = AgentJobSpecCreateConfig & {
|
|
28
|
+
jobSpecs: AgentJobSpec;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* An interface for working with Agents.
|
|
32
|
+
*/
|
|
33
|
+
export type SfAgent = {
|
|
34
|
+
create(config: AgentCreateConfig): Promise<AgentCreateResponse>;
|
|
35
|
+
createSpec(config: AgentJobSpecCreateConfig): Promise<AgentJobSpec>;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* The response from the `agent-job-spec` API.
|
|
39
|
+
*/
|
|
40
|
+
export type AgentJobSpecCreateResponse = {
|
|
41
|
+
isSuccess: boolean;
|
|
42
|
+
errorMessage?: string;
|
|
43
|
+
jobSpecs?: AgentJobSpec;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* The response from the `attach-agent-topics` API.
|
|
47
|
+
*/
|
|
48
|
+
export type AgentCreateResponse = {
|
|
49
|
+
isSuccess: boolean;
|
|
50
|
+
errorMessage?: string;
|
|
51
|
+
};
|
package/lib/types.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
package/lib/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
|
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@salesforce/agents",
|
|
3
|
+
"description": "Client side APIs for working with Salesforce agents",
|
|
4
|
+
"version": "0.1.2",
|
|
5
|
+
"license": "BSD-3-Clause",
|
|
6
|
+
"author": "Salesforce",
|
|
7
|
+
"main": "lib/index",
|
|
8
|
+
"types": "lib/index.d.ts",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/forcedotcom/agents.git"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@salesforce/core": "^8.5.2",
|
|
15
|
+
"@salesforce/kit": "^3.2.3"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@salesforce/cli-plugins-testkit": "^5.3.20",
|
|
19
|
+
"@salesforce/dev-scripts": "^10.2.10",
|
|
20
|
+
"ts-node": "^10.9.2",
|
|
21
|
+
"typescript": "^5.5.4"
|
|
22
|
+
},
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=18.0.0"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"/lib",
|
|
28
|
+
"/messages"
|
|
29
|
+
],
|
|
30
|
+
"keywords": [
|
|
31
|
+
"force",
|
|
32
|
+
"salesforce",
|
|
33
|
+
"salesforcedx",
|
|
34
|
+
"sf",
|
|
35
|
+
"sfdx",
|
|
36
|
+
"agents",
|
|
37
|
+
"agentforce",
|
|
38
|
+
"ai"
|
|
39
|
+
],
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "wireit",
|
|
42
|
+
"clean": "sf-clean",
|
|
43
|
+
"clean-all": "sf-clean all",
|
|
44
|
+
"compile": "wireit",
|
|
45
|
+
"docs": "sf-docs",
|
|
46
|
+
"format": "wireit",
|
|
47
|
+
"link-check": "wireit",
|
|
48
|
+
"lint": "wireit",
|
|
49
|
+
"lint-fix": "yarn sf-lint --fix",
|
|
50
|
+
"postcompile": "tsc -p test",
|
|
51
|
+
"prepack": "sf-prepack",
|
|
52
|
+
"prepare": "sf-install",
|
|
53
|
+
"test": "wireit",
|
|
54
|
+
"test:nuts": "echo 'No tests to run'",
|
|
55
|
+
"test:only": "wireit"
|
|
56
|
+
},
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"access": "public"
|
|
59
|
+
},
|
|
60
|
+
"wireit": {
|
|
61
|
+
"build": {
|
|
62
|
+
"dependencies": [
|
|
63
|
+
"compile",
|
|
64
|
+
"lint"
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
"compile": {
|
|
68
|
+
"command": "tsc -p . --pretty --incremental",
|
|
69
|
+
"files": [
|
|
70
|
+
"src/**/*.ts",
|
|
71
|
+
"**/tsconfig.json",
|
|
72
|
+
"messages/**"
|
|
73
|
+
],
|
|
74
|
+
"output": [
|
|
75
|
+
"lib/**",
|
|
76
|
+
"*.tsbuildinfo"
|
|
77
|
+
],
|
|
78
|
+
"clean": "if-file-deleted"
|
|
79
|
+
},
|
|
80
|
+
"format": {
|
|
81
|
+
"command": "prettier --write \"+(src|test|schemas)/**/*.+(ts|js|json)|command-snapshot.json\"",
|
|
82
|
+
"files": [
|
|
83
|
+
"src/**/*.ts",
|
|
84
|
+
"test/**/*.ts",
|
|
85
|
+
"schemas/**/*.json",
|
|
86
|
+
"command-snapshot.json",
|
|
87
|
+
".prettier*"
|
|
88
|
+
],
|
|
89
|
+
"output": []
|
|
90
|
+
},
|
|
91
|
+
"lint": {
|
|
92
|
+
"command": "eslint src test --color --cache --cache-location .eslintcache",
|
|
93
|
+
"files": [
|
|
94
|
+
"src/**/*.ts",
|
|
95
|
+
"test/**/*.ts",
|
|
96
|
+
"messages/**",
|
|
97
|
+
"**/.eslint*",
|
|
98
|
+
"**/tsconfig.json"
|
|
99
|
+
],
|
|
100
|
+
"output": []
|
|
101
|
+
},
|
|
102
|
+
"test:compile": {
|
|
103
|
+
"command": "tsc -p \"./test\" --pretty",
|
|
104
|
+
"files": [
|
|
105
|
+
"test/**/*.ts",
|
|
106
|
+
"**/tsconfig.json"
|
|
107
|
+
],
|
|
108
|
+
"output": []
|
|
109
|
+
},
|
|
110
|
+
"test": {
|
|
111
|
+
"dependencies": [
|
|
112
|
+
"test:only",
|
|
113
|
+
"test:compile",
|
|
114
|
+
"link-check"
|
|
115
|
+
]
|
|
116
|
+
},
|
|
117
|
+
"test:only": {
|
|
118
|
+
"command": "nyc mocha \"test/**/*.test.ts\"",
|
|
119
|
+
"env": {
|
|
120
|
+
"FORCE_COLOR": "2"
|
|
121
|
+
},
|
|
122
|
+
"files": [
|
|
123
|
+
"test/**/*.ts",
|
|
124
|
+
"src/**/*.ts",
|
|
125
|
+
"**/tsconfig.json",
|
|
126
|
+
".mocha*",
|
|
127
|
+
"!*.nut.ts",
|
|
128
|
+
".nycrc"
|
|
129
|
+
],
|
|
130
|
+
"output": []
|
|
131
|
+
},
|
|
132
|
+
"test:command-reference": {
|
|
133
|
+
"command": "node --loader ts-node/esm --no-warnings=ExperimentalWarning \"./bin/dev.js\" commandreference:generate --erroronwarnings",
|
|
134
|
+
"files": [
|
|
135
|
+
"src/**/*.ts",
|
|
136
|
+
"messages/**",
|
|
137
|
+
"package.json"
|
|
138
|
+
],
|
|
139
|
+
"output": [
|
|
140
|
+
"tmp/root"
|
|
141
|
+
]
|
|
142
|
+
},
|
|
143
|
+
"test:deprecation-policy": {
|
|
144
|
+
"command": "node --loader ts-node/esm --no-warnings=ExperimentalWarning \"./bin/dev.js\" snapshot:compare",
|
|
145
|
+
"files": [
|
|
146
|
+
"src/**/*.ts"
|
|
147
|
+
],
|
|
148
|
+
"output": [],
|
|
149
|
+
"dependencies": [
|
|
150
|
+
"compile"
|
|
151
|
+
]
|
|
152
|
+
},
|
|
153
|
+
"test:json-schema": {
|
|
154
|
+
"command": "node --loader ts-node/esm --no-warnings=ExperimentalWarning \"./bin/dev.js\" schema:compare",
|
|
155
|
+
"files": [
|
|
156
|
+
"src/**/*.ts",
|
|
157
|
+
"schemas"
|
|
158
|
+
],
|
|
159
|
+
"output": []
|
|
160
|
+
},
|
|
161
|
+
"link-check": {
|
|
162
|
+
"command": "node -e \"process.exit(process.env.CI ? 0 : 1)\" || linkinator \"**/*.md\" --skip \"CHANGELOG.md|node_modules|test/|confluence.internal.salesforce.com|my.salesforce.com|%s\" --markdown --retry --directory-listing --verbosity error",
|
|
163
|
+
"files": [
|
|
164
|
+
"./*.md",
|
|
165
|
+
"./!(CHANGELOG).md",
|
|
166
|
+
"messages/**/*.md"
|
|
167
|
+
],
|
|
168
|
+
"output": []
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|