@credal/actions 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 +32 -0
- package/dist/actions/actionMapper.d.ts +9 -0
- package/dist/actions/actionMapper.js +79 -0
- package/dist/actions/autogen/definitions.d.ts +5 -0
- package/dist/actions/autogen/definitions.js +132 -0
- package/dist/actions/autogen/templates.d.ts +11 -0
- package/dist/actions/autogen/templates.js +493 -0
- package/dist/actions/autogen/types.d.ts +482 -0
- package/dist/actions/autogen/types.js +153 -0
- package/dist/actions/definitions.js +35 -0
- package/dist/actions/groups.d.ts +6 -0
- package/dist/actions/groups.js +38 -0
- package/dist/actions/invoke.d.ts +8 -0
- package/dist/actions/invoke.js +20 -0
- package/dist/actions/invokeMapper.d.ts +9 -0
- package/dist/actions/invokeMapper.js +33 -0
- package/dist/actions/parse.d.ts +66 -0
- package/dist/actions/parse.js +201 -0
- package/dist/actions/providers/confluence/updatePage.d.ts +3 -0
- package/dist/actions/providers/confluence/updatePage.js +47 -0
- package/dist/actions/providers/credal/callCopilot.d.ts +3 -0
- package/dist/actions/providers/credal/callCopilot.js +31 -0
- package/dist/actions/providers/googlemaps/validateAddress.d.ts +3 -0
- package/dist/actions/providers/googlemaps/validateAddress.js +30 -0
- package/dist/actions/providers/jira/createJiraTicket.d.ts +3 -0
- package/dist/actions/providers/jira/createJiraTicket.js +34 -0
- package/dist/actions/providers/jira/createTicket.d.ts +3 -0
- package/dist/actions/providers/jira/createTicket.js +34 -0
- package/dist/actions/providers/math/add.d.ts +3 -0
- package/dist/actions/providers/math/add.js +17 -0
- package/dist/actions/providers/math/index.d.ts +1 -0
- package/dist/actions/providers/math/index.js +37 -0
- package/dist/actions/providers/mongodb/insertMongoDoc.d.ts +3 -0
- package/dist/actions/providers/mongodb/insertMongoDoc.js +36 -0
- package/dist/actions/providers/slack/helpers.d.ts +6 -0
- package/dist/actions/providers/slack/helpers.js +53 -0
- package/dist/actions/providers/slack/index.d.ts +1 -0
- package/dist/actions/providers/slack/index.js +37 -0
- package/dist/actions/providers/slack/listConversations.d.ts +3 -0
- package/dist/actions/providers/slack/listConversations.js +41 -0
- package/dist/actions/providers/slack/list_conversations.d.ts +3 -0
- package/dist/actions/providers/slack/list_conversations.js +60 -0
- package/dist/actions/providers/slack/sendMessage.d.ts +3 -0
- package/dist/actions/providers/slack/sendMessage.js +36 -0
- package/dist/actions/providers/snowflake/getRowByFieldValue.d.ts +3 -0
- package/dist/actions/providers/snowflake/getRowByFieldValue.js +100 -0
- package/dist/actions/providers/zendesk/createZendeskTicket.d.ts +3 -0
- package/dist/actions/providers/zendesk/createZendeskTicket.js +48 -0
- package/dist/actions/schema.js +6 -0
- package/dist/actions/types.js +2 -0
- package/dist/app.d.ts +9 -0
- package/dist/app.js +97 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +27 -0
- package/dist/main.js +11 -0
- package/dist/utils/string.d.ts +1 -0
- package/dist/utils/string.js +10 -0
- package/package.json +51 -0
package/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# actions
|
2
|
+
|
3
|
+
## Adding or updating actions
|
4
|
+
|
5
|
+
1. Add or update the action in `src/actions/schema.yaml`
|
6
|
+
2. Run `npm run generate:types` to generate the new types
|
7
|
+
3. Run `npm run prettier-format` to format the new files
|
8
|
+
4. Create a new provider function in `src/actions/providers/<provider>/<action>.ts` (eg. `src/actions/providers/math/add.ts`) which exports a function using the generated types
|
9
|
+
5. If adding a new action or provider, update `src/actions/actionMapper.ts` and `src/actions/groups.ts`.
|
10
|
+
6. In `package.json`, bump the version number.
|
11
|
+
7. Run `npm publish --access public` to publish the new version to npm. (Need to be logged in via `npm login`)
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
Invoking an action:
|
16
|
+
|
17
|
+
```ts
|
18
|
+
import { runAction } from "@credal-ai/actions";
|
19
|
+
|
20
|
+
const result = await runAction(
|
21
|
+
"listConversations",
|
22
|
+
"slack",
|
23
|
+
{ authToken: "xoxb-..." },
|
24
|
+
{}
|
25
|
+
);
|
26
|
+
```
|
27
|
+
|
28
|
+
## Running a basic test for `runAction`
|
29
|
+
|
30
|
+
```
|
31
|
+
npx ts-node -r tsconfig-paths/register --project tsconfig.json tests/testRunMathAction.ts
|
32
|
+
```
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { z } from "zod";
|
2
|
+
import { type ActionFunction } from "./autogen/types";
|
3
|
+
interface ActionFunctionComponents {
|
4
|
+
fn: ActionFunction<any, any, any>;
|
5
|
+
paramsSchema: z.ZodSchema;
|
6
|
+
outputSchema: z.ZodSchema;
|
7
|
+
}
|
8
|
+
export declare const ActionMapper: Record<string, Record<string, ActionFunctionComponents>>;
|
9
|
+
export {};
|
@@ -0,0 +1,79 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.ActionMapper = void 0;
|
7
|
+
const types_1 = require("./autogen/types");
|
8
|
+
const updatePage_1 = __importDefault(require("./providers/confluence/updatePage"));
|
9
|
+
const callCopilot_1 = __importDefault(require("./providers/credal/callCopilot"));
|
10
|
+
const validateAddress_1 = __importDefault(require("./providers/googlemaps/validateAddress"));
|
11
|
+
const add_1 = __importDefault(require("./providers/math/add"));
|
12
|
+
const insertMongoDoc_1 = __importDefault(require("./providers/mongodb/insertMongoDoc"));
|
13
|
+
const listConversations_1 = __importDefault(require("./providers/slack/listConversations"));
|
14
|
+
const sendMessage_1 = __importDefault(require("./providers/slack/sendMessage"));
|
15
|
+
const getRowByFieldValue_1 = __importDefault(require("./providers/snowflake/getRowByFieldValue"));
|
16
|
+
const createZendeskTicket_1 = __importDefault(require("./providers/zendesk/createZendeskTicket"));
|
17
|
+
exports.ActionMapper = {
|
18
|
+
math: {
|
19
|
+
add: {
|
20
|
+
fn: add_1.default,
|
21
|
+
paramsSchema: types_1.mathAddParamsSchema,
|
22
|
+
outputSchema: types_1.mathAddOutputSchema,
|
23
|
+
},
|
24
|
+
},
|
25
|
+
slack: {
|
26
|
+
listConversations: {
|
27
|
+
fn: listConversations_1.default,
|
28
|
+
paramsSchema: types_1.slackListConversationsParamsSchema,
|
29
|
+
outputSchema: types_1.slackListConversationsOutputSchema,
|
30
|
+
},
|
31
|
+
sendMessage: {
|
32
|
+
fn: sendMessage_1.default,
|
33
|
+
paramsSchema: types_1.slackSendMessageParamsSchema,
|
34
|
+
outputSchema: types_1.slackSendMessageOutputSchema,
|
35
|
+
},
|
36
|
+
},
|
37
|
+
confluence: {
|
38
|
+
updatePage: {
|
39
|
+
fn: updatePage_1.default,
|
40
|
+
paramsSchema: types_1.confluenceUpdatePageParamsSchema,
|
41
|
+
outputSchema: types_1.confluenceUpdatePageOutputSchema,
|
42
|
+
},
|
43
|
+
},
|
44
|
+
googlemaps: {
|
45
|
+
validateAddress: {
|
46
|
+
fn: validateAddress_1.default,
|
47
|
+
paramsSchema: types_1.googlemapsValidateAddressParamsSchema,
|
48
|
+
outputSchema: types_1.googlemapsValidateAddressOutputSchema,
|
49
|
+
},
|
50
|
+
},
|
51
|
+
credal: {
|
52
|
+
callCopilot: {
|
53
|
+
fn: callCopilot_1.default,
|
54
|
+
paramsSchema: types_1.credalCallCopilotParamsSchema,
|
55
|
+
outputSchema: types_1.credalCallCopilotOutputSchema,
|
56
|
+
},
|
57
|
+
},
|
58
|
+
zendesk: {
|
59
|
+
createZendeskTicket: {
|
60
|
+
fn: createZendeskTicket_1.default,
|
61
|
+
paramsSchema: types_1.zendeskCreateZendeskTicketParamsSchema,
|
62
|
+
outputSchema: types_1.zendeskCreateZendeskTicketOutputSchema,
|
63
|
+
},
|
64
|
+
},
|
65
|
+
mongo: {
|
66
|
+
insertMongoDoc: {
|
67
|
+
fn: insertMongoDoc_1.default,
|
68
|
+
paramsSchema: types_1.mongoInsertMongoDocParamsSchema,
|
69
|
+
outputSchema: types_1.mongoInsertMongoDocOutputSchema,
|
70
|
+
},
|
71
|
+
},
|
72
|
+
snowflake: {
|
73
|
+
getRowByFieldValue: {
|
74
|
+
fn: getRowByFieldValue_1.default,
|
75
|
+
paramsSchema: types_1.snowflakeGetRowByFieldValueParamsSchema,
|
76
|
+
outputSchema: types_1.snowflakeGetRowByFieldValueOutputSchema,
|
77
|
+
},
|
78
|
+
},
|
79
|
+
};
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { ActionTemplate } from "@/actions/parse";
|
2
|
+
export declare const slackSendMessageDefinition: ActionTemplate;
|
3
|
+
export declare const slackListConversationsDefinition: ActionTemplate;
|
4
|
+
export declare const mathAddDefinition: ActionTemplate;
|
5
|
+
export declare const confluenceUpdatePageDefinition: ActionTemplate;
|
@@ -0,0 +1,132 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.confluenceUpdatePageDefinition = exports.mathAddDefinition = exports.slackListConversationsDefinition = exports.slackSendMessageDefinition = void 0;
|
4
|
+
exports.slackSendMessageDefinition = {
|
5
|
+
provider: "slack",
|
6
|
+
name: "send_message",
|
7
|
+
description: "Sends a message to a Slack channel",
|
8
|
+
scopes: ["chat:write"],
|
9
|
+
parameters: {
|
10
|
+
channel: {
|
11
|
+
type: "string",
|
12
|
+
description: "The Slack channel to send the message to (e.g., \\#general, \\#alerts)",
|
13
|
+
required: true,
|
14
|
+
},
|
15
|
+
message: {
|
16
|
+
type: "string",
|
17
|
+
description: "The message content to send to Slack. Can include markdown formatting.",
|
18
|
+
required: true,
|
19
|
+
},
|
20
|
+
},
|
21
|
+
output: {},
|
22
|
+
};
|
23
|
+
exports.slackListConversationsDefinition = {
|
24
|
+
provider: "slack",
|
25
|
+
name: "list_conversations",
|
26
|
+
description: "Lists all conversations in a Slack workspace",
|
27
|
+
scopes: ["channels:read", "groups:read", "im:read", "mpim:read"],
|
28
|
+
authToken: {
|
29
|
+
type: "string",
|
30
|
+
description: "The Slack access token to use",
|
31
|
+
required: true,
|
32
|
+
},
|
33
|
+
parameters: {},
|
34
|
+
output: {
|
35
|
+
channels: {
|
36
|
+
type: "array",
|
37
|
+
description: "A list of channels in Slack",
|
38
|
+
required: true,
|
39
|
+
items: {
|
40
|
+
type: "object",
|
41
|
+
description: "A channel in Slack",
|
42
|
+
required: true,
|
43
|
+
properties: {
|
44
|
+
id: {
|
45
|
+
type: "string",
|
46
|
+
description: "The ID of the channel",
|
47
|
+
required: true,
|
48
|
+
},
|
49
|
+
name: {
|
50
|
+
type: "string",
|
51
|
+
description: "The name of the channel",
|
52
|
+
required: true,
|
53
|
+
},
|
54
|
+
topic: {
|
55
|
+
type: "string",
|
56
|
+
description: "The topic of the channel",
|
57
|
+
required: true,
|
58
|
+
},
|
59
|
+
purpose: {
|
60
|
+
type: "string",
|
61
|
+
description: "The purpose of the channel",
|
62
|
+
required: true,
|
63
|
+
},
|
64
|
+
},
|
65
|
+
},
|
66
|
+
},
|
67
|
+
},
|
68
|
+
};
|
69
|
+
exports.mathAddDefinition = {
|
70
|
+
provider: "math",
|
71
|
+
name: "add",
|
72
|
+
description: "Adds two numbers together",
|
73
|
+
scopes: [],
|
74
|
+
parameters: {
|
75
|
+
a: {
|
76
|
+
type: "number",
|
77
|
+
description: "The first number to add",
|
78
|
+
required: true,
|
79
|
+
},
|
80
|
+
b: {
|
81
|
+
type: "number",
|
82
|
+
description: "The second number to add",
|
83
|
+
required: true,
|
84
|
+
},
|
85
|
+
},
|
86
|
+
output: {
|
87
|
+
result: {
|
88
|
+
type: "number",
|
89
|
+
description: "The sum of the two numbers",
|
90
|
+
required: true,
|
91
|
+
},
|
92
|
+
},
|
93
|
+
};
|
94
|
+
exports.confluenceUpdatePageDefinition = {
|
95
|
+
provider: "confluence",
|
96
|
+
name: "updatePage",
|
97
|
+
description: "Updates a confluence page with the new content specified",
|
98
|
+
scopes: [],
|
99
|
+
authToken: {
|
100
|
+
type: "string",
|
101
|
+
description: "The access token to use for confluence",
|
102
|
+
required: true,
|
103
|
+
},
|
104
|
+
baseUrl: {
|
105
|
+
type: "string",
|
106
|
+
description: "The base url required to access the confluence instance",
|
107
|
+
required: true,
|
108
|
+
},
|
109
|
+
parameters: {
|
110
|
+
pageId: {
|
111
|
+
type: "string",
|
112
|
+
description: "The page id that should be updated",
|
113
|
+
required: true,
|
114
|
+
},
|
115
|
+
title: {
|
116
|
+
type: "string",
|
117
|
+
description: "The title of the page that should be updated",
|
118
|
+
required: true,
|
119
|
+
},
|
120
|
+
username: {
|
121
|
+
type: "string",
|
122
|
+
description: "The username of the person updating the page",
|
123
|
+
required: true,
|
124
|
+
},
|
125
|
+
content: {
|
126
|
+
type: "string",
|
127
|
+
description: "The new content for the page",
|
128
|
+
required: true,
|
129
|
+
},
|
130
|
+
},
|
131
|
+
output: {},
|
132
|
+
};
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { ActionTemplate } from "../../actions/parse";
|
2
|
+
export declare const slackSendMessageDefinition: ActionTemplate;
|
3
|
+
export declare const slackListConversationsDefinition: ActionTemplate;
|
4
|
+
export declare const mathAddDefinition: ActionTemplate;
|
5
|
+
export declare const confluenceUpdatePageDefinition: ActionTemplate;
|
6
|
+
export declare const jiraCreateJiraTicketDefinition: ActionTemplate;
|
7
|
+
export declare const googlemapsValidateAddressDefinition: ActionTemplate;
|
8
|
+
export declare const credalCallCopilotDefinition: ActionTemplate;
|
9
|
+
export declare const zendeskCreateZendeskTicketDefinition: ActionTemplate;
|
10
|
+
export declare const mongoInsertMongoDocDefinition: ActionTemplate;
|
11
|
+
export declare const snowflakeGetRowByFieldValueDefinition: ActionTemplate;
|