@artemiskit/cli 0.1.7 → 0.2.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.
@@ -263,6 +263,13 @@ function buildAzureOpenAIConfig(options: ProviderBuildOptions): AdapterConfigRes
263
263
  { value: '2024-02-15-preview', source: 'default' }
264
264
  );
265
265
 
266
+ // Embedding deployment (optional, for models that need separate embedding deployment)
267
+ const resolvedEmbeddingDeploymentName = resolveValueWithSource<string>(
268
+ { value: scenarioConfig?.embeddingDeploymentName, source: 'scenario' },
269
+ { value: fileProviderConfig?.embeddingDeploymentName, source: 'config' },
270
+ { value: process.env.AZURE_OPENAI_EMBEDDING_DEPLOYMENT, source: 'env' }
271
+ );
272
+
266
273
  const resolvedTimeout = resolveValueWithSource<number>(
267
274
  { value: scenarioConfig?.timeout, source: 'scenario' },
268
275
  { value: fileProviderConfig?.timeout, source: 'config' }
@@ -292,6 +299,7 @@ function buildAzureOpenAIConfig(options: ProviderBuildOptions): AdapterConfigRes
292
299
  defaultModel: resolvedModel.value,
293
300
  timeout: resolvedTimeout.value,
294
301
  maxRetries: resolvedMaxRetries.value,
302
+ embeddingDeploymentName: resolvedEmbeddingDeploymentName.value,
295
303
  },
296
304
  resolvedConfig: {
297
305
  provider,
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Non-blocking update checker for ArtemisKit CLI
3
+ */
4
+
5
+ import chalk from 'chalk';
6
+ import { version as currentVersion } from '../../package.json';
7
+
8
+ const PACKAGE_NAME = '@artemiskit/cli';
9
+ const NPM_REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
10
+ const FETCH_TIMEOUT_MS = 3000; // 3 second timeout to avoid blocking
11
+
12
+ // Brand color
13
+ const brandColor = chalk.hex('#fb923c');
14
+
15
+ export interface UpdateInfo {
16
+ currentVersion: string;
17
+ latestVersion: string;
18
+ updateAvailable: boolean;
19
+ }
20
+
21
+ /**
22
+ * Fetches the latest version from npm registry with a timeout
23
+ */
24
+ async function fetchLatestVersion(): Promise<string | null> {
25
+ const controller = new AbortController();
26
+ const timeoutId = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
27
+
28
+ try {
29
+ const response = await fetch(NPM_REGISTRY_URL, {
30
+ signal: controller.signal,
31
+ headers: {
32
+ Accept: 'application/json',
33
+ },
34
+ });
35
+
36
+ if (!response.ok) {
37
+ return null;
38
+ }
39
+
40
+ const data = (await response.json()) as { version?: string };
41
+ return data.version || null;
42
+ } catch {
43
+ // Silently fail - network issues shouldn't block CLI usage
44
+ return null;
45
+ } finally {
46
+ clearTimeout(timeoutId);
47
+ }
48
+ }
49
+
50
+ /**
51
+ * Compares two semver versions
52
+ * Returns true if latest > current
53
+ */
54
+ function isNewerVersion(current: string, latest: string): boolean {
55
+ const currentParts = current.replace(/^v/, '').split('.').map(Number);
56
+ const latestParts = latest.replace(/^v/, '').split('.').map(Number);
57
+
58
+ for (let i = 0; i < 3; i++) {
59
+ const c = currentParts[i] || 0;
60
+ const l = latestParts[i] || 0;
61
+ if (l > c) return true;
62
+ if (l < c) return false;
63
+ }
64
+ return false;
65
+ }
66
+
67
+ /**
68
+ * Check for updates (non-blocking)
69
+ * Returns update info or null if check fails
70
+ */
71
+ export async function checkForUpdate(): Promise<UpdateInfo | null> {
72
+ const latestVersion = await fetchLatestVersion();
73
+
74
+ if (!latestVersion) {
75
+ return null;
76
+ }
77
+
78
+ return {
79
+ currentVersion,
80
+ latestVersion,
81
+ updateAvailable: isNewerVersion(currentVersion, latestVersion),
82
+ };
83
+ }
84
+
85
+ /**
86
+ * Get the current CLI version
87
+ */
88
+ export function getCurrentVersion(): string {
89
+ return currentVersion;
90
+ }
91
+
92
+ /**
93
+ * Format version display string
94
+ */
95
+ export function formatVersionDisplay(version: string): string {
96
+ return `${chalk.bold('ArtemisKit CLI')} ${brandColor(`v${version}`)}`;
97
+ }
98
+
99
+ /**
100
+ * Format update available message
101
+ */
102
+ export function formatUpdateMessage(current: string, latest: string): string {
103
+ return `\n${chalk.yellow('╭─────────────────────────────────────────────────────╮')}\n${chalk.yellow('│')}${chalk.yellow(' Update available! ')}${chalk.gray(`${current}`)}${chalk.yellow(' → ')}${brandColor.bold(`${latest}`)}${' '.repeat(24 - current.length - latest.length)}${chalk.yellow('│')}\n${chalk.yellow('│')}${chalk.white(' Run ')}${chalk.cyan('npm install -g @artemiskit/cli')}${chalk.white(' to update ')}${chalk.yellow('│')}\n${chalk.yellow('╰─────────────────────────────────────────────────────╯')}`;
104
+ }
105
+
106
+ /**
107
+ * Non-blocking update check that prints message if update available
108
+ * Use this to fire-and-forget an update check
109
+ */
110
+ export function checkForUpdateAndNotify(): void {
111
+ // Fire and forget - don't await
112
+ checkForUpdate()
113
+ .then((info) => {
114
+ if (info?.updateAvailable) {
115
+ console.log(formatUpdateMessage(info.currentVersion, info.latestVersion));
116
+ }
117
+ })
118
+ .catch(() => {
119
+ // Silently ignore errors
120
+ });
121
+ }