@memberjunction/core-actions 2.106.0 → 2.107.0

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.
Files changed (41) hide show
  1. package/dist/config.d.ts +112 -0
  2. package/dist/config.d.ts.map +1 -1
  3. package/dist/config.js +34 -2
  4. package/dist/config.js.map +1 -1
  5. package/dist/custom/ai/summarize-content.action.d.ts +72 -0
  6. package/dist/custom/ai/summarize-content.action.d.ts.map +1 -0
  7. package/dist/custom/ai/summarize-content.action.js +388 -0
  8. package/dist/custom/ai/summarize-content.action.js.map +1 -0
  9. package/dist/custom/data/execute-research-query.action.d.ts +96 -0
  10. package/dist/custom/data/execute-research-query.action.d.ts.map +1 -0
  11. package/dist/custom/data/execute-research-query.action.js +413 -0
  12. package/dist/custom/data/execute-research-query.action.js.map +1 -0
  13. package/dist/custom/data/explore-database-schema.action.d.ts +91 -0
  14. package/dist/custom/data/explore-database-schema.action.d.ts.map +1 -0
  15. package/dist/custom/data/explore-database-schema.action.js +406 -0
  16. package/dist/custom/data/explore-database-schema.action.js.map +1 -0
  17. package/dist/custom/files/index.d.ts +2 -0
  18. package/dist/custom/files/index.d.ts.map +1 -1
  19. package/dist/custom/files/index.js +5 -1
  20. package/dist/custom/files/index.js.map +1 -1
  21. package/dist/custom/files/list-storage-providers.action.d.ts +52 -0
  22. package/dist/custom/files/list-storage-providers.action.d.ts.map +1 -0
  23. package/dist/custom/files/list-storage-providers.action.js +175 -0
  24. package/dist/custom/files/list-storage-providers.action.js.map +1 -0
  25. package/dist/custom/files/search-storage-files.action.d.ts +61 -0
  26. package/dist/custom/files/search-storage-files.action.d.ts.map +1 -0
  27. package/dist/custom/files/search-storage-files.action.js +183 -0
  28. package/dist/custom/files/search-storage-files.action.js.map +1 -0
  29. package/dist/custom/web/google-custom-search.action.d.ts +55 -0
  30. package/dist/custom/web/google-custom-search.action.d.ts.map +1 -0
  31. package/dist/custom/web/google-custom-search.action.js +310 -0
  32. package/dist/custom/web/google-custom-search.action.js.map +1 -0
  33. package/dist/generated/action_subclasses.d.ts +51 -3
  34. package/dist/generated/action_subclasses.d.ts.map +1 -1
  35. package/dist/generated/action_subclasses.js +174 -90
  36. package/dist/generated/action_subclasses.js.map +1 -1
  37. package/dist/index.d.ts +4 -0
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +16 -0
  40. package/dist/index.js.map +1 -1
  41. package/package.json +13 -11
package/dist/config.d.ts CHANGED
@@ -16,12 +16,62 @@ declare const apiIntegrationsSchema: z.ZodObject<{
16
16
  * API keys follow format: sk-gamma-xxxxxxxx
17
17
  */
18
18
  gammaApiKey: z.ZodOptional<z.ZodString>;
19
+ /**
20
+ * Google services configuration (nested structure)
21
+ * Follows MJStorage pattern for better organization and scalability
22
+ */
23
+ google: z.ZodOptional<z.ZodObject<{
24
+ /**
25
+ * Google Custom Search configuration
26
+ * Used by: Google Custom Search action
27
+ * Get your API key from: https://developers.google.com/custom-search/v1/overview
28
+ * Get your CX from: https://programmablesearchengine.google.com/
29
+ */
30
+ customSearch: z.ZodOptional<z.ZodObject<{
31
+ /**
32
+ * Google Custom Search API key
33
+ */
34
+ apiKey: z.ZodOptional<z.ZodString>;
35
+ /**
36
+ * Google Custom Search engine identifier (CX)
37
+ */
38
+ cx: z.ZodOptional<z.ZodString>;
39
+ }, "strip", z.ZodTypeAny, {
40
+ apiKey?: string;
41
+ cx?: string;
42
+ }, {
43
+ apiKey?: string;
44
+ cx?: string;
45
+ }>>;
46
+ }, "strip", z.ZodTypeAny, {
47
+ customSearch?: {
48
+ apiKey?: string;
49
+ cx?: string;
50
+ };
51
+ }, {
52
+ customSearch?: {
53
+ apiKey?: string;
54
+ cx?: string;
55
+ };
56
+ }>>;
19
57
  }, "strip", z.ZodTypeAny, {
20
58
  perplexityApiKey?: string;
21
59
  gammaApiKey?: string;
60
+ google?: {
61
+ customSearch?: {
62
+ apiKey?: string;
63
+ cx?: string;
64
+ };
65
+ };
22
66
  }, {
23
67
  perplexityApiKey?: string;
24
68
  gammaApiKey?: string;
69
+ google?: {
70
+ customSearch?: {
71
+ apiKey?: string;
72
+ cx?: string;
73
+ };
74
+ };
25
75
  }>;
