@credal/actions 0.1.1 → 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",
@@ -15,6 +15,7 @@ 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
17
  const createJiraTicket_1 = __importDefault(require("./providers/jira/createJiraTicket"));
18
+ const getLatitudeLongitudeFromLocation_1 = __importDefault(require("./providers/openstreetmap/getLatitudeLongitudeFromLocation"));
18
19
  exports.ActionMapper = {
19
20
  math: {
20
21
  add: {
@@ -84,4 +85,11 @@ exports.ActionMapper = {
84
85
  outputSchema: types_1.jiraCreateJiraTicketOutputSchema,
85
86
  },
86
87
  },
88
+ openstreetmap: {
89
+ getLatitudeLongitudeFromLocation: {
90
+ fn: getLatitudeLongitudeFromLocation_1.default,
91
+ paramsSchema: types_1.openstreetmapGetLatitudeLongitudeFromLocationParamsSchema,
92
+ outputSchema: types_1.openstreetmapGetLatitudeLongitudeFromLocationOutputSchema,
93
+ },
94
+ },
87
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"],
@@ -505,3 +505,47 @@ exports.snowflakeGetRowByFieldValueDefinition = {
505
505
  name: "getRowByFieldValue",
506
506
  provider: "snowflake",
507
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
+ };
@@ -281,15 +281,15 @@ export declare const googlemapsValidateAddressOutputSchema: z.ZodObject<{
281
281
  } | undefined;
282
282
  }>>;
283
283
  uspsData: z.ZodOptional<z.ZodObject<{
284
- 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">>>;
285
285
  deliveryPointValidation: z.ZodOptional<z.ZodString>;
286
286
  uspsAddressPrecision: z.ZodOptional<z.ZodString>;
287
287
  }, "strip", z.ZodTypeAny, {
288
- standardizedAddress?: Record<string, any> | undefined;
288
+ standardizedAddress?: z.objectOutputType<{}, z.ZodAny, "strip"> | undefined;
289
289
  deliveryPointValidation?: string | undefined;
290
290
  uspsAddressPrecision?: string | undefined;
291
291
  }, {
292
- standardizedAddress?: Record<string, any> | undefined;
292
+ standardizedAddress?: z.objectInputType<{}, z.ZodAny, "strip"> | undefined;
293
293
  deliveryPointValidation?: string | undefined;
294
294
  uspsAddressPrecision?: string | undefined;
295
295
  }>>;
@@ -323,7 +323,7 @@ export declare const googlemapsValidateAddressOutputSchema: z.ZodObject<{
323
323
  } | undefined;
324
324
  } | undefined;
325
325
  uspsData?: {
326
- standardizedAddress?: Record<string, any> | undefined;
326
+ standardizedAddress?: z.objectOutputType<{}, z.ZodAny, "strip"> | undefined;
327
327
  deliveryPointValidation?: string | undefined;
328
328
  uspsAddressPrecision?: string | undefined;
329
329
  } | undefined;
@@ -357,7 +357,7 @@ export declare const googlemapsValidateAddressOutputSchema: z.ZodObject<{
357
357
  } | undefined;
358
358
  } | undefined;
359
359
  uspsData?: {
360
- standardizedAddress?: Record<string, any> | undefined;
360
+ standardizedAddress?: z.objectInputType<{}, z.ZodAny, "strip"> | undefined;
361
361
  deliveryPointValidation?: string | undefined;
362
362
  uspsAddressPrecision?: string | undefined;
363
363
  } | undefined;
@@ -419,15 +419,19 @@ export type zendeskCreateZendeskTicketFunction = ActionFunction<zendeskCreateZen
419
419
  export declare const mongoInsertMongoDocParamsSchema: z.ZodObject<{
420
420
  databaseName: z.ZodString;
421
421
  collectionName: z.ZodString;
422
- document: z.ZodRecord<z.ZodString, z.ZodAny>;
422
+ document: z.ZodObject<{}, "strip", z.ZodAny, z.objectOutputType<{}, z.ZodAny, "strip">, z.objectInputType<{}, z.ZodAny, "strip">>;
423
423
  }, "strip", z.ZodTypeAny, {
424
424
  databaseName: string;
425
425
  collectionName: string;
426
- document: Record<string, any>;
426
+ document: {} & {
427
+ [k: string]: any;
428
+ };
427
429
  }, {
428
430
  databaseName: string;
429
431
  collectionName: string;
430
- document: Record<string, any>;
432
+ document: {} & {
433
+ [k: string]: any;
434
+ };
431
435
  }>;
