npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@salesforce/sfdx-agent-chat-generations

v0.25.0

Published

Temporary GovCloud chat/generations fallback for @salesforce/sfdx-agent-harness-mastra

Downloads

6,455

Readme

@salesforce/sfdx-agent-chat-generations

Temporary GovCloud chat/generations fallback for @salesforce/sfdx-agent-harness-mastra. This package is slated for removal once the Responses API is onboarded in GovCloud.

Closed source. This package is published to npm under the Salesforce Public Code License and is for use by Salesforce only.

Overview

This package provides a temporary fallback for GovCloud deployments where the Responses API is not yet available. It implements the legacy Salesforce LLM Gateway chat/generations wire shape — the only LLM path onboarded in GovCloud (GIA2H) — and is injected into the Mastra harness via the generic languageModelBuilders seam and a connectivity-resolver decorator. GPT-5 is the only supported model family. The fallback is expected to be deleted within a few weeks once the Responses API is SFAP-onboarded in GovCloud (W-23560954).

Install

npm install @salesforce/sfdx-agent-sdk @salesforce/sfdx-agent-harness-mastra @salesforce/sfdx-agent-chat-generations

Usage

Bootstrap

Wire the GovCloud chat/generations fallback by injecting the resolver and language-model builder at construction time. Two forms are supported:

Explicit construction

import { MastraHarnessFactory } from '@salesforce/sfdx-agent-harness-mastra';
import { createAgentManager } from '@salesforce/sfdx-agent-sdk';
import {
  buildChatGenerationsLanguageModel,
  ChatGenerationsResolver,
  CHAT_GENERATIONS_PROVIDER_HINT,
} from '@salesforce/sfdx-agent-chat-generations';

const factory = new MastraHarnessFactory({
  languageModelBuilders: {
    [CHAT_GENERATIONS_PROVIDER_HINT]: buildChatGenerationsLanguageModel,
  },
});

const connectivityResolver = new ChatGenerationsResolver({
  delegate: myExistingResolver, // e.g., VibesAgentConnectivityResolver
  baseUrl: 'https://dev.api.gov.salesforce.com/ai/gpt/v1',
  extraHeaders: { 'x-salesforce-region': 'us-gov-east-1' }, // VERIFY: region header requirement TBD
});

const manager = await createAgentManager(storageRoot, factory, { connectivityResolver });

Convenience factory (preferred)

import { MastraHarnessFactory } from '@salesforce/sfdx-agent-harness-mastra';
import { createAgentManager } from '@salesforce/sfdx-agent-sdk';
import { createChatGenerationsFallback } from '@salesforce/sfdx-agent-chat-generations';

const { connectivityResolver, languageModelBuilders } = createChatGenerationsFallback({
  delegate: myExistingResolver,
  baseUrl: 'https://dev.api.gov.salesforce.com/ai/gpt/v1',
  extraHeaders: { 'x-salesforce-region': 'us-gov-east-1' }, // VERIFY: region header requirement TBD
});

const factory = new MastraHarnessFactory({ languageModelBuilders });
const manager = await createAgentManager(storageRoot, factory, { connectivityResolver });

Important: The consumer MUST set AgentConfig.modelId to a GovCloud-provisioned GPT model (e.g., sfdc_ai__DefaultGPT4_8). The SDK default (Claude Sonnet 4.6) will not resolve in GovCloud.

const agent = await manager.createAgent(projectRoot, {
  modelId: 'sfdc_ai__DefaultGPT4_8', // Required: must be a GPT model provisioned in GovCloud
  instructions: '...',
});

The x-salesforce-region header requirement and value (us-gov-east-1) are unconfirmed pending live endpoint validation. Consumers should verify these against the live GovCloud gateway.

Public API

  • buildChatGenerationsLanguageModelMastraLanguageModelBuilder that produces a LanguageModelV3 speaking the chat/generations wire shape. Injects into MastraHarnessFactory.languageModelBuilders[CHAT_GENERATIONS_PROVIDER_HINT].
  • ChatGenerationsResolver — Connectivity resolver decorator that wraps the consumer's real resolver and rewrites its ModelConnectivityInfo bag onto the GovCloud chat/generations path (flips baseUrl + providerHint, merges extraHeaders, reuses the delegate's getHeaders() verbatim).
  • ChatGenerationsResolverOptions — Configuration type for ChatGenerationsResolver:
    • delegate: AgentConnectivityResolver — the consumer's real resolver (e.g., VibesAgentConnectivityResolver).
    • baseUrl: string — GovCloud gateway base URL (e.g., 'https://dev.api.gov.salesforce.com/ai/gpt/v1').
    • extraHeaders?: Record<string, string> — optional extra headers required by GovCloud chat/generations (e.g., { 'x-salesforce-region': 'us-gov-east-1' }). Unconfirmed.
    • enabled?: boolean — kill-switch; when false, the resolver passes the delegate's result through unchanged. Defaults to reading process.env.SF_GOVCLOUD_LEGACY_FALLBACK === '1'.
  • CHAT_GENERATIONS_PROVIDER_HINT — Provider hint constant ('salesforce-chat-generations') keying the injected builder.
  • createChatGenerationsFallback — Convenience factory returning { connectivityResolver, languageModelBuilders } ready to spread into createAgentManager and MastraHarnessFactory constructors.
  • ChatGenerationsFallback — Return type of createChatGenerationsFallback ({ connectivityResolver: ChatGenerationsResolver, languageModelBuilders: Record<...> }).

Deletion

This package is temporary. When the Responses API is onboarded in GovCloud (expected within a few weeks):

  1. Remove the consumer bootstrap wiring (stop passing languageModelBuilders to MastraHarnessFactory and stop wrapping the resolver in ChatGenerationsResolver), or set SF_GOVCLOUD_LEGACY_FALLBACK unset / enabled: false to disable at runtime.
  2. Delete this package directory entirely.
  3. Remove sfdx-agent-chat-generations from .github/workflows/version-bump.yml and the root README.md monorepo index, then run npm install to drop it from the lockfile.

See DELETION.md for the full deletion runbook.

Development

# Build
npm run build -w @salesforce/sfdx-agent-chat-generations

# Test
npm run test -w @salesforce/sfdx-agent-chat-generations

# Lint
npm run lint -w @salesforce/sfdx-agent-chat-generations