@credal/actions 0.1.0 → 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Credal.ai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -15,7 +15,7 @@
15
15
  Invoking an action:
16
16
 
17
17
  ```ts
18
- import { runAction } from "@credal-ai/actions";
18
+ import { runAction } from "@credal/actions";
19
19
 
20
20
  const result = await runAction(
21
21
  "listConversations",
@@ -14,6 +14,8 @@ const listConversations_1 = __importDefault(require("./providers/slack/listConve
14
14
  const sendMessage_1 = __importDefault(require("./providers/slack/sendMessage"));
15
15
  const getRowByFieldValue_1 = __importDefault(require("./providers/snowflake/getRowByFieldValue"));
16
16
  const createZendeskTicket_1 = __importDefault(require("./providers/zendesk/createZendeskTicket"));
17
+ const createJiraTicket_1 = __importDefault(require("./providers/jira/createJiraTicket"));
18
+ const getLatitudeLongitudeFromLocation_1 = __importDefault(require("./providers/openstreetmap/getLatitudeLongitudeFromLocation"));
17
19
  exports.ActionMapper = {
18
20
  math: {
19
21
  add: {
@@ -76,4 +78,18 @@ exports.ActionMapper = {
76
78
  outputSchema: types_1.snowflakeGetRowByFieldValueOutputSchema,
77
79
  },
78
80
  },
81
+ jira: {
82
+ createJiraTicket: {
83
+ fn: createJiraTicket_1.default,
84
+ paramsSchema: types_1.jiraCreateJiraTicketParamsSchema,
85
+ outputSchema: types_1.jiraCreateJiraTicketOutputSchema,
86
+ },
87
+ },
88
+ openstreetmap: {
89
+ getLatitudeLongitudeFromLocation: {
90
+ fn: getLatitudeLongitudeFromLocation_1.default,
91
+ paramsSchema: types_1.openstreetmapGetLatitudeLongitudeFromLocationParamsSchema,
92
+ outputSchema: types_1.openstreetmapGetLatitudeLongitudeFromLocationOutputSchema,
93
+ },
94
+ },
79
95
  };
@@ -9,3 +9,4 @@ export declare const credalCallCopilotDefinition: ActionTemplate;
9
9
  export declare const zendeskCreateZendeskTicketDefinition: ActionTemplate;
10
10
  export declare const mongoInsertMongoDocDefinition: ActionTemplate;
11
11
  export declare const snowflakeGetRowByFieldValueDefinition: ActionTemplate;
12
+ export declare const openstreetmapGetLatitudeLongitudeFromLocationDefinition: ActionTemplate;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.snowflakeGetRowByFieldValueDefinition = exports.mongoInsertMongoDocDefinition = exports.zendeskCreateZendeskTicketDefinition = exports.credalCallCopilotDefinition = exports.googlemapsValidateAddressDefinition = exports.jiraCreateJiraTicketDefinition = exports.confluenceUpdatePageDefinition = exports.mathAddDefinition = exports.slackListConversationsDefinition = exports.slackSendMessageDefinition = void 0;
3
+ exports.openstreetmapGetLatitudeLongitudeFromLocationDefinition = exports.snowflakeGetRowByFieldValueDefinition = exports.mongoInsertMongoDocDefinition = exports.zendeskCreateZendeskTicketDefinition = exports.credalCallCopilotDefinition = exports.googlemapsValidateAddressDefinition = exports.jiraCreateJiraTicketDefinition = exports.confluenceUpdatePageDefinition = exports.mathAddDefinition = exports.slackListConversationsDefinition = exports.slackSendMessageDefinition = void 0;
4
4
  exports.slackSendMessageDefinition = {
5
5
  description: "Sends a message to a Slack channel",
6
6
  scopes: ["chat:write"],
@@ -145,12 +145,26 @@ exports.jiraCreateJiraTicketDefinition = {
145
145
  type: "string",
146
146
  description: "The reporter for the new ticket creation",
147
147
  },
148
+ assignee: {
149
+ type: "string",
150
+ description: "The assignee for the new ticket creation",
151
+ },
148
152
  username: {
149
153
  type: "string",
150
154
  description: "The username of the person creating the ticket",
151
155
  },
152
156
  },
153
157
  },
158
+ output: {
159
+ type: "object",
160
+ required: ["ticketUrl"],
161
+ properties: {
162
+ ticketUrl: {
163
+ type: "string",
164
+ description: "The url to the created Jira Ticket",
165
+ },
166
+ },
167
+ },
154
168
  name: "createJiraTicket",
155
169
  provider: "jira",
156
170
  };
@@ -491,3 +505,47 @@ exports.snowflakeGetRowByFieldValueDefinition = {
491
505
  name: "getRowByFieldValue",
492
506
  provider: "snowflake",
493
507
  };
508
+ exports.openstreetmapGetLatitudeLongitudeFromLocationDefinition = {
509
+ description: "Get the latitude and longitude of a location",
510
+ scopes: [],
511
+ parameters: {
512
+ type: "object",
513
+ required: ["location"],
514
+ properties: {
515
+ location: {
516
+ type: "string",
517
+ description: "The location to get the latitude and longitude of",
518
+ },
519
+ },
520
+ },
521
+ output: {
522
+ type: "object",
523
+ required: [],
524
+ properties: {
525
+ results: {
526
+ type: "array",
527
+ description: "The results of the query",
528
+ items: {
529
+ type: "object",
530
+ required: ["latitude", "longitude", "display_name"],
531
+ properties: {
532
+ latitude: {
533
+ type: "number",
534
+ description: "The latitude of the location",
535
+ },
536
+ longitude: {
537
+ type: "number",
538
+ description: "The longitude of the location",
539
+ },
540
+ display_name: {
541
+ type: "string",
542
+ description: "The display name of the location",
543
+ },
544
+ },
545
+ },
546
+ },
547
+ },
548
+ },
549
+ name: "getLatitudeLongitudeFromLocation",
550
+ provider: "openstreetmap",
551
+ };
@@ -113,6 +113,7 @@ export declare const jiraCreateJiraTicketParamsSchema: z.ZodObject<{
113
113
  description: z.ZodString;
114
114
  issueType: z.ZodString;
115
115
  reporter: z.ZodOptional<z.ZodString>;
116
+ assignee: z.ZodOptional<z.ZodString>;
116
117
  username: z.ZodString;
117
118
  }, "strip", z.ZodTypeAny, {
118
119
  description: string;
@@ -121,6 +122,7 @@ export declare const jiraCreateJiraTicketParamsSchema: z.ZodObject<{
121
122
  summary: string;
122
123
  issueType: string;
123
124
  reporter?: string | undefined;
125
+ assignee?: string | undefined;
124
126
  }, {
125
127
  description: string;
126
128
  username: string;
@@ -128,9 +130,16 @@ export declare const jiraCreateJiraTicketParamsSchema: z.ZodObject<{
128
130
  summary: string;
129
131
  issueType: string;
130
132
  reporter?: string | undefined;
133
+ assignee?: string | undefined;
131
134
  }>;
132
135
  export type jiraCreateJiraTicketParamsType = z.infer<typeof jiraCreateJiraTicketParamsSchema>;
133
- export declare const jiraCreateJiraTicketOutputSchema: z.ZodVoid;
136
+ export declare const jiraCreateJiraTicketOutputSchema: z.ZodObject<{
137
+ ticketUrl: z.ZodString;
138
+ }, "strip", z.ZodTypeAny, {
139
+ ticketUrl: string;
140
+ }, {
141
+ ticketUrl: string;
142
+ }>;
134
143
  export type jiraCreateJiraTicketOutputType = z.infer<typeof jiraCreateJiraTicketOutputSchema>;
135
144
  export type jiraCreateJiraTicketFunction = ActionFunction<jiraCreateJiraTicketParamsType, AuthParamsType, jiraCreateJiraTicketOutputType>;
136
145
  export declare const googlemapsValidateAddressParamsSchema: z.ZodObject<{
@@ -272,15 +281,15 @@ export declare const googlemapsValidateAddressOutputSchema: z.ZodObject<{
272
281
  } | undefined;
273
282
  }>>;
274
283
  uspsData: z.ZodOptional<z.ZodObject<{
275
- standardizedAddress: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
284
+ standardizedAddress: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodAny, z.objectOutputType<{}, z.ZodAny, "strip">, z.objectInputType<{}, z.ZodAny, "strip">>>;
276
285
  deliveryPointValidation: z.ZodOptional<z.ZodString>;
277
286
  uspsAddressPrecision: z.ZodOptional<z.ZodString>;
278
287
  }, "strip", z.ZodTypeAny, {
279
- standardizedAddress?: Record<string, any> | undefined;
288
+ standardizedAddress?: z.objectOutputType<{}, z.ZodAny, "strip"> | undefined;
280
289
  deliveryPointValidation?: string | undefined;
281
290
  uspsAddressPrecision?: string | undefined;
282
291
  }, {
283
- standardizedAddress?: Record<string, any> | undefined;
292
+ standardizedAddress?: z.objectInputType<{}, z.ZodAny, "strip"> | undefined;
284
293
  deliveryPointValidation?: string | undefined;
285
294
  uspsAddressPrecision?: string | undefined;
286
295
  }>>;
@@ -314,7 +323,7 @@ export declare const googlemapsValidateAddressOutputSchema: z.ZodObject<{
314
323
  } | undefined;
315
324
  } | undefined;
316
325
  uspsData?: {
317
- standardizedAddress?: Record<string, any> | undefined;
326
+ standardizedAddress?: z.objectOutputType<{}, z.ZodAny, "strip"> | undefined;
318
327
  deliveryPointValidation?: string | undefined;
319
328
  uspsAddressPrecision?: string | undefined;
320
329
  } | undefined;
@@ -348,7 +357,7 @@ export declare const googlemapsValidateAddressOutputSchema: z.ZodObject<{
348
357
  } | undefined;
349
358
  } | undefined;
350
359
  uspsData?: {
351
- standardizedAddress?: Record<string, any> | undefined;
360
+ standardizedAddress?: z.objectInputType<{}, z.ZodAny, "strip"> | undefined;
352
361
  deliveryPointValidation?: string | undefined;
353
362
  uspsAddressPrecision?: string | undefined;
354
363
  } | undefined;
@@ -410,15 +419,19 @@ export type zendeskCreateZendeskTicketFunction = ActionFunction<zendeskCreateZen
410
419
  export declare const mongoInsertMongoDocParamsSchema: z.ZodObject<{
411
420
  databaseName: z.ZodString;
412
421
  collectionName: z.ZodString;
413
- document: z.ZodRecord<z.ZodString, z.ZodAny>;
422
+ document: z.ZodObject<{}, "strip", z.ZodAny, z.objectOutputType<{}, z.ZodAny, "strip">, z.objectInputType<{}, z.ZodAny, "strip">>;
414
423
  }, "strip", z.ZodTypeAny, {
415
424
  databaseName: string;
416
425
  collectionName: string;
417
- document: Record<string, any>;
426
+ document: {} & {
427
+ [k: string]: any;
428
+ };
418
429
  }, {
419
430
  databaseName: string;
420
431
  collectionName: string;
421
- document: Record<string, any>;
432
+ document: {} & {
433
+ [k: string]: any;
434
+ };
422
435
  }>;
423
436
  export type mongoInsertMongoDocParamsType = z.infer<typeof mongoInsertMongoDocParamsSchema>;
424
437
  export declare const mongoInsertMongoDocOutputSchema: z.ZodObject<{
@@ -459,24 +472,61 @@ export type snowflakeGetRowByFieldValueParamsType = z.infer<typeof snowflakeGetR
459
472
  export declare const snowflakeGetRowByFieldValueOutputSchema: z.ZodObject<{
460
473
  row: z.ZodObject<{
461
474
  id: z.ZodOptional<z.ZodString>;
462
- rowContents: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
475
+ rowContents: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodAny, z.objectOutputType<{}, z.ZodAny, "strip">, z.objectInputType<{}, z.ZodAny, "strip">>>;
463
476
  }, "strip", z.ZodTypeAny, {
464
477
  id?: string | undefined;
465
- rowContents?: Record<string, any> | undefined;
478
+ rowContents?: z.objectOutputType<{}, z.ZodAny, "strip"> | undefined;
466
479
  }, {
467
480
  id?: string | undefined;
468
- rowContents?: Record<string, any> | undefined;
481
+ rowContents?: z.objectInputType<{}, z.ZodAny, "strip"> | undefined;
469
482
  }>;
470
483
  }, "strip", z.ZodTypeAny, {
471
484
  row: {
472
485
  id?: string | undefined;
473
- rowContents?: Record<string, any> | undefined;
486
+ rowContents?: z.objectOutputType<{}, z.ZodAny, "strip"> | undefined;
474
487
  };
475
488
  }, {
476
489
  row: {
477
490
  id?: string | undefined;
478
- rowContents?: Record<string, any> | undefined;
491
+ rowContents?: z.objectInputType<{}, z.ZodAny, "strip"> | undefined;
479
492
  };
480
493
  }>;
481
494
  export type snowflakeGetRowByFieldValueOutputType = z.infer<typeof snowflakeGetRowByFieldValueOutputSchema>;
482
495
  export type snowflakeGetRowByFieldValueFunction = ActionFunction<snowflakeGetRowByFieldValueParamsType, AuthParamsType, snowflakeGetRowByFieldValueOutputType>;
496
+ export declare const openstreetmapGetLatitudeLongitudeFromLocationParamsSchema: z.ZodObject<{
497
+ location: z.ZodString;
498
+ }, "strip", z.ZodTypeAny, {
499
+ location: string;
500
+ }, {
501
+ location: string;
502
+ }>;
503
+ export type openstreetmapGetLatitudeLongitudeFromLocationParamsType = z.infer<typeof openstreetmapGetLatitudeLongitudeFromLocationParamsSchema>;
504
+ export declare const openstreetmapGetLatitudeLongitudeFromLocationOutputSchema: z.ZodObject<{
505
+ results: z.ZodOptional<z.ZodArray<z.ZodObject<{
506
+ latitude: z.ZodNumber;
507
+ longitude: z.ZodNumber;
508
+ display_name: z.ZodString;
509
+ }, "strip", z.ZodTypeAny, {
510
+ latitude: number;
511
+ longitude: number;
512
+ display_name: string;
513
+ }, {
514
+ latitude: number;
515
+ longitude: number;
516
+ display_name: string;
517
+ }>, "many">>;
518
+ }, "strip", z.ZodTypeAny, {
519
+ results?: {
520
+ latitude: number;
521
+ longitude: number;
522
+ display_name: string;
523
+ }[] | undefined;
524
+ }, {
525
+ results?: {
526
+ latitude: number;
527
+ longitude: number;
528
+ display_name: string;
529
+ }[] | undefined;
530
+ }>;
531
+ export type openstreetmapGetLatitudeLongitudeFromLocationOutputType = z.infer<typeof openstreetmapGetLatitudeLongitudeFromLocationOutputSchema>;
532
+ export type openstreetmapGetLatitudeLongitudeFromLocationFunction = ActionFunction<openstreetmapGetLatitudeLongitudeFromLocationParamsType, AuthParamsType, openstreetmapGetLatitudeLongitudeFromLocationOutputType>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.snowflakeGetRowByFieldValueOutputSchema = exports.snowflakeGetRowByFieldValueParamsSchema = exports.mongoInsertMongoDocOutputSchema = exports.mongoInsertMongoDocParamsSchema = exports.zendeskCreateZendeskTicketOutputSchema = exports.zendeskCreateZendeskTicketParamsSchema = exports.credalCallCopilotOutputSchema = exports.credalCallCopilotParamsSchema = exports.googlemapsValidateAddressOutputSchema = exports.googlemapsValidateAddressParamsSchema = exports.jiraCreateJiraTicketOutputSchema = exports.jiraCreateJiraTicketParamsSchema = exports.confluenceUpdatePageOutputSchema = exports.confluenceUpdatePageParamsSchema = exports.mathAddOutputSchema = exports.mathAddParamsSchema = exports.slackListConversationsOutputSchema = exports.slackListConversationsParamsSchema = exports.slackSendMessageOutputSchema = exports.slackSendMessageParamsSchema = exports.AuthParamsSchema = void 0;
3
+ exports.openstreetmapGetLatitudeLongitudeFromLocationOutputSchema = exports.openstreetmapGetLatitudeLongitudeFromLocationParamsSchema = exports.snowflakeGetRowByFieldValueOutputSchema = exports.snowflakeGetRowByFieldValueParamsSchema = exports.mongoInsertMongoDocOutputSchema = exports.mongoInsertMongoDocParamsSchema = exports.zendeskCreateZendeskTicketOutputSchema = exports.zendeskCreateZendeskTicketParamsSchema = exports.credalCallCopilotOutputSchema = exports.credalCallCopilotParamsSchema = exports.googlemapsValidateAddressOutputSchema = exports.googlemapsValidateAddressParamsSchema = exports.jiraCreateJiraTicketOutputSchema = exports.jiraCreateJiraTicketParamsSchema = exports.confluenceUpdatePageOutputSchema = exports.confluenceUpdatePageParamsSchema = exports.mathAddOutputSchema = exports.mathAddParamsSchema = exports.slackListConversationsOutputSchema = exports.slackListConversationsParamsSchema = exports.slackSendMessageOutputSchema = exports.slackSendMessageParamsSchema = exports.AuthParamsSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  exports.AuthParamsSchema = zod_1.z.object({
6
6
  authToken: zod_1.z.string().optional(),
@@ -43,9 +43,12 @@ exports.jiraCreateJiraTicketParamsSchema = zod_1.z.object({
43
43
  description: zod_1.z.string().describe("The description for the new ticket"),
44
44
  issueType: zod_1.z.string().describe("The issue type of the new ticket"),
45
45
  reporter: zod_1.z.string().describe("The reporter for the new ticket creation").optional(),
46
+ assignee: zod_1.z.string().describe("The assignee for the new ticket creation").optional(),
46
47
  username: zod_1.z.string().describe("The username of the person creating the ticket"),
47
48
  });
48
- exports.jiraCreateJiraTicketOutputSchema = zod_1.z.void();
49
+ exports.jiraCreateJiraTicketOutputSchema = zod_1.z.object({
50
+ ticketUrl: zod_1.z.string().describe("The url to the created Jira Ticket"),
51
+ });
49
52
  exports.googlemapsValidateAddressParamsSchema = zod_1.z.object({
50
53
  regionCode: zod_1.z.string().describe("The country of the address being verified."),
51
54
  locality: zod_1.z.string().describe("The locality of the address being verified. This is likely a city."),
@@ -101,7 +104,7 @@ exports.googlemapsValidateAddressOutputSchema = zod_1.z.object({
101
104
  .optional(),
102
105
  uspsData: zod_1.z
103
106
  .object({
104
- standardizedAddress: zod_1.z.record(zod_1.z.any()).describe("The standardized USPS address.").optional(),
107
+ standardizedAddress: zod_1.z.object({}).catchall(zod_1.z.any()).describe("The standardized USPS address.").optional(),
105
108
  deliveryPointValidation: zod_1.z.string().describe("The USPS delivery point validation status.").optional(),
106
109
  uspsAddressPrecision: zod_1.z.string().describe("The level of precision for the USPS address.").optional(),
107
110
  })
@@ -129,7 +132,7 @@ exports.zendeskCreateZendeskTicketOutputSchema = zod_1.z.object({
129
132
  exports.mongoInsertMongoDocParamsSchema = zod_1.z.object({
130
133
  databaseName: zod_1.z.string().describe("Database to connect to"),
131
134
  collectionName: zod_1.z.string().describe("Collection to insert the document into"),
132
- document: zod_1.z.record(zod_1.z.any()).describe("The document to insert"),
135
+ document: zod_1.z.object({}).catchall(zod_1.z.any()).describe("The document to insert"),
133
136
  });
134
137
  exports.mongoInsertMongoDocOutputSchema = zod_1.z.object({
135
138
  objectId: zod_1.z.string().describe("The new ID of the document inserted"),
@@ -147,7 +150,20 @@ exports.snowflakeGetRowByFieldValueOutputSchema = zod_1.z.object({
147
150
  row: zod_1.z
148
151
  .object({
149
152
  id: zod_1.z.string().describe("The ID of the row").optional(),
150
- rowContents: zod_1.z.record(zod_1.z.any()).describe("The contents of the row").optional(),
153
+ rowContents: zod_1.z.object({}).catchall(zod_1.z.any()).describe("The contents of the row").optional(),
151
154
  })
152
155
  .describe("The row from the Snowflake table"),
153
156
  });
157
+ exports.openstreetmapGetLatitudeLongitudeFromLocationParamsSchema = zod_1.z.object({
158
+ location: zod_1.z.string().describe("The location to get the latitude and longitude of"),
159
+ });
160
+ exports.openstreetmapGetLatitudeLongitudeFromLocationOutputSchema = zod_1.z.object({
161
+ results: zod_1.z
162
+ .array(zod_1.z.object({
163
+ latitude: zod_1.z.number().describe("The latitude of the location"),
164
+ longitude: zod_1.z.number().describe("The longitude of the location"),
165
+ display_name: zod_1.z.string().describe("The display name of the location"),
166
+ }))
167
+ .describe("The results of the query")
168
+ .optional(),
169
+ });
@@ -96,7 +96,8 @@ function addActionTypes(_a) {
96
96
  }
97
97
  function addTypesToFile(_a) {
98
98
  return __awaiter(this, arguments, void 0, function* ({ file, obj, fallback, name, }) {
99
- const zodSchema = obj ? (0, json_schema_to_zod_1.default)(obj) : fallback;
99
+ // Tool calling framework currently having trouble filling in records as opposed to objects
100
+ const zodSchema = obj ? (0, json_schema_to_zod_1.default)(obj).replace(/z\.record\(z\.any\(\)\)/g, "z.object({}).catchall(z.any())") : fallback;
100
101
  const zodName = `${name}Schema`;
101
102
  file.addVariableStatement({
102
103
  declarationKind: ts_morph_1.VariableDeclarationKind.Const,
@@ -1,3 +1,3 @@
1
1
  import { jiraCreateJiraTicketFunction } from "../../autogen/types";
2
- declare const createTicket: jiraCreateJiraTicketFunction;
3
- export default createTicket;
2
+ declare const createJiraTicket: jiraCreateJiraTicketFunction;
3
+ export default createJiraTicket;
@@ -13,15 +13,63 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const axios_1 = __importDefault(require("axios"));
16
- const createTicket = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
16
+ function getUserAccountId(email, baseUrl, authToken, username) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ try {
19
+ const response = yield axios_1.default.get(`${baseUrl}/rest/api/3/user/search?query=${encodeURIComponent(email)}`, {
20
+ headers: {
21
+ Authorization: `Basic ${Buffer.from(`${username}:${authToken}`).toString("base64")}`,
22
+ "Content-Type": "application/json",
23
+ },
24
+ });
25
+ if (response.data && response.data.length > 0) {
26
+ return response.data[0].accountId;
27
+ }
28
+ return null;
29
+ }
30
+ catch (error) {
31
+ const axiosError = error;
32
+ console.error("Error finding user:", axiosError.message);
33
+ return null;
34
+ }
35
+ });
36
+ }
37
+ const createJiraTicket = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
17
38
  const { authToken, baseUrl } = authParams;
18
39
  const url = `${baseUrl}/rest/api/3/issue`;
40
+ // If assignee is an email, look up the account ID
41
+ let reporterId = null;
42
+ if (params.reporter && typeof params.reporter === "string" && params.reporter.includes("@") && baseUrl && authToken) {
43
+ reporterId = yield getUserAccountId(params.reporter, baseUrl, authToken, params.username);
44
+ }
45
+ // If assignee is an email, look up the account ID
46
+ let assigneeId = null;
47
+ if (params.assignee && typeof params.assignee === "string" && params.assignee.includes("@") && baseUrl && authToken) {
48
+ assigneeId = yield getUserAccountId(params.assignee, baseUrl, authToken, params.username);
49
+ }
50
+ const description = typeof params.description === "string"
51
+ ? {
52
+ type: "doc",
53
+ version: 1,
54
+ content: [
55
+ {
56
+ type: "paragraph",
57
+ content: [
58
+ {
59
+ type: "text",
60
+ text: params.description,
61
+ },
62
+ ],
63
+ },
64
+ ],
65
+ }
66
+ : params.description;
19
67
  const payload = {
20
- fields: Object.assign({ project: {
68
+ fields: Object.assign(Object.assign({ project: {
21
69
  key: params.projectKey,
22
- }, summary: params.summary, description: params.description, issuetype: {
70
+ }, summary: params.summary, description: description, issuetype: {
23
71
  name: params.issueType,
24
- } }, (params.reporter ? { reporter: { id: params.reporter } } : {})),
72
+ } }, (reporterId ? { reporter: { id: reporterId } } : {})), (assigneeId ? { assignee: { id: assigneeId } } : {})),
25
73
  };
26
74
  const response = yield axios_1.default.post(url, payload, {
27
75
  headers: {
@@ -29,6 +77,9 @@ const createTicket = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params
29
77
  "Content-Type": "application/json",
30
78
  },
31
79
  });
32
- return response.data;
80
+ // At the end of your function, wrap the response
81
+ return {
82
+ ticketUrl: `${baseUrl}/browse/${response.data.key}`,
83
+ };
33
84
  });
34
- exports.default = createTicket;
85
+ exports.default = createJiraTicket;
@@ -0,0 +1,3 @@
1
+ import { openstreetmapGetLatitudeLongitudeFromLocationFunction } from "../../autogen/types";
2
+ declare const getLatitudeLongitudeFromLocation: openstreetmapGetLatitudeLongitudeFromLocationFunction;
3
+ export default getLatitudeLongitudeFromLocation;
@@ -13,22 +13,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const axios_1 = __importDefault(require("axios"));
16
- const createTicket = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
17
- const { authToken, baseUrl } = authParams;
18
- const url = `${baseUrl}/rest/api/3/issue`;
19
- const payload = {
20
- fields: Object.assign({ project: {
21
- key: params.projectKey,
22
- }, summary: params.summary, description: params.description, issuetype: {
23
- name: params.issueType,
24
- } }, (params.reporter ? { reporter: { id: params.reporter } } : {})),
25
- };
26
- const response = yield axios_1.default.post(url, payload, {
27
- headers: {
28
- Authorization: `Basic ${Buffer.from(`${params.username}:${authToken}`).toString("base64")}`,
29
- "Content-Type": "application/json",
30
- },
31
- });
32
- return response.data;
16
+ const getLatitudeLongitudeFromLocation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, }) {
17
+ const { location } = params;
18
+ const url = `https://nominatim.openstreetmap.org/search?q=${encodeURIComponent(location)}&format=json`;
19
+ const response = yield axios_1.default.get(url, { headers: { "User-Agent": "Credal/1.0" } });
20
+ return response.data.map((result) => ({
21
+ latitude: parseFloat(result.lat),
22
+ longitude: parseFloat(result.lon),
23
+ displayName: result.display_name,
24
+ }));
33
25
  });