26
76
  /**
27
77
  * Complete configuration schema for Core Actions package
@@ -44,22 +94,84 @@ declare const coreActionsConfigSchema: z.ZodObject<{
44
94
  * API keys follow format: sk-gamma-xxxxxxxx
45
95
  */
46
96
  gammaApiKey: z.ZodOptional<z.ZodString>;
97
+ /**
98
+ * Google services configuration (nested structure)
99
+ * Follows MJStorage pattern for better organization and scalability
100
+ */
101
+ google: z.ZodOptional<z.ZodObject<{
102
+ /**
103
+ * Google Custom Search configuration
104
+ * Used by: Google Custom Search action
105
+ * Get your API key from: https://developers.google.com/custom-search/v1/overview
106
+ * Get your CX from: https://programmablesearchengine.google.com/
107
+ */
108
+ customSearch: z.ZodOptional<z.ZodObject<{
109
+ /**
110
+ * Google Custom Search API key
111
+ */
112
+ apiKey: z.ZodOptional<z.ZodString>;
113
+ /**
114
+ * Google Custom Search engine identifier (CX)
115
+ */
116
+ cx: z.ZodOptional<z.ZodString>;
117
+ }, "strip", z.ZodTypeAny, {
118
+ apiKey?: string;
119
+ cx?: string;
120
+ }, {
121
+ apiKey?: string;
122
+ cx?: string;
123
+ }>>;
124
+ }, "strip", z.ZodTypeAny, {
125
+ customSearch?: {
126
+ apiKey?: string;
127
+ cx?: string;
128
+ };
129
+ }, {
130
+ customSearch?: {
131
+ apiKey?: string;
132
+ cx?: string;
133
+ };
134
+ }>>;
47
135
  }, "strip", z.ZodTypeAny, {
48
136
  perplexityApiKey?: string;
49
137
  gammaApiKey?: string;
138
+ google?: {
139
+ customSearch?: {
140
+ apiKey?: string;
141
+ cx?: string;
142
+ };
143
+ };
50
144
  }, {
51
145
  perplexityApiKey?: string;
52
146
  gammaApiKey?: string;
147
+ google?: {
148
+ customSearch?: {
149
+ apiKey?: string;
150
+ cx?: string;
151
+ };
152
+ };
53
153
  }>>>;
54
154
  }, "strip", z.ZodTypeAny, {
55
155
  apiIntegrations?: {
56
156
  perplexityApiKey?: string;
57
157
  gammaApiKey?: string;
158
+ google?: {
159
+ customSearch?: {
160
+ apiKey?: string;
161
+ cx?: string;
162
+ };
163
+ };
58
164
  };
59
165
  }, {
60
166
  apiIntegrations?: {
61
167
  perplexityApiKey?: string;
62
168
  gammaApiKey?: string;
169
+ google?: {
170
+ customSearch?: {
171
+ apiKey?: string;
172
+ cx?: string;
173
+ };
174
+ };
63
175
  };
64
176
  }>;
