chat-agent-toolkit 1.2.367 → 1.2.369

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 (48) hide show
  1. package/dist/chat-agent-toolkit/src/tools/qwksearch-api-tools.d.ts +1 -1
  2. package/package.json +2 -2
  3. package/src/config/config-manager.d.ts +29 -0
  4. package/src/config/config-types.d.ts +58 -0
  5. package/src/config/environment-variables.d.ts +6 -0
  6. package/src/config/index.d.ts +18 -0
  7. package/src/config/language-models-database.d.ts +95 -0
  8. package/src/config/model-registry.d.ts +70 -0
  9. package/src/config/model-tester.d.ts +51 -0
  10. package/src/config/model-utils.d.ts +44 -0
  11. package/src/config/provider-ui-config.d.ts +13 -0
  12. package/src/connectors/index.d.ts +84 -0
  13. package/src/index.d.ts +27 -0
  14. package/src/mastra/agents.d.ts +78 -0
  15. package/src/mastra/evals.d.ts +63 -0
  16. package/src/mastra/index.d.ts +15 -0
  17. package/src/mastra/model-routing.d.ts +71 -0
  18. package/src/mastra/rag.d.ts +83 -0
  19. package/src/mastra/telemetry.d.ts +41 -0
  20. package/src/mastra/workflows.d.ts +85 -0
  21. package/src/memory/agent-memory-manager.d.ts +135 -0
  22. package/src/memory/index.d.ts +18 -0
  23. package/src/memory/mastra-integration.d.ts +161 -0
  24. package/src/memory/storage/drizzle-storage.d.ts +87 -0
  25. package/src/memory/storage/in-memory-storage.d.ts +86 -0
  26. package/src/memory/storage/storage-interface.d.ts +43 -0
  27. package/src/memory/types.d.ts +122 -0
  28. package/src/models/registry.d.ts +4 -0
  29. package/src/models/types.d.ts +4 -0
  30. package/src/prompts/index.d.ts +5 -0
  31. package/src/prompts/meta-search-types.d.ts +6 -0
  32. package/src/prompts/search-prompts.d.ts +25 -0
  33. package/src/tools/index.d.ts +13 -0
  34. package/src/tools/qwksearch-api-tools.d.ts +106 -0
  35. package/src/tools/qwksearch-mcp-tools.d.ts +26 -0
  36. package/src/tools/search/doc-utils.d.ts +49 -0
  37. package/src/tools/search/document.d.ts +14 -0
  38. package/src/tools/search/index.d.ts +13 -0
  39. package/src/tools/search/link-summarizer.d.ts +11 -0
  40. package/src/tools/search/meta-search-types.d.ts +56 -0
  41. package/src/tools/search/metaSearchAgent.d.ts +26 -0
  42. package/src/tools/search/search-handlers.d.ts +34 -0
  43. package/src/tools/search/suggestionGeneratorAgent.d.ts +19 -0
  44. package/src/tools/search/titleGeneratorAgent.d.ts +13 -0
  45. package/src/utils/chat-helpers.d.ts +10 -0
  46. package/src/utils/index.d.ts +5 -0
  47. package/src/utils/outputParser.d.ts +22 -0
  48. package/src/utils/provider-image-cropper.d.ts +127 -0