34
- exports.default = createTicket;
26
+ exports.default = getLatitudeLongitudeFromLocation;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credal/actions",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "AI Actions by Credal AI",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -38,6 +38,7 @@
38
38
  "typescript-eslint": "^8.18.0"
39
39
  },
40
40
  "dependencies": {
41
+ "@credal/actions": "^0.1.1",
41
42
  "@credal/sdk": "^0.0.21",
42
43
  "@slack/web-api": "^7.8.0",
43
44
  "@types/snowflake-sdk": "^1.6.24",
@@ -1,5 +0,0 @@
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;
@@ -1,132 +0,0 @@
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
- };
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mathAddDefinition = exports.slackSendMessageDefinition = void 0;
4
- exports.slackSendMessageDefinition = {
5
- name: "send_message",
6
- description: "Sends a message to a Slack channel",
7
- parameters: {
8
- "channel": {
9
- "type": "string",
10
- "description": "The Slack channel to send the message to (e.g., \\#general, \\#alerts)",
11
- "required": true
12
- },
13
- "message": {
14
- "type": "string",
15
- "description": "The message content to send to Slack. Can include markdown formatting.",
16
- "required": true
17
- }
18
- }
19
- };
20
- exports.mathAddDefinition = {
21
- name: "add",
22
- description: "Adds two numbers together",
23
- parameters: {
24
- "a": {
25
- "type": "number",
26
- "description": "The first number to add",
27
- "required": true
28
- },
29
- "b": {
30
- "type": "number",
31
- "description": "The second number to add",
32
- "required": true
33
- }
34
- }
35
- };
@@ -1,9 +0,0 @@
1
- import { type ActionFunction } from "./autogen/types";
2
- import { z } from "zod";
3
- interface ActionFunctionComponents {
4
- fn: ActionFunction<any, any, any>;
5
- paramsSchema: z.ZodSchema;
6
- outputSchema: z.ZodSchema;
7
- }
8
- export declare const FunctionMapper: Record<string, Record<string, ActionFunctionComponents>>;
9
- export {};
@@ -1,33 +0,0 @@
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.FunctionMapper = void 0;
7
- const add_1 = __importDefault(require("./providers/math/add"));
8
- const list_conversations_1 = __importDefault(require("./providers/slack/list_conversations"));
9
- const updatePage_1 = __importDefault(require("./providers/confluence/updatePage"));
10
- const types_1 = require("./autogen/types");
11
- exports.FunctionMapper = {
12
- math: {
13
- add: {
14
- fn: add_1.default,
15
- paramsSchema: types_1.mathAddParamsSchema,
16
- outputSchema: types_1.mathAddOutputSchema,
17
- },
18
- },
19
- slack: {
20
- listConversations: {
21
- fn: list_conversations_1.default,
22
- paramsSchema: types_1.slackListConversationsParamsSchema,
23
- outputSchema: types_1.slackListConversationsOutputSchema,
24
- },
25
- },
26
- confluence: {
27
- updatePage: {
28
- fn: updatePage_1.default,
29
- paramsSchema: types_1.confluenceUpdatePageParamsSchema,
30
- outputSchema: types_1.confluenceUpdatePageOutputSchema,
31
- },
32
- },
33
- };
@@ -1,3 +0,0 @@
1
- import { jiraCreateTicketFunction } from "../../autogen/types";
2
- declare const createTicket: jiraCreateTicketFunction;
3
- export default createTicket;
@@ -1,3 +0,0 @@
1
- import { slackListConversationsFunction } from "../../../actions/autogen/types";
2
- declare const slackListConversations: slackListConversationsFunction;
3
- export default slackListConversations;
@@ -1,60 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const web_api_1 = require("@slack/web-api");
13
- const slackListConversations = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authParams, }) {
14
- var _b;
15
- const client = new web_api_1.WebClient(authParams.authToken);
16
- const allChannels = [];
17
- let cursor;
18
- const limit = 100;
19
- try {
20
- do {
21
- const response = yield client.conversations.list({
22
- exclude_archived: true,
23
- limit: limit,
24
- cursor: cursor,
25
- });
26
- if (!response.ok) {
27
- throw new Error(`Slack API error: ${response.error}`);
28
- }
29
- // Add channels from this page to our results
30
- if (response.channels && Array.isArray(response.channels)) {
31
- allChannels.push(...response.channels);
32
- }
33
- // Get cursor for next page
34
- cursor = (_b = response.response_metadata) === null || _b === void 0 ? void 0 : _b.next_cursor;
35
- // If user specified a limit and we've hit it, stop paginating
36
- if (limit && allChannels.length >= limit) {
37
- allChannels.splice(limit); // Trim to exact limit
38
- break;
39
- }
40
- } while (cursor && cursor.length > 0);
41
- return {
42
- channels: allChannels.map(channel => ({
43
- id: channel.id,
44
- name: channel.name,
45
- topic: channel.topic.value,
46
- purpose: channel.purpose.value,
47
- })),
48
- };
49
- }
50
- catch (error) {
51
- if (error instanceof Error) {
52
- // Enhance error with more context
53
- throw new Error(`Failed to list Slack conversations: ${error.message}`);
54
- }
55
- else {
56
- throw error;
57
- }
58
- }
59
- });
60
- exports.default = slackListConversations;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createParametersObject = createParametersObject;
4
- function createParametersObject(parameters) {
5
- return Object.fromEntries(Object.entries(parameters).map(([key, param]) => [key, param.type]));
6
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/dist/main.js DELETED
@@ -1,11 +0,0 @@
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
- const list_conversations_1 = __importDefault(require("./actions/providers/slack/list_conversations"));
7
- const result = (0, list_conversations_1.default)({
8
- accessToken: "xoxp-4172665288294-8092684180551-8154529379075-89f1f70cc06e5648e8f912ba96f56626"
9
- }).then((result) => {
10
- console.log(result);
11
- });