@equinor/fusion-framework-cli-plugin-ai-base 2.0.1 → 4.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 +30 -0
- package/README.md +18 -26
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/options/options.js +43 -86
- package/dist/esm/options/options.js.map +1 -1
- package/dist/esm/options/schema.js +14 -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 +31 -89
- package/dist/esm/options/with-options.js.map +1 -1
- package/dist/esm/setup-framework.js +45 -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 +24 -84
- package/dist/types/options/schema.d.ts +13 -28
- package/dist/types/options/types.d.ts +19 -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 +55 -109
- package/src/options/schema.ts +14 -63
- package/src/options/types.ts +19 -37
- package/src/options/with-options.ts +38 -130
- package/src/setup-framework.ts +52 -88
- package/src/version.ts +1 -1
- package/tsconfig.json +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @equinor/fusion-framework-cli-plugin-ai-base
|
|
2
2
|
|
|
3
|
+
## 4.0.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 4711dbc: Add `-d, --debug` option to all AI CLI commands, with automatic activation via the `RUNNER_DEBUG` environment variable.
|
|
8
|
+
|
|
9
|
+
When GitHub Actions debug logging is enabled (`RUNNER_DEBUG=1`), all `ffc ai` commands now start in debug mode automatically. Debug output includes environment, auth mode, AI service URL, scopes, and token acquisition status.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [8d7b8a1]
|
|
14
|
+
- Updated dependencies [4711dbc]
|
|
15
|
+
- @equinor/fusion-framework-cli@15.0.0
|
|
16
|
+
|
|
17
|
+
## 3.0.0
|
|
18
|
+
|
|
19
|
+
### Major Changes
|
|
20
|
+
|
|
21
|
+
- ece8f42: **BREAKING:** Replace Azure API key options with Fusion service discovery options.
|
|
22
|
+
|
|
23
|
+
CLI options now use `--env`, `--token`, `--tenant-id`, `--client-id`, `--chat-model`, `--embed-model`, and `--index-name` instead of `--openai-api-key`, `--openai-instance`, `--azure-search-endpoint`, etc. The `setupFramework` function bootstraps MSAL authentication and resolves the AI service endpoint via Fusion service discovery.
|
|
24
|
+
|
|
25
|
+
Ref: https://github.com/equinor/fusion-framework/issues/1008
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- Updated dependencies [ece8f42]
|
|
30
|
+
- Updated dependencies [ece8f42]
|
|
31
|
+
- @equinor/fusion-framework-module-ai@4.0.0
|
|
32
|
+
|
|
3
33
|
## 2.0.1
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -11,10 +11,9 @@ logic from this package.
|
|
|
11
11
|
|
|
12
12
|
## Who should use this
|
|
13
13
|
|
|
14
|
-
Authors of **new Fusion CLI AI plugins** that need the same
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
plugins directly.
|
|
14
|
+
Authors of **new Fusion CLI AI plugins** that need the same Fusion service
|
|
15
|
+
discovery options and framework setup that the existing plugins share. If you
|
|
16
|
+
are building a Fusion application, use the published CLI plugins directly.
|
|
18
17
|
|
|
19
18
|
## Quick start
|
|
20
19
|
|
|
@@ -45,7 +44,7 @@ import {
|
|
|
45
44
|
const myCommand = createCommand('my-task')
|
|
46
45
|
.description('Run my custom AI task');
|
|
47
46
|
|
|
48
|
-
// Attach core + chat + embedding options and pre-action validation
|
|
47
|
+
// Attach core auth + chat + embedding options and pre-action validation
|
|
49
48
|
withOptions(myCommand, { includeChat: true, includeEmbedding: true });
|
|
50
49
|
|
|
51
50
|
myCommand.action(async (options: AiOptions) => {
|
|
@@ -61,16 +60,10 @@ export const register = (program: Command) =>
|
|
|
61
60
|
### 3. Load a configuration file (optional)
|
|
62
61
|
|
|
63
62
|
```ts
|
|
64
|
-
import {
|
|
65
|
-
loadFusionAIConfig,
|
|
66
|
-
configureFusionAI,
|
|
67
|
-
} from '@equinor/fusion-framework-cli-plugin-ai-base';
|
|
63
|
+
import { loadFusionAIConfig } from '@equinor/fusion-framework-cli-plugin-ai-base';
|
|
68
64
|
|
|
69
|
-
// fusion-ai.config.ts
|
|
70
|
-
export default
|
|
71
|
-
apiKey: process.env.OPENAI_API_KEY,
|
|
72
|
-
deployment: 'gpt-4',
|
|
73
|
-
}));
|
|
65
|
+
// fusion-ai.config.ts — export a default configuration object
|
|
66
|
+
export default { includes: ['./src/**/*.ts'] };
|
|
74
67
|
|
|
75
68
|
// at runtime
|
|
76
69
|
const config = await loadFusionAIConfig('fusion-ai.config', {
|
|
@@ -91,7 +84,7 @@ The package exposes two entry points:
|
|
|
91
84
|
|
|
92
85
|
| Export | Kind | Description |
|
|
93
86
|
|---|---|---|
|
|
94
|
-
| `setupFramework` | function | Initialise the Fusion Framework with
|
|
87
|
+
| `setupFramework` | function | Initialise the Fusion Framework with AI module, MSAL auth, and service discovery |
|
|
95
88
|
| `registerAiPlugin` | function | Register a Commander sub-command under the shared `ai` command group |
|
|
96
89
|
| `loadFusionAIConfig` | function | Locate and import a `fusion-ai.config.{ts,mjs,js,json}` file |
|
|
97
90
|
| `configureFusionAI` | function | Type-safe factory for writing configuration files |
|
|
@@ -116,14 +109,13 @@ without explicit flags.
|
|
|
116
109
|
|
|
117
110
|
| Flag | Environment variable | Required | Default |
|
|
118
111
|
|---|---|---|---|
|
|
119
|
-
| `--
|
|
120
|
-
| `--
|
|
121
|
-
| `--
|
|
122
|
-
| `--
|
|
123
|
-
| `--
|
|
124
|
-
| `--
|
|
125
|
-
| `--
|
|
126
|
-
| `--azure-search-index-name` | `AZURE_SEARCH_INDEX_NAME` | When search is enabled | — |
|
|
112
|
+
| `--env` | `FUSION_ENV` | No | `ci` |
|
|
113
|
+
| `--token` | `FUSION_TOKEN` | No | — (MSAL interactive login) |
|
|
114
|
+
| `--tenant-id` | `FUSION_TENANT_ID` | No | Equinor default |
|
|
115
|
+
| `--client-id` | `FUSION_CLIENT_ID` | No | Fusion CLI default |
|
|
116
|
+
| `--chat-model` | `FUSION_AI_CHAT_MODEL` | When chat is enabled | `gpt-5.1-chat` |
|
|
117
|
+
| `--embed-model` | `FUSION_AI_EMBED_MODEL` | When embedding is enabled | `text-embedding-3-large` |
|
|
118
|
+
| `--index-name` | `FUSION_AI_INDEX_NAME` | When search is enabled | — |
|
|
127
119
|
|
|
128
120
|
## Key concepts
|
|
129
121
|
|
|
@@ -142,9 +134,9 @@ that includes the corresponding environment variable name.
|
|
|
142
134
|
|
|
143
135
|
### Framework bootstrap
|
|
144
136
|
|
|
145
|
-
`setupFramework` creates a
|
|
146
|
-
|
|
147
|
-
|
|
137
|
+
`setupFramework` creates a Fusion Framework instance with MSAL authentication,
|
|
138
|
+
service discovery, and the AI module. It registers strategy-based model, embed,
|
|
139
|
+
and index providers resolved through Fusion's AI service. The returned
|
|
148
140
|
`FrameworkInstance` is ready for downstream use.
|
|
149
141
|
|
|
150
142
|
## Consuming plugins
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAGL,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAGL,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAA0B,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -1,90 +1,47 @@
|
|
|
1
1
|
import { createOption } from 'commander';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Commander option for the Azure OpenAI embedding deployment (`--openai-embedding-deployment`).
|
|
39
|
-
*
|
|
40
|
-
* @remarks
|
|
41
|
-
* Required for embedding and vector-search operations. Falls back to the
|
|
42
|
-
* `AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME` environment variable when the flag is omitted.
|
|
43
|
-
* Only added to a command when `withOptions` is called with `includeEmbedding: true`.
|
|
44
|
-
*/
|
|
45
|
-
export const embeddingDeploymentOption = createOption('--openai-embedding-deployment <name>', 'Azure OpenAI embedding deployment name').env('AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME');
|
|
46
|
-
/**
|
|
47
|
-
* Commander option for the Azure Cognitive Search endpoint (`--azure-search-endpoint`).
|
|
48
|
-
*
|
|
49
|
-
* @remarks
|
|
50
|
-
* Required for vector-search operations. Falls back to the
|
|
51
|
-
* `AZURE_SEARCH_ENDPOINT` environment variable when the flag is omitted.
|
|
52
|
-
* Only added to a command when `withOptions` is called with `includeSearch: true`.
|
|
53
|
-
*/
|
|
54
|
-
export const azureSearchEndpointOption = createOption('--azure-search-endpoint <url>', 'Azure Search endpoint URL').env('AZURE_SEARCH_ENDPOINT');
|
|
55
|
-
/**
|
|
56
|
-
* Commander option for the Azure Cognitive Search API key (`--azure-search-api-key`).
|
|
57
|
-
*
|
|
58
|
-
* @remarks
|
|
59
|
-
* Required for authenticating with Azure Cognitive Search. Falls back to the
|
|
60
|
-
* `AZURE_SEARCH_API_KEY` environment variable when the flag is omitted.
|
|
61
|
-
* Only added to a command when `withOptions` is called with `includeSearch: true`.
|
|
62
|
-
*/
|
|
63
|
-
export const azureSearchApiKeyOption = createOption('--azure-search-api-key <key>', 'Azure Search API key').env('AZURE_SEARCH_API_KEY');
|
|
64
|
-
/**
|
|
65
|
-
* Commander option for the Azure Cognitive Search index name (`--azure-search-index-name`).
|
|
66
|
-
*
|
|
67
|
-
* @remarks
|
|
68
|
-
* Identifies the target search index to query or write to. Falls back to the
|
|
69
|
-
* `AZURE_SEARCH_INDEX_NAME` environment variable when the flag is omitted.
|
|
70
|
-
* Only added to a command when `withOptions` is called with `includeSearch: true`.
|
|
71
|
-
*/
|
|
72
|
-
export const azureSearchIndexNameOption = createOption('--azure-search-index-name <name>', 'Azure Search index name').env('AZURE_SEARCH_INDEX_NAME');
|
|
73
|
-
/**
|
|
74
|
-
* All AI-related Commander option definitions as a single object.
|
|
75
|
-
*
|
|
76
|
-
* @remarks
|
|
77
|
-
* Use this default export for convenient bulk access when you need every option.
|
|
78
|
-
* For selective inclusion prefer importing the named constants directly.
|
|
79
|
-
*/
|
|
2
|
+
// Default Fusion AAD identifiers (same defaults as the CLI's auth options)
|
|
3
|
+
const DEFAULT_TENANT_ID = '3aa4a235-b6e2-48d5-9195-7fcf05b459b0';
|
|
4
|
+
const DEFAULT_CLIENT_ID = 'a318b8e1-0295-4e17-98d5-35f67dfeba14';
|
|
5
|
+
const DEFAULT_MODEL_CHAT = 'gpt-5.1-chat';
|
|
6
|
+
const DEFAULT_MODEL_EMBED = 'text-embedding-3-large';
|
|
7
|
+
/** `--env` | `FUSION_ENV` — Fusion environment for service discovery */
|
|
8
|
+
export const envOption = createOption('--env <env>', 'Fusion environment for service discovery')
|
|
9
|
+
.env('FUSION_ENV')
|
|
10
|
+
.default('ci');
|
|
11
|
+
/** `--token` | `FUSION_TOKEN` — explicit bearer token */
|
|
12
|
+
export const tokenOption = createOption('--token <token>', 'Azure AD bearer token (skips interactive/silent MSAL auth)')
|
|
13
|
+
.env('FUSION_TOKEN')
|
|
14
|
+
.default(undefined);
|
|
15
|
+
/** `--tenant-id` | `FUSION_TENANT_ID` */
|
|
16
|
+
export const tenantIdOption = createOption('--tenant-id <id>', 'Azure AD tenant ID')
|
|
17
|
+
.env('FUSION_TENANT_ID')
|
|
18
|
+
.default(DEFAULT_TENANT_ID);
|
|
19
|
+
/** `--client-id` | `FUSION_CLIENT_ID` */
|
|
20
|
+
export const clientIdOption = createOption('--client-id <id>', 'Azure AD application client ID')
|
|
21
|
+
.env('FUSION_CLIENT_ID')
|
|
22
|
+
.default(DEFAULT_CLIENT_ID);
|
|
23
|
+
/** `--chat-model` | `FUSION_AI_CHAT_MODEL` */
|
|
24
|
+
export const chatModelOption = createOption('--chat-model <name>', 'Azure OpenAI chat model deployment name')
|
|
25
|
+
.env('FUSION_AI_CHAT_MODEL')
|
|
26
|
+
.default(DEFAULT_MODEL_CHAT);
|
|
27
|
+
/** `--embed-model` | `FUSION_AI_EMBED_MODEL` */
|
|
28
|
+
export const embedModelOption = createOption('--embed-model <name>', 'Azure OpenAI embedding model deployment name')
|
|
29
|
+
.env('FUSION_AI_EMBED_MODEL')
|
|
30
|
+
.default(DEFAULT_MODEL_EMBED);
|
|
31
|
+
/** `--index-name` | `FUSION_AI_INDEX_NAME` */
|
|
32
|
+
export const indexNameOption = createOption('--index-name <name>', 'Azure AI Search index name').env('FUSION_AI_INDEX_NAME');
|
|
33
|
+
/** `-d, --debug` | `RUNNER_DEBUG` — enable verbose logging */
|
|
34
|
+
export const debugOption = createOption('-d, --debug', 'Enable debug mode for verbose logging')
|
|
35
|
+
.env('RUNNER_DEBUG')
|
|
36
|
+
.default(false);
|
|
80
37
|
export default {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
38
|
+
envOption,
|
|
39
|
+
tokenOption,
|
|
40
|
+
tenantIdOption,
|
|
41
|
+
clientIdOption,
|
|
42
|
+
chatModelOption,
|
|
43
|
+
embedModelOption,
|
|
44
|
+
indexNameOption,
|
|
45
|
+
debugOption,
|
|
89
46
|
};
|
|
90
47
|
//# sourceMappingURL=options.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/options/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/options/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,2EAA2E;AAC3E,MAAM,iBAAiB,GAAG,sCAA+C,CAAC;AAC1E,MAAM,iBAAiB,GAAG,sCAA+C,CAAC;AAC1E,MAAM,kBAAkB,GAAG,cAAuB,CAAC;AACnD,MAAM,mBAAmB,GAAG,wBAAiC,CAAC;AAE9D,wEAAwE;AACxE,MAAM,CAAC,MAAM,SAAS,GAAG,YAAY,CAAC,aAAa,EAAE,0CAA0C,CAAC;KAC7F,GAAG,CAAC,YAAY,CAAC;KACjB,OAAO,CAAC,IAAI,CAAC,CAAC;AAEjB,yDAAyD;AACzD,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CACrC,iBAAiB,EACjB,4DAA4D,CAC7D;KACE,GAAG,CAAC,cAAc,CAAC;KACnB,OAAO,CAAC,SAAS,CAAC,CAAC;AAEtB,yCAAyC;AACzC,MAAM,CAAC,MAAM,cAAc,GAAG,YAAY,CAAC,kBAAkB,EAAE,oBAAoB,CAAC;KACjF,GAAG,CAAC,kBAAkB,CAAC;KACvB,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE9B,yCAAyC;AACzC,MAAM,CAAC,MAAM,cAAc,GAAG,YAAY,CAAC,kBAAkB,EAAE,gCAAgC,CAAC;KAC7F,GAAG,CAAC,kBAAkB,CAAC;KACvB,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE9B,8CAA8C;AAC9C,MAAM,CAAC,MAAM,eAAe,GAAG,YAAY,CACzC,qBAAqB,EACrB,yCAAyC,CAC1C;KACE,GAAG,CAAC,sBAAsB,CAAC;KAC3B,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAE/B,gDAAgD;AAChD,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,CAC1C,sBAAsB,EACtB,8CAA8C,CAC/C;KACE,GAAG,CAAC,uBAAuB,CAAC;KAC5B,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAEhC,8CAA8C;AAC9C,MAAM,CAAC,MAAM,eAAe,GAAG,YAAY,CACzC,qBAAqB,EACrB,4BAA4B,CAC7B,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;AAE9B,8DAA8D;AAC9D,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC,aAAa,EAAE,uCAAuC,CAAC;KAC5F,GAAG,CAAC,cAAc,CAAC;KACnB,OAAO,CAAC,KAAK,CAAC,CAAC;AAElB,eAAe;IACb,SAAS;IACT,WAAW;IACX,cAAc;IACd,cAAc;IACd,eAAe;IACf,gBAAgB;IAChB,eAAe;IACf,WAAW;CACZ,CAAC"}
|
|
@@ -1,67 +1,26 @@
|
|
|
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 const AiOptionsSchema = z
|
|
24
15
|
.object({
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
.describe('Azure OpenAI API version'),
|
|
34
|
-
openaiInstance: z
|
|
35
|
-
.string({ message: 'Azure OpenAI instance name is required and must be a non-empty string.' })
|
|
36
|
-
.min(1, 'Instance name must be a non-empty string.')
|
|
37
|
-
.describe('Azure OpenAI instance name'),
|
|
38
|
-
// Optional AI options
|
|
39
|
-
openaiChatDeployment: z
|
|
40
|
-
.string()
|
|
41
|
-
.min(1, 'Chat deployment name must be a non-empty string.')
|
|
42
|
-
.optional()
|
|
43
|
-
.describe('Azure OpenAI chat deployment name'),
|
|
44
|
-
openaiEmbeddingDeployment: z
|
|
45
|
-
.string()
|
|
46
|
-
.min(1, 'Embedding deployment name must be a non-empty string.')
|
|
47
|
-
.optional()
|
|
48
|
-
.describe('Azure OpenAI embedding deployment name'),
|
|
49
|
-
azureSearchEndpoint: z
|
|
50
|
-
.string()
|
|
51
|
-
.url('Azure Search endpoint must be a valid URL.')
|
|
52
|
-
.min(1, 'Azure Search endpoint must be a non-empty string.')
|
|
53
|
-
.optional()
|
|
54
|
-
.describe('Azure Search endpoint URL'),
|
|
55
|
-
azureSearchApiKey: z
|
|
56
|
-
.string()
|
|
57
|
-
.min(1, 'Azure Search API key must be a non-empty string.')
|
|
58
|
-
.optional()
|
|
59
|
-
.describe('Azure Search API key'),
|
|
60
|
-
azureSearchIndexName: z
|
|
61
|
-
.string()
|
|
62
|
-
.min(1, 'Azure Search index name must be a non-empty string.')
|
|
63
|
-
.optional()
|
|
64
|
-
.describe('Azure Search index name'),
|
|
16
|
+
env: z.string().optional(),
|
|
17
|
+
token: z.string().optional(),
|
|
18
|
+
tenantId: z.string().optional(),
|
|
19
|
+
clientId: z.string().optional(),
|
|
20
|
+
chatModel: z.string().min(1).optional(),
|
|
21
|
+
embedModel: z.string().min(1).optional(),
|
|
22
|
+
indexName: z.string().min(1).optional(),
|
|
23
|
+
debug: z.coerce.boolean().default(false),
|
|
65
24
|
})
|
|
66
|
-
.describe('Base AI
|
|
25
|
+
.describe('Base Fusion AI command options');
|
|
67
26
|
//# sourceMappingURL=schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/options/schema.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/options/schema.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC;KAC7B,MAAM,CAAC;IACN,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC1B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACvC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACxC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACvC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;CACzC,CAAC;KACD,QAAQ,CAAC,gCAAgC,CAAC,CAAC"}
|
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hand-authored TypeScript interface for AI CLI command options.
|
|
3
|
-
*
|
|
4
|
-
* @remarks
|
|
5
|
-
* Use {@link AiOptions} when you need a lightweight type without pulling in Zod.
|
|
6
|
-
* For runtime validation prefer {@link AiOptionsSchema} from the schema module.
|
|
7
|
-
*
|
|
8
|
-
* @packageDocumentation
|
|
9
|
-
*/
|
|
10
1
|
export {};
|
|
11
2
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/options/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/options/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,102 +1,44 @@
|
|
|
1
1
|
import { InvalidOptionArgumentError } from 'commander';
|
|
2
|
-
import {
|
|
2
|
+
import { chatModelOption, clientIdOption, debugOption, embedModelOption, envOption, indexNameOption, tenantIdOption, tokenOption, } from './options.js';
|
|
3
3
|
/**
|
|
4
|
-
* Enhances a Commander command with AI
|
|
4
|
+
* Enhances a Commander command with Fusion AI options and validation.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* based on the command's requirements.
|
|
6
|
+
* Core auth options (`--env`, `--token`, `--tenant-id`, `--client-id`) are always
|
|
7
|
+
* added. When no explicit `--token` is provided, the framework will authenticate
|
|
8
|
+
* via MSAL and resolve the AI service endpoint from Fusion service discovery.
|
|
10
9
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* - Chat: `openaiChatDeployment` (if includeChat is true)
|
|
14
|
-
* - Embedding: `openaiEmbeddingDeployment` (if includeEmbedding is true)
|
|
15
|
-
* - Search: `azureSearchEndpoint`, `azureSearchApiKey`, `azureSearchIndexName` (if includeSearch is true)
|
|
10
|
+
* Pass flags to include optional chat, embed, or index options and make
|
|
11
|
+
* them required at runtime via the `preAction` validation hook.
|
|
16
12
|
*
|
|
17
|
-
* @param command - The Commander command
|
|
18
|
-
* @param args -
|
|
19
|
-
* @param args.
|
|
20
|
-
* @param args.
|
|
21
|
-
* @param args.includeSearch -
|
|
22
|
-
* @returns The
|
|
23
|
-
* @throws {InvalidOptionArgumentError} During command execution if required options are missing or invalid
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```ts
|
|
27
|
-
* const chatCommand = createCommand('chat')
|
|
28
|
-
* .description('Start a chat session');
|
|
29
|
-
*
|
|
30
|
-
* withOptions(chatCommand, { includeChat: true });
|
|
31
|
-
* ```
|
|
13
|
+
* @param command - The Commander command to decorate with options.
|
|
14
|
+
* @param args - Feature flags controlling which optional options to add.
|
|
15
|
+
* @param args.includeChat - Add `--chat-model` and validate it at runtime.
|
|
16
|
+
* @param args.includeEmbedding - Add `--embed-model` and validate it at runtime.
|
|
17
|
+
* @param args.includeSearch - Add `--index-name` and validate it at runtime.
|
|
18
|
+
* @returns The decorated command.
|
|
32
19
|
*/
|
|
33
20
|
export const withOptions = (command, args) => {
|
|
34
|
-
|
|
35
|
-
command.addOption(
|
|
36
|
-
command.addOption(
|
|
37
|
-
command.addOption(
|
|
38
|
-
|
|
39
|
-
if (args?.includeChat
|
|
40
|
-
command.addOption(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// Azure Search options
|
|
46
|
-
if (args?.includeSearch === true) {
|
|
47
|
-
command.addOption(azureSearchEndpointOption);
|
|
48
|
-
command.addOption(azureSearchApiKeyOption);
|
|
49
|
-
command.addOption(azureSearchIndexNameOption);
|
|
50
|
-
}
|
|
51
|
-
// Validation hook
|
|
21
|
+
command.addOption(envOption);
|
|
22
|
+
command.addOption(tokenOption);
|
|
23
|
+
command.addOption(tenantIdOption);
|
|
24
|
+
command.addOption(clientIdOption);
|
|
25
|
+
command.addOption(debugOption);
|
|
26
|
+
if (args?.includeChat)
|
|
27
|
+
command.addOption(chatModelOption);
|
|
28
|
+
if (args?.includeEmbedding)
|
|
29
|
+
command.addOption(embedModelOption);
|
|
30
|
+
if (args?.includeSearch)
|
|
31
|
+
command.addOption(indexNameOption);
|
|
52
32
|
command.hook('preAction', (thisCommand) => {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
typeof options.openaiApiKey !== 'string' ||
|
|
57
|
-
options.openaiApiKey.trim() === '') {
|
|
58
|
-
throw new InvalidOptionArgumentError('Azure OpenAI API key is required. Provide it via --openai-api-key option or AZURE_OPENAI_API_KEY environment variable.');
|
|
59
|
-
}
|
|
60
|
-
// Validate API version
|
|
61
|
-
if (!options.openaiApiVersion || typeof options.openaiApiVersion !== 'string') {
|
|
62
|
-
throw new InvalidOptionArgumentError('API version must be a non-empty string.');
|
|
63
|
-
}
|
|
64
|
-
// Validate instance name
|
|
65
|
-
if (!options.openaiInstance ||
|
|
66
|
-
typeof options.openaiInstance !== 'string' ||
|
|
67
|
-
options.openaiInstance.trim() === '') {
|
|
68
|
-
throw new InvalidOptionArgumentError('Azure OpenAI instance name is required. Provide it via --openai-instance option or AZURE_OPENAI_INSTANCE_NAME environment variable.');
|
|
69
|
-
}
|
|
70
|
-
if (args?.includeChat === true) {
|
|
71
|
-
if (!options.openaiChatDeployment ||
|
|
72
|
-
typeof options.openaiChatDeployment !== 'string' ||
|
|
73
|
-
options.openaiChatDeployment.trim() === '') {
|
|
74
|
-
throw new InvalidOptionArgumentError('Chat deployment name is required and must be a non-empty string.');
|
|
75
|
-
}
|
|
33
|
+
const opts = thisCommand.opts();
|
|
34
|
+
if (args?.includeChat && !opts.chatModel?.trim()) {
|
|
35
|
+
throw new InvalidOptionArgumentError('Chat model name is required. Provide --chat-model or set FUSION_AI_CHAT_MODEL.');
|
|
76
36
|
}
|
|
77
|
-
if (args?.includeEmbedding
|
|
78
|
-
|
|
79
|
-
typeof options.openaiEmbeddingDeployment !== 'string' ||
|
|
80
|
-
options.openaiEmbeddingDeployment.trim() === '') {
|
|
81
|
-
throw new InvalidOptionArgumentError('Azure OpenAI embedding deployment name is required. Provide it via --openai-embedding-deployment option or AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME environment variable.');
|
|
82
|
-
}
|
|
37
|
+
if (args?.includeEmbedding && !opts.embedModel?.trim()) {
|
|
38
|
+
throw new InvalidOptionArgumentError('Embedding model name is required. Provide --embed-model or set FUSION_AI_EMBED_MODEL.');
|
|
83
39
|
}
|
|
84
|
-
if (args?.includeSearch
|
|
85
|
-
|
|
86
|
-
typeof options.azureSearchEndpoint !== 'string' ||
|
|
87
|
-
options.azureSearchEndpoint.trim() === '') {
|
|
88
|
-
throw new InvalidOptionArgumentError('Azure Search endpoint is required and must be a non-empty string.');
|
|
89
|
-
}
|
|
90
|
-
if (!options.azureSearchApiKey ||
|
|
91
|
-
typeof options.azureSearchApiKey !== 'string' ||
|
|
92
|
-
options.azureSearchApiKey.trim() === '') {
|
|
93
|
-
throw new InvalidOptionArgumentError('Azure Search API key is required. Provide it via --azure-search-api-key option or AZURE_SEARCH_API_KEY environment variable.');
|
|
94
|
-
}
|
|
95
|
-
if (!options.azureSearchIndexName ||
|
|
96
|
-
typeof options.azureSearchIndexName !== 'string' ||
|
|
97
|
-
options.azureSearchIndexName.trim() === '') {
|
|
98
|
-
throw new InvalidOptionArgumentError('Azure Search index name is required and must be a non-empty string.');
|
|
99
|
-
}
|
|
40
|
+
if (args?.includeSearch && !opts.indexName?.trim()) {
|
|
41
|
+
throw new InvalidOptionArgumentError('Index name is required. Provide --index-name or set FUSION_AI_INDEX_NAME.');
|
|
100
42
|
}
|
|
101
43
|
});
|
|
102
44
|
return command;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-options.js","sourceRoot":"","sources":["../../../src/options/with-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,0BAA0B,EAAE,MAAM,WAAW,CAAC;AACrE,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"with-options.js","sourceRoot":"","sources":["../../../src/options/with-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,0BAA0B,EAAE,MAAM,WAAW,CAAC;AACrE,OAAO,EACL,eAAe,EACf,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,cAAc,EACd,WAAW,GACZ,MAAM,cAAc,CAAC;AAEtB;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,OAAgB,EAChB,IAIE,EACO,EAAE;IACX,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAC/B,OAAO,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAClC,OAAO,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAClC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAE/B,IAAI,IAAI,EAAE,WAAW;QAAE,OAAO,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IAC1D,IAAI,IAAI,EAAE,gBAAgB;QAAE,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAChE,IAAI,IAAI,EAAE,aAAa;QAAE,OAAO,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IAE5D,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,WAAW,EAAE,EAAE;QACxC,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC;QAEhC,IAAI,IAAI,EAAE,WAAW,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC;YACjD,MAAM,IAAI,0BAA0B,CAClC,gFAAgF,CACjF,CAAC;QACJ,CAAC;QACD,IAAI,IAAI,EAAE,gBAAgB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,EAAE,CAAC;YACvD,MAAM,IAAI,0BAA0B,CAClC,uFAAuF,CACxF,CAAC;QACJ,CAAC;QACD,IAAI,IAAI,EAAE,aAAa,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC;YACnD,MAAM,IAAI,0BAA0B,CAClC,2EAA2E,CAC5E,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|