@avalant/piece-promptx-agent 0.0.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/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # pieces-promptx-agent
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build pieces-promptx-agent` to build the library.
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@avalant/piece-promptx-agent",
3
+ "version": "0.0.1",
4
+ "type": "commonjs",
5
+ "main": "./src/index.js",
6
+ "types": "./src/index.d.ts",
7
+ "dependencies": {
8
+ "@ai-sdk/anthropic": "1.2.12",
9
+ "@ai-sdk/openai": "1.3.22",
10
+ "@ai-sdk/replicate": "0.2.8",
11
+ "@sinclair/typebox": "0.34.11",
12
+ "ai": "4.3.16",
13
+ "axios": "1.8.3",
14
+ "axios-retry": "4.4.1",
15
+ "deepmerge-ts": "7.1.0",
16
+ "fast-glob": "3.3.3",
17
+ "mime-types": "2.1.35",
18
+ "nanoid": "3.3.8",
19
+ "semver": "7.6.0",
20
+ "zod": "3.25.64",
21
+ "@activepieces/pieces-common": "link:/Users/rupalbarman/avalant/AutomationX/dist/packages/pieces/community/common",
22
+ "@activepieces/pieces-framework": "link:/Users/rupalbarman/avalant/AutomationX/dist/packages/pieces/community/framework",
23
+ "@activepieces/shared": "link:/Users/rupalbarman/avalant/AutomationX/dist/packages/shared",
24
+ "tslib": "2.8.1"
25
+ },
26
+ "overrides": {
27
+ "@tryfabric/martian": {
28
+ "@notionhq/client": "$@notionhq/client"
29
+ },
30
+ "vite": {
31
+ "rollup": "npm:@rollup/wasm-node"
32
+ }
33
+ },
34
+ "resolutions": {
35
+ "rollup": "npm:@rollup/wasm-node"
36
+ }
37
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export declare const promptxAgent: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").CustomAuthProperty<{
2
+ server: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
3
+ username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
+ password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
5
+ }>>;
package/src/index.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.promptxAgent = void 0;
4
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
5
+ const auth_1 = require("./lib/common/auth");
6
+ const shared_1 = require("@activepieces/shared");
7
+ const talk_to_agent_1 = require("./lib/actions/talk-to-agent");
8
+ const fetch_conversations_1 = require("./lib/actions/fetch-conversations");
9
+ const create_conversation_1 = require("./lib/actions/create-conversation");
10
+ exports.promptxAgent = (0, pieces_framework_1.createPiece)({
11
+ displayName: 'PromptX Agent',
12
+ description: 'Interact and talk to your agents created in AgentX',
13
+ auth: auth_1.promptxAuth,
14
+ minimumSupportedRelease: '0.36.1',
15
+ logoUrl: 'https://cdn.activepieces.com/pieces/agent.png',
16
+ categories: [shared_1.PieceCategory.ARTIFICIAL_INTELLIGENCE],
17
+ authors: ['rupalbarman'],
18
+ actions: [talk_to_agent_1.talkToAgent, fetch_conversations_1.fetchConversationsAction, create_conversation_1.createConversationAction],
19
+ triggers: [],
20
+ });
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/promptx-agent/src/index.ts"],"names":[],"mappings":";;;AAAA,qEAA6D;AAC7D,4CAAgD;AAChD,iDAAqD;AACrD,+DAA0D;AAC1D,2EAA6E;AAC7E,2EAA6E;AAEhE,QAAA,YAAY,GAAG,IAAA,8BAAW,EAAC;IACtC,WAAW,EAAE,eAAe;IAC5B,WAAW,EAAE,oDAAoD;IACjE,IAAI,EAAE,kBAAW;IACjB,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,+CAA+C;IACxD,UAAU,EAAE,CAAC,sBAAa,CAAC,uBAAuB,CAAC;IACnD,OAAO,EAAE,CAAC,aAAa,CAAC;IACxB,OAAO,EAAE,CAAC,2BAAW,EAAE,8CAAwB,EAAE,8CAAwB,CAAC;IAC1E,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ export declare const createConversationAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
2
+ server: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
3
+ username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
+ password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
5
+ }>, {
6
+ title: import("@activepieces/pieces-framework").ShortTextProperty<true>;
7
+ slug: import("@activepieces/pieces-framework").ShortTextProperty<false>;
8
+ agentId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
9
+ }>;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createConversationAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const helper_1 = require("../common/helper");
7
+ const auth_1 = require("../common/auth");
8
+ exports.createConversationAction = (0, pieces_framework_1.createAction)({
9
+ auth: auth_1.promptxAuth,
10
+ name: 'createConversation',
11
+ displayName: 'Create Conversation',
12
+ description: 'Create a new conversation with an agent',
13
+ props: {
14
+ title: pieces_framework_1.Property.ShortText({
15
+ displayName: 'Title',
16
+ description: 'Conversation title',
17
+ required: true,
18
+ }),
19
+ slug: pieces_framework_1.Property.ShortText({
20
+ displayName: 'Slug',
21
+ description: 'Conversation slug / key which can be used to ensure a single conversation is used while interacting with the agent',
22
+ required: false,
23
+ }),
24
+ agentId: pieces_framework_1.Property.Dropdown({
25
+ displayName: 'Agent',
26
+ description: 'Agent that you would like to converse with',
27
+ required: true,
28
+ refreshers: [],
29
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
30
+ const promptXAuth = auth;
31
+ const agentXToken = yield (0, helper_1.getAgentXToken)(promptXAuth);
32
+ const agents = yield (0, helper_1.fetchAgents)(Object.assign(Object.assign({}, promptXAuth), { agentXToken }));
33
+ return {
34
+ disabled: false,
35
+ options: agents.map((agent) => {
36
+ return {
37
+ label: agent.name,
38
+ value: agent.id,
39
+ };
40
+ }),
41
+ };
42
+ }),
43
+ }),
44
+ },
45
+ run(_a) {
46
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
47
+ const promptXAuth = auth;
48
+ const agentXToken = yield (0, helper_1.getAgentXToken)(promptXAuth);
49
+ const conversation = yield (0, helper_1.createConversation)(Object.assign(Object.assign({}, promptXAuth), { agentXToken }), propsValue);
50
+ return conversation;
51
+ });
52
+ },
53
+ });
54
+ //# sourceMappingURL=create-conversation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-conversation.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/promptx-agent/src/lib/actions/create-conversation.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AAExE,6CAI0B;AAC1B,yCAA6C;AAEhC,QAAA,wBAAwB,GAAG,IAAA,+BAAY,EAAC;IACnD,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,qBAAqB;IAClC,WAAW,EAAE,yCAAyC;IACtD,KAAK,EAAE;QACL,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,oBAAoB;YACjC,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,IAAI,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACvB,WAAW,EAAE,MAAM;YACnB,WAAW,EACT,oHAAoH;YACtH,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,OAAO,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACzB,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,4CAA4C;YACzD,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,EAAE;YACd,OAAO,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;gBACtB,MAAM,WAAW,GAAG,IAAuB,CAAC;gBAC5C,MAAM,WAAW,GAAG,MAAM,IAAA,uBAAc,EAAC,WAAW,CAAC,CAAC;gBACtD,MAAM,MAAM,GAAG,MAAM,IAAA,oBAAW,kCAC3B,WAAW,KACd,WAAW,IACX,CAAC;gBACH,OAAO;oBACL,QAAQ,EAAE,KAAK;oBACf,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;wBAC5B,OAAO;4BACL,KAAK,EAAE,KAAK,CAAC,IAAI;4BACjB,KAAK,EAAE,KAAK,CAAC,EAAE;yBAChB,CAAC;oBACJ,CAAC,CAAC;iBACH,CAAC;YACJ,CAAC,CAAA;SACF,CAAC;KACH;IACK,GAAG;qEAAC,EAAE,IAAI,EAAE,UAAU,EAAE;YAC5B,MAAM,WAAW,GAAG,IAAuB,CAAC;YAC5C,MAAM,WAAW,GAAG,MAAM,IAAA,uBAAc,EAAC,WAAW,CAAC,CAAC;YACtD,MAAM,YAAY,GAAG,MAAM,IAAA,2BAAkB,kCACtC,WAAW,KAAE,WAAW,KAC7B,UAAU,CACX,CAAC;YACF,OAAO,YAAY,CAAC;QACtB,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare const fetchConversationsAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
2
+ server: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
3
+ username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
+ password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
5
+ }>, {
6
+ slug: import("@activepieces/pieces-framework").ShortTextProperty<false>;
7
+ }>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchConversationsAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const helper_1 = require("../common/helper");
7
+ const auth_1 = require("../common/auth");
8
+ exports.fetchConversationsAction = (0, pieces_framework_1.createAction)({
9
+ auth: auth_1.promptxAuth,
10
+ name: 'fetchConversations',
11
+ displayName: 'Fetch Conversations',
12
+ description: 'Fetch list of conversations by the user',
13
+ props: {
14
+ slug: pieces_framework_1.Property.ShortText({
15
+ displayName: 'Slug',
16
+ description: 'The slug / key of the conversation to search for. Returns empty list if it does not exist',
17
+ required: false,
18
+ }),
19
+ },
20
+ run(_a) {
21
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
22
+ const promptXAuth = auth;
23
+ const agentXToken = yield (0, helper_1.getAgentXToken)(promptXAuth);
24
+ const conversations = yield (0, helper_1.fetchConversations)(Object.assign(Object.assign({}, promptXAuth), { agentXToken }), propsValue);
25
+ return conversations;
26
+ });
27
+ },
28
+ });
29
+ //# sourceMappingURL=fetch-conversations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-conversations.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/promptx-agent/src/lib/actions/fetch-conversations.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AAExE,6CAAsE;AACtE,yCAA6C;AAEhC,QAAA,wBAAwB,GAAG,IAAA,+BAAY,EAAC;IACnD,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,qBAAqB;IAClC,WAAW,EAAE,yCAAyC;IACtD,KAAK,EAAE;QACL,IAAI,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACvB,WAAW,EAAE,MAAM;YACnB,WAAW,EACT,2FAA2F;YAC7F,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH;IACK,GAAG;qEAAC,EAAE,IAAI,EAAE,UAAU,EAAE;YAC5B,MAAM,WAAW,GAAG,IAAuB,CAAC;YAC5C,MAAM,WAAW,GAAG,MAAM,IAAA,uBAAc,EAAC,WAAW,CAAC,CAAC;YACtD,MAAM,aAAa,GAAG,MAAM,IAAA,2BAAkB,kCACvC,WAAW,KAAE,WAAW,KAC7B,UAAU,CACX,CAAC;YACF,OAAO,aAAa,CAAC;QACvB,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare const talkToAgent: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
2
+ server: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
3
+ username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
+ password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
5
+ }>, {
6
+ conversationId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
7
+ message: import("@activepieces/pieces-framework").LongTextProperty<true>;
8
+ }>;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.talkToAgent = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const auth_1 = require("../common/auth");
7
+ const helper_1 = require("../common/helper");
8
+ exports.talkToAgent = (0, pieces_framework_1.createAction)({
9
+ auth: auth_1.promptxAuth,
10
+ name: 'talkToAgent',
11
+ displayName: 'Talk to Agent',
12
+ description: 'Talk to your agent pre-configured in AgentX',
13
+ props: {
14
+ conversationId: pieces_framework_1.Property.ShortText({
15
+ displayName: 'Conversation',
16
+ description: 'Conversation ID to continue your talk with the agent',
17
+ required: true,
18
+ }),
19
+ message: pieces_framework_1.Property.LongText({
20
+ displayName: 'Message',
21
+ required: true,
22
+ }),
23
+ },
24
+ run(_a) {
25
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
26
+ const { message, conversationId } = propsValue;
27
+ const promptXAuth = auth;
28
+ const agentXToken = yield (0, helper_1.getAgentXToken)(promptXAuth);
29
+ const chatResponse = yield (0, helper_1.postChatMessage)(Object.assign(Object.assign({}, promptXAuth), { agentXToken }), conversationId, message);
30
+ return chatResponse;
31
+ });
32
+ },
33
+ });
34
+ //# sourceMappingURL=talk-to-agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"talk-to-agent.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/promptx-agent/src/lib/actions/talk-to-agent.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,yCAA6C;AAE7C,6CAAmE;AAEtD,QAAA,WAAW,GAAG,IAAA,+BAAY,EAAC;IACtC,IAAI,EAAE,kBAAW;IACjB,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,eAAe;IAC5B,WAAW,EAAE,6CAA6C;IAC1D,KAAK,EAAE;QACL,cAAc,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACjC,WAAW,EAAE,cAAc;YAC3B,WAAW,EAAE,sDAAsD;YACnE,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,OAAO,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACzB,WAAW,EAAE,SAAS;YACtB,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG;qEAAC,EAAE,IAAI,EAAE,UAAU,EAAE;YAC5B,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,UAAU,CAAC;YAC/C,MAAM,WAAW,GAAG,IAAuB,CAAC;YAC5C,MAAM,WAAW,GAAG,MAAM,IAAA,uBAAc,EAAC,WAAW,CAAC,CAAC;YACtD,MAAM,YAAY,GAAG,MAAM,IAAA,wBAAe,kCACnC,WAAW,KAAE,WAAW,KAC7B,cAAc,EACd,OAAO,CACR,CAAC;YACF,OAAO,YAAY,CAAC;QACtB,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const promptxAuth: import("@activepieces/pieces-framework").CustomAuthProperty<{
2
+ server: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
3
+ username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
+ password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
5
+ }>;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.promptxAuth = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const shared_1 = require("@activepieces/shared");
7
+ const helper_1 = require("./helper");
8
+ const pieces_common_1 = require("@activepieces/pieces-common");
9
+ const zod_1 = require("zod");
10
+ exports.promptxAuth = pieces_framework_1.PieceAuth.CustomAuth({
11
+ required: true,
12
+ props: {
13
+ server: pieces_framework_1.Property.StaticDropdown({
14
+ displayName: 'Server',
15
+ options: {
16
+ options: [
17
+ {
18
+ label: 'Production',
19
+ value: 'production',
20
+ },
21
+ {
22
+ label: 'Test',
23
+ value: 'staging',
24
+ },
25
+ ],
26
+ },
27
+ required: true,
28
+ defaultValue: 'production',
29
+ }),
30
+ username: pieces_framework_1.Property.ShortText({
31
+ displayName: 'Username',
32
+ description: 'PromptX username',
33
+ required: true,
34
+ }),
35
+ password: pieces_framework_1.PieceAuth.SecretText({
36
+ displayName: 'Password',
37
+ description: 'PromptX password',
38
+ required: true,
39
+ }),
40
+ },
41
+ validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
42
+ try {
43
+ yield validateAuth(auth);
44
+ return { valid: true };
45
+ }
46
+ catch (e) {
47
+ return {
48
+ valid: false,
49
+ error: e === null || e === void 0 ? void 0 : e.message,
50
+ };
51
+ }
52
+ }),
53
+ });
54
+ const validateAuth = (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
55
+ yield pieces_common_1.propsValidation.validateZod(auth, {
56
+ server: zod_1.z.union([zod_1.z.literal('production'), zod_1.z.literal('staging')]),
57
+ username: zod_1.z.string(),
58
+ password: zod_1.z.string(),
59
+ });
60
+ const accessToken = yield (0, helper_1.getAccessToken)(auth);
61
+ if ((0, shared_1.isNil)(accessToken)) {
62
+ throw new Error('Authentication failed. Please check your credentials and try again.');
63
+ }
64
+ console.log('[promptx-agent] validated authentication');
65
+ });
66
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/promptx-agent/src/lib/common/auth.ts"],"names":[],"mappings":";;;;AAAA,qEAAqE;AACrE,iDAA6C;AAC7C,qCAA0C;AAE1C,+DAA8D;AAC9D,6BAAwB;AAEX,QAAA,WAAW,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC9C,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE;QACL,MAAM,EAAE,2BAAQ,CAAC,cAAc,CAAC;YAC9B,WAAW,EAAE,QAAQ;YACrB,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP;wBACE,KAAK,EAAE,YAAY;wBACnB,KAAK,EAAE,YAAY;qBACpB;oBACD;wBACE,KAAK,EAAE,MAAM;wBACb,KAAK,EAAE,SAAS;qBACjB;iBACF;aACF;YACD,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,YAAY;SAC3B,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC3B,WAAW,EAAE,UAAU;YACvB,WAAW,EAAE,kBAAkB;YAC/B,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,QAAQ,EAAE,4BAAS,CAAC,UAAU,CAAC;YAC7B,WAAW,EAAE,UAAU;YACvB,WAAW,EAAE,kBAAkB;YAC/B,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACD,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACvB,IAAI,CAAC;YACH,MAAM,YAAY,CAAC,IAAuB,CAAC,CAAC;YAC5C,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACzB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO;gBACL,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAG,CAAW,aAAX,CAAC,uBAAD,CAAC,CAAY,OAAO;aAC7B,CAAC;QACJ,CAAC;IACH,CAAC,CAAA;CACF,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,CAAO,IAAqB,EAAE,EAAE;IACnD,MAAM,+BAAe,CAAC,WAAW,CAAC,IAAI,EAAE;QACtC,MAAM,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;QAChE,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;QACpB,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;KACrB,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,MAAM,IAAA,uBAAc,EAAC,IAAI,CAAC,CAAC;IAE/C,IAAI,IAAA,cAAK,EAAC,WAAW,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CACb,qEAAqE,CACtE,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;AAC1D,CAAC,CAAA,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { Agent, Conversation, PromptXAuthType, PromptXUserResponseType } from './types';
2
+ export declare const urlMap: {
3
+ production: {
4
+ loginUrl: string;
5
+ myProfileUrl: string;
6
+ agentXTokenUrl: string;
7
+ agentXBaseUrl: string;
8
+ };
9
+ staging: {
10
+ loginUrl: string;
11
+ myProfileUrl: string;
12
+ agentXTokenUrl: string;
13
+ agentXBaseUrl: string;
14
+ };
15
+ };
16
+ export declare const getAccessToken: (auth: PromptXAuthType) => Promise<string>;
17
+ export declare const getUserProfile: (auth: PromptXAuthType) => Promise<PromptXUserResponseType>;
18
+ export declare const getAgentXToken: (auth: PromptXAuthType) => Promise<string>;
19
+ export declare const fetchAgents: (auth: PromptXAuthType) => Promise<Agent[]>;
20
+ export declare const fetchConversations: (auth: PromptXAuthType, params: {
21
+ slug?: string;
22
+ }) => Promise<Conversation[]>;
23
+ export declare const createConversation: (auth: PromptXAuthType, params: {
24
+ title: string;
25
+ agentId: string;
26
+ slug?: string;
27
+ }) => Promise<Conversation>;
28
+ export declare const postChatMessage: (auth: PromptXAuthType, threadId: string, message: string) => Promise<string>;
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.postChatMessage = exports.createConversation = exports.fetchConversations = exports.fetchAgents = exports.getAgentXToken = exports.getUserProfile = exports.getAccessToken = exports.urlMap = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const shared_1 = require("@activepieces/shared");
6
+ const querystring_1 = tslib_1.__importDefault(require("querystring"));
7
+ exports.urlMap = {
8
+ production: {
9
+ loginUrl: 'https://centerapp.io/center/auth/login',
10
+ myProfileUrl: 'https://centerapp.io/center//api/v1/users/me',
11
+ agentXTokenUrl: 'https://test.oneweb.tech/zero-service//pmtx/sign-jwt',
12
+ agentXBaseUrl: 'https://test.oneweb.tech/agentx/v1',
13
+ },
14
+ staging: {
15
+ loginUrl: 'https://test.oneweb.tech/zero-service/pmtx/login',
16
+ myProfileUrl: 'https://mocha.centerapp.io/center//api/v1/users/me',
17
+ agentXTokenUrl: 'https://test.oneweb.tech/zero-service//pmtx/sign-jwt',
18
+ agentXBaseUrl: 'https://test.oneweb.tech/agentx/v1',
19
+ },
20
+ };
21
+ const getAccessToken = (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
22
+ const { server, username, password } = auth;
23
+ const response = yield fetch(exports.urlMap[server].loginUrl, {
24
+ method: 'POST',
25
+ body: new URLSearchParams({
26
+ username: username,
27
+ password: password,
28
+ }).toString(),
29
+ headers: {
30
+ 'Content-Type': 'application/x-www-form-urlencoded',
31
+ },
32
+ });
33
+ const data = yield response.json();
34
+ if (response.status !== 200) {
35
+ throw new Error((data === null || data === void 0 ? void 0 : data.error) || (data === null || data === void 0 ? void 0 : data.message));
36
+ }
37
+ console.log('[promptx-agent] acquired promptx access token');
38
+ return data === null || data === void 0 ? void 0 : data.access_token;
39
+ });
40
+ exports.getAccessToken = getAccessToken;
41
+ const getUserProfile = (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
42
+ if ((0, shared_1.isNil)(auth.accessToken)) {
43
+ throw new Error('Access token is missing to fetch user profile');
44
+ }
45
+ const { server, accessToken } = auth;
46
+ const response = yield fetch(exports.urlMap[server].myProfileUrl, {
47
+ headers: {
48
+ 'Content-Type': 'application/json',
49
+ Authorization: `Bearer ${accessToken}`,
50
+ },
51
+ });
52
+ if (response.status !== 200) {
53
+ throw new Error(`API error: ${response.statusText}`);
54
+ }
55
+ console.log('[promptx-agent] acquired promptx user profile');
56
+ const result = yield response.json();
57
+ return result;
58
+ });
59
+ exports.getUserProfile = getUserProfile;
60
+ const getAgentXToken = (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
61
+ const { server } = auth;
62
+ const accessToken = yield (0, exports.getAccessToken)(auth);
63
+ const profile = yield (0, exports.getUserProfile)(Object.assign(Object.assign({}, auth), { accessToken }));
64
+ const response = yield fetch(exports.urlMap[server].agentXTokenUrl, {
65
+ method: 'POST',
66
+ headers: {
67
+ 'Content-Type': 'application/json',
68
+ Authorization: `Bearer ${accessToken}`,
69
+ },
70
+ body: JSON.stringify({
71
+ email: profile.email,
72
+ userId: profile.userIAM2ID,
73
+ firstName: profile.firstname,
74
+ lastName: profile.lastname,
75
+ }),
76
+ });
77
+ if (response.status !== 200) {
78
+ throw new Error(`API error: ${response.statusText}`);
79
+ }
80
+ console.log('[promptx-agent] acquired agentx token');
81
+ const result = yield response.json();
82
+ return result.token;
83
+ });
84
+ exports.getAgentXToken = getAgentXToken;
85
+ const fetchAgents = (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
86
+ if ((0, shared_1.isNil)(auth.agentXToken)) {
87
+ throw new Error('Token is missing to fetch agents');
88
+ }
89
+ const baseUrl = `${exports.urlMap[auth.server].agentXBaseUrl}/agents`;
90
+ const response = yield fetch(baseUrl, {
91
+ headers: {
92
+ Authorization: `Bearer ${auth.agentXToken}`,
93
+ },
94
+ });
95
+ const agents = yield response.json();
96
+ console.log('[promptx-agent] acquired list of agents', agents.length);
97
+ return agents;
98
+ });
99
+ exports.fetchAgents = fetchAgents;
100
+ const fetchConversations = (auth, params) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
101
+ if ((0, shared_1.isNil)(auth.agentXToken)) {
102
+ throw new Error('Token is missing to fetch conversations');
103
+ }
104
+ let baseUrl = `${exports.urlMap[auth.server].agentXBaseUrl}/conversations`;
105
+ if (params.slug) {
106
+ baseUrl += `?${querystring_1.default.stringify(params)}`;
107
+ }
108
+ const response = yield fetch(baseUrl, {
109
+ headers: {
110
+ Authorization: `Bearer ${auth.agentXToken}`,
111
+ },
112
+ });
113
+ const conversations = yield response.json();
114
+ console.log('[promptx-agent] acquired conversations', conversations.length);
115
+ return conversations;
116
+ });
117
+ exports.fetchConversations = fetchConversations;
118
+ const createConversation = (auth, params) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
119
+ if ((0, shared_1.isNil)(auth.agentXToken)) {
120
+ throw new Error('Token is missing to create conversation');
121
+ }
122
+ const baseUrl = `${exports.urlMap[auth.server].agentXBaseUrl}/conversations`;
123
+ const response = yield fetch(baseUrl, {
124
+ method: 'POST',
125
+ headers: {
126
+ 'Content-Type': 'application/json',
127
+ Authorization: `Bearer ${auth.agentXToken}`,
128
+ },
129
+ body: JSON.stringify(params),
130
+ });
131
+ if (response.status !== 200) {
132
+ throw new Error(`API error: ${response.statusText}`);
133
+ }
134
+ const conversation = yield response.json();
135
+ console.log('[promptx-agent] created conversation', conversation.id);
136
+ return conversation;
137
+ });
138
+ exports.createConversation = createConversation;
139
+ const postChatMessage = (auth, threadId, message) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
140
+ if ((0, shared_1.isNil)(auth.agentXToken)) {
141
+ throw new Error('Token is missing to post chat message');
142
+ }
143
+ const baseUrl = `${exports.urlMap[auth.server].agentXBaseUrl}/chat`;
144
+ const response = yield fetch(baseUrl, {
145
+ method: 'POST',
146
+ headers: {
147
+ 'Content-Type': 'application/json',
148
+ Authorization: `Bearer ${auth.agentXToken}`,
149
+ },
150
+ body: JSON.stringify({ message, threadId }),
151
+ });
152
+ if (response.status !== 200) {
153
+ throw new Error(`API error: ${response.statusText}`);
154
+ }
155
+ const chatResponse = yield response.text();
156
+ console.log('[promptx-agent] received chat response');
157
+ return chatResponse;
158
+ });
159
+ exports.postChatMessage = postChatMessage;
160
+ //# sourceMappingURL=helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/promptx-agent/src/lib/common/helper.ts"],"names":[],"mappings":";;;;AAAA,iDAA6C;AAS7C,sEAAsC;AAEzB,QAAA,MAAM,GAAG;IACpB,UAAU,EAAE;QACV,QAAQ,EAAE,wCAAwC;QAClD,YAAY,EAAE,8CAA8C;QAC5D,cAAc,EAAE,sDAAsD;QACtE,aAAa,EAAE,oCAAoC;KACpD;IACD,OAAO,EAAE;QACP,QAAQ,EAAE,kDAAkD;QAC5D,YAAY,EAAE,oDAAoD;QAClE,cAAc,EAAE,sDAAsD;QACtE,aAAa,EAAE,oCAAoC;KACpD;CACF,CAAC;AAEK,MAAM,cAAc,GAAG,CAAO,IAAqB,EAAE,EAAE;IAC5D,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAC5C,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,cAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE;QACpD,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI,eAAe,CAAC;YACxB,QAAQ,EAAE,QAAQ;YAClB,QAAQ,EAAE,QAAQ;SACnB,CAAC,CAAC,QAAQ,EAAE;QACb,OAAO,EAAE;YACP,cAAc,EAAE,mCAAmC;SACpD;KACF,CAAC,CAAC;IACH,MAAM,IAAI,GAA6B,MAAM,QA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AW,EAAE;SAC5C;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;KAC5C,CAAC,CAAC;IACH,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,cAAc,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IACvD,CAAC;IACD,MAAM,YAAY,GAAW,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACnD,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;IACtD,OAAO,YAAY,CAAC;AACtB,CAAC,CAAA,CAAC;AAvBW,QAAA,eAAe,mBAuB1B"}
@@ -0,0 +1,40 @@
1
+ export type PromptXAuthType = {
2
+ server: 'staging' | 'production';
3
+ username: string;
4
+ password: string;
5
+ accessToken?: string;
6
+ agentXToken?: string;
7
+ };
8
+ export type PromptXLoginResponseType = {
9
+ access_token: string;
10
+ error?: string;
11
+ message?: string;
12
+ };
13
+ export type AgentXLoginResponseType = {
14
+ token: string;
15
+ };
16
+ export type PromptXUserResponseType = {
17
+ id: string;
18
+ email: string;
19
+ username: string;
20
+ firstname: string;
21
+ lastname: string;
22
+ userIAM2ID: number;
23
+ };
24
+ export type Agent = {
25
+ createdAt: string;
26
+ updatedAt: string;
27
+ id: string;
28
+ name: string;
29
+ persona: string;
30
+ role: string;
31
+ creatorId: string;
32
+ };
33
+ export type Conversation = {
34
+ createdAt: string;
35
+ updatedAt: string;
36
+ id: string;
37
+ title: string;
38
+ creatorId: string;
39
+ agentId: string;
40
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/promptx-agent/src/lib/common/types.ts"],"names":[],"mappings":""}