@credal/actions 0.2.158 → 0.2.159

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.
@@ -9,21 +9,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { WebClient } from "@slack/web-api";
11
11
  import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
12
- import { getSlackChannels } from "./helpers.js";
13
12
  const archiveChannel = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
14
13
  if (!authParams.authToken) {
15
14
  throw new Error(MISSING_AUTH_TOKEN);
16
15
  }
17
16
  try {
18
17
  const client = new WebClient(authParams.authToken);
19
- const { channelName } = params;
20
- const allChannels = yield getSlackChannels(client);
21
- const channel = allChannels.find(channel => channel.name == channelName);
22
- if (!channel || !channel.id) {
23
- throw Error(`Channel with name ${channelName} not found`);
24
- }
25
- yield client.conversations.join({ channel: channel.id });
26
- const result = yield client.conversations.archive({ channel: channel.id });
18
+ const { channelId } = params;
19
+ const result = yield client.conversations.archive({ channel: channelId });
27
20
  if (!result.ok) {
28
21
  return {
29
22
  success: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credal/actions",
3
- "version": "0.2.158",
3
+ "version": "0.2.159",
4
4
  "type": "module",
5
5
  "description": "AI Actions by Credal AI",
6
6
  "sideEffects": false,
@@ -61,6 +61,7 @@
61
61
  "docx": "^9.3.0",
62
62
  "dotenv": "^16.4.7",
63
63
  "html-to-text": "^9.0.5",
64
+ "jira.js": "^5.2.2",
64
65
  "json-schema-to-zod": "^2.5.0",
65
66
  "jsonwebtoken": "^9.0.2",
66
67
  "limiter": "^3.0.0",
@@ -1,3 +0,0 @@
1
- import { confluenceUpdatePageFunction } from "../../../actions/autogen/types";
2
- declare const confluenceUpdatePage: confluenceUpdatePageFunction;
3
- export default confluenceUpdatePage;
@@ -1,47 +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
- 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
- function getConfluenceApi(baseUrl, username, apiToken) {
17
- const api = axios_1.default.create({
18
- baseURL: baseUrl,
19
- headers: {
20
- Accept: "application/json",
21
- // Tokens are associated with a specific user.
22
- Authorization: `Basic ${Buffer.from(`${username}:${apiToken}`).toString("base64")}`,
23
- },
24
- });
25
- return api;
26
- }
27
- const confluenceUpdatePage = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
28
- const { pageId, username, content, title } = params;
29
- const { baseUrl, authToken } = authParams;
30
- const api = getConfluenceApi(baseUrl, username, authToken);
31
- // Get current version number
32
- const response = yield api.get(`/api/v2/pages/${pageId}`);
33
- const currVersion = response.data.version.number;
34
- yield api.put(`/api/v2/pages/${pageId}`, {
35
- id: pageId,
36
- status: "current",
37
- title,
38
- body: {
39
- representation: "storage",
40
- value: content,
41
- },
42
- version: {
43
- number: currVersion + 1,
44
- },
45
- });
46
- });
47
- exports.default = confluenceUpdatePage;
@@ -1,3 +0,0 @@
1
- import type { credalCallCopilotFunction } from "../../autogen/types";
2
- declare const callCopilot: credalCallCopilotFunction;
3
- export default callCopilot;
@@ -1,36 +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 sdk_1 = require("@credal/sdk");
13
- const callCopilot = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
14
- var _b;
15
- const requestBody = {
16
- agentId: params.agentId,
17
- query: params.query,
18
- userEmail: params.userEmail,
19
- };
20
- const baseUrl = (_b = authParams.baseUrl) !== null && _b !== void 0 ? _b : "https://app.credal.ai/api";
21
- const client = new sdk_1.CredalClient({ environment: baseUrl, apiKey: authParams.apiKey });
22
- const response = yield client.copilots.sendMessage({
23
- agentId: requestBody.agentId,
24
- message: requestBody.query,
25
- userEmail: requestBody.userEmail,
26
- });
27
- return {
28
- response: response.sendChatResult.type === "ai_response_result"
29
- ? response.sendChatResult.response.message
30
- : "Error getting response",
31
- referencedSources: response.sendChatResult.type === "ai_response_result" ? response.sendChatResult.referencedSources : [],
32
- sourcesInDataContext: response.sendChatResult.type === "ai_response_result" ? response.sendChatResult.sourcesInDataContext : [],
33
- webSearchResults: response.sendChatResult.type === "ai_response_result" ? response.sendChatResult.webSearchResults : [],
34
- };
35
- });
36
- exports.default = callCopilot;
@@ -1,8 +0,0 @@
1
- import { z } from "zod";
2
- export declare const TokenResponseSchema: z.ZodObject<{
3
- token: z.ZodString;
4
- }, "strip", z.ZodTypeAny, {
5
- token: string;
6
- }, {
7
- token: string;
8
- }>;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TokenResponseSchema = void 0;
4
- const zod_1 = require("zod");
5
- exports.TokenResponseSchema = zod_1.z.object({
6
- token: zod_1.z.string(),
7
- });
@@ -1 +0,0 @@
1
- export * as add from "./add";
@@ -1,37 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.add = void 0;
37
- exports.add = __importStar(require("./add"));
@@ -1 +0,0 @@
1
- export * as listConversations from "./listConversations";
@@ -1,37 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.listConversations = void 0;
37
- exports.listConversations = __importStar(require("./listConversations"));
@@ -1,3 +0,0 @@
1
- import type { slackListConversationsFunction } from "../../autogen/types";
2
- declare const slackListConversations: slackListConversationsFunction;
3
- export default slackListConversations;
@@ -1,41 +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 helpers_1 = require("./helpers");
14
- const slackListConversations = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authParams, }) {
15
- const client = new web_api_1.WebClient(authParams.authToken);
16
- try {
17
- const allChannels = yield (0, helpers_1.getSlackChannels)(client);
18
- const filteredChannels = [];
19
- for (const channel of allChannels) {
20
- if (channel.name && channel.topic && channel.topic.value && channel.purpose && channel.purpose.value) {
21
- const purpose = channel.purpose.value;
22
- const topic = channel.topic.value;
23
- const name = channel.name;
24
- filteredChannels.push(Object.assign(Object.assign({}, channel), { purpose, topic, name }));
25
- }
26
- }
27
- return {
28
- channels: filteredChannels,
29
- };
30
- }
31
- catch (error) {
32
- if (error instanceof Error) {
33
- // Enhance error with more context
34
- throw new Error(`Failed to list Slack conversations: ${error.message}`);
35
- }
36
- else {
37
- throw error;
38
- }
39
- }
40
- });
41
- exports.default = slackListConversations;