🚨 Latest Research:Tanstack npm Packages Compromised in Ongoing Mini Shai-Hulud Supply-Chain Attack.Learn More
Socket
Book a DemoSign in
Socket

@equinor/fusion-framework-cli-plugin-ai-base

Package Overview
Dependencies
Maintainers
4
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@equinor/fusion-framework-cli-plugin-ai-base

Base AI plugin package for Fusion Framework CLI

latest
Source
npmnpm
Version
4.0.1
Version published
Weekly downloads
43
-88.8%
Maintainers
4
Weekly downloads
 
Created
Source

@equinor/fusion-framework-cli-plugin-ai-base

[!CAUTION] Internal base package — not intended for direct consumption. Use the higher-level AI CLI plugins (ai-chat, ai-index) instead.

Shared utilities, option definitions, and framework bootstrapping for the Fusion Framework AI CLI plugins. Every AI sub-command in the Fusion CLI inherits its Commander options, Zod validation, and framework initialisation logic from this package.

Who should use this

Authors of new Fusion CLI AI plugins that need the same Fusion service discovery options and framework setup that the existing plugins share. If you are building a Fusion application, use the published CLI plugins directly.

Quick start

1. Add the dependency

// package.json (monorepo)
{
  "dependencies": {
    "@equinor/fusion-framework-cli-plugin-ai-base": "workspace:*"
  }
}

2. Create a sub-command with AI options

import { createCommand } from 'commander';
import {
  withOptions,
  type AiOptions,
} from '@equinor/fusion-framework-cli-plugin-ai-base/command-options';
import {
  registerAiPlugin,
  setupFramework,
} from '@equinor/fusion-framework-cli-plugin-ai-base';

const myCommand = createCommand('my-task')
  .description('Run my custom AI task');

// Attach core auth + chat + embedding options and pre-action validation
withOptions(myCommand, { includeChat: true, includeEmbedding: true });

myCommand.action(async (options: AiOptions) => {
  const framework = await setupFramework(options);
  // use framework.ai …
});

// Register under `fusion-cli ai my-task`
export const register = (program: Command) =>
  registerAiPlugin(program, myCommand);

3. Load a configuration file (optional)

import { loadFusionAIConfig } from '@equinor/fusion-framework-cli-plugin-ai-base';

// fusion-ai.config.ts — export a default configuration object
export default { includes: ['./src/**/*.ts'] };

// at runtime
const config = await loadFusionAIConfig('fusion-ai.config', {
  baseDir: process.cwd(),
});

Export map

The package exposes two entry points:

Entry pointImport pathPurpose
Main@equinor/fusion-framework-cli-plugin-ai-baseFramework setup, plugin registration, config loading
Command options@equinor/fusion-framework-cli-plugin-ai-base/command-optionsCommander option definitions, Zod schema, types

Main entry point (.)

ExportKindDescription
setupFrameworkfunctionInitialise the Fusion Framework with AI module, MSAL auth, and service discovery
registerAiPluginfunctionRegister a Commander sub-command under the shared ai command group
loadFusionAIConfigfunctionLocate and import a fusion-ai.config.{ts,mjs,js,json} file
configureFusionAIfunctionType-safe factory for writing configuration files
FrameworkInstancetypeInitialised framework with the AI module
FusionAIConfiginterfaceBase configuration shape (extend for custom fields)
LoadFusionAIConfigOptionsinterfaceOptions for loadFusionAIConfig (base dir, extensions)

Command options entry point (./command-options)

ExportKindDescription
withOptionsfunctionAttach AI options and pre-action validation to a Commander command
optionsobjectAll Commander Option instances as a single record
AiOptionsSchemaZod schemaRuntime validation for the AI options object
AiOptionsTypetypeInferred type from AiOptionsSchema
AiOptionsinterfaceHand-authored TypeScript interface for the options

Environment variables

Every CLI flag has an environment-variable fallback, so plugins work in CI without explicit flags.

FlagEnvironment variableRequiredDefault
--envFUSION_ENVNoci
--tokenFUSION_TOKENNo— (MSAL interactive login)
--tenant-idFUSION_TENANT_IDNoEquinor default
--client-idFUSION_CLIENT_IDNoFusion CLI default
--chat-modelFUSION_AI_CHAT_MODELWhen chat is enabledgpt-5.1-chat
--embed-modelFUSION_AI_EMBED_MODELWhen embedding is enabledtext-embedding-3-large
--index-nameFUSION_AI_INDEX_NAMEWhen search is enabled

Key concepts

Selective option inclusion

withOptions accepts an args object with three boolean flags — includeChat, includeEmbedding, and includeSearch — that control which options (and which pre-action validation rules) are attached. Only include what your command needs.

Pre-action validation

withOptions registers a Commander preAction hook that validates required options before the action handler runs. If a required option is missing or empty the hook throws InvalidOptionArgumentError with a descriptive message that includes the corresponding environment variable name.

Framework bootstrap

setupFramework creates a Fusion Framework instance with MSAL authentication, service discovery, and the AI module. It registers strategy-based model, embed, and index providers resolved through Fusion's AI service. The returned FrameworkInstance is ready for downstream use.

Consuming plugins

Changes to this package affect every AI CLI plugin:

  • @equinor/fusion-framework-cli-plugin-ai-chat
  • @equinor/fusion-framework-cli-plugin-ai-index

Coordinate updates carefully and create changesets for any consumer-visible change.

Development

pnpm build        # type-check (no bundling)
pnpm test         # run Vitest suite

Keywords

fusion-framework

FAQs

Package last updated on 07 May 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts