@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.
Files changed (31) hide show
  1. package/dist/config.d.ts +68 -10
  2. package/dist/config.d.ts.map +1 -1
  3. package/dist/config.js +32 -5
  4. package/dist/config.js.map +1 -1
  5. package/dist/custom/ai/generate-image.action.d.ts +13 -1
  6. package/dist/custom/ai/generate-image.action.d.ts.map +1 -1
  7. package/dist/custom/ai/generate-image.action.js +25 -13
  8. package/dist/custom/ai/generate-image.action.js.map +1 -1
  9. package/dist/custom/utilities/base-file-handler.d.ts.map +1 -1
  10. package/dist/custom/utilities/base-file-handler.js +4 -2
  11. package/dist/custom/utilities/base-file-handler.js.map +1 -1
  12. package/dist/custom/web/brave-search.action.d.ts +108 -0
  13. package/dist/custom/web/brave-search.action.d.ts.map +1 -0
  14. package/dist/custom/web/brave-search.action.js +285 -0
  15. package/dist/custom/web/brave-search.action.js.map +1 -0
  16. package/dist/custom/web/perplexity-search.action.d.ts +76 -44
  17. package/dist/custom/web/perplexity-search.action.d.ts.map +1 -1
  18. package/dist/custom/web/perplexity-search.action.js +228 -157
  19. package/dist/custom/web/perplexity-search.action.js.map +1 -1
  20. package/dist/custom/web/rss-feed-read.action.d.ts.map +1 -1
  21. package/dist/custom/web/rss-feed-read.action.js +4 -1
  22. package/dist/custom/web/rss-feed-read.action.js.map +1 -1
  23. package/dist/custom/web/web-search.action.d.ts +56 -40
  24. package/dist/custom/web/web-search.action.d.ts.map +1 -1
  25. package/dist/custom/web/web-search.action.js +141 -413
  26. package/dist/custom/web/web-search.action.js.map +1 -1
  27. package/dist/index.d.ts +1 -0
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +1 -0
  30. package/dist/index.js.map +1 -1
  31. package/package.json +40 -39
@@ -1,66 +1,82 @@
1
1
  import { ActionResultSimple, RunActionParams } from "@memberjunction/actions-base";
2
2
  import { BaseAction } from "@memberjunction/actions";
3
3
  /**
4
- * Action that performs web search using DuckDuckGo's Instant Answer API
5
- * Returns search results with titles, URLs, and snippets
4
+ * Action that performs a web search through whichever provider the administrator has configured.
5
+ *
6
+ * This is the **provider-neutral entry point** agents should bind to. It holds no vendor logic of
7
+ * its own: it extracts parameters, hands them to {@link WebSearchEngine}, and maps the result
8
+ * back. Which vendor actually serves the request — Brave, Tavily, Perplexity, or a fallback when
9
+ * the first choice is rate-limited — is decided by the `MJ: Web Search Providers` records and
10
+ * their `Priority`, not by the caller and not by the agent.
11
+ *
12
+ * That is the point. An LLM choosing between named vendor actions is making an infrastructure
13
+ * decision it has no information for: it cannot know which key is configured, which is cheaper,
14
+ * or which is rate-limited right now. Swapping vendors here is a metadata edit, with no change to
15
+ * any agent.
16
+ *
17
+ * `Provider` is the escape hatch for a caller who genuinely knows better. When set, the engine
18
+ * **fails rather than substituting** — a silent substitution is how you discover months later
19
+ * that a deliberate choice stopped being honoured.
6
20
  *
7
21
  * @example
8
22
  * ```typescript
9
- * // Basic web search
23
+ * // Let the administrator's priority order decide
24
+ * await runAction({
25
+ * ActionName: 'Web Search',
26
+ * Params: [{ Name: 'Query', Value: 'association management trends' }]
27
+ * });
28
+ *
29
+ * // Recent results from two domains, with a synthesized answer
10
30
  * await runAction({
11
31
  * ActionName: 'Web Search',
12
- * Params: [{
13
- * Name: 'SearchTerms',
14
- * Value: 'TypeScript programming'
15
- * }]
32
+ * Params: [
33
+ * { Name: 'Query', Value: 'IRS Form 990 filing changes' },
34
+ * { Name: 'Freshness', Value: 'month' },
35
+ * { Name: 'IncludeDomains', Value: ['irs.gov', 'councilofnonprofits.org'] },
36
+ * { Name: 'IncludeAnswer', Value: true }
37
+ * ]
16
38
  * });
17
39
  *
18
- * // Search with custom result count
40
+ * // Pin one vendor — fails if it is not available rather than using another
19
41
  * await runAction({
20
42
  * ActionName: 'Web Search',
21
- * Params: [{
22
- * Name: 'SearchTerms',
23
- * Value: 'machine learning tutorials'
24
- * }, {
25
- * Name: 'MaxResults',
26
- * Value: 15
27
- * }]
43
+ * Params: [
44
+ * { Name: 'Query', Value: 'quantum error correction 2026' },
45
+ * { Name: 'Provider', Value: 'Brave' }
46
+ * ]
28
47
  * });
29
48
  * ```
30
49
  */