432
436
  export type mongoInsertMongoDocParamsType = z.infer<typeof mongoInsertMongoDocParamsSchema>;
433
437
  export declare const mongoInsertMongoDocOutputSchema: z.ZodObject<{
@@ -468,24 +472,61 @@ export type snowflakeGetRowByFieldValueParamsType = z.infer<typeof snowflakeGetR
468
472
  export declare const snowflakeGetRowByFieldValueOutputSchema: z.ZodObject<{
469
473
  row: z.ZodObject<{
470
474
  id: z.ZodOptional<z.ZodString>;
471
- 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">>>;
472
476
  }, "strip", z.ZodTypeAny, {
473
477
  id?: string | undefined;
474
- rowContents?: Record<string, any> | undefined;
478
+ rowContents?: z.objectOutputType<{}, z.ZodAny, "strip"> | undefined;
475
479
  }, {
476
480
  id?: string | undefined;
477
- rowContents?: Record<string, any> | undefined;
481
+ rowContents?: z.objectInputType<{}, z.ZodAny, "strip"> | undefined;
478
482
  }>;
479
483
  }, "strip", z.ZodTypeAny, {
480
484
  row: {
481
485
  id?: string | undefined;
482
- rowContents?: Record<string, any> | undefined;
486
+ rowContents?: z.objectOutputType<{}, z.ZodAny, "strip"> | undefined;
483
487
  };
484
488
  }, {
485
489
  row: {
486
490
  id?: string | undefined;
487
- rowContents?: Record<string, any> | undefined;
491
+ rowContents?: z.objectInputType<{}, z.ZodAny, "strip"> | undefined;
488
492
  };
489
493
  }>;
490
494
  export type snowflakeGetRowByFieldValueOutputType = z.infer<typeof snowflakeGetRowByFieldValueOutputSchema>;
491
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(),
@@ -104,7 +104,7 @@ exports.googlemapsValidateAddressOutputSchema = zod_1.z.object({
104
104
  .optional(),
105
105
  uspsData: zod_1.z
106
106
  .object({
107
- 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(),
108
108
  deliveryPointValidation: zod_1.z.string().describe("The USPS delivery point validation status.").optional(),
109
109
  uspsAddressPrecision: zod_1.z.string().describe("The level of precision for the USPS address.").optional(),
110
110
  })
@@ -132,7 +132,7 @@ exports.zendeskCreateZendeskTicketOutputSchema = zod_1.z.object({
132
132
  exports.mongoInsertMongoDocParamsSchema = zod_1.z.object({
133
133
  databaseName: zod_1.z.string().describe("Database to connect to"),
134
134
  collectionName: zod_1.z.string().describe("Collection to insert the document into"),
135
- 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"),
136
136
  });
137
137
  exports.mongoInsertMongoDocOutputSchema = zod_1.z.object({
138
138
  objectId: zod_1.z.string().describe("The new ID of the document inserted"),
@@ -150,7 +150,20 @@ exports.snowflakeGetRowByFieldValueOutputSchema = zod_1.z.object({
150
150
  row: zod_1.z
151
151
  .object({
152
152
  id: zod_1.z.string().describe("The ID of the row").optional(),
153
- 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(),
154
154
  })
155
155
  .describe("The row from the Snowflake table"),
156
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,
@@ -0,0 +1,3 @@
1
+ import { openstreetmapGetLatitudeLongitudeFromLocationFunction } from "../../autogen/types";
2
+ declare const getLatitudeLongitudeFromLocation: openstreetmapGetLatitudeLongitudeFromLocationFunction;
3
+ export default getLatitudeLongitudeFromLocation;
@@ -0,0 +1,26 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const axios_1 = __importDefault(require("axios"));
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
+ }));
25
+ });
26
+ exports.default = getLatitudeLongitudeFromLocation;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credal/actions",
3
- "version": "0.1.1",
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",