65
177
  export type CoreActionsConfig = z.infer<typeof coreActionsConfigSchema>;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;GAEG;AACH,QAAA,MAAM,qBAAqB;IACzB;;;;OAIG;;IAGH;;;;;OAKG;;;;;;;;EAEH,CAAC;AAEH;;GAEG;AACH,QAAA,MAAM,uBAAuB;IAC3B;;OAEG;;QAtBH;;;;WAIG;;QAGH;;;;;WAKG;;;;;;;;;;;;;;;;;;;EAYH,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACxE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAI1E;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,iBAAiB,CA2BxD;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,IAAI,qBAAqB,CAGhE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;GAEG;AACH,QAAA,MAAM,qBAAqB;IACzB;;;;OAIG;;IAGH;;;;;OAKG;;IAGH;;;OAGG;;QAED;;;;;WAKG;;YAED;;eAEG;;YAEH;;eAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIP,CAAC;AAEH;;GAEG;AACH,QAAA,MAAM,uBAAuB;IAC3B;;OAEG;;QA7CH;;;;WAIG;;QAGH;;;;;WAKG;;QAGH;;;WAGG;;YAED;;;;;eAKG;;gBAED;;mBAEG;;gBAEH;;mBAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAcP,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACxE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAI1E;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,iBAAiB,CAqCxD;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,IAAI,qBAAqB,CAGhE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C"}
package/dist/config.js CHANGED
@@ -22,6 +22,28 @@ const apiIntegrationsSchema = zod_1.z.object({
22
22
  * API keys follow format: sk-gamma-xxxxxxxx
23
23
  */
24
24
  gammaApiKey: zod_1.z.string().optional(),
25
+ /**
26
+ * Google services configuration (nested structure)
27
+ * Follows MJStorage pattern for better organization and scalability
28
+ */
29
+ google: zod_1.z.object({
30
+ /**
31
+ * Google Custom Search configuration
32
+ * Used by: Google Custom Search action
33
+ * Get your API key from: https://developers.google.com/custom-search/v1/overview
34
+ * Get your CX from: https://programmablesearchengine.google.com/
35
+ */
36
+ customSearch: zod_1.z.object({
37
+ /**
38
+ * Google Custom Search API key
39
+ */
40
+ apiKey: zod_1.z.string().optional(),
41
+ /**
42
+ * Google Custom Search engine identifier (CX)
43
+ */
44
+ cx: zod_1.z.string().optional(),
45
+ }).optional(),
46
+ }).optional(),
25
47
  });
26
48
  /**
27
49
  * Complete configuration schema for Core Actions package
@@ -51,8 +73,18 @@ function getCoreActionsConfig() {
51
73
  // Extract only the fields relevant to Core Actions
52
74
  const rawConfig = {
53
75
  apiIntegrations: {
54
- perplexityApiKey: result.config.perplexityApiKey || process.env.PERPLEXITY_API_KEY,
55
- gammaApiKey: result.config.gammaApiKey || process.env.GAMMA_API_KEY,
76
+ perplexityApiKey: result.config?.perplexityApiKey || process.env.PERPLEXITY_API_KEY,
77
+ gammaApiKey: result.config?.gammaApiKey || process.env.GAMMA_API_KEY,
78
+ google: {
79
+ customSearch: {
80
+ apiKey: result.config?.google?.customSearch?.apiKey ||
81
+ result.config?.googleCustomSearchApiKey || // Backwards compatibility
82
+ process.env.GOOGLE_CUSTOM_SEARCH_API_KEY,
83
+ cx: result.config?.google?.customSearch?.cx ||
84
+ result.config?.googleCustomSearchCx || // Backwards compatibility
85
+ process.env.GOOGLE_CUSTOM_SEARCH_CX,
86
+ },
87
+ },
56
88
  },
57
89
  };
58
90
  _config = coreActionsConfigSchema.parse(rawConfig);
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,6CAA8C;AAC9C,+CAA2D;AAE3D,MAAM,QAAQ,GAAG,IAAA,6BAAe,EAAC,IAAI,EAAE,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC,CAAC;AAErE;;GAEG;AACH,MAAM,qBAAqB,GAAG,OAAC,CAAC,MAAM,CAAC;IACrC;;;;OAIG;IACH,gBAAgB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAEvC;;;;;OAKG;IACH,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACnC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAC;IACvC;;OAEG;IACH,eAAe,EAAE,qBAAqB,CAAC,QAAQ,EAAE,CAAC,OA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+ import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
2
+ import { BaseAction } from "@memberjunction/actions";
3
+ /**
4
+ * Action that creates a concise summary of content with citations to source material.
5
+ * Can work with either a URL (fetch + summarize) or pre-fetched content.
6
+ *
7
+ * Features:
8
+ * - Flexible input: URL or pre-fetched content
9
+ * - Configurable summary length (word count target)
10
+ * - Optional citations with quotes and links
11
+ * - Focus instructions for domain-specific summarization
12
+ * - Multiple output formats (paragraph, bullets, hybrid)
13
+ * - Automatic anchor link detection for precise citations
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * // Summarize from URL
18
+ * await runAction({
19
+ * ActionName: 'Summarize Content',
20
+ * Params: [{
21
+ * Name: 'url',
22
+ * Value: 'https://docs.memberjunction.org/architecture'
23
+ * }, {
24
+ * Name: 'summaryWords',
25
+ * Value: 200
26
+ * }, {
27
+ * Name: 'instructions',
28
+ * Value: 'Focus on metadata layer and entity system'
29
+ * }]
30
+ * });
31
+ *
32
+ * // Summarize pre-fetched content
33
+ * await runAction({
34
+ * ActionName: 'Summarize Content',
35
+ * Params: [{
36
+ * Name: 'content',
37
+ * Value: '<html>...</html>'
38
+ * }, {
39
+ * Name: 'sourceUrl',
40
+ * Value: 'https://docs.memberjunction.org/architecture'
41
+ * }, {
42
+ * Name: 'includeCitations',
43
+ * Value: true
44
+ * }]
45
+ * });
46
+ * ```
47
+ */
48
+ export declare class SummarizeContentAction extends BaseAction {
49
+ protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
50
+ /**
51
+ * Fetch web page content using the Get Web Page Content action
52
+ */
53
+ private fetchWebPageContent;
54
+ /**
55
+ * Generate summary using LLM via the Execute AI Prompt action
56
+ */
57
+ private generateSummary;
58
+ /**
59
+ * Execute another action by name
60
+ */
61
+ private executeAction;
62
+ private getStringParam;
63
+ private getNumericParam;
64
+ private getBooleanParam;
65
+ private addOutputParam;
66
+ private createErrorResult;
67
+ }
68
+ /**
69
+ * Loader function to ensure the SummarizeContentAction class is included in the bundle.
70
+ */
71
+ export declare function LoadSummarizeContentAction(): void;
72
+ //# sourceMappingURL=summarize-content.action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarize-content.action.d.ts","sourceRoot":"","sources":["../../../src/custom/ai/summarize-content.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAe,MAAM,8BAA8B,CAAC;AAChG,OAAO,EAAE,UAAU,EAAsB,MAAM,yBAAyB,CAAC;AAuBzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,qBACa,sBAAuB,SAAQ,UAAU;cAElC,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA6FvF;;OAEG;YACW,mBAAmB;IAoCjC;;OAEG;YACW,eAAe;IA2H7B;;OAEG;YACW,aAAa;IA4C3B,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,iBAAiB;CAO5B;AAED;;GAEG;AACH,wBAAgB,0BAA0B,SAEzC"}
@@ -0,0 +1,388 @@
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 __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || function (mod) {
25
+ if (mod && mod.__esModule) return mod;
26
+ var result = {};
27
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
+ __setModuleDefault(result, mod);
29
+ return result;
30
+ };
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.LoadSummarizeContentAction = exports.SummarizeContentAction = void 0;
33
+ const actions_base_1 = require("@memberjunction/actions-base");
34
+ const actions_1 = require("@memberjunction/actions");
35
+ const global_1 = require("@memberjunction/global");
36
+ const core_1 = require("@memberjunction/core");
37
+ /**
38
+ * Action that creates a concise summary of content with citations to source material.
39
+ * Can work with either a URL (fetch + summarize) or pre-fetched content.
40
+ *
41
+ * Features:
42
+ * - Flexible input: URL or pre-fetched content
43
+ * - Configurable summary length (word count target)
44
+ * - Optional citations with quotes and links
45
+ * - Focus instructions for domain-specific summarization
46
+ * - Multiple output formats (paragraph, bullets, hybrid)
47
+ * - Automatic anchor link detection for precise citations
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * // Summarize from URL
52
+ * await runAction({
53
+ * ActionName: 'Summarize Content',
54
+ * Params: [{
55
+ * Name: 'url',
56
+ * Value: 'https://docs.memberjunction.org/architecture'
57
+ * }, {
58
+ * Name: 'summaryWords',
59
+ * Value: 200
60
+ * }, {
61
+ * Name: 'instructions',
62
+ * Value: 'Focus on metadata layer and entity system'
63
+ * }]
64
+ * });
65
+ *
66
+ * // Summarize pre-fetched content
67
+ * await runAction({
68
+ * ActionName: 'Summarize Content',
69
+ * Params: [{
70
+ * Name: 'content',
71
+ * Value: '<html>...</html>'
72
+ * }, {
73
+ * Name: 'sourceUrl',
74
+ * Value: 'https://docs.memberjunction.org/architecture'
75
+ * }, {
76
+ * Name: 'includeCitations',
77
+ * Value: true
78
+ * }]
79
+ * });
80
+ * ```
81
+ */
82
+ let SummarizeContentAction = class SummarizeContentAction extends actions_1.BaseAction {
83
+ async InternalRunAction(params) {
84
+ try {
85
+ // Extract parameters
86
+ const url = this.getStringParam(params, "url");
87
+ const content = this.getStringParam(params, "content");
88
+ const sourceUrl = this.getStringParam(params, "sourceurl");
89
+ const summaryWords = this.getNumericParam(params, "summarywords", 200);
90
+ const includeCitations = this.getBooleanParam(params, "includecitations", true);
91
+ const maxCitations = this.getNumericParam(params, "maxcitations", 5);
92
+ const instructions = this.getStringParam(params, "instructions", "Provide a comprehensive summary");
93
+ const format = this.getStringParam(params, "format", "paragraph");
94
+ // Validation: Must have either URL or content
95
+ if (!url && !content) {
96
+ return this.createErrorResult("Must provide either 'url' or 'content' parameter", "MISSING_INPUT");
97
+ }
98
+ // Validation: If content provided, must have sourceUrl
99
+ if (content && !sourceUrl) {
100
+ return this.createErrorResult("When using 'content' parameter, 'sourceUrl' is required for citations", "MISSING_SOURCE_URL");
101
+ }
102
+ let pageContent;
103
+ let finalSourceUrl;
104
+ // Fetch content if URL provided
105
+ if (url) {
106
+ const fetchResult = await this.fetchWebPageContent(url, params);
107
+ if (!fetchResult.success) {
108
+ return this.createErrorResult(`Failed to fetch web page: ${fetchResult.error}`, "FETCH_FAILED");
109
+ }
110
+ pageContent = fetchResult.content;
111
+ finalSourceUrl = url;
112
+ }
113
+ else {
114
+ // Use provided content
115
+ pageContent = content;
116
+ finalSourceUrl = sourceUrl;
117
+ }
118
+ // Call the LLM prompt action to do the actual summarization
119
+ const summaryResult = await this.generateSummary(pageContent, finalSourceUrl, {
120
+ summaryWords,
121
+ includeCitations,
122
+ maxCitations,
123
+ instructions,
124
+ format
125
+ }, params);
126
+ if (!summaryResult.success) {
127
+ return this.createErrorResult(`Failed to generate summary: ${summaryResult.error}`, "SUMMARIZATION_FAILED");
128
+ }
129
+ // Add output parameters
130
+ const outputData = summaryResult.data;
131
+ this.addOutputParam(params, "summary", outputData.summary);
132
+ this.addOutputParam(params, "wordCount", outputData.wordCount);
133
+ if (outputData.citations) {
134
+ this.addOutputParam(params, "citations", outputData.citations);
135
+ }
136
+ if (outputData.keyPoints) {
137
+ this.addOutputParam(params, "keyPoints", outputData.keyPoints);
138
+ }
139
+ if (outputData.metadata) {
140
+ this.addOutputParam(params, "metadata", outputData.metadata);
141
+ }
142
+ return {
143
+ Success: true,
144
+ ResultCode: "SUCCESS",
145
+ Message: JSON.stringify(outputData, null, 2)
146
+ };
147
+ }
148
+ catch (error) {
149
+ (0, core_1.LogError)(`Error in Summarize Content action: ${error}`);
150
+ return this.createErrorResult(`Error summarizing content: ${error instanceof Error ? error.message : String(error)}`, "UNEXPECTED_ERROR");
151
+ }
152
+ }
153
+ /**
154
+ * Fetch web page content using the Get Web Page Content action
155
+ */
156
+ async fetchWebPageContent(url, params) {
157
+ try {
158
+ // Create params for the web page content action
159
+ const actionParams = [{
160
+ Name: "url",
161
+ Type: "Input",
162
+ Value: url
163
+ }];
164
+ // Execute the Get Web Page Content action
165
+ const result = await this.executeAction("Get Web Page Content", actionParams, params.ContextUser);
166
+ if (!result.Success) {
167
+ return {
168
+ success: false,
169
+ error: result.Message || "Failed to fetch web page"
170
+ };
171
+ }
172
+ // Extract content from result
173
+ const content = result.Message || "";
174
+ return {
175
+ success: true,
176
+ content
177
+ };
178
+ }
179
+ catch (error) {
180
+ return {
181
+ success: false,
182
+ error: error instanceof Error ? error.message : String(error)
183
+ };
184
+ }
185
+ }
186
+ /**
187
+ * Generate summary using LLM via the Execute AI Prompt action
188
+ */
189
+ async generateSummary(content, sourceUrl, options, params) {
190
+ try {
191
+ // Build structured output schema
192
+ const structuredOutput = {
193
+ type: "object",
194
+ properties: {
195
+ summary: {
196
+ type: "string",
197
+ description: `Main summary in ${options.format} format, approximately ${options.summaryWords} words`
198
+ },
199
+ wordCount: {
200
+ type: "number",
201
+ description: "Actual word count of summary"
202
+ },
203
+ ...(options.includeCitations && {
204
+ citations: {
205
+ type: "array",
206
+ description: `Up to ${options.maxCitations} most relevant quotes with source links`,
207
+ items: {
208
+ type: "object",
209
+ properties: {
210
+ text: { type: "string", description: "Exact quote from content" },
211
+ url: { type: "string", description: "URL with anchor if available" },
212
+ anchorId: { type: "string", description: "HTML anchor ID if found" },
213
+ context: { type: "string", description: "Brief context around quote" },
214
+ relevance: { type: "string", description: "Why this quote is important" }
215
+ },
216
+ required: ["text", "url", "relevance"]
217
+ }
218
+ }
219
+ }),
220
+ ...(options.format === "bullets" || options.format === "hybrid" ? {
221
+ keyPoints: {
222
+ type: "array",
223
+ description: "Key bullet points from content",
224
+ items: { type: "string" }
225
+ }
226
+ } : {}),
227
+ metadata: {
228
+ type: "object",
229
+ properties: {
230
+ pageTitle: { type: "string" },
231
+ sourceUrl: { type: "string" }
232
+ }
233
+ }
234
+ },
235
+ required: ["summary", "wordCount", "metadata"]
236
+ };
237
+ // Build the prompt data
238
+ const promptData = {
239
+ content,
240
+ sourceUrl,
241
+ summaryWords: options.summaryWords,
242
+ includeCitations: options.includeCitations,
243
+ maxCitations: options.maxCitations,
244
+ instructions: options.instructions,
245
+ format: options.format,
246
+ structuredOutput: JSON.stringify(structuredOutput)
247
+ };
248
+ // Execute AI Prompt action with the "Summarize Content" prompt
249
+ const actionParams = [{
250
+ Name: "promptName",
251
+ Type: "Input",
252
+ Value: "Summarize Content"
253
+ }, {
254
+ Name: "data",
255
+ Type: "Input",
256
+ Value: JSON.stringify(promptData)
257
+ }, {
258
+ Name: "responseFormat",
259
+ Type: "Input",
260
+ Value: "json_object"
261
+ }];
262
+ const result = await this.executeAction("Execute AI Prompt", actionParams, params.ContextUser);
263
+ if (!result.Success) {
264
+ return {
265
+ success: false,
266
+ error: result.Message || "Failed to execute AI prompt"
267
+ };
268
+ }
269
+ // Parse the result
270
+ let parsedResult;
271
+ try {
272
+ // The Execute AI Prompt action should return parsed JSON in Message
273
+ parsedResult = typeof result.Message === "string"
274
+ ? JSON.parse(result.Message)
275
+ : result.Message;
276
+ }
277
+ catch (parseError) {
278
+ return {
279
+ success: false,
280
+ error: `Failed to parse AI response: ${parseError}`
281
+ };
282
+ }
283
+ return {
284
+ success: true,
285
+ data: parsedResult
286
+ };
287
+ }
288
+ catch (error) {
289
+ return {
290
+ success: false,
291
+ error: error instanceof Error ? error.message : String(error)
292
+ };
293
+ }
294
+ }
295
+ /**
296
+ * Execute another action by name
297
+ */
298
+ async executeAction(actionName, params, contextUser) {
299
+ // Load the action entity using RunView
300
+ const { RunView } = await Promise.resolve().then(() => __importStar(require("@memberjunction/core")));
301
+ const rv = new RunView();
302
+ const result = await rv.RunView({
303
+ EntityName: 'Actions',
304
+ ExtraFilter: `Name='${actionName.replace(/'/g, "''")}'`,
305
+ ResultType: 'entity_object'
306
+ }, contextUser);
307
+ if (!result.Success || !result.Results || result.Results.length === 0) {
308
+ return {
309
+ Success: false,
310
+ ResultCode: "ACTION_NOT_FOUND",
311
+ Message: `Action "${actionName}" not found`
312
+ };
313
+ }
314
+ const action = result.Results[0];
315
+ // Build RunActionParams
316
+ const runParams = new actions_base_1.RunActionParams();
317
+ runParams.Action = action;
318
+ runParams.Params = params;
319
+ runParams.ContextUser = contextUser;
320
+ runParams.SkipActionLog = true; // Don't log sub-action executions
321
+ // Execute the action
322
+ const engine = new actions_1.ActionEngineServer();
323
+ const actionResult = await engine.RunAction(runParams);
324
+ return {
325
+ Success: actionResult.Success,
326
+ ResultCode: actionResult.Success ? "SUCCESS" : "ERROR",
327
+ Message: actionResult.Message,
328
+ Params: actionResult.Params
329
+ };
330
+ }
331
+ // Helper methods (consistent with other actions)
332
+ getStringParam(params, paramName, defaultValue) {
333
+ const param = params.Params.find(p => p.Name.trim().toLowerCase() === paramName.toLowerCase());
334
+ if (!param || param.Value === undefined || param.Value === null) {
335
+ return defaultValue;
336
+ }
337
+ const value = String(param.Value).trim();
338
+ return value.length > 0 ? value : defaultValue;
339
+ }
340
+ getNumericParam(params, paramName, defaultValue) {
341
+ const param = params.Params.find(p => p.Name.trim().toLowerCase() === paramName.toLowerCase());
342
+ if (!param || param.Value === undefined || param.Value === null) {
343
+ return defaultValue;
344
+ }
345
+ const parsed = Number(param.Value);
346
+ return isNaN(parsed) ? defaultValue : parsed;
347
+ }
348
+ getBooleanParam(params, paramName, defaultValue) {
349
+ const param = params.Params.find(p => p.Name.trim().toLowerCase() === paramName.toLowerCase());
350
+ if (!param || param.Value === undefined || param.Value === null) {
351
+ return defaultValue;
352
+ }
353
+ const value = String(param.Value).trim().toLowerCase();
354
+ if (value === "true" || value === "1" || value === "yes") {
355
+ return true;
356
+ }
357
+ if (value === "false" || value === "0" || value === "no") {
358
+ return false;
359
+ }
360
+ return defaultValue;
361
+ }
362
+ addOutputParam(params, name, value) {
363
+ params.Params.push({
364
+ Name: name,
365
+ Type: "Output",
366
+ Value: value
367
+ });
368
+ }
369
+ createErrorResult(message, code) {
370
+ return {
371
+ Success: false,
372
+ Message: message,
373
+ ResultCode: code
374
+ };
375
+ }
376
+ };
377
+ exports.SummarizeContentAction = SummarizeContentAction;
378
+ exports.SummarizeContentAction = SummarizeContentAction = __decorate([
379
+ (0, global_1.RegisterClass)(actions_1.BaseAction, "Summarize Content")
380
+ ], SummarizeContentAction);
381
+ /**
382
+ * Loader function to ensure the SummarizeContentAction class is included in the bundle.
383
+ */
384
+ function LoadSummarizeContentAction() {
385
+ // This function is a stub that is used to force the bundler to include the above class in the final bundle
386
+ }
387
+ exports.LoadSummarizeContentAction = LoadSummarizeContentAction;
388
+ //# sourceMappingURL=summarize-content.action.js.map