31
50
  export declare class WebSearchAction extends BaseAction {
51
+ private static readonly FRESHNESS_WINDOWS;
52
+ private static readonly SAFE_SEARCH_VALUES;
32
53
  /**
33
- * Executes the web search using DuckDuckGo's API
54
+ * Executes the search.
34
55
  *
35
56
  * @param params - The action parameters containing:
36
- * - SearchTerms: Keywords to search for (required)
37
- * - MaxResults: Maximum number of results to return (default: 10, max: 30)
38
- * - Region: Regional search preference (default: 'us-en')
39
- * - SafeSearch: Safe search level - 'strict', 'moderate', 'off' (default: 'moderate')
40
- * - DisableQueueing: If true, fails immediately when rate limited instead of queueing (default: false)
57
+ * - Query: Search query text (required)
58
+ * - MaxResults: Desired result count, clamped to the serving provider's cap (default 10)
59
+ * - Provider: Pin to one provider by Name or DriverClass. Fails if unavailable
60
+ * - IncludeDomains / ExcludeDomains: Array or comma-separated domain lists
61
+ * - Freshness: 'day' | 'week' | 'month' | 'year'
62
+ * - Country: Two-letter country code, e.g. 'US'
63
+ * - Language: Language code, e.g. 'en'
64
+ * - SafeSearch: 'off' | 'moderate' | 'strict' (default 'moderate')
65
+ * - IncludeAnswer: Also return a synthesized answer, restricting provider selection
41
66
  *
42
- * @returns Web search results with titles, URLs, and snippets
67
+ * @returns Normalised results plus which provider served them
43
68
  */
44
69
  protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
70
+ private getStringParam;
71
+ private getBooleanParam;
72
+ private getOptionalNumericParam;
45
73
  /**
46
- * Parses DuckDuckGo Instant Answer API JSON response
47
- */
48
- private parseInstantResults;
49
- /**
50
- * Extracts domain from URL
51
- */
52
- private extractDomain;
53
- /**
54
- * Parses DuckDuckGo HTML search results
55
- */
56
- private parseSearchResults;
57
- /**
58
- * Decodes DuckDuckGo URL redirects
59
- */
60
- private decodeUrl;
61
- /**
62
- * Strips HTML tags and decodes entities
74
+ * A list param, accepted as a real array or as a comma-separated string — both forms arrive
75
+ * in practice, from agent input mappings and from humans respectively.
63
76
  */
64
- private stripHtml;
77
+ private getStringArrayParam;
78
+ private addOutputParam;
79
+ private createErrorResult;
65
80
  }
81
+ export declare function LoadWebSearchAction(): void;
66
82
  //# sourceMappingURL=web-search.action.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"web-search.action.d.ts","sourceRoot":"","sources":["../../../src/custom/web/web-search.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAIrD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBACa,eAAgB,SAAQ,UAAU;IAE3C;;;;;;;;;;;OAWG;cACa,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA0MvF;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAkE3B;;OAEG;IACH,OAAO,CAAC,aAAa;IAQrB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IA+H1B;;OAEG;IACH,OAAO,CAAC,SAAS;IAcjB;;OAEG;IACH,OAAO,CAAC,SAAS;CAYpB"}
1
+ {"version":3,"file":"web-search.action.d.ts","sourceRoot":"","sources":["../../../src/custom/web/web-search.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AASrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,qBACa,eAAgB,SAAQ,UAAU;IAC3C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAA6C;IACtF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAA0C;IAEpF;;;;;;;;;;;;;;;OAeG;cACa,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA4EvF,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,uBAAuB;IAO/B;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,iBAAiB;CAG5B;AAED,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C"}