@didim365/agent-cli-core 0.1.2 → 0.1.3
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.
|
@@ -4,14 +4,34 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Mapping from provider name to keychain entry name.
|
|
8
|
+
* 'gemini' maps to 'default-api-key' for backward compatibility.
|
|
9
|
+
*/
|
|
10
|
+
export declare const PROVIDER_KEYCHAIN_ENTRIES: Record<string, string>;
|
|
11
|
+
/**
|
|
12
|
+
* Load API key for a specific provider from the keychain.
|
|
13
|
+
*/
|
|
14
|
+
export declare function loadProviderApiKey(provider: string): Promise<string | null>;
|
|
15
|
+
/**
|
|
16
|
+
* Save API key for a specific provider to the keychain.
|
|
17
|
+
*/
|
|
18
|
+
export declare function saveProviderApiKey(provider: string, apiKey: string | null | undefined): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Clear API key for a specific provider from the keychain.
|
|
21
|
+
*/
|
|
22
|
+
export declare function clearProviderApiKey(provider: string): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Load cached API key (Gemini)
|
|
25
|
+
* @deprecated Use loadProviderApiKey('gemini') instead
|
|
8
26
|
*/
|
|
9
27
|
export declare function loadApiKey(): Promise<string | null>;
|
|
10
28
|
/**
|
|
11
|
-
* Save API key
|
|
29
|
+
* Save API key (Gemini)
|
|
30
|
+
* @deprecated Use saveProviderApiKey('gemini', apiKey) instead
|
|
12
31
|
*/
|
|
13
32
|
export declare function saveApiKey(apiKey: string | null | undefined): Promise<void>;
|
|
14
33
|
/**
|
|
15
|
-
* Clear cached API key
|
|
34
|
+
* Clear cached API key (Gemini)
|
|
35
|
+
* @deprecated Use clearProviderApiKey('gemini') instead
|
|
16
36
|
*/
|
|
17
37
|
export declare function clearApiKey(): Promise<void>;
|
|
@@ -7,41 +7,58 @@ import { HybridTokenStorage } from '../mcp/token-storage/hybrid-token-storage.js
|
|
|
7
7
|
import { debugLogger } from '../utils/debugLogger.js';
|
|
8
8
|
const KEYCHAIN_SERVICE_NAME = 'gemini-cli-api-key';
|
|
9
9
|
const DEFAULT_API_KEY_ENTRY = 'default-api-key';
|
|
10
|
+
/**
|
|
11
|
+
* Mapping from provider name to keychain entry name.
|
|
12
|
+
* 'gemini' maps to 'default-api-key' for backward compatibility.
|
|
13
|
+
*/
|
|
14
|
+
export const PROVIDER_KEYCHAIN_ENTRIES = {
|
|
15
|
+
gemini: DEFAULT_API_KEY_ENTRY,
|
|
16
|
+
claude: 'claude-api-key',
|
|
17
|
+
openai: 'openai-api-key',
|
|
18
|
+
'openai-compatible': 'slm-api-key',
|
|
19
|
+
didim: 'didim-api-key',
|
|
20
|
+
};
|
|
10
21
|
const storage = new HybridTokenStorage(KEYCHAIN_SERVICE_NAME);
|
|
11
22
|
/**
|
|
12
|
-
*
|
|
23
|
+
* Get the keychain entry name for a provider.
|
|
24
|
+
* Falls back to the provider string itself if not found in the mapping.
|
|
13
25
|
*/
|
|
14
|
-
|
|
26
|
+
function getEntryName(provider) {
|
|
27
|
+
return PROVIDER_KEYCHAIN_ENTRIES[provider] ?? provider;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Load API key for a specific provider from the keychain.
|
|
31
|
+
*/
|
|
32
|
+
export async function loadProviderApiKey(provider) {
|
|
15
33
|
try {
|
|
16
|
-
const
|
|
34
|
+
const entryName = getEntryName(provider);
|
|
35
|
+
const credentials = await storage.getCredentials(entryName);
|
|
17
36
|
if (credentials?.token?.accessToken) {
|
|
18
37
|
return credentials.token.accessToken;
|
|
19
38
|
}
|
|
20
39
|
return null;
|
|
21
40
|
}
|
|
22
41
|
catch (error) {
|
|
23
|
-
|
|
24
|
-
debugLogger.error('Failed to load API key from storage:', error);
|
|
42
|
+
debugLogger.error(`Failed to load API key for provider '${provider}' from storage:`, error);
|
|
25
43
|
return null;
|
|
26
44
|
}
|
|
27
45
|
}
|
|
28
46
|
/**
|
|
29
|
-
* Save API key
|
|
47
|
+
* Save API key for a specific provider to the keychain.
|
|
30
48
|
*/
|
|
31
|
-
export async function
|
|
49
|
+
export async function saveProviderApiKey(provider, apiKey) {
|
|
50
|
+
const entryName = getEntryName(provider);
|
|
32
51
|
if (!apiKey || apiKey.trim() === '') {
|
|
33
52
|
try {
|
|
34
|
-
await storage.deleteCredentials(
|
|
53
|
+
await storage.deleteCredentials(entryName);
|
|
35
54
|
}
|
|
36
55
|
catch (error) {
|
|
37
|
-
|
|
38
|
-
debugLogger.warn('Failed to delete API key from storage:', error);
|
|
56
|
+
debugLogger.warn(`Failed to delete API key for provider '${provider}' from storage:`, error);
|
|
39
57
|
}
|
|
40
58
|
return;
|
|
41
59
|
}
|
|
42
|
-
// Wrap API key in OAuthCredentials format as required by HybridTokenStorage
|
|
43
60
|
const credentials = {
|
|
44
|
-
serverName:
|
|
61
|
+
serverName: entryName,
|
|
45
62
|
token: {
|
|
46
63
|
accessToken: apiKey,
|
|
47
64
|
tokenType: 'ApiKey',
|
|
@@ -51,14 +68,37 @@ export async function saveApiKey(apiKey) {
|
|
|
51
68
|
await storage.setCredentials(credentials);
|
|
52
69
|
}
|
|
53
70
|
/**
|
|
54
|
-
* Clear
|
|
71
|
+
* Clear API key for a specific provider from the keychain.
|
|
55
72
|
*/
|
|
56
|
-
export async function
|
|
73
|
+
export async function clearProviderApiKey(provider) {
|
|
57
74
|
try {
|
|
58
|
-
|
|
75
|
+
const entryName = getEntryName(provider);
|
|
76
|
+
await storage.deleteCredentials(entryName);
|
|
59
77
|
}
|
|
60
78
|
catch (error) {
|
|
61
|
-
debugLogger.error(
|
|
79
|
+
debugLogger.error(`Failed to clear API key for provider '${provider}' from storage:`, error);
|
|
62
80
|
}
|
|
63
81
|
}
|
|
82
|
+
// --- Backward-compatible aliases (delegate to gemini provider) ---
|
|
83
|
+
/**
|
|
84
|
+
* Load cached API key (Gemini)
|
|
85
|
+
* @deprecated Use loadProviderApiKey('gemini') instead
|
|
86
|
+
*/
|
|
87
|
+
export async function loadApiKey() {
|
|
88
|
+
return loadProviderApiKey('gemini');
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Save API key (Gemini)
|
|
92
|
+
* @deprecated Use saveProviderApiKey('gemini', apiKey) instead
|
|
93
|
+
*/
|
|
94
|
+
export async function saveApiKey(apiKey) {
|
|
95
|
+
return saveProviderApiKey('gemini', apiKey);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Clear cached API key (Gemini)
|
|
99
|
+
* @deprecated Use clearProviderApiKey('gemini') instead
|
|
100
|
+
*/
|
|
101
|
+
export async function clearApiKey() {
|
|
102
|
+
return clearProviderApiKey('gemini');
|
|
103
|
+
}
|
|
64
104
|
//# sourceMappingURL=apiKeyCredentialStorage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiKeyCredentialStorage.js","sourceRoot":"","sources":["../../../src/core/apiKeyCredentialStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAElF,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AACnD,MAAM,qBAAqB,GAAG,iBAAiB,CAAC;AAEhD,MAAM,OAAO,GAAG,IAAI,kBAAkB,CAAC,qBAAqB,CAAC,CAAC;AAE9D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"apiKeyCredentialStorage.js","sourceRoot":"","sources":["../../../src/core/apiKeyCredentialStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAElF,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AACnD,MAAM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c,EAAE,CAAC;YACxB,WAAW,CAAC,IAAI,CACd,0CAA0C,QAAQ,iBAAiB,EACnE,KAAK,CACN,CAAC;QACJ,CAAC;QACD,OAAO;IACT,CAAC;IAED,MAAM,WAAW,GAAqB;QACpC,UAAU,EAAE,SAAS;QACrB,KAAK,EAAE;YACL,WAAW,EAAE,MAAM;YACnB,SAAS,EAAE,QAAQ;SACpB;QACD,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;KACtB,CAAC;IAEF,MAAM,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;AAC5C,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,QAAgB;IACxD,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;QACzC,MAAM,OAAO,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,WAAW,CAAC,KAAK,CACf,yCAAyC,QAAQ,iBAAiB,EAClE,KAAK,CACN,CAAC;IACJ,CAAC;AACH,CAAC;AAED,oEAAoE;AAEpE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,OAAO,kBAAkB,CAAC,QAAQ,CAAC,CAAC;AACtC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,MAAiC;IAEjC,OAAO,kBAAkB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC9C,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,OAAO,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
*/
|
|
6
6
|
// This file is auto-generated by the build script (scripts/generate-git-commit-info.js)
|
|
7
7
|
// Do not edit this file manually.
|
|
8
|
-
export const GIT_COMMIT_INFO = '
|
|
8
|
+
export const GIT_COMMIT_INFO = 'ed20709df';
|
|
9
9
|
export const CLI_VERSION = '0.27.0-nightly.20260121.97aac696f';
|
|
10
10
|
//# sourceMappingURL=git-commit.js.map
|