@equinor/fusion-framework-cli-plugin-ai-base 2.0.1 → 3.0.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.
- package/CHANGELOG.md +16 -0
- package/README.md +18 -26
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/options/options.js +38 -86
- package/dist/esm/options/options.js.map +1 -1
- package/dist/esm/options/schema.js +13 -55
- package/dist/esm/options/schema.js.map +1 -1
- package/dist/esm/options/types.js +0 -9
- package/dist/esm/options/types.js.map +1 -1
- package/dist/esm/options/with-options.js +30 -89
- package/dist/esm/options/with-options.js.map +1 -1
- package/dist/esm/setup-framework.js +72 -62
- package/dist/esm/setup-framework.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/options/options.d.ts +21 -84
- package/dist/types/options/schema.d.ts +12 -28
- package/dist/types/options/types.d.ts +17 -36
- package/dist/types/options/with-options.d.ts +13 -26
- package/dist/types/setup-framework.d.ts +13 -27
- package/dist/types/version.d.ts +1 -1
- package/package.json +5 -5
- package/src/index.ts +1 -1
- package/src/options/options.ts +54 -114
- package/src/options/schema.ts +13 -63
- package/src/options/types.ts +17 -37
- package/src/options/with-options.ts +36 -130
- package/src/setup-framework.ts +79 -84
- package/src/version.ts +1 -1
- package/tsconfig.json +3 -0
package/dist/types/index.d.ts
CHANGED
|
@@ -9,5 +9,5 @@
|
|
|
9
9
|
* @packageDocumentation
|
|
10
10
|
*/
|
|
11
11
|
export { type FusionAIConfig, type LoadFusionAIConfigOptions, configureFusionAI, loadFusionAIConfig, } from './config.js';
|
|
12
|
-
export { setupFramework, FrameworkInstance } from './setup-framework.js';
|
|
12
|
+
export { setupFramework, type FrameworkInstance } from './setup-framework.js';
|
|
13
13
|
export { registerAiPlugin } from './register.js';
|
|
@@ -1,87 +1,24 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*/
|
|
8
|
-
export declare const
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*/
|
|
16
|
-
export declare const apiVersionOption: import("commander").Option;
|
|
17
|
-
/**
|
|
18
|
-
* Commander option for the Azure OpenAI instance name (`--openai-instance`).
|
|
19
|
-
*
|
|
20
|
-
* @remarks
|
|
21
|
-
* Required for constructing the Azure OpenAI service endpoint. Falls back to
|
|
22
|
-
* the `AZURE_OPENAI_INSTANCE_NAME` environment variable when the flag is omitted.
|
|
23
|
-
*/
|
|
24
|
-
export declare const apiInstanceOption: import("commander").Option;
|
|
25
|
-
/**
|
|
26
|
-
* Commander option for the Azure OpenAI chat deployment (`--openai-chat-deployment`).
|
|
27
|
-
*
|
|
28
|
-
* @remarks
|
|
29
|
-
* Required for chat-completion operations. Falls back to the
|
|
30
|
-
* `AZURE_OPENAI_CHAT_DEPLOYMENT_NAME` environment variable when the flag is omitted.
|
|
31
|
-
* Only added to a command when `withOptions` is called with `includeChat: true`.
|
|
32
|
-
*/
|
|
33
|
-
export declare const chatDeploymentOption: import("commander").Option;
|
|
34
|
-
/**
|
|
35
|
-
* Commander option for the Azure OpenAI embedding deployment (`--openai-embedding-deployment`).
|
|
36
|
-
*
|
|
37
|
-
* @remarks
|
|
38
|
-
* Required for embedding and vector-search operations. Falls back to the
|
|
39
|
-
* `AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME` environment variable when the flag is omitted.
|
|
40
|
-
* Only added to a command when `withOptions` is called with `includeEmbedding: true`.
|
|
41
|
-
*/
|
|
42
|
-
export declare const embeddingDeploymentOption: import("commander").Option;
|
|
43
|
-
/**
|
|
44
|
-
* Commander option for the Azure Cognitive Search endpoint (`--azure-search-endpoint`).
|
|
45
|
-
*
|
|
46
|
-
* @remarks
|
|
47
|
-
* Required for vector-search operations. Falls back to the
|
|
48
|
-
* `AZURE_SEARCH_ENDPOINT` environment variable when the flag is omitted.
|
|
49
|
-
* Only added to a command when `withOptions` is called with `includeSearch: true`.
|
|
50
|
-
*/
|
|
51
|
-
export declare const azureSearchEndpointOption: import("commander").Option;
|
|
52
|
-
/**
|
|
53
|
-
* Commander option for the Azure Cognitive Search API key (`--azure-search-api-key`).
|
|
54
|
-
*
|
|
55
|
-
* @remarks
|
|
56
|
-
* Required for authenticating with Azure Cognitive Search. Falls back to the
|
|
57
|
-
* `AZURE_SEARCH_API_KEY` environment variable when the flag is omitted.
|
|
58
|
-
* Only added to a command when `withOptions` is called with `includeSearch: true`.
|
|
59
|
-
*/
|
|
60
|
-
export declare const azureSearchApiKeyOption: import("commander").Option;
|
|
61
|
-
/**
|
|
62
|
-
* Commander option for the Azure Cognitive Search index name (`--azure-search-index-name`).
|
|
63
|
-
*
|
|
64
|
-
* @remarks
|
|
65
|
-
* Identifies the target search index to query or write to. Falls back to the
|
|
66
|
-
* `AZURE_SEARCH_INDEX_NAME` environment variable when the flag is omitted.
|
|
67
|
-
* Only added to a command when `withOptions` is called with `includeSearch: true`.
|
|
68
|
-
*/
|
|
69
|
-
export declare const azureSearchIndexNameOption: import("commander").Option;
|
|
70
|
-
/**
|
|
71
|
-
* All AI-related Commander option definitions as a single object.
|
|
72
|
-
*
|
|
73
|
-
* @remarks
|
|
74
|
-
* Use this default export for convenient bulk access when you need every option.
|
|
75
|
-
* For selective inclusion prefer importing the named constants directly.
|
|
76
|
-
*/
|
|
1
|
+
/** `--env` | `FUSION_ENV` — Fusion environment for service discovery */
|
|
2
|
+
export declare const envOption: import("commander").Option;
|
|
3
|
+
/** `--token` | `FUSION_TOKEN` — explicit bearer token */
|
|
4
|
+
export declare const tokenOption: import("commander").Option;
|
|
5
|
+
/** `--tenant-id` | `FUSION_TENANT_ID` */
|
|
6
|
+
export declare const tenantIdOption: import("commander").Option;
|
|
7
|
+
/** `--client-id` | `FUSION_CLIENT_ID` */
|
|
8
|
+
export declare const clientIdOption: import("commander").Option;
|
|
9
|
+
/** `--chat-model` | `FUSION_AI_CHAT_MODEL` */
|
|
10
|
+
export declare const chatModelOption: import("commander").Option;
|
|
11
|
+
/** `--embed-model` | `FUSION_AI_EMBED_MODEL` */
|
|
12
|
+
export declare const embedModelOption: import("commander").Option;
|
|
13
|
+
/** `--index-name` | `FUSION_AI_INDEX_NAME` */
|
|
14
|
+
export declare const indexNameOption: import("commander").Option;
|
|
77
15
|
declare const _default: {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
azureSearchIndexNameOption: import("commander").Option;
|
|
16
|
+
envOption: import("commander").Option;
|
|
17
|
+
tokenOption: import("commander").Option;
|
|
18
|
+
tenantIdOption: import("commander").Option;
|
|
19
|
+
clientIdOption: import("commander").Option;
|
|
20
|
+
chatModelOption: import("commander").Option;
|
|
21
|
+
embedModelOption: import("commander").Option;
|
|
22
|
+
indexNameOption: import("commander").Option;
|
|
86
23
|
};
|
|
87
24
|
export default _default;
|
|
@@ -1,39 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zod validation schema and inferred type for AI command options.
|
|
3
|
-
*
|
|
4
|
-
* @packageDocumentation
|
|
5
|
-
*/
|
|
6
1
|
import z from 'zod';
|
|
7
2
|
/**
|
|
8
|
-
* Base Zod schema for AI
|
|
3
|
+
* Base Zod schema for Fusion AI command options.
|
|
9
4
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
5
|
+
* All fields are optional — when omitted the service URL and token are
|
|
6
|
+
* resolved automatically from Fusion service discovery and MSAL auth.
|
|
12
7
|
*
|
|
13
8
|
* @example
|
|
14
9
|
* ```ts
|
|
15
|
-
* import { AiOptionsSchema } from '@equinor/fusion-framework-cli-plugin-ai-base';
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* const MyCommandOptionsSchema = AiOptionsSchema.extend({
|
|
19
|
-
* myOption: z.string(),
|
|
20
|
-
* });
|
|
10
|
+
* import { AiOptionsSchema } from '@equinor/fusion-framework-cli-plugin-ai-base/command-options';
|
|
11
|
+
* const MySchema = AiOptionsSchema.extend({ extra: z.string() });
|
|
21
12
|
* ```
|
|
22
13
|
*/
|
|
23
14
|
export declare const AiOptionsSchema: z.ZodObject<{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
azureSearchIndexName: z.ZodOptional<z.ZodString>;
|
|
15
|
+
env: z.ZodOptional<z.ZodString>;
|
|
16
|
+
token: z.ZodOptional<z.ZodString>;
|
|
17
|
+
tenantId: z.ZodOptional<z.ZodString>;
|
|
18
|
+
clientId: z.ZodOptional<z.ZodString>;
|
|
19
|
+
chatModel: z.ZodOptional<z.ZodString>;
|
|
20
|
+
embedModel: z.ZodOptional<z.ZodString>;
|
|
21
|
+
indexName: z.ZodOptional<z.ZodString>;
|
|
32
22
|
}, z.z.core.$strip>;
|
|
33
|
-
/**
|
|
34
|
-
* Type representing the validated AI options.
|
|
35
|
-
*
|
|
36
|
-
* This type is inferred from the Zod schema and should be used throughout AI plugins
|
|
37
|
-
* to ensure type safety and consistency with the schema.
|
|
38
|
-
*/
|
|
39
23
|
export type AiOptionsType = z.infer<typeof AiOptionsSchema>;
|
|
@@ -1,41 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Base options for all Fusion AI CLI commands.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* For runtime validation prefer {@link AiOptionsSchema} from the schema module.
|
|
7
|
-
*
|
|
8
|
-
* @packageDocumentation
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Configuration options for AI-related CLI commands.
|
|
12
|
-
*
|
|
13
|
-
* This interface defines all available options for configuring Azure OpenAI services
|
|
14
|
-
* and Azure Cognitive Search integration. Required fields must be provided either
|
|
15
|
-
* via command-line arguments or environment variables. Optional fields enable
|
|
16
|
-
* specific features (chat, embeddings, vector search) when provided.
|
|
17
|
-
*
|
|
18
|
-
* @remarks
|
|
19
|
-
* - All required fields (apiKey, apiVersion, instance) must be provided for any AI operation
|
|
20
|
-
* - Chat operations require `openaiChatDeployment`
|
|
21
|
-
* - Embedding operations require `openaiEmbeddingDeployment`
|
|
22
|
-
* - Vector search requires all three Azure Search fields plus `openaiEmbeddingDeployment`
|
|
4
|
+
* The service URL and token are resolved automatically from Fusion
|
|
5
|
+
* service discovery using the provided environment and authentication options.
|
|
23
6
|
*/
|
|
24
7
|
export interface AiOptions {
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
/** Azure
|
|
30
|
-
|
|
31
|
-
/** Azure
|
|
32
|
-
|
|
33
|
-
/** Azure OpenAI
|
|
34
|
-
|
|
35
|
-
/** Azure
|
|
36
|
-
|
|
37
|
-
/** Azure
|
|
38
|
-
|
|
39
|
-
/** Azure Cognitive Search index name. Required for vector search operations */
|
|
40
|
-
azureSearchIndexName?: string;
|
|
8
|
+
/** Fusion environment used for service discovery (e.g. `ci`, `fprd`). */
|
|
9
|
+
env?: string;
|
|
10
|
+
/** Bearer token passed directly to the auth module (overrides clientId/tenantId). */
|
|
11
|
+
token?: string;
|
|
12
|
+
/** Azure AD tenant ID for MSAL silent authentication. */
|
|
13
|
+
tenantId?: string;
|
|
14
|
+
/** Azure AD client ID for MSAL silent authentication. */
|
|
15
|
+
clientId?: string;
|
|
16
|
+
/** Azure OpenAI chat model deployment name. Required for chat operations. */
|
|
17
|
+
chatModel?: string;
|
|
18
|
+
/** Azure OpenAI embedding model deployment name. Required for embedding and index operations. */
|
|
19
|
+
embedModel?: string;
|
|
20
|
+
/** Azure AI Search index name. Required for vector search / indexing operations. */
|
|
21
|
+
indexName?: string;
|
|
41
22
|
}
|
|
@@ -1,37 +1,24 @@
|
|
|
1
1
|
import { type Command } from 'commander';
|
|
2
2
|
/**
|
|
3
|
-
* Enhances a Commander command with AI
|
|
3
|
+
* Enhances a Commander command with Fusion AI options and validation.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* based on the command's requirements.
|
|
5
|
+
* Core auth options (`--env`, `--token`, `--tenant-id`, `--client-id`) are always
|
|
6
|
+
* added. When no explicit `--token` is provided, the framework will authenticate
|
|
7
|
+
* via MSAL and resolve the AI service endpoint from Fusion service discovery.
|
|
9
8
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* - Chat: `openaiChatDeployment` (if includeChat is true)
|
|
13
|
-
* - Embedding: `openaiEmbeddingDeployment` (if includeEmbedding is true)
|
|
14
|
-
* - Search: `azureSearchEndpoint`, `azureSearchApiKey`, `azureSearchIndexName` (if includeSearch is true)
|
|
9
|
+
* Pass flags to include optional chat, embed, or index options and make
|
|
10
|
+
* them required at runtime via the `preAction` validation hook.
|
|
15
11
|
*
|
|
16
|
-
* @param command - The Commander command
|
|
17
|
-
* @param args -
|
|
18
|
-
* @param args.
|
|
19
|
-
* @param args.
|
|
20
|
-
* @param args.includeSearch -
|
|
21
|
-
* @returns The
|
|
22
|
-
* @throws {InvalidOptionArgumentError} During command execution if required options are missing or invalid
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* const chatCommand = createCommand('chat')
|
|
27
|
-
* .description('Start a chat session');
|
|
28
|
-
*
|
|
29
|
-
* withOptions(chatCommand, { includeChat: true });
|
|
30
|
-
* ```
|
|
12
|
+
* @param command - The Commander command to decorate with options.
|
|
13
|
+
* @param args - Feature flags controlling which optional options to add.
|
|
14
|
+
* @param args.includeChat - Add `--chat-model` and validate it at runtime.
|
|
15
|
+
* @param args.includeEmbedding - Add `--embed-model` and validate it at runtime.
|
|
16
|
+
* @param args.includeSearch - Add `--index-name` and validate it at runtime.
|
|
17
|
+
* @returns The decorated command.
|
|
31
18
|
*/
|
|
32
19
|
export declare const withOptions: (command: Command, args?: Partial<{
|
|
33
|
-
includeEmbedding: boolean;
|
|
34
20
|
includeChat: boolean;
|
|
21
|
+
includeEmbedding: boolean;
|
|
35
22
|
includeSearch: boolean;
|
|
36
23
|
}>) => Command;
|
|
37
24
|
export default withOptions;
|
|
@@ -1,33 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AIModule } from '@equinor/fusion-framework-module-ai';
|
|
2
|
+
import type { FusionFramework } from '@equinor/fusion-framework-cli/bin';
|
|
2
3
|
import type { AiOptions } from './options/index.js';
|
|
3
|
-
|
|
4
|
+
/** Initialized framework instance with the AI module. */
|
|
5
|
+
export type FrameworkInstance = FusionFramework<[AIModule]>;
|
|
4
6
|
/**
|
|
5
|
-
* Framework instance with AI module
|
|
7
|
+
* Creates a Fusion Framework instance with the AI module enabled.
|
|
6
8
|
*
|
|
7
|
-
*
|
|
8
|
-
* the
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
export type FrameworkInstance = ModulesInstance<[AIModule]>;
|
|
12
|
-
/**
|
|
13
|
-
* Initializes and configures the Fusion Framework with AI module capabilities.
|
|
14
|
-
*
|
|
15
|
-
* Sets up the framework with Azure OpenAI chat models, embedding services, and
|
|
16
|
-
* optionally Azure Cognitive Search vector stores. The function handles the complete
|
|
17
|
-
* initialization process including service registration and dependency injection.
|
|
9
|
+
* Initialises the Fusion Framework with service discovery and MSAL auth,
|
|
10
|
+
* resolves the `'ai'` service endpoint, and pre-caches a bearer token.
|
|
11
|
+
* If MSAL has no cached credentials, the CLI's interactive `auth login`
|
|
12
|
+
* flow is spawned automatically before retrying.
|
|
18
13
|
*
|
|
19
|
-
* @param options -
|
|
20
|
-
* @
|
|
21
|
-
* @
|
|
22
|
-
* @param options.openaiInstance - Azure OpenAI instance name
|
|
23
|
-
* @param options.openaiChatDeployment - Optional chat model deployment name
|
|
24
|
-
* @param options.openaiEmbeddingDeployment - Optional embedding model deployment name
|
|
25
|
-
* @param options.azureSearchEndpoint - Optional Azure Search service endpoint URL
|
|
26
|
-
* @param options.azureSearchApiKey - Optional Azure Search API key
|
|
27
|
-
* @param options.azureSearchIndexName - Optional Azure Search index name
|
|
28
|
-
* @returns Promise resolving to an initialized framework instance with AI module configured
|
|
29
|
-
* @throws {Error} If embedding deployment is required but not provided when configuring vector store
|
|
30
|
-
* @throws {Error} If embedding service cannot be retrieved for vector store configuration
|
|
14
|
+
* @param options - CLI options resolved by {@link withOptions}.
|
|
15
|
+
* @returns A fully initialised framework instance with the AI module.
|
|
16
|
+
* @throws {Error} When authentication fails after the interactive retry.
|
|
31
17
|
*/
|
|
32
|
-
export declare const setupFramework: (options: AiOptions) => Promise<
|
|
18
|
+
export declare const setupFramework: (options: AiOptions) => Promise<FusionFramework<[AIModule]>>;
|
|
33
19
|
export default setupFramework;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "
|
|
1
|
+
export declare const version = "3.0.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/fusion-framework-cli-plugin-ai-base",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Base AI plugin package for Fusion Framework CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -46,16 +46,16 @@
|
|
|
46
46
|
"commander": "^14.0.1",
|
|
47
47
|
"zod": "^4.3.6",
|
|
48
48
|
"@equinor/fusion-framework-module": "6.0.0",
|
|
49
|
-
"@equinor/fusion-
|
|
50
|
-
"@equinor/fusion-
|
|
49
|
+
"@equinor/fusion-imports": "2.0.0",
|
|
50
|
+
"@equinor/fusion-framework-module-ai": "4.0.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@equinor/fusion-framework-cli": "^14.2.
|
|
53
|
+
"@equinor/fusion-framework-cli": "^14.2.7"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"typescript": "^5.9.3",
|
|
57
57
|
"vitest": "^4.1.0",
|
|
58
|
-
"@equinor/fusion-framework-cli": "^14.2.
|
|
58
|
+
"@equinor/fusion-framework-cli": "^14.2.7"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"build": "tsc -b",
|
package/src/index.ts
CHANGED
|
@@ -15,5 +15,5 @@ export {
|
|
|
15
15
|
configureFusionAI,
|
|
16
16
|
loadFusionAIConfig,
|
|
17
17
|
} from './config.js';
|
|
18
|
-
export { setupFramework, FrameworkInstance } from './setup-framework.js';
|
|
18
|
+
export { setupFramework, type FrameworkInstance } from './setup-framework.js';
|
|
19
19
|
export { registerAiPlugin } from './register.js';
|
package/src/options/options.ts
CHANGED
|
@@ -1,122 +1,62 @@
|
|
|
1
1
|
import { createOption } from 'commander';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*/
|
|
10
|
-
export const
|
|
11
|
-
'
|
|
12
|
-
'
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* @remarks
|
|
19
|
-
* Defaults to `2024-02-15-preview`. Falls back to the
|
|
20
|
-
* `AZURE_OPENAI_API_VERSION` environment variable when the flag is omitted.
|
|
21
|
-
*/
|
|
22
|
-
export const apiVersionOption = createOption(
|
|
23
|
-
'--openai-api-version <version>',
|
|
24
|
-
'Azure OpenAI API version',
|
|
3
|
+
// Default Fusion AAD identifiers (same defaults as the CLI's auth options)
|
|
4
|
+
const DEFAULT_TENANT_ID = '3aa4a235-b6e2-48d5-9195-7fcf05b459b0' as const;
|
|
5
|
+
const DEFAULT_CLIENT_ID = 'a318b8e1-0295-4e17-98d5-35f67dfeba14' as const;
|
|
6
|
+
const DEFAULT_MODEL_CHAT = 'gpt-5.1-chat' as const;
|
|
7
|
+
const DEFAULT_MODEL_EMBED = 'text-embedding-3-large' as const;
|
|
8
|
+
|
|
9
|
+
/** `--env` | `FUSION_ENV` — Fusion environment for service discovery */
|
|
10
|
+
export const envOption = createOption('--env <env>', 'Fusion environment for service discovery')
|
|
11
|
+
.env('FUSION_ENV')
|
|
12
|
+
.default('ci');
|
|
13
|
+
|
|
14
|
+
/** `--token` | `FUSION_TOKEN` — explicit bearer token */
|
|
15
|
+
export const tokenOption = createOption(
|
|
16
|
+
'--token <token>',
|
|
17
|
+
'Azure AD bearer token (skips interactive/silent MSAL auth)',
|
|
25
18
|
)
|
|
26
|
-
.env('
|
|
27
|
-
.default(
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
* `AZURE_OPENAI_CHAT_DEPLOYMENT_NAME` environment variable when the flag is omitted.
|
|
47
|
-
* Only added to a command when `withOptions` is called with `includeChat: true`.
|
|
48
|
-
*/
|
|
49
|
-
export const chatDeploymentOption = createOption(
|
|
50
|
-
'--openai-chat-deployment <name>',
|
|
51
|
-
'Azure OpenAI chat deployment name',
|
|
52
|
-
).env('AZURE_OPENAI_CHAT_DEPLOYMENT_NAME');
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Commander option for the Azure OpenAI embedding deployment (`--openai-embedding-deployment`).
|
|
56
|
-
*
|
|
57
|
-
* @remarks
|
|
58
|
-
* Required for embedding and vector-search operations. Falls back to the
|
|
59
|
-
* `AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME` environment variable when the flag is omitted.
|
|
60
|
-
* Only added to a command when `withOptions` is called with `includeEmbedding: true`.
|
|
61
|
-
*/
|
|
62
|
-
export const embeddingDeploymentOption = createOption(
|
|
63
|
-
'--openai-embedding-deployment <name>',
|
|
64
|
-
'Azure OpenAI embedding deployment name',
|
|
65
|
-
).env('AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME');
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Commander option for the Azure Cognitive Search endpoint (`--azure-search-endpoint`).
|
|
69
|
-
*
|
|
70
|
-
* @remarks
|
|
71
|
-
* Required for vector-search operations. Falls back to the
|
|
72
|
-
* `AZURE_SEARCH_ENDPOINT` environment variable when the flag is omitted.
|
|
73
|
-
* Only added to a command when `withOptions` is called with `includeSearch: true`.
|
|
74
|
-
*/
|
|
75
|
-
export const azureSearchEndpointOption = createOption(
|
|
76
|
-
'--azure-search-endpoint <url>',
|
|
77
|
-
'Azure Search endpoint URL',
|
|
78
|
-
).env('AZURE_SEARCH_ENDPOINT');
|
|
19
|
+
.env('FUSION_TOKEN')
|
|
20
|
+
.default(undefined);
|
|
21
|
+
|
|
22
|
+
/** `--tenant-id` | `FUSION_TENANT_ID` */
|
|
23
|
+
export const tenantIdOption = createOption('--tenant-id <id>', 'Azure AD tenant ID')
|
|
24
|
+
.env('FUSION_TENANT_ID')
|
|
25
|
+
.default(DEFAULT_TENANT_ID);
|
|
26
|
+
|
|
27
|
+
/** `--client-id` | `FUSION_CLIENT_ID` */
|
|
28
|
+
export const clientIdOption = createOption('--client-id <id>', 'Azure AD application client ID')
|
|
29
|
+
.env('FUSION_CLIENT_ID')
|
|
30
|
+
.default(DEFAULT_CLIENT_ID);
|
|
31
|
+
|
|
32
|
+
/** `--chat-model` | `FUSION_AI_CHAT_MODEL` */
|
|
33
|
+
export const chatModelOption = createOption(
|
|
34
|
+
'--chat-model <name>',
|
|
35
|
+
'Azure OpenAI chat model deployment name',
|
|
36
|
+
)
|
|
37
|
+
.env('FUSION_AI_CHAT_MODEL')
|
|
38
|
+
.default(DEFAULT_MODEL_CHAT);
|
|
79
39
|
|
|
80
|
-
/**
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
*/
|
|
88
|
-
export const azureSearchApiKeyOption = createOption(
|
|
89
|
-
'--azure-search-api-key <key>',
|
|
90
|
-
'Azure Search API key',
|
|
91
|
-
).env('AZURE_SEARCH_API_KEY');
|
|
40
|
+
/** `--embed-model` | `FUSION_AI_EMBED_MODEL` */
|
|
41
|
+
export const embedModelOption = createOption(
|
|
42
|
+
'--embed-model <name>',
|
|
43
|
+
'Azure OpenAI embedding model deployment name',
|
|
44
|
+
)
|
|
45
|
+
.env('FUSION_AI_EMBED_MODEL')
|
|
46
|
+
.default(DEFAULT_MODEL_EMBED);
|
|
92
47
|
|
|
93
|
-
/**
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
* `AZURE_SEARCH_INDEX_NAME` environment variable when the flag is omitted.
|
|
99
|
-
* Only added to a command when `withOptions` is called with `includeSearch: true`.
|
|
100
|
-
*/
|
|
101
|
-
export const azureSearchIndexNameOption = createOption(
|
|
102
|
-
'--azure-search-index-name <name>',
|
|
103
|
-
'Azure Search index name',
|
|
104
|
-
).env('AZURE_SEARCH_INDEX_NAME');
|
|
48
|
+
/** `--index-name` | `FUSION_AI_INDEX_NAME` */
|
|
49
|
+
export const indexNameOption = createOption(
|
|
50
|
+
'--index-name <name>',
|
|
51
|
+
'Azure AI Search index name',
|
|
52
|
+
).env('FUSION_AI_INDEX_NAME');
|
|
105
53
|
|
|
106
|
-
/**
|
|
107
|
-
* All AI-related Commander option definitions as a single object.
|
|
108
|
-
*
|
|
109
|
-
* @remarks
|
|
110
|
-
* Use this default export for convenient bulk access when you need every option.
|
|
111
|
-
* For selective inclusion prefer importing the named constants directly.
|
|
112
|
-
*/
|
|
113
54
|
export default {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
azureSearchIndexNameOption,
|
|
55
|
+
envOption,
|
|
56
|
+
tokenOption,
|
|
57
|
+
tenantIdOption,
|
|
58
|
+
clientIdOption,
|
|
59
|
+
chatModelOption,
|
|
60
|
+
embedModelOption,
|
|
61
|
+
indexNameOption,
|
|
122
62
|
};
|
package/src/options/schema.ts
CHANGED
|
@@ -1,77 +1,27 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zod validation schema and inferred type for AI command options.
|
|
3
|
-
*
|
|
4
|
-
* @packageDocumentation
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
1
|
import z from 'zod';
|
|
8
2
|
|
|
9
3
|
/**
|
|
10
|
-
* Base Zod schema for AI
|
|
4
|
+
* Base Zod schema for Fusion AI command options.
|
|
11
5
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
6
|
+
* All fields are optional — when omitted the service URL and token are
|
|
7
|
+
* resolved automatically from Fusion service discovery and MSAL auth.
|
|
14
8
|
*
|
|
15
9
|
* @example
|
|
16
10
|
* ```ts
|
|
17
|
-
* import { AiOptionsSchema } from '@equinor/fusion-framework-cli-plugin-ai-base';
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* const MyCommandOptionsSchema = AiOptionsSchema.extend({
|
|
21
|
-
* myOption: z.string(),
|
|
22
|
-
* });
|
|
11
|
+
* import { AiOptionsSchema } from '@equinor/fusion-framework-cli-plugin-ai-base/command-options';
|
|
12
|
+
* const MySchema = AiOptionsSchema.extend({ extra: z.string() });
|
|
23
13
|
* ```
|
|
24
14
|
*/
|
|
25
15
|
export const AiOptionsSchema = z
|
|
26
16
|
.object({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
.min(1, 'API version must be a non-empty string.')
|
|
35
|
-
.describe('Azure OpenAI API version'),
|
|
36
|
-
openaiInstance: z
|
|
37
|
-
.string({ message: 'Azure OpenAI instance name is required and must be a non-empty string.' })
|
|
38
|
-
.min(1, 'Instance name must be a non-empty string.')
|
|
39
|
-
.describe('Azure OpenAI instance name'),
|
|
40
|
-
|
|
41
|
-
// Optional AI options
|
|
42
|
-
openaiChatDeployment: z
|
|
43
|
-
.string()
|
|
44
|
-
.min(1, 'Chat deployment name must be a non-empty string.')
|
|
45
|
-
.optional()
|
|
46
|
-
.describe('Azure OpenAI chat deployment name'),
|
|
47
|
-
openaiEmbeddingDeployment: z
|
|
48
|
-
.string()
|
|
49
|
-
.min(1, 'Embedding deployment name must be a non-empty string.')
|
|
50
|
-
.optional()
|
|
51
|
-
.describe('Azure OpenAI embedding deployment name'),
|
|
52
|
-
azureSearchEndpoint: z
|
|
53
|
-
.string()
|
|
54
|
-
.url('Azure Search endpoint must be a valid URL.')
|
|
55
|
-
.min(1, 'Azure Search endpoint must be a non-empty string.')
|
|
56
|
-
.optional()
|
|
57
|
-
.describe('Azure Search endpoint URL'),
|
|
58
|
-
azureSearchApiKey: z
|
|
59
|
-
.string()
|
|
60
|
-
.min(1, 'Azure Search API key must be a non-empty string.')
|
|
61
|
-
.optional()
|
|
62
|
-
.describe('Azure Search API key'),
|
|
63
|
-
azureSearchIndexName: z
|
|
64
|
-
.string()
|
|
65
|
-
.min(1, 'Azure Search index name must be a non-empty string.')
|
|
66
|
-
.optional()
|
|
67
|
-
.describe('Azure Search index name'),
|
|
17
|
+
env: z.string().optional(),
|
|
18
|
+
token: z.string().optional(),
|
|
19
|
+
tenantId: z.string().optional(),
|
|
20
|
+
clientId: z.string().optional(),
|
|
21
|
+
chatModel: z.string().min(1).optional(),
|
|
22
|
+
embedModel: z.string().min(1).optional(),
|
|
23
|
+
indexName: z.string().min(1).optional(),
|
|
68
24
|
})
|
|
69
|
-
.describe('Base AI
|
|
25
|
+
.describe('Base Fusion AI command options');
|
|
70
26
|
|
|
71
|
-
/**
|
|
72
|
-
* Type representing the validated AI options.
|
|
73
|
-
*
|
|
74
|
-
* This type is inferred from the Zod schema and should be used throughout AI plugins
|
|
75
|
-
* to ensure type safety and consistency with the schema.
|
|
76
|
-
*/
|
|
77
27
|
export type AiOptionsType = z.infer<typeof AiOptionsSchema>;
|