@memberjunction/core-actions 6.1.3 → 6.2.0-edge.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.
- package/dist/config.d.ts +68 -10
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +32 -5
- package/dist/config.js.map +1 -1
- package/dist/custom/ai/generate-image.action.d.ts +13 -1
- package/dist/custom/ai/generate-image.action.d.ts.map +1 -1
- package/dist/custom/ai/generate-image.action.js +25 -13
- package/dist/custom/ai/generate-image.action.js.map +1 -1
- package/dist/custom/utilities/base-file-handler.d.ts.map +1 -1
- package/dist/custom/utilities/base-file-handler.js +4 -2
- package/dist/custom/utilities/base-file-handler.js.map +1 -1
- package/dist/custom/web/brave-search.action.d.ts +108 -0
- package/dist/custom/web/brave-search.action.d.ts.map +1 -0
- package/dist/custom/web/brave-search.action.js +285 -0
- package/dist/custom/web/brave-search.action.js.map +1 -0
- package/dist/custom/web/perplexity-search.action.d.ts +76 -44
- package/dist/custom/web/perplexity-search.action.d.ts.map +1 -1
- package/dist/custom/web/perplexity-search.action.js +228 -157
- package/dist/custom/web/perplexity-search.action.js.map +1 -1
- package/dist/custom/web/rss-feed-read.action.d.ts.map +1 -1
- package/dist/custom/web/rss-feed-read.action.js +4 -1
- package/dist/custom/web/rss-feed-read.action.js.map +1 -1
- package/dist/custom/web/web-search.action.d.ts +56 -40
- package/dist/custom/web/web-search.action.d.ts.map +1 -1
- package/dist/custom/web/web-search.action.js +141 -413
- package/dist/custom/web/web-search.action.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +40 -39
package/dist/config.d.ts
CHANGED
|
@@ -8,10 +8,30 @@ declare const apiIntegrationsSchema: z.ZodObject<{
|
|
|
8
8
|
* Used by: Perplexity Search action
|
|
9
9
|
* Get your API key from: https://www.perplexity.ai/settings/api
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* Serves two distinct products behind one key, selected by the action's `Mode` parameter:
|
|
12
|
+
* `search` (default) calls Perplexity's raw `/search` endpoint, which returns structured
|
|
13
|
+
* title/url/snippet results at a flat per-query price; `answer` calls the Sonar chat models,
|
|
14
|
+
* which return prose plus citations and are billed per token.
|
|
15
|
+
*
|
|
16
|
+
* For a web-search role prefer `braveApiKey` below — an independent index with lower latency.
|
|
17
|
+
* Use this when a synthesised answer is genuinely what the caller wants.
|
|
13
18
|
*/
|
|
14
19
|
perplexityApiKey: z.ZodOptional<z.ZodString>;
|
|
20
|
+
/**
|
|
21
|
+
* Brave Search API Key for independent web search
|
|
22
|
+
* Used by: Brave Search action
|
|
23
|
+
* Get your API key from: https://api-dashboard.search.brave.com/
|
|
24
|
+
*
|
|
25
|
+
* This is the recommended web-search credential for new deployments. Brave serves from its
|
|
26
|
+
* own index rather than reselling Google's or Bing's, so it does not share a failure mode
|
|
27
|
+
* with the SERP-proxy vendors or with `google.customSearch` below. It returns the same
|
|
28
|
+
* title/url/snippet shape the Google action returns, which is what makes it a migration
|
|
29
|
+
* rather than a rewrite.
|
|
30
|
+
*
|
|
31
|
+
* NOTE: Brave retired its free tier in early 2026. Keys now meter against a stored card
|
|
32
|
+
* with no spending cap, so set a budget alert before pointing production traffic at it.
|
|
33
|
+
*/
|
|
34
|
+
braveApiKey: z.ZodOptional<z.ZodString>;
|
|
15
35
|
/**
|
|
16
36
|
* Tavily API Key for search built for LLM consumption
|
|
17
37
|
* Used by: Tavily Search action
|
|
@@ -38,9 +58,15 @@ declare const apiIntegrationsSchema: z.ZodObject<{
|
|
|
38
58
|
*
|
|
39
59
|
* NOTE: the Custom Search JSON API is CLOSED TO NEW CUSTOMERS. Projects that already have it
|
|
40
60
|
* enabled are served until 2027-01-01, when the API is discontinued. New deployments should
|
|
41
|
-
* configure `
|
|
42
|
-
*
|
|
43
|
-
*
|
|
61
|
+
* configure `braveApiKey` above instead — it is the only credential here that yields the same
|
|
62
|
+
* title/url/snippet result shape from an index that is not Google's.
|
|
63
|
+
*
|
|
64
|
+
* Google's stated successor (Vertex AI Search, since renamed Agent Search) searches your own
|
|
65
|
+
* indexed content or up to 50 verified domains rather than the public web, and yields neither
|
|
66
|
+
* an API key nor a CX. Gemini's `google_search` grounding does reach the public index, but
|
|
67
|
+
* returns expiring redirect URLs with no snippets, and its terms forbid caching or analysing
|
|
68
|
+
* the results — so neither is a drop-in for this action. `perplexityApiKey` is a reasonable
|
|
69
|
+
* fallback, but note its default mode is an answer engine rather than a search index.
|
|
44
70
|
*/
|
|
45
71
|
customSearch: z.ZodOptional<z.ZodObject<{
|
|
46
72
|
/**
|
|
@@ -93,6 +119,7 @@ declare const apiIntegrationsSchema: z.ZodObject<{
|
|
|
93
119
|
}>>;
|
|
94
120
|
}, "strip", z.ZodTypeAny, {
|
|
95
121
|
perplexityApiKey?: string;
|
|
122
|
+
braveApiKey?: string;
|
|
96
123
|
tavilyApiKey?: string;
|
|
97
124
|
gammaApiKey?: string;
|
|
98
125
|
google?: {
|
|
@@ -106,6 +133,7 @@ declare const apiIntegrationsSchema: z.ZodObject<{
|
|
|
106
133
|
};
|
|
107
134
|
}, {
|
|
108
135
|
perplexityApiKey?: string;
|
|
136
|
+
braveApiKey?: string;
|
|
109
137
|
tavilyApiKey?: string;
|
|
110
138
|
gammaApiKey?: string;
|
|
111
139
|
google?: {
|
|
@@ -131,10 +159,30 @@ declare const coreActionsConfigSchema: z.ZodObject<{
|
|
|
131
159
|
* Used by: Perplexity Search action
|
|
132
160
|
* Get your API key from: https://www.perplexity.ai/settings/api
|
|
133
161
|
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
162
|
+
* Serves two distinct products behind one key, selected by the action's `Mode` parameter:
|
|
163
|
+
* `search` (default) calls Perplexity's raw `/search` endpoint, which returns structured
|
|
164
|
+
* title/url/snippet results at a flat per-query price; `answer` calls the Sonar chat models,
|
|
165
|
+
* which return prose plus citations and are billed per token.
|
|
166
|
+
*
|
|
167
|
+
* For a web-search role prefer `braveApiKey` below — an independent index with lower latency.
|
|
168
|
+
* Use this when a synthesised answer is genuinely what the caller wants.
|
|
136
169
|
*/
|
|
137
170
|
perplexityApiKey: z.ZodOptional<z.ZodString>;
|
|
171
|
+
/**
|
|
172
|
+
* Brave Search API Key for independent web search
|
|
173
|
+
* Used by: Brave Search action
|
|
174
|
+
* Get your API key from: https://api-dashboard.search.brave.com/
|
|
175
|
+
*
|
|
176
|
+
* This is the recommended web-search credential for new deployments. Brave serves from its
|
|
177
|
+
* own index rather than reselling Google's or Bing's, so it does not share a failure mode
|
|
178
|
+
* with the SERP-proxy vendors or with `google.customSearch` below. It returns the same
|
|
179
|
+
* title/url/snippet shape the Google action returns, which is what makes it a migration
|
|
180
|
+
* rather than a rewrite.
|
|
181
|
+
*
|
|
182
|
+
* NOTE: Brave retired its free tier in early 2026. Keys now meter against a stored card
|
|
183
|
+
* with no spending cap, so set a budget alert before pointing production traffic at it.
|
|
184
|
+
*/
|
|
185
|
+
braveApiKey: z.ZodOptional<z.ZodString>;
|
|
138
186
|
/**
|
|
139
187
|
* Tavily API Key for search built for LLM consumption
|
|
140
188
|
* Used by: Tavily Search action
|
|
@@ -161,9 +209,15 @@ declare const coreActionsConfigSchema: z.ZodObject<{
|
|
|
161
209
|
*
|
|
162
210
|
* NOTE: the Custom Search JSON API is CLOSED TO NEW CUSTOMERS. Projects that already have it
|
|
163
211
|
* enabled are served until 2027-01-01, when the API is discontinued. New deployments should
|
|
164
|
-
* configure `
|
|
165
|
-
*
|
|
166
|
-
*
|
|
212
|
+
* configure `braveApiKey` above instead — it is the only credential here that yields the same
|
|
213
|
+
* title/url/snippet result shape from an index that is not Google's.
|
|
214
|
+
*
|
|
215
|
+
* Google's stated successor (Vertex AI Search, since renamed Agent Search) searches your own
|
|
216
|
+
* indexed content or up to 50 verified domains rather than the public web, and yields neither
|
|
217
|
+
* an API key nor a CX. Gemini's `google_search` grounding does reach the public index, but
|
|
218
|
+
* returns expiring redirect URLs with no snippets, and its terms forbid caching or analysing
|
|
219
|
+
* the results — so neither is a drop-in for this action. `perplexityApiKey` is a reasonable
|
|
220
|
+
* fallback, but note its default mode is an answer engine rather than a search index.
|
|
167
221
|
*/
|
|
168
222
|
customSearch: z.ZodOptional<z.ZodObject<{
|
|
169
223
|
/**
|
|
@@ -216,6 +270,7 @@ declare const coreActionsConfigSchema: z.ZodObject<{
|
|
|
216
270
|
}>>;
|
|
217
271
|
}, "strip", z.ZodTypeAny, {
|
|
218
272
|
perplexityApiKey?: string;
|
|
273
|
+
braveApiKey?: string;
|
|
219
274
|
tavilyApiKey?: string;
|
|
220
275
|
gammaApiKey?: string;
|
|
221
276
|
google?: {
|
|
@@ -229,6 +284,7 @@ declare const coreActionsConfigSchema: z.ZodObject<{
|
|
|
229
284
|
};
|
|
230
285
|
}, {
|
|
231
286
|
perplexityApiKey?: string;
|
|
287
|
+
braveApiKey?: string;
|
|
232
288
|
tavilyApiKey?: string;
|
|
233
289
|
gammaApiKey?: string;
|
|
234
290
|
google?: {
|
|
@@ -244,6 +300,7 @@ declare const coreActionsConfigSchema: z.ZodObject<{
|
|
|
244
300
|
}, "strip", z.ZodTypeAny, {
|
|
245
301
|
apiIntegrations?: {
|
|
246
302
|
perplexityApiKey?: string;
|
|
303
|
+
braveApiKey?: string;
|
|
247
304
|
tavilyApiKey?: string;
|
|
248
305
|
gammaApiKey?: string;
|
|
249
306
|
google?: {
|
|
@@ -259,6 +316,7 @@ declare const coreActionsConfigSchema: z.ZodObject<{
|
|
|
259
316
|
}, {
|
|
260
317
|
apiIntegrations?: {
|
|
261
318
|
perplexityApiKey?: string;
|
|
319
|
+
braveApiKey?: string;
|
|
262
320
|
tavilyApiKey?: string;
|
|
263
321
|
gammaApiKey?: string;
|
|
264
322
|
google?: {
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AA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I,CAE7C"}
|
package/dist/config.js
CHANGED
|
@@ -11,10 +11,30 @@ const apiIntegrationsSchema = z.object({
|
|
|
11
11
|
* Used by: Perplexity Search action
|
|
12
12
|
* Get your API key from: https://www.perplexity.ai/settings/api
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* Serves two distinct products behind one key, selected by the action's `Mode` parameter:
|
|
15
|
+
* `search` (default) calls Perplexity's raw `/search` endpoint, which returns structured
|
|
16
|
+
* title/url/snippet results at a flat per-query price; `answer` calls the Sonar chat models,
|
|
17
|
+
* which return prose plus citations and are billed per token.
|
|
18
|
+
*
|
|
19
|
+
* For a web-search role prefer `braveApiKey` below — an independent index with lower latency.
|
|
20
|
+
* Use this when a synthesised answer is genuinely what the caller wants.
|
|
16
21
|
*/
|
|
17
22
|
perplexityApiKey: z.string().optional(),
|
|
23
|
+
/**
|
|
24
|
+
* Brave Search API Key for independent web search
|
|
25
|
+
* Used by: Brave Search action
|
|
26
|
+
* Get your API key from: https://api-dashboard.search.brave.com/
|
|
27
|
+
*
|
|
28
|
+
* This is the recommended web-search credential for new deployments. Brave serves from its
|
|
29
|
+
* own index rather than reselling Google's or Bing's, so it does not share a failure mode
|
|
30
|
+
* with the SERP-proxy vendors or with `google.customSearch` below. It returns the same
|
|
31
|
+
* title/url/snippet shape the Google action returns, which is what makes it a migration
|
|
32
|
+
* rather than a rewrite.
|
|
33
|
+
*
|
|
34
|
+
* NOTE: Brave retired its free tier in early 2026. Keys now meter against a stored card
|
|
35
|
+
* with no spending cap, so set a budget alert before pointing production traffic at it.
|
|
36
|
+
*/
|
|
37
|
+
braveApiKey: z.string().optional(),
|
|
18
38
|
/**
|
|
19
39
|
* Tavily API Key for search built for LLM consumption
|
|
20
40
|
* Used by: Tavily Search action
|
|
@@ -41,9 +61,15 @@ const apiIntegrationsSchema = z.object({
|
|
|
41
61
|
*
|
|
42
62
|
* NOTE: the Custom Search JSON API is CLOSED TO NEW CUSTOMERS. Projects that already have it
|
|
43
63
|
* enabled are served until 2027-01-01, when the API is discontinued. New deployments should
|
|
44
|
-
* configure `
|
|
45
|
-
*
|
|
46
|
-
*
|
|
64
|
+
* configure `braveApiKey` above instead — it is the only credential here that yields the same
|
|
65
|
+
* title/url/snippet result shape from an index that is not Google's.
|
|
66
|
+
*
|
|
67
|
+
* Google's stated successor (Vertex AI Search, since renamed Agent Search) searches your own
|
|
68
|
+
* indexed content or up to 50 verified domains rather than the public web, and yields neither
|
|
69
|
+
* an API key nor a CX. Gemini's `google_search` grounding does reach the public index, but
|
|
70
|
+
* returns expiring redirect URLs with no snippets, and its terms forbid caching or analysing
|
|
71
|
+
* the results — so neither is a drop-in for this action. `perplexityApiKey` is a reasonable
|
|
72
|
+
* fallback, but note its default mode is an answer engine rather than a search index.
|
|
47
73
|
*/
|
|
48
74
|
customSearch: z.object({
|
|
49
75
|
/**
|
|
@@ -103,6 +129,7 @@ export function getCoreActionsConfig() {
|
|
|
103
129
|
apiIntegrations: {
|
|
104
130
|
perplexityApiKey: fileConfig?.perplexityApiKey || process.env.PERPLEXITY_API_KEY,
|
|
105
131
|
tavilyApiKey: fileConfig?.tavilyApiKey || process.env.TAVILY_API_KEY,
|
|
132
|
+
braveApiKey: fileConfig?.braveApiKey || process.env.BRAVE_SEARCH_API_KEY,
|
|
106
133
|
gammaApiKey: fileConfig?.gammaApiKey || process.env.GAMMA_API_KEY,
|
|
107
134
|
google: {
|
|
108
135
|
customSearch: {
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAE3D,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,EAAE,EAAE,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,OAAO,CAAC,GAAG,CAAC,4BAA4B;wBAChD,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE;4BACpC,UAAU,EAAE,oBAAoB,IAAK,0BAA0B;4BAC/D,OAAO,CAAC,GAAG,CAAC,uBAAuB;qBACxC;oBACD,SAAS,EAAE;wBACT,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;4BACrC,OAAO,CAAC,GAAG,CAAC,wBAAwB;4BACpC,OAAO,CAAC,GAAG,CAAC,mBAAmB;qBACxC;iBACF;aACF;SACF,CAAC;QAEF,OAAO,GAAG,uBAAuB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACnD,OAAO,OAAO,CAAC;IACjB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,QAAQ,CAAC,0CAA0C,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QACvE,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,wBAAwB;IACtC,MAAM,MAAM,GAAG,oBAAoB,EAAE,CAAC;IACtC,OAAO,MAAM,CAAC,eAAe,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO,GAAG,IAAI,CAAC;AACjB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
|
|
1
|
+
import { ActionResultSimple, RunActionParams, RuntimeAPIKeyResolver } from "@memberjunction/actions-base";
|
|
2
2
|
import { BaseAction } from "@memberjunction/actions";
|
|
3
3
|
/**
|
|
4
4
|
* Action that generates images using AI image generation models (DALL-E, Gemini, etc.)
|
|
@@ -57,6 +57,18 @@ import { BaseAction } from "@memberjunction/actions";
|
|
|
57
57
|
* });
|
|
58
58
|
* ```
|
|
59
59
|
*/
|
|
60
|
+
/**
|
|
61
|
+
* Resolve the key an image generator should use.
|
|
62
|
+
*
|
|
63
|
+
* Inside an agent run, `resolve` is the run's {@link RuntimeAPIKeyResolver}: the RUN'S key for the
|
|
64
|
+
* driver class first, then the platform's — the same order the run's prompts use, so a run on a
|
|
65
|
+
* customer's OpenAI key now generates its images on that key too. Outside a run (or when the agent
|
|
66
|
+
* refuses this action the run's key) it is undefined / answers undefined, and `GetAIAPIKey` gives
|
|
67
|
+
* the platform key as it always did. Then the vendor-name fallback that was always here — but
|
|
68
|
+
* actually USED this time: the previous code found a key by vendor name and then handed the empty
|
|
69
|
+
* driver-class result to the generator, so that branch never produced an image.
|
|
70
|
+
*/
|
|
71
|
+
export declare function ResolveImageGenerationAPIKey(driverClass: string, vendorName: string | undefined, resolve?: RuntimeAPIKeyResolver): string;
|
|
60
72
|
export declare class GenerateImageAction extends BaseAction {
|
|
61
73
|
/**
|
|
62
74
|
* Generates or edits image(s) using AI image generation models.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-image.action.d.ts","sourceRoot":"","sources":["../../../src/custom/ai/generate-image.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"generate-image.action.d.ts","sourceRoot":"","sources":["../../../src/custom/ai/generate-image.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE1G,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAcrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH;;;;;;;;;;GAUG;AACH,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,MAAM,CAMzI;AAED,qBACa,mBAAoB,SAAQ,UAAU;IAE/C;;;;;;;;;;;;;;;;;;;OAmBG;cACa,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAiIvF;;OAEG;YACW,qBAAqB;IA+DnC;;OAEG;YACW,sBAAsB;IAkCpC;;OAEG;YACW,gBAAgB;IAgC9B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAYzB;;OAEG;IACH,OAAO,CAAC,aAAa;IAKrB;;OAEG;IACH,OAAO,CAAC,cAAc;CAMzB"}
|
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { RegisterClass } from "@memberjunction/global";
|
|
8
8
|
import { BaseAction } from "@memberjunction/actions";
|
|
9
9
|
import { MJGlobal, UUIDsEqual } from "@memberjunction/global";
|
|
10
|
-
import { BaseImageGenerator, GetAIAPIKey } from "@memberjunction/ai";
|
|
10
|
+
import { BaseImageGenerator, GetAIAPIKey, } from "@memberjunction/ai";
|
|
11
11
|
import { AIEngineBase } from "@memberjunction/ai-engine-base";
|
|
12
12
|
/**
|
|
13
13
|
* Action that generates images using AI image generation models (DALL-E, Gemini, etc.)
|
|
@@ -66,6 +66,26 @@ import { AIEngineBase } from "@memberjunction/ai-engine-base";
|
|
|
66
66
|
* });
|
|
67
67
|
* ```
|
|
68
68
|
*/
|
|
69
|
+
/**
|
|
70
|
+
* Resolve the key an image generator should use.
|
|
71
|
+
*
|
|
72
|
+
* Inside an agent run, `resolve` is the run's {@link RuntimeAPIKeyResolver}: the RUN'S key for the
|
|
73
|
+
* driver class first, then the platform's — the same order the run's prompts use, so a run on a
|
|
74
|
+
* customer's OpenAI key now generates its images on that key too. Outside a run (or when the agent
|
|
75
|
+
* refuses this action the run's key) it is undefined / answers undefined, and `GetAIAPIKey` gives
|
|
76
|
+
* the platform key as it always did. Then the vendor-name fallback that was always here — but
|
|
77
|
+
* actually USED this time: the previous code found a key by vendor name and then handed the empty
|
|
78
|
+
* driver-class result to the generator, so that branch never produced an image.
|
|
79
|
+
*/
|
|
80
|
+
export function ResolveImageGenerationAPIKey(driverClass, vendorName, resolve) {
|
|
81
|
+
const byDriver = resolve?.(driverClass) || GetAIAPIKey(driverClass);
|
|
82
|
+
if (byDriver)
|
|
83
|
+
return byDriver;
|
|
84
|
+
const byVendor = vendorName ? resolve?.(vendorName) || GetAIAPIKey(vendorName) : '';
|
|
85
|
+
if (byVendor)
|
|
86
|
+
return byVendor;
|
|
87
|
+
throw new Error(`No API key found for ${driverClass} or vendor ${vendorName || 'unknown'}`);
|
|
88
|
+
}
|
|
69
89
|
let GenerateImageAction = class GenerateImageAction extends BaseAction {
|
|
70
90
|
/**
|
|
71
91
|
* Generates or edits image(s) using AI image generation models.
|
|
@@ -108,7 +128,7 @@ let GenerateImageAction = class GenerateImageAction extends BaseAction {
|
|
|
108
128
|
};
|
|
109
129
|
}
|
|
110
130
|
// Get image generator model and create instance
|
|
111
|
-
const { generator, model, apiName } = await this.prepareImageGenerator(params.ContextUser, modelName);
|
|
131
|
+
const { generator, model, apiName } = await this.prepareImageGenerator(params.ContextUser, modelName, params.RuntimeAPIKeyResolver);
|
|
112
132
|
let result;
|
|
113
133
|
if (sourceImage) {
|
|
114
134
|
// Image-to-image: use EditImage when source image is provided
|
|
@@ -202,7 +222,7 @@ let GenerateImageAction = class GenerateImageAction extends BaseAction {
|
|
|
202
222
|
/**
|
|
203
223
|
* Prepare an image generator instance using proper metadata lookup
|
|
204
224
|
*/
|
|
205
|
-
async prepareImageGenerator(contextUser, modelName) {
|
|
225
|
+
async prepareImageGenerator(contextUser, modelName, resolve) {
|
|
206
226
|
// Ensure AIEngine is loaded
|
|
207
227
|
await AIEngineBase.Instance.Config(false, contextUser);
|
|
208
228
|
// Find image generator models
|
|
@@ -230,18 +250,10 @@ let GenerateImageAction = class GenerateImageAction extends BaseAction {
|
|
|
230
250
|
if (!inferenceProvider) {
|
|
231
251
|
throw new Error(`No active inference provider found for model '${model.Name}'`);
|
|
232
252
|
}
|
|
233
|
-
// Get API key using the vendor's driver class
|
|
234
253
|
const driverClass = inferenceProvider.DriverClass;
|
|
235
254
|
const apiName = inferenceProvider.APIName || model.APIName || model.Name;
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
// Try getting by vendor name as fallback
|
|
239
|
-
const vendor = AIEngineBase.Instance.Vendors.find(v => UUIDsEqual(v.ID, inferenceProvider.VendorID));
|
|
240
|
-
const vendorApiKey = vendor ? GetAIAPIKey(vendor.Name) : null;
|
|
241
|
-
if (!vendorApiKey) {
|
|
242
|
-
throw new Error(`No API key found for ${driverClass} or vendor ${vendor?.Name || 'unknown'}`);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
255
|
+
const vendor = AIEngineBase.Instance.Vendors.find(v => UUIDsEqual(v.ID, inferenceProvider.VendorID));
|
|
256
|
+
const apiKey = ResolveImageGenerationAPIKey(driverClass, vendor?.Name, resolve);
|
|
245
257
|
const generator = MJGlobal.Instance.ClassFactory.CreateInstance(BaseImageGenerator, driverClass, apiKey);
|
|
246
258
|
if (!generator) {
|
|
247
259
|
throw new Error(`Failed to create image generator instance for ${driverClass}. Ensure the provider is registered.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-image.action.js","sourceRoot":"","sources":["../../../src/custom/ai/generate-image.action.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EACH,kBAAkB,EAKlB,WAAW,
|
|
1
|
+
{"version":3,"file":"generate-image.action.js","sourceRoot":"","sources":["../../../src/custom/ai/generate-image.action.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EA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QACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,SAAS,GAAG,KAAK,GAAG,QAAQ,CAAC;KACxC,CAAC;IAyBF;;OAEG;YACW,iBAAiB;IAkC/B;;OAEG;YACW,WAAW;
|
|
1
|
+
{"version":3,"file":"base-file-handler.d.ts","sourceRoot":"","sources":["../../../src/custom/utilities/base-file-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAM/D;;;;;;GAMG;AACH,8BAAsB,qBAAsB,SAAQ,UAAU;IAC1D;;;;;;;;;OASG;cACa,cAAc,CAC1B,MAAM,EAAE,eAAe,EACvB,aAAa,EAAE,MAAM,EACrB,aAAa,GAAE,MAAiB,EAChC,YAAY,GAAE,MAAkB,GACjC,OAAO,CAAC;QACP,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;QACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,SAAS,GAAG,KAAK,GAAG,QAAQ,CAAC;KACxC,CAAC;IAyBF;;OAEG;YACW,iBAAiB;IAkC/B;;OAEG;YACW,WAAW;IAmDzB;;;;;;;;;;;OAWG;cACa,eAAe,CAC3B,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,eAAe,EACvB,kBAAkB,CAAC,EAAE,MAAM,EAC3B,WAAW,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,MAAM,CAAC;IAiClB;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAQhC;;;OAGG;YACW,uBAAuB;IAarC;;OAEG;YACW,uBAAuB;IASrC;;OAEG;IACH,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,GAAG,GAAG;IAKxE;;OAEG;IACH,SAAS,CAAC,eAAe,CAAC,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAE,OAAe,GAAG,OAAO;IAM7G;;OAEG;IACH,SAAS,CAAC,eAAe,CAAC,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAE,MAAU,GAAG,MAAM;CAM1G"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseAction } from "@memberjunction/actions";
|
|
2
2
|
import { RunView } from "@memberjunction/core";
|
|
3
3
|
import { FileStorageEngine } from "@memberjunction/storage";
|
|
4
|
-
import { DrainResponseBody } from "@memberjunction/network-utils";
|
|
4
|
+
import { DrainResponseBody, SafeFetch } from "@memberjunction/network-utils";
|
|
5
5
|
/**
|
|
6
6
|
* Base class for actions that handle file inputs from multiple sources
|
|
7
7
|
* Provides common functionality for loading files from:
|
|
@@ -80,7 +80,9 @@ export class BaseFileHandlerAction extends BaseAction {
|
|
|
80
80
|
if (!['http:', 'https:'].includes(urlObj.protocol)) {
|
|
81
81
|
throw new Error('Only HTTP and HTTPS URLs are supported');
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
// Route through the SSRF guard: the URL is caller-controlled, so private/loopback/
|
|
84
|
+
// link-local/reserved targets are blocked and every redirect hop is re-validated.
|
|
85
|
+
const response = await SafeFetch(url);
|
|
84
86
|
if (!response.ok) {
|
|
85
87
|
await DrainResponseBody(response);
|
|
86
88
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-file-handler.js","sourceRoot":"","sources":["../../../src/custom/utilities/base-file-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAAE,i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K,KAAK,IAAI;YAAE,OAAO,YAAY,CAAC;QAC/D,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC;IAClD,CAAC;IAED;;OAEG;IACO,eAAe,CAAC,MAAuB,EAAE,SAAiB,EAAE,eAAuB,CAAC;QAC1F,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QACpD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,YAAY,CAAC;QAC/D,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC1B,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC;IAC3C,CAAC;CACJ"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
|
|
2
|
+
import { BaseAction } from "@memberjunction/actions";
|
|
3
|
+
/** One result from Brave's web search endpoint, normalised to this package's naming. */
|
|
4
|
+
export interface BraveSearchResultItem {
|
|
5
|
+
title: string;
|
|
6
|
+
url: string;
|
|
7
|
+
/** Brave calls this `description`; it is the result snippet. */
|
|
8
|
+
snippet: string;
|
|
9
|
+
/** Host as Brave displays it, e.g. `irs.gov`. Empty when Brave omits `meta_url`. */
|
|
10
|
+
displayUrl: string;
|
|
11
|
+
/** Human-readable relative age ("3 days ago"). Only present on results Brave dates. */
|
|
12
|
+
age?: string;
|
|
13
|
+
/** Publication/modification date when Brave resolved one, as an ISO-ish string. */
|
|
14
|
+
pageAge?: string;
|
|
15
|
+
/** Additional snippets from the same page. Only populated when `ExtraSnippets` is set. */
|
|
16
|
+
extraSnippets?: string[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Action that searches the web through the Brave Search API.
|
|
20
|
+
*
|
|
21
|
+
* Brave matters here for a reason that is structural rather than qualitative: it
|
|
22
|
+
* serves results from **its own index** (40B+ pages) rather than reselling
|
|
23
|
+
* Google's or Bing's. Every SERP-proxy vendor — and every product built on the
|
|
24
|
+
* Google Custom Search JSON API, which is discontinued on 2027-01-01 — depends on
|
|
25
|
+
* a search engine continuing to permit that access. Brave does not, so it fails
|
|
26
|
+
* independently of the rest of this package's web-search actions. That is the
|
|
27
|
+
* whole point of adding it.
|
|
28
|
+
*
|
|
29
|
+
* Its output shape is deliberately `title` / `url` / `snippet`, which is the shape
|
|
30
|
+
* `Google Custom Search` returns today, so callers migrating off that action are
|
|
31
|
+
* making a rename rather than a rewrite.
|
|
32
|
+
*
|
|
33
|
+
* Authentication is the `X-Subscription-Token` header. Brave requires
|
|
34
|
+
* `Accept: application/json` and returns gzip, which `fetch` negotiates itself.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* // Basic search
|
|
39
|
+
* await runAction({
|
|
40
|
+
* ActionName: 'Brave Search',
|
|
41
|
+
* Params: [{ Name: 'Query', Value: 'association management software trends' }]
|
|
42
|
+
* });
|
|
43
|
+
*
|
|
44
|
+
* // Recent results only, more of them
|
|
45
|
+
* await runAction({
|
|
46
|
+
* ActionName: 'Brave Search',
|
|
47
|
+
* Params: [
|
|
48
|
+
* { Name: 'Query', Value: 'nonprofit membership dues changes' },
|
|
49
|
+
* { Name: 'Freshness', Value: 'pw' },
|
|
50
|
+
* { Name: 'Count', Value: 20 }
|
|
51
|
+
* ]
|
|
52
|
+
* });
|
|
53
|
+
*
|
|
54
|
+
* // Second page, UK results, with the extra per-page snippets
|
|
55
|
+
* await runAction({
|
|
56
|
+
* ActionName: 'Brave Search',
|
|
57
|
+
* Params: [
|
|
58
|
+
* { Name: 'Query', Value: 'charity commission filing deadlines' },
|
|
59
|
+
* { Name: 'Country', Value: 'GB' },
|
|
60
|
+
* { Name: 'Offset', Value: 1 },
|
|
61
|
+
* { Name: 'ExtraSnippets', Value: true }
|
|
62
|
+
* ]
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare class BraveSearchAction extends BaseAction {
|
|
67
|
+
private static readonly ENDPOINT;
|
|
68
|
+
/** Brave's cap on results per request. */
|
|
69
|
+
private static readonly MAX_COUNT;
|
|
70
|
+
private static readonly DEFAULT_COUNT;
|
|
71
|
+
/** Brave's cap on the pagination offset (in pages, not results). */
|
|
72
|
+
private static readonly MAX_OFFSET;
|
|
73
|
+
/** Brave rejects queries longer than this outright. */
|
|
74
|
+
private static readonly MAX_QUERY_CHARS;
|
|
75
|
+
private static readonly SAFESEARCH_VALUES;
|
|
76
|
+
/** `pd`/`pw`/`pm`/`py` = past day/week/month/year. Brave also accepts a date range. */
|
|
77
|
+
private static readonly FRESHNESS_CODES;
|
|
78
|
+
private static readonly FRESHNESS_RANGE;
|
|
79
|
+
/**
|
|
80
|
+
* Executes the Brave search.
|
|
81
|
+
*
|
|
82
|
+
* @param params - The action parameters containing:
|
|
83
|
+
* - Query: Search query text (required, max 400 characters)
|
|
84
|
+
* - Count: 1-20 results (default 10)
|
|
85
|
+
* - Offset: Page offset 0-9 (default 0) — pages, not results
|
|
86
|
+
* - Country: 2-letter country code for localisation, e.g. 'US', 'GB'
|
|
87
|
+
* - SearchLang: Language code for results, e.g. 'en'
|
|
88
|
+
* - SafeSearch: 'off' | 'moderate' (default) | 'strict'
|
|
89
|
+
* - Freshness: 'pd' | 'pw' | 'pm' | 'py', or 'YYYY-MM-DDtoYYYY-MM-DD'
|
|
90
|
+
* - ExtraSnippets: Return additional snippets per result (default false).
|
|
91
|
+
* Brave gates this on plan tier, so it is off unless asked for
|
|
92
|
+
*
|
|
93
|
+
* @returns Structured web results with titles, URLs and snippets
|
|
94
|
+
*/
|
|
95
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
96
|
+
private mapHttpError;
|
|
97
|
+
/** Pull whatever explanation the error body carries, without assuming a shape. */
|
|
98
|
+
private describeErrorBody;
|
|
99
|
+
private isValidFreshness;
|
|
100
|
+
private clamp;
|
|
101
|
+
private getStringParam;
|
|
102
|
+
private getBooleanParam;
|
|
103
|
+
private getNumericParam;
|
|
104
|
+
private addOutputParam;
|
|
105
|
+
private createErrorResult;
|
|
106
|
+
}
|
|
107
|
+
export declare function LoadBraveSearchAction(): void;
|
|
108
|
+
//# sourceMappingURL=brave-search.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brave-search.action.d.ts","sourceRoot":"","sources":["../../../src/custom/web/brave-search.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAKrD,wFAAwF;AACxF,MAAM,WAAW,qBAAqB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC;IAChB,oFAAoF;IACpF,UAAU,EAAE,MAAM,CAAC;IACnB,uFAAuF;IACvF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,mFAAmF;IACnF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0FAA0F;IAC1F,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAsBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,qBACa,iBAAkB,SAAQ,UAAU;IAC7C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAoD;IACpF,0CAA0C;IAC1C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAM;IACvC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAM;IAC3C,oEAAoE;IACpE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAK;IACvC,uDAAuD;IACvD,OAAO,CAAC,MAAM,CAAC,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