@salesforce/sfdx-agent-harness-mastra
v0.5.0
Published
Mastra-backed AgentHarness implementation for @salesforce/sfdx-agent-sdk
Maintainers
Keywords
Readme
@salesforce/sfdx-agent-harness-mastra
Mastra-backed AgentHarness implementation for @salesforce/sfdx-agent-sdk. Provides
MastraHarnessFactory, the entry point consumers pass to createAgentManager.
Closed source. This package is published to npm under the Salesforce Public Code License and is for use by Salesforce only.
Install
npm install @salesforce/sfdx-agent-sdk @salesforce/sfdx-agent-harness-mastraQuick start
import { createAgentManager } from '@salesforce/sfdx-agent-sdk';
import { MastraHarnessFactory } from '@salesforce/sfdx-agent-harness-mastra';
const manager = await createAgentManager('/path/to/storage', new MastraHarnessFactory());See the @salesforce/sfdx-agent-sdk README for the full consumer-facing API. For
internal architecture, see ARCHITECTURE.md.
Public API
| Export | Kind | Description |
| ------------------------------------- | --------- | ----------------------------------------------------------------------------------------- |
| MastraHarnessFactory | class | HarnessFactory that produces a Mastra-backed AgentHarness bound to a storage root. |
| MastraModelConfigFactory | interface | Strategy for creating model configurations; injected into MastraHarnessFactory. |
| ResolvedModelConfig | type | Return type of MastraModelConfigFactory.create() — wraps a MastraModelConfig. |
| DefaultMastraModelConfigFactory | class | Default factory using the Salesforce LLM Gateway (SalesforceMastraModelGateway). |
| LLMGExpressMastraModelConfigFactory | class | Factory for LLM Gateway Express (API-key-authenticated, OpenAI-compatible endpoint). |
| LLMGExpressConfig | type | Configuration for LLMGExpressMastraModelConfigFactory (apiKey, baseUrl, modelId). |
Using LLM Gateway Express
import { createAgentManager } from '@salesforce/sfdx-agent-sdk';
import { MastraHarnessFactory, LLMGExpressMastraModelConfigFactory } from '@salesforce/sfdx-agent-harness-mastra';
const harnessFactory = new MastraHarnessFactory(
new LLMGExpressMastraModelConfigFactory({
apiKey: process.env.LLMG_EXPRESS_API_KEY!,
baseUrl: process.env.LLMG_EXPRESS_BASE_URL!,
modelId: 'claude-sonnet-4-20250514',
}),
);
const manager = await createAgentManager('/path/to/storage', harnessFactory);Development
npm run build # TypeScript compilation
npm run test # Unit tests with coverage
npm run lint # ESLint
npm run lint:fix # Auto-fix ESLint issues
npm run format # Prettier
npm run clean # Remove build artifactsFrom the repo root:
npm run build -w @salesforce/sfdx-agent-harness-mastranpm run test -w @salesforce/sfdx-agent-harness-mastra