@@ -81,8 +81,8 @@ export declare const AGENT_TOOLS: ({
81
81
  bypassCaptcha: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
82
82
  sessionId: z.ZodDefault<z.ZodOptional<z.ZodString>>;
83
83
  format: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
84
- html: "html";
85
84
  json: "json";
85
+ html: "html";
86
86
  }>>>;
87
87
  scraperUrl: z.ZodOptional<z.ZodString>;
88
88
  scraperApiKey: z.ZodOptional<z.ZodString>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chat-agent-toolkit",
3
- "version": "1.2.367",
3
+ "version": "1.2.369",
4
4
  "description": "Multi-provider AI agent toolkit: generate language responses, search the web, extract content, and manage memory across 10+ LLM providers.",
5
5
  "author": "vtempest <grokthiscontact@gmail.com>",
6
6
  "license": "rights.institute/PROSPER",
@@ -98,7 +98,7 @@
98
98
  "html-entities": "^2.6.0",
99
99
  "manage-storage": "^0.0.47",
100
100
  "marked": "^18.0.12",
101
- "qwksearch-api-client": "^1.0.39",
101
+ "qwksearch-api-client": "^1.0.41",
102
102
  "write-language": "^0.1.153",
103
103
  "zod": "^4.5.4"
104
104
  },
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @fileoverview Configuration Manager
3
+ *
4
+ * Manages model providers, MCP servers, and search configuration in memory.
5
+ * Handles environment variable loading, provider hashing, and config updates.
6
+ */
7
+ import type { ConfigModelProvider, Config, UIConfigSections } from "./config-types";
8
+ declare class ConfigManager {
9
+ configVersion: number;
10
+ currentConfig: Config;
11
+ uiConfigSections: UIConfigSections;
12
+ private initialized;
13
+ constructor();
14
+ private ensureInitialized;
15
+ private initialize;
16
+ getConfig(key: string, defaultValue?: any): any;
17
+ updateConfig(key: string, val: any): void;
18
+ addModelProvider(type: string, name: string, config: any): ConfigModelProvider;
19
+ removeModelProvider(id: string): void;
20
+ updateModelProvider(id: string, name: string, config: any): Promise<ConfigModelProvider>;
21
+ addProviderModel(providerId: string, type: "chat", model: any): any;
22
+ removeProviderModel(providerId: string, type: "chat", modelKey: string): void;
23
+ isSetupComplete(): boolean;
24
+ markSetupComplete(): void;
25
+ getUIConfigSections(): UIConfigSections;
26
+ getCurrentConfig(): Config;
27
+ }
28
+ declare const configManager: ConfigManager;
29
+ export default configManager;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @module research/models/types
3
+ * @description Shared types for the config system and model registry.
4
+ */
5
+ /** A chat model entry as shown in provider model lists. */
6
+ export type Model = {
7
+ name: string;
8
+ key: string;
9
+ };
10
+ /** Provider shape consumed by model-selector UI components. */
11
+ export type MinimalProvider = {
12
+ id: string;
13
+ name: string;
14
+ chatModels: Model[];
15
+ };
16
+ /** Client-side model selection: which provider and model key to use. */
17
+ export type ModelWithProvider = {
18
+ key?: string;
19
+ providerId?: string;
20
+ };
21
+ /** A configured model provider (env-based or user-added). */
22
+ export type ConfigModelProvider = {
23
+ id: string;
24
+ name: string;
25
+ /** Provider type key, e.g. "openai", "anthropic", "gemini". */
26
+ type: string;
27
+ /** User-added chat models (defaults come from LANGUAGE_MODELS). */
28
+ chatModels: Model[];
29
+ /** Provider connection config, e.g. { apiKey, baseURL }. */
30
+ config: Record<string, any>;
31
+ /** Hash of the config, used as the provider id. */
32
+ hash: string;
33
+ /** True when the provider was configured from environment variables. */
34
+ isEnvBased?: boolean;
35
+ };
36
+ export type MCPServerConfig = {
37
+ command?: string;
38
+ args?: string[];
39
+ env?: Record<string, string>;
40
+ [key: string]: any;
41
+ };
42
+ export type Config = {
43
+ version: number;
44
+ setupComplete: boolean;
45
+ preferences: Record<string, any>;
46
+ personalization: Record<string, any>;
47
+ modelProviders: ConfigModelProvider[];
48
+ mcpServers: MCPServerConfig[];
49
+ search: Record<string, any>;
50
+ };
51
+ /** UI field/section definitions consumed by the settings screens. */
52
+ export type UIConfigSections = {
53
+ preferences: any[];
54
+ personalization: any[];
55
+ modelProviders: any[];
56
+ mcpServers: any[];
57
+ search: any[];
58
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Runtime env-var accessor.
3
+ * Supports both local development (process.env) and Cloudflare Workers
4
+ * (cloudflare:workers virtual module) via dynamic import.
5
+ */
6
+ export declare function getEnv(key: string): string | undefined;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @fileoverview Configuration Management Module
3
+ *
4
+ * Manages model providers, environment variables, and UI configuration
5
+ * for the AI agent toolkit. Provides in-memory config storage with
6
+ * support for multiple LLM providers and MCP servers.
7
+ *
8
+ * @module config
9
+ * @author ai-research-agent contributors
10
+ */
11
+ export { default as configManager } from "./config-manager";
12
+ export { default as ModelRegistry } from "./model-registry";
13
+ export { getEnv } from "./environment-variables";
14
+ export { LANGUAGE_MODELS } from "./language-models-database";
15
+ export { getModelProvidersUIConfigSection } from "./provider-ui-config";
16
+ export * from "./model-tester";
17
+ export * from "./model-utils";
18
+ export type { Config, ConfigModelProvider, MCPServerConfig, UIConfigSections, Model, ModelWithProvider, } from "./config-types";
@@ -0,0 +1,95 @@
1
+ /**
2
+ * List of default models for the chat providers and a list of models
3
+ * @property {string} provider - The provider name
4
+ * @property {string} docs - The documentation URL for the model
5
+ * @property {string} api_key - The API key url for the model
6
+ * @property {string} default - The default model for the chat provider
7
+ * @property {Object[]} models - The list of models available for the chat provider
8
+ * @category Generate
9
+ */
10
+ export declare const LANGUAGE_MODELS: ({
11
+ provider: string;
12
+ docs: string;
13
+ api_key: string;
14
+ default: string;
15
+ models: {
16
+ name: string;
17
+ id: string;
18
+ contextLength: number;
19
+ free: boolean;
20
+ type: string;
21
+ }[];
22
+ } | {
23
+ provider: string;
24
+ docs: string;
25
+ api_key: string;
26
+ default: string;
27
+ models: {
28
+ name: string;
29
+ id: string;
30
+ contextLength: number;
31
+ }[];
32
+ } | {
33
+ provider: string;
34
+ docs: string;
35
+ api_key: string;
36
+ default: string;
37
+ models: {
38
+ name: string;
39
+ id: string;
40
+ contextLength: number;
41
+ free: boolean;
42
+ type: string;
43
+ rateLimit: string;
44
+ }[];
45
+ } | {
46
+ default?: undefined;
47
+ provider: string;
48
+ docs: string;
49
+ api_key: string;
50
+ models: {
51
+ name: string;
52
+ id: string;
53
+ contextLength: number;
54
+ }[];
55
+ } | {
56
+ provider: string;
57
+ docs: string;
58
+ api_key: string;
59
+ default: string;
60
+ models: ({
61
+ type?: undefined;
62
+ name: string;
63
+ id: string;
64
+ contextLength: number;
65
+ provider: string;
66
+ } | {
67
+ name: string;
68
+ id: string;
69
+ contextLength: number;
70
+ provider: string;
71
+ type: string;
72
+ })[];
73
+ })[];
74
+ /** List of available LLM provider services */
75
+ export declare const LANGUAGE_PROVIDERS: string[];
76
+ /**
77
+ * Guest-safe models that are known to work reliably.
78
+ * Based on test results: only models with HTTP 200 status.
79
+ * Last tested: 2026-07-22
80
+ */
81
+ export declare const GUEST_SAFE_MODELS: {
82
+ nvidia: string[];
83
+ anyapi: string[];
84
+ openrouter: string[];
85
+ };
86
+ /**
87
+ * Filter models to only those in the guest-safe list.
88
+ * Returns models with `free: true` property.
89
+ */
90
+ export declare function filterModelsForGuests(models: any[]): any[];
91
+ /**
92
+ * Get guest-safe provider list (only tested working models).
93
+ * Uses GUEST_SAFE_MODELS whitelist to ensure reliability.
94
+ */
95
+ export declare function getGuestSafeProviders(): typeof LANGUAGE_MODELS;
@@ -0,0 +1,70 @@
1
+ import type { ConfigModelProvider, Model } from "./config-types";
2
+ export default class ModelRegistry {
3
+ /**
4
+ * Currently configured providers (env-based + user-added).
5
+ * Sync getter used by the chat handler for logging and lookups.
6
+ */
7
+ get activeProviders(): ConfigModelProvider[];
8
+ /**
9
+ * Providers with their full chat model lists (defaults merged with
10
+ * user-added models), shaped for the settings/providers UI.
11
+ */
12
+ getActiveProviders(guestMode?: boolean): Promise<{
13
+ id: string;
14
+ name: string;
15
+ type: string;
16
+ chatModels: Model[];
17
+ }[]>;
18
+ /**
19
+ * Get guest-safe chat models for a provider (only tested working models).
20
+ */
21
+ private getGuestChatModels;
22
+ /**
23
+ * Finds a provider by id, falling back to free providers in order:
24
+ * OpenRouter (no daily limits, best for guests), Groq (fastest, daily limits),
25
+ * AnyAPI (100,000 anyTokens/day free), then NVIDIA, then the first
26
+ * configured provider.
27
+ * Client-side provider ids are config hashes that go stale whenever
28
+ * server env config changes, so a graceful fallback keeps existing
29
+ * chat sessions working after a redeploy.
30
+ */
31
+ private findProvider;
32
+ /** Whether the resolved provider was configured from environment variables. */
33
+ isProviderEnvBased(providerId?: string): boolean;
34
+ /**
35
+ * Instantiates a Vercel AI SDK language model for the given provider and
36
+ * model key. Falls back to the provider's first/default model when no key
37
+ * is given. Temperature is a per-call setting in the AI SDK, so callers
38
+ * pass it to generateText/streamText rather than the model instance.
39
+ */
40
+ loadChatModel(providerId?: string, modelKey?: string): Promise<any>;
41
+ /**
42
+ * Registers a new provider. Accepts both `(type, config)` — used by the
43
+ * providers API route — and `(type, name, config)`.
44
+ */
45
+ addProvider(type: string, nameOrConfig: any, config?: Record<string, any>): Promise<{
46
+ id: string;
47
+ name: string;
48
+ type: string;
49
+ config: Record<string, any>;
50
+ hash: string;
51
+ isEnvBased?: boolean;
52
+ chatModels: Model[];
53
+ }>;
54
+ removeProvider(providerId: string): Promise<void>;
55
+ /**
56
+ * Updates a provider's config. Accepts both `(id, config)` — used by the
57
+ * providers API route — and `(id, name, config)`.
58
+ */
59
+ updateProvider(providerId: string, nameOrConfig: any, config?: Record<string, any>): Promise<{
60
+ id: string;
61
+ name: string;
62
+ type: string;
63
+ config: Record<string, any>;
64
+ hash: string;
65
+ isEnvBased?: boolean;
66
+ chatModels: Model[];
67
+ }>;
68
+ addProviderModel(providerId: string, type: "chat", model: any): Promise<any>;
69
+ removeProviderModel(providerId: string, type: "chat", modelKey: string): Promise<void>;
70
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @fileoverview Model availability testing and validation
3
+ * Tests which models are actually working for a given provider
4
+ */
5
+ export interface ModelTestResult {
6
+ modelId: string;
7
+ modelName: string;
8
+ available: boolean;
9
+ error?: string;
10
+ latency?: number;
11
+ type?: string;
12
+ }
13
+ export interface ProviderTestResult {
14
+ provider: string;
15
+ totalModels: number;
16
+ availableModels: ModelTestResult[];
17
+ unavailableModels: ModelTestResult[];
18
+ testDuration: number;
19
+ }
20
+ /**
21
+ * Test a single model to see if it's working
22
+ */
23
+ export declare function testModel(provider: string, apiKey: string, modelId: string, modelName: string, modelType?: string, timeout?: number): Promise<ModelTestResult>;
24
+ /**
25
+ * Test all models for a provider
26
+ */
27
+ export declare function testProviderModels(provider: string, apiKey: string, models: Array<{
28
+ id: string;
29
+ name: string;
30
+ type?: string;
31
+ free?: boolean;
32
+ }>, options?: {
33
+ onlyFree?: boolean;
34
+ concurrency?: number;
35
+ timeout?: number;
36
+ onProgress?: (current: number, total: number, modelName: string) => void;
37
+ }): Promise<ProviderTestResult>;
38
+ /**
39
+ * Get only free models from a model list
40
+ */
41
+ export declare function getOnlyFreeModels<T extends {
42
+ free?: boolean;
43
+ }>(models: T[]): T[];
44
+ /**
45
+ * Categorize models by type
46
+ */
47
+ export declare function categorizeModelsByType<T extends {
48
+ type?: string;
49
+ id: string;
50
+ name: string;
51
+ }>(models: T[]): Record<string, T[]>;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Utility functions for working with AI models
3
+ */
4
+ /**
5
+ * List of model IDs that are free to use (no per-token cost)
6
+ * Updated regularly as providers change their pricing
7
+ */
8
+ export declare const FREE_MODELS: Set<string>;
9
+ /**
10
+ * Providers that offer free tiers with generous limits
11
+ */
12
+ export declare const FREE_TIER_PROVIDERS: Set<string>;
13
+ /**
14
+ * Check if a model is free to use (no per-token cost)
15
+ * Note: Free models may have rate limits
16
+ */
17
+ export declare function isModelFree(modelId: string): boolean;
18
+ /**
19
+ * Check if a provider offers a free tier
20
+ */
21
+ export declare function hasFreeTier(providerType: string): boolean;
22
+ /**
23
+ * Get a display name for a model with cost indicator
24
+ * Example: "Llama 3.3 70B (Free)" or "GPT-4o"
25
+ */
26
+ export declare function getModelDisplayName(modelName: string, modelId: string): string;
27
+ /**
28
+ * Get provider-specific information
29
+ */
30
+ export declare function getProviderInfo(providerType: string): {
31
+ name: string;
32
+ hasFreeTier: boolean;
33
+ signupUrl: string;
34
+ docsUrl: string;
35
+ };
36
+ /**
37
+ * Get recommended free providers for getting started
38
+ */
39
+ export declare function getRecommendedFreeProviders(): Array<{
40
+ type: string;
41
+ name: string;
42
+ reason: string;
43
+ signupUrl: string;
44
+ }>;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @module research/models/providers/index
3
+ * @description Research library module.
4
+ *
5
+ * This file provides metadata about providers without importing them directly,
6
+ * to avoid circular dependency issues with the config system.
7
+ */
8
+ import { ModelProviderUISection } from "../types";
9
+ /**
10
+ * Gets provider UI configuration without triggering circular dependencies.
11
+ * This function uses static metadata instead of importing provider classes.
12
+ */
13
+ export declare const getModelProvidersUIConfigSection: () => ModelProviderUISection[];
@@ -0,0 +1,84 @@
1
+ /**
2
+ * OpenConnector Integration for OOMOL SaaS
3
+ *
4
+ * Multi-tenant connector platform for OAuth & credential management.
5
+ * Allows users to link external accounts (Gmail, Slack, GitHub, Airtable, etc.)
6
+ * securely managed by OOMOL Cloud.
7
+ *
8
+ * @module connectors
9
+ * @see {@link https://connector.oomol.com}
10
+ * @example
11
+ * ```ts
12
+ * import { ProjectConnector } from "chat-agent-toolkit/connectors";
13
+ *
14
+ * const project = new ProjectConnector({
15
+ * apiKey: process.env.OOMOL_PROJECT_API_KEY,
16
+ * });
17
+ *
18
+ * const user = project.forUser(userId);
19
+ * const oauth = await user.connect.oauth({
20
+ * service: "gmail",
21
+ * returnUri: "https://myapp.com/oauth-callback",
22
+ * });
23
+ * ```
24
+ */
25
+ export type { ConnectorError as OOMOLConnectorError, ProjectConnector as OOMOLProjectConnector, } from "@oomol-lab/connector";
26
+ export { ConnectorError, ProjectConnector } from "@oomol-lab/connector";
27
+ export type CatalogProvider = {
28
+ service: string;
29
+ displayName: string;
30
+ categories: string[];
31
+ authTypes: ("oauth2" | "api_key" | "custom_credential" | "no_auth")[];
32
+ actionCount: number;
33
+ };
34
+ export type ProviderIndexEntry = CatalogProvider & {
35
+ homepageUrl?: string;
36
+ actions?: string[];
37
+ };
38
+ /**
39
+ * Lightweight provider catalog (basic info: service, display name, auth types).
40
+ * ~900 providers, fast catalog search and picker UI.
41
+ */
42
+ export declare const catalog: CatalogProvider[];
43
+ /**
44
+ * Detailed provider index with action lists and metadata.
45
+ * Use for deep integration: listing available actions, mapping capabilities.
46
+ */
47
+ export declare const providerIndex: ProviderIndexEntry[];
48
+ /**
49
+ * Search the catalog by service name or display name.
50
+ * @param query Search term (case-insensitive)
51
+ * @param limit Max results
52
+ * @returns Matching providers
53
+ */
54
+ export declare function searchCatalog(query: string, limit?: number): CatalogProvider[];
55
+ /**
56
+ * Get a provider by service ID.
57
+ * @param serviceId The provider's service identifier (e.g., "gmail", "slack")
58
+ * @returns Provider info or undefined
59
+ */
60
+ export declare function getCatalogProvider(serviceId: string): CatalogProvider | undefined;
61
+ /**
62
+ * Get detailed provider info including actions.
63
+ * @param serviceId The provider's service identifier
64
+ * @returns Detailed provider entry or undefined
65
+ */
66
+ export declare function getProviderDetails(serviceId: string): ProviderIndexEntry | undefined;
67
+ /**
68
+ * Filter catalog by authentication type.
69
+ * @param authType The auth type to filter by
70
+ * @returns Providers supporting this auth type
71
+ */
72
+ export declare function getCatalogByAuthType(authType: "oauth2" | "api_key" | "custom_credential" | "no_auth"): CatalogProvider[];
73
+ /**
74
+ * Filter catalog by category.
75
+ * @param category The category to filter by (e.g., "Communication", "Productivity")
76
+ * @returns Providers in this category
77
+ */
78
+ export declare function getCatalogByCategory(category: string): CatalogProvider[];
79
+ /**
80
+ * Get all unique categories in the catalog.
81
+ * @returns Sorted list of category names
82
+ */
83
+ export declare function getCatalogCategories(): string[];
84
+ export type { Express } from "express";
package/src/index.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @fileoverview AI Agent Toolkit
3
+ *
4
+ * Multi-provider AI agent toolkit for generating language responses, searching the web,
5
+ * extracting page content, and managing long-term memory across 10+ LLM providers.
6
+ *
7
+ * Built on Vercel AI SDK with prompt templates for research, summarization, citation
8
+ * answering, query resolution, and knowledge-graph extraction.
9
+ *
10
+ * @module ai-research-agent
11
+ * @author vtempest <grokthiscontact@gmail.com>
12
+ * @license AGPL-3.0
13
+ * @see {@link https://github.com/vtempest/ai-research-agent}
14
+ */
15
+ export * from "write-language";
16
+ export * from "./prompts";
17
+ export * from "./memory";
18
+ export * from "./tools";
19
+ export { AGENT_TOOLS } from "./tools";
20
+ export * from "./utils";
21
+ export * from "./mastra";
22
+ export { configManager, ModelRegistry, getEnv, getModelProvidersUIConfigSection } from "./config";
23
+ export type { Config, ConfigModelProvider, MCPServerConfig, UIConfigSections, Model, ModelWithProvider } from "./config";
24
+ export { cropProvider, cropProviderAsBlob, cropProviderAsDataURL, getProviderImage, getProviderNames } from "./utils/provider-image-cropper";
25
+ export type { Provider } from "./utils/provider-image-cropper";
26
+ export * from "./connectors";
27
+ export * as connectors from "./connectors";
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @fileoverview Mastra Agent Factory
3
+ *
4
+ * Creates typed Mastra agents with tool-calling, model selection,
5
+ * and optional memory integration.
6
+ */
7
+ import { Agent } from "@mastra/core/agent";
8
+ import { z } from "zod";
9
+ export interface MastraAgentConfig {
10
+ id: string;
11
+ name: string;
12
+ instructions: string;
13
+ model: any;
14
+ tools?: Record<string, any>;
15
+ maxSteps?: number;
16
+ memory?: {
17
+ enabled: boolean;
18
+ threadId?: string;
19
+ userId?: string;
20
+ };
21
+ }
22
+ /**
23
+ * Create a Mastra agent with full configuration.
24
+ * Supports tool-calling, multi-step reasoning, and memory.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import { createMastraAgent } from "chat-agent-toolkit/mastra";
29
+ * import { openai } from "@ai-sdk/openai";
30
+ *
31
+ * const agent = createMastraAgent({
32
+ * id: "research-assistant",
33
+ * name: "Research Assistant",
34
+ * instructions: "Help users research topics thoroughly.",
35
+ * model: openai("gpt-4o"),
36
+ * tools: { webSearch, extractPage },
37
+ * });
38
+ *
39
+ * const result = await agent.generate("What is RAG?");
40
+ * ```
41
+ */
42
+ export declare function createMastraAgent(config: MastraAgentConfig): Agent;
43
+ /**
44
+ * Create a Mastra agent with inline tool definitions using Zod schemas.
45
+ * Convenience wrapper for quick prototyping.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * const agent = createToolAgent({
50
+ * id: "calculator",
51
+ * name: "Calculator",
52
+ * instructions: "Perform math operations.",
53
+ * model: openai("gpt-4o"),
54
+ * toolDefs: [{
55
+ * id: "add",
56
+ * description: "Add two numbers",
57
+ * inputSchema: z.object({ a: z.number(), b: z.number() }),
58
+ * outputSchema: z.object({ result: z.number() }),
59
+ * execute: async ({ context }) => ({ result: context.a + context.b }),
60
+ * }],
61
+ * });
62
+ * ```
63
+ */
64
+ export declare function createToolAgent(config: {
65
+ id: string;
66
+ name: string;
67
+ instructions: string;
68
+ model: any;
69
+ toolDefs: Array<{
70
+ id: string;
71
+ description: string;
72
+ inputSchema: z.ZodType;
73
+ outputSchema: z.ZodType;
74
+ execute: (params: {
75
+ context: any;
76
+ }) => Promise<any>;
77
+ }>;
78
+ }): Agent;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @fileoverview Mastra Evals
3
+ *
4
+ * Scorer-based evaluation functions for LLM outputs.
5
+ * Assess factuality, relevance, coherence, and safety.
6
+ */
7
+ export interface EvalResult {
8
+ score: number;
9
+ reason: string;
10
+ }
11
+ export interface EvalSuiteResult {
12
+ overall: number;
13
+ results: Record<string, EvalResult>;
14
+ }
15
+ /**
16
+ * Evaluate factuality/groundedness of a response.
17
+ * Checks whether the output references sources or evidence.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * const result = await factualityEval(
22
+ * "The earth orbits the sun (source: NASA).",
23
+ * "What does the earth orbit?"
24
+ * );
25
+ * // { score: 0.9, reason: "Response includes source attribution." }
26
+ * ```
27
+ */
28
+ export declare function factualityEval(output: string, _query?: string, sources?: string[]): Promise<EvalResult>;
29
+ /**
30
+ * Evaluate relevance of a response to the query.
31
+ * Uses keyword overlap and length heuristics.
32
+ */
33
+ export declare function relevanceEval(output: string, query: string): Promise<EvalResult>;
34
+ /**
35
+ * Evaluate coherence and structure of a response.
36
+ * Checks sentence structure, paragraph flow, and logical markers.
37
+ */
38
+ export declare function coherenceEval(output: string): Promise<EvalResult>;
39
+ /**
40
+ * Evaluate output for toxic or harmful content.
41
+ * Basic keyword/pattern-based detection.
42
+ */
43
+ export declare function toxicityEval(output: string): Promise<EvalResult>;
44
+ /**
45
+ * Run a full evaluation suite against a response.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * const results = await runEvalSuite({
50
+ * output: agentResponse,
51
+ * query: "What is photosynthesis?",
52
+ * sources: ["Biology textbook chapter 3"],
53
+ * });
54
+ *
55
+ * console.log(results.overall); // 0.78
56
+ * console.log(results.results.factuality.score); // 0.85
57
+ * ```
58
+ */
59
+ export declare function runEvalSuite(params: {
60
+ output: string;
61
+ query?: string;
62
+ sources?: string[];
63
+ }): Promise<EvalSuiteResult>;