@fgv/ts-extras 5.0.2 → 5.1.0-1
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/dist/index.browser.js +6 -2
- package/dist/index.js +5 -1
- package/dist/packlets/ai-assist/apiClient.js +484 -0
- package/dist/packlets/ai-assist/converters.js +121 -0
- package/dist/packlets/ai-assist/index.js +10 -0
- package/dist/packlets/ai-assist/model.js +90 -0
- package/dist/packlets/ai-assist/registry.js +145 -0
- package/dist/packlets/ai-assist/toolFormats.js +160 -0
- package/dist/packlets/crypto-utils/constants.js +48 -0
- package/dist/packlets/crypto-utils/converters.js +155 -0
- package/dist/packlets/crypto-utils/directEncryptionProvider.js +86 -0
- package/dist/packlets/crypto-utils/encryptedFile.js +161 -0
- package/dist/packlets/crypto-utils/index.browser.js +41 -0
- package/dist/packlets/crypto-utils/index.js +41 -0
- package/dist/packlets/crypto-utils/keystore/converters.js +84 -0
- package/dist/packlets/crypto-utils/keystore/index.js +31 -0
- package/dist/packlets/crypto-utils/keystore/keyStore.js +758 -0
- package/dist/packlets/crypto-utils/keystore/model.js +64 -0
- package/dist/packlets/crypto-utils/model.js +39 -0
- package/dist/packlets/crypto-utils/nodeCryptoProvider.js +159 -0
- package/dist/packlets/experimental/formatter.js +1 -1
- package/dist/packlets/mustache/index.js +23 -0
- package/dist/packlets/mustache/interfaces.js +25 -0
- package/dist/packlets/mustache/mustacheTemplate.js +242 -0
- package/dist/packlets/record-jar/recordJarHelpers.js +1 -1
- package/dist/packlets/yaml/converters.js +46 -0
- package/dist/packlets/yaml/index.js +23 -0
- package/dist/packlets/zip-file-tree/index.js +1 -0
- package/dist/packlets/zip-file-tree/zipFileTreeAccessors.js +6 -2
- package/dist/packlets/zip-file-tree/zipFileTreeWriter.js +40 -0
- package/dist/ts-extras.d.ts +1964 -112
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/index.browser.d.ts +3 -1
- package/lib/index.browser.js +6 -1
- package/lib/index.d.ts +5 -1
- package/lib/index.js +9 -1
- package/lib/packlets/ai-assist/apiClient.d.ts +60 -0
- package/lib/packlets/ai-assist/apiClient.js +488 -0
- package/lib/packlets/ai-assist/converters.d.ts +55 -0
- package/lib/packlets/ai-assist/converters.js +124 -0
- package/lib/packlets/ai-assist/index.d.ts +10 -0
- package/lib/packlets/ai-assist/index.js +33 -0
- package/lib/packlets/ai-assist/model.d.ts +222 -0
- package/lib/packlets/ai-assist/model.js +95 -0
- package/lib/packlets/ai-assist/registry.d.ts +25 -0
- package/lib/packlets/ai-assist/registry.js +150 -0
- package/lib/packlets/ai-assist/toolFormats.d.ts +44 -0
- package/lib/packlets/ai-assist/toolFormats.js +166 -0
- package/lib/packlets/crypto-utils/constants.d.ts +26 -0
- package/lib/packlets/crypto-utils/constants.js +51 -0
- package/lib/packlets/crypto-utils/converters.d.ts +58 -0
- package/lib/packlets/crypto-utils/converters.js +192 -0
- package/lib/packlets/crypto-utils/directEncryptionProvider.d.ts +69 -0
- package/lib/packlets/crypto-utils/directEncryptionProvider.js +90 -0
- package/lib/packlets/crypto-utils/encryptedFile.d.ts +88 -0
- package/lib/packlets/crypto-utils/encryptedFile.js +201 -0
- package/lib/packlets/crypto-utils/index.browser.d.ts +14 -0
- package/lib/packlets/crypto-utils/index.browser.js +91 -0
- package/lib/packlets/crypto-utils/index.d.ts +15 -0
- package/lib/packlets/crypto-utils/index.js +88 -0
- package/lib/packlets/crypto-utils/keystore/converters.d.ts +29 -0
- package/lib/packlets/crypto-utils/keystore/converters.js +87 -0
- package/lib/packlets/crypto-utils/keystore/index.d.ts +9 -0
- package/lib/packlets/crypto-utils/keystore/index.js +71 -0
- package/lib/packlets/crypto-utils/keystore/keyStore.d.ts +239 -0
- package/lib/packlets/crypto-utils/keystore/keyStore.js +795 -0
- package/lib/packlets/crypto-utils/keystore/model.d.ts +245 -0
- package/lib/packlets/crypto-utils/keystore/model.js +68 -0
- package/lib/packlets/crypto-utils/model.d.ts +236 -0
- package/lib/packlets/crypto-utils/model.js +76 -0
- package/lib/packlets/crypto-utils/nodeCryptoProvider.d.ts +62 -0
- package/lib/packlets/crypto-utils/nodeCryptoProvider.js +196 -0
- package/lib/packlets/experimental/formatter.d.ts +1 -1
- package/lib/packlets/experimental/formatter.js +1 -1
- package/lib/packlets/mustache/index.d.ts +3 -0
- package/lib/packlets/mustache/index.js +27 -0
- package/lib/packlets/mustache/interfaces.d.ts +97 -0
- package/lib/packlets/mustache/interfaces.js +26 -0
- package/lib/packlets/mustache/mustacheTemplate.d.ts +76 -0
- package/lib/packlets/mustache/mustacheTemplate.js +249 -0
- package/lib/packlets/record-jar/recordJarHelpers.js +1 -1
- package/lib/packlets/yaml/converters.d.ts +9 -0
- package/lib/packlets/yaml/converters.js +82 -0
- package/lib/packlets/yaml/index.d.ts +2 -0
- package/lib/packlets/yaml/index.js +39 -0
- package/lib/packlets/zip-file-tree/index.d.ts +1 -0
- package/lib/packlets/zip-file-tree/index.js +15 -0
- package/lib/packlets/zip-file-tree/zipFileTreeAccessors.d.ts +5 -1
- package/lib/packlets/zip-file-tree/zipFileTreeAccessors.js +6 -2
- package/lib/packlets/zip-file-tree/zipFileTreeWriter.d.ts +27 -0
- package/lib/packlets/zip-file-tree/zipFileTreeWriter.js +43 -0
- package/package.json +50 -31
package/dist/ts-extras.d.ts
CHANGED
|
@@ -3,9 +3,207 @@ import { Converter } from '@fgv/ts-utils';
|
|
|
3
3
|
import { FileTree } from '@fgv/ts-json-base';
|
|
4
4
|
import { Hash as Hash_2 } from '@fgv/ts-utils';
|
|
5
5
|
import { JsonValue } from '@fgv/ts-json-base';
|
|
6
|
+
import { Logging } from '@fgv/ts-utils';
|
|
6
7
|
import { Result } from '@fgv/ts-utils';
|
|
7
8
|
import { Validator } from '@fgv/ts-utils';
|
|
8
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Key size in bytes for AES-256.
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
declare const AES_256_KEY_SIZE: number;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* API format categories for provider routing.
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
declare type AiApiFormat = 'openai' | 'anthropic' | 'gemini';
|
|
21
|
+
|
|
22
|
+
declare namespace AiAssist {
|
|
23
|
+
export {
|
|
24
|
+
AiPrompt,
|
|
25
|
+
AiProviderId,
|
|
26
|
+
AiServerToolType,
|
|
27
|
+
AiServerToolConfig,
|
|
28
|
+
IAiWebSearchToolConfig,
|
|
29
|
+
IAiToolEnablement,
|
|
30
|
+
IAiCompletionResponse,
|
|
31
|
+
IChatMessage,
|
|
32
|
+
AiApiFormat,
|
|
33
|
+
IAiProviderDescriptor,
|
|
34
|
+
IAiAssistProviderConfig,
|
|
35
|
+
IAiAssistSettings,
|
|
36
|
+
DEFAULT_AI_ASSIST,
|
|
37
|
+
IAiAssistKeyStore,
|
|
38
|
+
ModelSpec,
|
|
39
|
+
ModelSpecKey,
|
|
40
|
+
IModelSpecMap,
|
|
41
|
+
allModelSpecKeys,
|
|
42
|
+
MODEL_SPEC_BASE_KEY,
|
|
43
|
+
resolveModel,
|
|
44
|
+
allProviderIds,
|
|
45
|
+
getProviderDescriptors,
|
|
46
|
+
getProviderDescriptor,
|
|
47
|
+
callProviderCompletion,
|
|
48
|
+
callProxiedCompletion,
|
|
49
|
+
IProviderCompletionParams,
|
|
50
|
+
aiProviderId,
|
|
51
|
+
aiServerToolType,
|
|
52
|
+
aiWebSearchToolConfig,
|
|
53
|
+
aiServerToolConfig,
|
|
54
|
+
aiToolEnablement,
|
|
55
|
+
aiAssistProviderConfig,
|
|
56
|
+
aiAssistSettings,
|
|
57
|
+
modelSpecKey,
|
|
58
|
+
modelSpec,
|
|
59
|
+
resolveEffectiveTools
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export { AiAssist }
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Converter for {@link IAiAssistProviderConfig}.
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
declare const aiAssistProviderConfig: Converter<IAiAssistProviderConfig>;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Converter for {@link IAiAssistSettings}.
|
|
72
|
+
* @public
|
|
73
|
+
*/
|
|
74
|
+
declare const aiAssistSettings: Converter<IAiAssistSettings>;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* A structured AI prompt with system/user split for direct API calls,
|
|
78
|
+
* and a lazily-constructed combined version for copy/paste workflows.
|
|
79
|
+
* @public
|
|
80
|
+
*/
|
|
81
|
+
declare class AiPrompt {
|
|
82
|
+
/** System instructions: schema documentation, format rules, general guidance. */
|
|
83
|
+
readonly system: string;
|
|
84
|
+
/** User request: the specific entity generation request. */
|
|
85
|
+
readonly user: string;
|
|
86
|
+
constructor(user: string, system: string);
|
|
87
|
+
/** Combined single-string version (user + system joined) for copy/paste. */
|
|
88
|
+
get combined(): string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* All known AI provider identifiers.
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
declare type AiProviderId = 'copy-paste' | 'xai-grok' | 'openai' | 'anthropic' | 'google-gemini' | 'groq' | 'mistral';
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Converter for {@link AiProviderId}.
|
|
99
|
+
* @public
|
|
100
|
+
*/
|
|
101
|
+
declare const aiProviderId: Converter<AiProviderId>;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Union of all server-side tool configurations. Discriminated on `type`.
|
|
105
|
+
* @public
|
|
106
|
+
*/
|
|
107
|
+
declare type AiServerToolConfig = IAiWebSearchToolConfig;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Converter for {@link AiServerToolConfig} (discriminated union on `type`).
|
|
111
|
+
* @public
|
|
112
|
+
*/
|
|
113
|
+
declare const aiServerToolConfig: Converter<AiServerToolConfig>;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Built-in server-side tool types supported across providers.
|
|
117
|
+
* @public
|
|
118
|
+
*/
|
|
119
|
+
declare type AiServerToolType = 'web_search';
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Converter for {@link AiServerToolType}.
|
|
123
|
+
* @public
|
|
124
|
+
*/
|
|
125
|
+
declare const aiServerToolType: Converter<AiServerToolType>;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Converter for {@link IAiToolEnablement}.
|
|
129
|
+
* @public
|
|
130
|
+
*/
|
|
131
|
+
declare const aiToolEnablement: Converter<IAiToolEnablement>;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Converter for {@link IAiWebSearchToolConfig}.
|
|
135
|
+
* @public
|
|
136
|
+
*/
|
|
137
|
+
declare const aiWebSearchToolConfig: Converter<IAiWebSearchToolConfig>;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* All valid key store secret types.
|
|
141
|
+
* @public
|
|
142
|
+
*/
|
|
143
|
+
declare const allKeyStoreSecretTypes: ReadonlyArray<KeyStoreSecretType>;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* All valid {@link ModelSpecKey} values.
|
|
147
|
+
* @public
|
|
148
|
+
*/
|
|
149
|
+
declare const allModelSpecKeys: ReadonlyArray<ModelSpecKey>;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* All valid provider ID values, in the same order as the registry.
|
|
153
|
+
* @public
|
|
154
|
+
*/
|
|
155
|
+
declare const allProviderIds: ReadonlyArray<AiProviderId>;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Converter for base64 strings (validates format).
|
|
159
|
+
* @public
|
|
160
|
+
*/
|
|
161
|
+
declare const base64String: Converter<string>;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Calls the appropriate chat completion API for a given provider.
|
|
165
|
+
*
|
|
166
|
+
* Routes based on the provider descriptor's `apiFormat` field:
|
|
167
|
+
* - `'openai'` for xAI, OpenAI, Groq, Mistral
|
|
168
|
+
* - `'anthropic'` for Anthropic Claude
|
|
169
|
+
* - `'gemini'` for Google Gemini
|
|
170
|
+
*
|
|
171
|
+
* When tools are provided and the provider supports them:
|
|
172
|
+
* - OpenAI-format providers switch to the Responses API
|
|
173
|
+
* - Anthropic includes tools in the Messages API request
|
|
174
|
+
* - Gemini includes Google Search grounding
|
|
175
|
+
*
|
|
176
|
+
* @param params - Request parameters including descriptor, API key, prompt, and optional tools
|
|
177
|
+
* @returns The completion response with content and truncation status, or a failure
|
|
178
|
+
* @public
|
|
179
|
+
*/
|
|
180
|
+
declare function callProviderCompletion(params: IProviderCompletionParams): Promise<Result<IAiCompletionResponse>>;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Calls the AI completion endpoint on a proxy server instead of calling
|
|
184
|
+
* the provider API directly from the browser.
|
|
185
|
+
*
|
|
186
|
+
* The proxy server handles provider dispatch, CORS, and API key forwarding.
|
|
187
|
+
* The request shape mirrors {@link IProviderCompletionParams} but is serialized
|
|
188
|
+
* as JSON for the proxy endpoint.
|
|
189
|
+
*
|
|
190
|
+
* @param proxyUrl - Base URL of the proxy server (e.g. `http://localhost:3001`)
|
|
191
|
+
* @param params - Same parameters as {@link callProviderCompletion}
|
|
192
|
+
* @returns The completion response, or a failure
|
|
193
|
+
* @public
|
|
194
|
+
*/
|
|
195
|
+
declare function callProxiedCompletion(proxyUrl: string, params: IProviderCompletionParams): Promise<Result<IAiCompletionResponse>>;
|
|
196
|
+
|
|
197
|
+
declare namespace Constants {
|
|
198
|
+
export {
|
|
199
|
+
ENCRYPTED_FILE_FORMAT,
|
|
200
|
+
DEFAULT_ALGORITHM,
|
|
201
|
+
AES_256_KEY_SIZE,
|
|
202
|
+
GCM_IV_SIZE,
|
|
203
|
+
GCM_AUTH_TAG_SIZE
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
9
207
|
declare namespace Converters {
|
|
10
208
|
export {
|
|
11
209
|
templateString,
|
|
@@ -17,6 +215,87 @@ declare namespace Converters {
|
|
|
17
215
|
}
|
|
18
216
|
export { Converters }
|
|
19
217
|
|
|
218
|
+
declare namespace Converters_2 {
|
|
219
|
+
export {
|
|
220
|
+
keystoreFormat,
|
|
221
|
+
keystoreSecretType,
|
|
222
|
+
keystoreSecretEntryJson,
|
|
223
|
+
keystoreVaultContents,
|
|
224
|
+
keystoreFile
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
declare namespace Converters_3 {
|
|
229
|
+
export {
|
|
230
|
+
createEncryptedFileConverter,
|
|
231
|
+
encryptionAlgorithm,
|
|
232
|
+
encryptedFileFormat,
|
|
233
|
+
encryptedFileErrorMode,
|
|
234
|
+
keyDerivationFunction,
|
|
235
|
+
keyDerivationParams,
|
|
236
|
+
base64String,
|
|
237
|
+
uint8ArrayFromBase64,
|
|
238
|
+
namedSecret,
|
|
239
|
+
encryptedFile
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Creates an {@link CryptoUtils.IEncryptedFile | encrypted file} from JSON content.
|
|
245
|
+
* @typeParam TMetadata - Type of optional unencrypted metadata
|
|
246
|
+
* @param params - Encryption parameters
|
|
247
|
+
* @returns `Success` with encrypted file structure, or `Failure` with an error.
|
|
248
|
+
* @public
|
|
249
|
+
*/
|
|
250
|
+
declare function createEncryptedFile<TMetadata = JsonValue>(params: ICreateEncryptedFileParams<TMetadata>): Promise<Result<IEncryptedFile<TMetadata>>>;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Creates a converter for {@link CryptoUtils.IEncryptedFile | encrypted files} with optional typed metadata.
|
|
254
|
+
* @typeParam TMetadata - Type of optional unencrypted metadata
|
|
255
|
+
* @param metadataConverter - Optional converter for validating metadata field
|
|
256
|
+
* @returns A converter that validates and converts encrypted file structures
|
|
257
|
+
* @public
|
|
258
|
+
*/
|
|
259
|
+
declare function createEncryptedFileConverter<TMetadata = JsonValue>(metadataConverter?: Converter<TMetadata>): Converter<IEncryptedFile<TMetadata>>;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Creates a zip file from an array of text files.
|
|
263
|
+
* @public
|
|
264
|
+
*/
|
|
265
|
+
declare function createZipFromTextFiles(files: ReadonlyArray<IZipTextFile>, options?: ICreateZipOptions): Result<Uint8Array>;
|
|
266
|
+
|
|
267
|
+
declare namespace CryptoUtils {
|
|
268
|
+
export {
|
|
269
|
+
Constants,
|
|
270
|
+
KeyStore,
|
|
271
|
+
Converters_3 as Converters,
|
|
272
|
+
DirectEncryptionProvider,
|
|
273
|
+
IDirectEncryptionProviderParams,
|
|
274
|
+
NodeCryptoProvider,
|
|
275
|
+
nodeCryptoProvider,
|
|
276
|
+
createEncryptedFile,
|
|
277
|
+
decryptFile,
|
|
278
|
+
fromBase64,
|
|
279
|
+
ICreateEncryptedFileParams,
|
|
280
|
+
toBase64,
|
|
281
|
+
tryDecryptFile,
|
|
282
|
+
isEncryptedFile,
|
|
283
|
+
EncryptionAlgorithm,
|
|
284
|
+
EncryptedFileFormat,
|
|
285
|
+
INamedSecret,
|
|
286
|
+
IEncryptionResult,
|
|
287
|
+
KeyDerivationFunction,
|
|
288
|
+
IKeyDerivationParams,
|
|
289
|
+
IEncryptedFile,
|
|
290
|
+
ICryptoProvider,
|
|
291
|
+
IEncryptionProvider,
|
|
292
|
+
EncryptedFileErrorMode,
|
|
293
|
+
SecretProvider,
|
|
294
|
+
IEncryptionConfig
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
export { CryptoUtils }
|
|
298
|
+
|
|
20
299
|
declare namespace Csv {
|
|
21
300
|
export {
|
|
22
301
|
parseCsvString,
|
|
@@ -35,6 +314,37 @@ declare interface CsvOptions {
|
|
|
35
314
|
delimiter?: string;
|
|
36
315
|
}
|
|
37
316
|
|
|
317
|
+
/**
|
|
318
|
+
* Decrypts an {@link CryptoUtils.IEncryptedFile | encrypted file} and returns the JSON content.
|
|
319
|
+
* @typeParam TPayload - Expected type of decrypted content
|
|
320
|
+
* @param file - The encrypted file structure
|
|
321
|
+
* @param key - The decryption key (32 bytes for AES-256)
|
|
322
|
+
* @param cryptoProvider - {@link CryptoUtils.ICryptoProvider | Crypto provider} to use for decryption
|
|
323
|
+
* @param payloadConverter - Optional converter to validate and convert decrypted content
|
|
324
|
+
* @returns `Success` with decrypted content, or `Failure` with an error.
|
|
325
|
+
* @public
|
|
326
|
+
*/
|
|
327
|
+
declare function decryptFile<TPayload extends JsonValue = JsonValue>(file: IEncryptedFile<unknown>, key: Uint8Array, cryptoProvider: ICryptoProvider, payloadConverter?: Converter<TPayload>): Promise<Result<TPayload>>;
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Default AI assist settings (copy-paste only).
|
|
331
|
+
* @public
|
|
332
|
+
*/
|
|
333
|
+
declare const DEFAULT_AI_ASSIST: IAiAssistSettings;
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Default encryption algorithm.
|
|
337
|
+
* @public
|
|
338
|
+
*/
|
|
339
|
+
declare const DEFAULT_ALGORITHM: "AES-256-GCM";
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Default PBKDF2 iterations for key store encryption.
|
|
343
|
+
* Higher than regular files since this protects the master key vault.
|
|
344
|
+
* @public
|
|
345
|
+
*/
|
|
346
|
+
declare const DEFAULT_KEYSTORE_ITERATIONS: number;
|
|
347
|
+
|
|
38
348
|
/**
|
|
39
349
|
* Default {@link Experimental.RangeOfFormats | formats} to use for both
|
|
40
350
|
* open-ended and complete {@link Experimental.RangeOf | RangeOf<T>}.
|
|
@@ -42,6 +352,107 @@ declare interface CsvOptions {
|
|
|
42
352
|
*/
|
|
43
353
|
declare const DEFAULT_RANGEOF_FORMATS: RangeOfFormats;
|
|
44
354
|
|
|
355
|
+
/**
|
|
356
|
+
* Default PBKDF2 iterations for secret-level key derivation.
|
|
357
|
+
* Lower than keystore encryption since these are used more frequently.
|
|
358
|
+
* @public
|
|
359
|
+
*/
|
|
360
|
+
declare const DEFAULT_SECRET_ITERATIONS: number;
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* An {@link IEncryptionProvider} that uses a pre-supplied key and crypto provider.
|
|
364
|
+
*
|
|
365
|
+
* This is useful when you have the raw encryption key from an external source
|
|
366
|
+
* (e.g. a `SecretProvider` callback, password derivation, or a one-shot
|
|
367
|
+
* operation) and don't want to open a full KeyStore.
|
|
368
|
+
*
|
|
369
|
+
* Optionally bound to a specific secret name for safety: if a `boundSecretName`
|
|
370
|
+
* is provided, calls to `encryptByName` with a different name will fail.
|
|
371
|
+
*
|
|
372
|
+
* @example
|
|
373
|
+
* ```typescript
|
|
374
|
+
* const provider = DirectEncryptionProvider.create({
|
|
375
|
+
* cryptoProvider: nodeCryptoProvider,
|
|
376
|
+
* key: myKey,
|
|
377
|
+
* boundSecretName: 'my-collection'
|
|
378
|
+
* }).orThrow();
|
|
379
|
+
*
|
|
380
|
+
* const encrypted = await provider.encryptByName('my-collection', jsonContent);
|
|
381
|
+
* ```
|
|
382
|
+
*
|
|
383
|
+
* @public
|
|
384
|
+
*/
|
|
385
|
+
declare class DirectEncryptionProvider implements IEncryptionProvider {
|
|
386
|
+
private readonly _cryptoProvider;
|
|
387
|
+
private readonly _key;
|
|
388
|
+
private readonly _boundSecretName;
|
|
389
|
+
private constructor();
|
|
390
|
+
/**
|
|
391
|
+
* Creates a new DirectEncryptionProvider.
|
|
392
|
+
* @param params - Provider configuration
|
|
393
|
+
* @returns Success with provider, or Failure if parameters are invalid
|
|
394
|
+
* @public
|
|
395
|
+
*/
|
|
396
|
+
static create(params: IDirectEncryptionProviderParams): Result<DirectEncryptionProvider>;
|
|
397
|
+
/**
|
|
398
|
+
* The secret name this provider is bound to, if any.
|
|
399
|
+
* @public
|
|
400
|
+
*/
|
|
401
|
+
get boundSecretName(): string | undefined;
|
|
402
|
+
/**
|
|
403
|
+
* {@inheritDoc IEncryptionProvider.encryptByName}
|
|
404
|
+
*/
|
|
405
|
+
encryptByName<TMetadata = JsonValue>(secretName: string, content: JsonValue, metadata?: TMetadata): Promise<Result<IEncryptedFile<TMetadata>>>;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Current format version for encrypted files.
|
|
410
|
+
* @public
|
|
411
|
+
*/
|
|
412
|
+
declare const ENCRYPTED_FILE_FORMAT: "encrypted-collection-v1";
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Default converter for encrypted files without typed metadata.
|
|
416
|
+
* @public
|
|
417
|
+
*/
|
|
418
|
+
declare const encryptedFile: Converter<IEncryptedFile>;
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Behavior when an encrypted file cannot be decrypted.
|
|
422
|
+
* @public
|
|
423
|
+
*/
|
|
424
|
+
declare type EncryptedFileErrorMode = 'fail' | 'skip' | 'warn';
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Converter for {@link CryptoUtils.EncryptedFileErrorMode | encrypted file error mode}.
|
|
428
|
+
* @public
|
|
429
|
+
*/
|
|
430
|
+
declare const encryptedFileErrorMode: Converter<EncryptedFileErrorMode>;
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Format version for encrypted files.
|
|
434
|
+
* @public
|
|
435
|
+
*/
|
|
436
|
+
declare type EncryptedFileFormat = typeof Constants.ENCRYPTED_FILE_FORMAT;
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Converter for {@link CryptoUtils.EncryptedFileFormat | encrypted file format} version.
|
|
440
|
+
* @public
|
|
441
|
+
*/
|
|
442
|
+
declare const encryptedFileFormat: Converter<EncryptedFileFormat>;
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Supported encryption algorithms.
|
|
446
|
+
* @public
|
|
447
|
+
*/
|
|
448
|
+
declare type EncryptionAlgorithm = typeof Constants.DEFAULT_ALGORITHM;
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Converter for {@link CryptoUtils.EncryptionAlgorithm | encryption algorithm} values.
|
|
452
|
+
* @public
|
|
453
|
+
*/
|
|
454
|
+
declare const encryptionAlgorithm: Converter<EncryptionAlgorithm>;
|
|
455
|
+
|
|
45
456
|
declare namespace Experimental {
|
|
46
457
|
export {
|
|
47
458
|
ExtendedArray,
|
|
@@ -68,178 +479,1523 @@ export { Experimental }
|
|
|
68
479
|
declare class ExtendedArray<T> extends Array<T> {
|
|
69
480
|
readonly itemDescription: string;
|
|
70
481
|
/**
|
|
71
|
-
* Constructs an {@link Experimental.ExtendedArray | ExtendedArray}.
|
|
72
|
-
* @param itemDescription - Brief description of the type of each item in this array.
|
|
73
|
-
* @param items - The initial contents of the array.
|
|
482
|
+
* Constructs an {@link Experimental.ExtendedArray | ExtendedArray}.
|
|
483
|
+
* @param itemDescription - Brief description of the type of each item in this array.
|
|
484
|
+
* @param items - The initial contents of the array.
|
|
485
|
+
*/
|
|
486
|
+
constructor(itemDescription: string, ...items: T[]);
|
|
487
|
+
/**
|
|
488
|
+
* Type guard to determine if some arbitrary array is an
|
|
489
|
+
* {@link Experimental.ExtendedArray}
|
|
490
|
+
* @param a - The `Array` to be tested.
|
|
491
|
+
* @returns Returns `true` if `a` is an {@link Experimental.ExtendedArray | ExtendedArray},
|
|
492
|
+
* `false` otherwise.
|
|
493
|
+
*/
|
|
494
|
+
static isExtendedArray<T>(a?: T[]): a is ExtendedArray<T>;
|
|
495
|
+
/**
|
|
496
|
+
* Determines if this array contains exactly one element which matches
|
|
497
|
+
* a supplied predicate.
|
|
498
|
+
* @param predicate - The predicate function to be applied.
|
|
499
|
+
* @returns Returns `Success<T>` with the single matching
|
|
500
|
+
* result if exactly one item matches `predicate`. Returns `Failure<T>`
|
|
501
|
+
* with an error message if there are no matches or more than one match.
|
|
502
|
+
*/
|
|
503
|
+
single(predicate?: (item: T) => boolean): Result<T>;
|
|
504
|
+
/**
|
|
505
|
+
* Returns the first element of an {@link Experimental.ExtendedArray | ExtendedArray}. Fails with an
|
|
506
|
+
* error message if the array is empty.
|
|
507
|
+
* @param failMessage - Optional message to be displayed in the event of failure.
|
|
508
|
+
* @returns Returns `Success<T>` with the value of the first element
|
|
509
|
+
* in the array, or `Failure<T>` with an error message if the array is empty.
|
|
510
|
+
*/
|
|
511
|
+
first(failMessage?: string): Result<T>;
|
|
512
|
+
/**
|
|
513
|
+
* Returns an array containing all elements of an {@link Experimental.ExtendedArray | ExtendedArray}.
|
|
514
|
+
* Fails with an error message if the array is empty.
|
|
515
|
+
* @param failMessage - Optional message to be displayed in the event of failure.
|
|
516
|
+
* @returns Returns `Success<T>` with a new (non-extended) `Array`
|
|
517
|
+
* containing the elements of this array, or `Failure<T>` with an error message
|
|
518
|
+
* if the array is empty.
|
|
519
|
+
*/
|
|
520
|
+
atLeastOne(failMessage?: string): Result<T[]>;
|
|
521
|
+
/**
|
|
522
|
+
* Gets a new (non-extended) `Array` containing all of the elements from this
|
|
523
|
+
* {@link Experimental.ExtendedArray | ExtendedArray}.
|
|
524
|
+
* @returns A new (non-extended) `Array<T>`.
|
|
525
|
+
*/
|
|
526
|
+
all(): T[];
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* A helper function to create a `Converter` which converts `unknown` to {@link Experimental.ExtendedArray | ExtendedArray<T>}.
|
|
531
|
+
* @remarks
|
|
532
|
+
* If `onError` is `'failOnError'` (default), then the entire conversion fails if any element cannot
|
|
533
|
+
* be converted. If `onError` is `'ignoreErrors'`, then failing elements are silently ignored.
|
|
534
|
+
* @param converter - `Converter` used to convert each item in the array
|
|
535
|
+
* @param ignoreErrors - Specifies treatment of unconvertible elements
|
|
536
|
+
* @beta
|
|
537
|
+
*/
|
|
538
|
+
declare function extendedArrayOf<T, TC = undefined>(label: string, converter: Converter<T, TC>, onError?: Conversion.OnError): Converter<ExtendedArray<T>, TC>;
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Formats a list of items using the supplied template and formatter, one result
|
|
542
|
+
* per output line.
|
|
543
|
+
* @param format - A mustache template used to format each item.
|
|
544
|
+
* @param items - The items to be formatted.
|
|
545
|
+
* @param itemFormatter - The {@link Experimental.Formatter | Formatter<T>} used to format each item.
|
|
546
|
+
* @returns The resulting string.
|
|
547
|
+
* @beta
|
|
548
|
+
*/
|
|
549
|
+
declare function formatList<T>(format: string, items: T[], itemFormatter: Formatter<T>): Result<string>;
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Interface for an object that can be formatted.
|
|
553
|
+
* @beta
|
|
554
|
+
*/
|
|
555
|
+
declare interface Formattable {
|
|
556
|
+
/**
|
|
557
|
+
* Formats an object using the supplied mustache template.
|
|
558
|
+
* @param format - A mustache template used to format the object.
|
|
559
|
+
* @returns `Success<string>` with the resulting string, or `Failure<string>`
|
|
560
|
+
* with an error message if an error occurs.
|
|
561
|
+
*/
|
|
562
|
+
format(format: string): Result<string>;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* Base class which adds common formatting.
|
|
567
|
+
* @beta
|
|
568
|
+
*/
|
|
569
|
+
declare class FormattableBase {
|
|
570
|
+
/**
|
|
571
|
+
* Helper enables derived classes to add named details to a formatted presentation.
|
|
572
|
+
* @param details - An array of detail description strings.
|
|
573
|
+
* @param label - Label to use for the new detail.
|
|
574
|
+
* @param value - Value to use for the new detail.
|
|
575
|
+
* @internal
|
|
576
|
+
*/
|
|
577
|
+
protected static _tryAddDetail(details: string[], label: string, value: string | undefined): void;
|
|
578
|
+
/**
|
|
579
|
+
* {@inheritDoc Experimental.Formattable.format}
|
|
580
|
+
*/
|
|
581
|
+
format(template: string): Result<string>;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Destination format for some formatted string.
|
|
586
|
+
* @beta
|
|
587
|
+
*/
|
|
588
|
+
declare type FormatTargets = 'text' | 'markdown' | 'embed';
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* Type definition for a formatting function, which takes a `string` and an
|
|
592
|
+
* item and returns `Result<string>`.
|
|
593
|
+
* @beta
|
|
594
|
+
*/
|
|
595
|
+
declare type Formatter<T> = (format: string, item: T) => Result<string>;
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* A collection of {@link Experimental.Formatter | formatters} indexed by target name, to enable
|
|
599
|
+
* different format methods per output target.
|
|
600
|
+
* @beta
|
|
601
|
+
*/
|
|
602
|
+
declare type FormattersByExtendedTarget<TFT extends FormatTargets, T> = Record<TFT, Formatter<T>>;
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* A collection of {@link Experimental.Formatter | formatters} indexed by the
|
|
606
|
+
* {@link Experimental.FormatTargets | default supported target formats}.
|
|
607
|
+
* @beta
|
|
608
|
+
*/
|
|
609
|
+
declare type FormattersByTarget<T> = FormattersByExtendedTarget<FormatTargets, T>;
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Decodes a base64 string to a `Uint8Array`.
|
|
613
|
+
* @param base64 - Base64 string to decode
|
|
614
|
+
* @returns Decoded bytes
|
|
615
|
+
* @public
|
|
616
|
+
*/
|
|
617
|
+
declare function fromBase64(base64: string): Uint8Array;
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* Auth tag size in bytes for GCM mode.
|
|
621
|
+
* @public
|
|
622
|
+
*/
|
|
623
|
+
declare const GCM_AUTH_TAG_SIZE: number;
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* IV size in bytes for GCM mode.
|
|
627
|
+
* @public
|
|
628
|
+
*/
|
|
629
|
+
declare const GCM_IV_SIZE: number;
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Get a provider descriptor by id.
|
|
633
|
+
* @param id - The provider identifier
|
|
634
|
+
* @returns The descriptor, or a failure if the provider is unknown
|
|
635
|
+
* @public
|
|
636
|
+
*/
|
|
637
|
+
declare function getProviderDescriptor(id: string): Result<IAiProviderDescriptor>;
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Get all known provider descriptors. Copy-paste first, then alphabetical.
|
|
641
|
+
* @returns All built-in provider descriptors
|
|
642
|
+
* @public
|
|
643
|
+
*/
|
|
644
|
+
declare function getProviderDescriptors(): ReadonlyArray<IAiProviderDescriptor>;
|
|
645
|
+
|
|
646
|
+
declare namespace Hash {
|
|
647
|
+
export {
|
|
648
|
+
Md5Normalizer
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
export { Hash }
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* Options for adding a secret derived from a password.
|
|
655
|
+
* @public
|
|
656
|
+
*/
|
|
657
|
+
declare interface IAddSecretFromPasswordOptions extends IAddSecretOptions {
|
|
658
|
+
/**
|
|
659
|
+
* Whether to replace an existing secret with the same name.
|
|
660
|
+
*/
|
|
661
|
+
readonly replace?: boolean;
|
|
662
|
+
/**
|
|
663
|
+
* PBKDF2 iterations for key derivation.
|
|
664
|
+
* @defaultValue DEFAULT_SECRET_ITERATIONS (350000)
|
|
665
|
+
*/
|
|
666
|
+
readonly iterations?: number;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* Result of adding a password-derived secret.
|
|
671
|
+
* Extends {@link IAddSecretResult} with key derivation parameters
|
|
672
|
+
* needed to store alongside encrypted files.
|
|
673
|
+
* @public
|
|
674
|
+
*/
|
|
675
|
+
declare interface IAddSecretFromPasswordResult extends IAddSecretResult {
|
|
676
|
+
/**
|
|
677
|
+
* Key derivation parameters used to derive the secret key.
|
|
678
|
+
* Store these in encrypted file metadata so the password alone
|
|
679
|
+
* can re-derive the same key for decryption.
|
|
680
|
+
*/
|
|
681
|
+
readonly keyDerivation: IKeyDerivationParams;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Options for adding a secret.
|
|
686
|
+
* @public
|
|
687
|
+
*/
|
|
688
|
+
declare interface IAddSecretOptions {
|
|
689
|
+
/**
|
|
690
|
+
* Optional description for the secret.
|
|
691
|
+
*/
|
|
692
|
+
readonly description?: string;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
/**
|
|
696
|
+
* Result of adding a secret to the key store.
|
|
697
|
+
* @public
|
|
698
|
+
*/
|
|
699
|
+
declare interface IAddSecretResult {
|
|
700
|
+
/**
|
|
701
|
+
* The secret entry that was added.
|
|
702
|
+
*/
|
|
703
|
+
readonly entry: IKeyStoreSecretEntry;
|
|
704
|
+
/**
|
|
705
|
+
* Whether this replaced an existing secret.
|
|
706
|
+
*/
|
|
707
|
+
readonly replaced: boolean;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* Minimal keystore interface for AI assist API key resolution.
|
|
712
|
+
* Satisfied structurally by the concrete `KeyStore` class from `@fgv/ts-extras`.
|
|
713
|
+
* @public
|
|
714
|
+
*/
|
|
715
|
+
declare interface IAiAssistKeyStore {
|
|
716
|
+
/** Whether the keystore is currently unlocked */
|
|
717
|
+
readonly isUnlocked: boolean;
|
|
718
|
+
/** Check if a named secret exists */
|
|
719
|
+
hasSecret(name: string): Result<boolean>;
|
|
720
|
+
/** Get an API key by secret name */
|
|
721
|
+
getApiKey(name: string): Result<string>;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
* Configuration for a single AI assist provider.
|
|
726
|
+
* @public
|
|
727
|
+
*/
|
|
728
|
+
declare interface IAiAssistProviderConfig {
|
|
729
|
+
/** Which provider this configures */
|
|
730
|
+
readonly provider: AiProviderId;
|
|
731
|
+
/** For API-based providers: the keystore secret name holding the API key */
|
|
732
|
+
readonly secretName?: string;
|
|
733
|
+
/** Optional model override — string or context-aware map. */
|
|
734
|
+
readonly model?: ModelSpec;
|
|
735
|
+
/** Tool enablement/configuration. Tools are disabled unless explicitly enabled. */
|
|
736
|
+
readonly tools?: ReadonlyArray<IAiToolEnablement>;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* AI assist settings — which providers are enabled and their configuration.
|
|
741
|
+
* @public
|
|
742
|
+
*/
|
|
743
|
+
declare interface IAiAssistSettings {
|
|
744
|
+
/** Enabled providers and their configuration. */
|
|
745
|
+
readonly providers: ReadonlyArray<IAiAssistProviderConfig>;
|
|
746
|
+
/** Which enabled provider is the default for the main button. Falls back to first in list. */
|
|
747
|
+
readonly defaultProvider?: AiProviderId;
|
|
748
|
+
/** Optional proxy URL for routing API requests through a backend server (e.g. `http://localhost:3002`). */
|
|
749
|
+
readonly proxyUrl?: string;
|
|
750
|
+
/** When true, route all providers through the proxy. When false (default), only CORS-restricted providers use the proxy. */
|
|
751
|
+
readonly proxyAllProviders?: boolean;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* Result of an AI provider completion call.
|
|
756
|
+
* @public
|
|
757
|
+
*/
|
|
758
|
+
declare interface IAiCompletionResponse {
|
|
759
|
+
/** The generated text content */
|
|
760
|
+
readonly content: string;
|
|
761
|
+
/** Whether the response was truncated due to token limits */
|
|
762
|
+
readonly truncated: boolean;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* Describes a single AI provider — single source of truth for all metadata.
|
|
767
|
+
* @public
|
|
768
|
+
*/
|
|
769
|
+
declare interface IAiProviderDescriptor {
|
|
770
|
+
/** Provider identifier (e.g. 'xai-grok', 'anthropic') */
|
|
771
|
+
readonly id: AiProviderId;
|
|
772
|
+
/** Human-readable label (e.g. "xAI Grok") */
|
|
773
|
+
readonly label: string;
|
|
774
|
+
/** Button label for action buttons (e.g. "AI Assist | Grok") */
|
|
775
|
+
readonly buttonLabel: string;
|
|
776
|
+
/** Whether this provider requires an API key secret */
|
|
777
|
+
readonly needsSecret: boolean;
|
|
778
|
+
/** Which API adapter format to use */
|
|
779
|
+
readonly apiFormat: AiApiFormat;
|
|
780
|
+
/** Base URL for the API (e.g. 'https://api.x.ai/v1') */
|
|
781
|
+
readonly baseUrl: string;
|
|
782
|
+
/** Default model specification — string or context-aware map. */
|
|
783
|
+
readonly defaultModel: ModelSpec;
|
|
784
|
+
/** Which server-side tools this provider supports (empty = none). */
|
|
785
|
+
readonly supportedTools: ReadonlyArray<AiServerToolType>;
|
|
786
|
+
/** Whether this provider's API enforces CORS restrictions that prevent direct browser calls. */
|
|
787
|
+
readonly corsRestricted: boolean;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* Declares a tool as enabled/disabled in provider settings.
|
|
792
|
+
* Tools are disabled by default — consuming apps must opt in explicitly.
|
|
793
|
+
* @public
|
|
794
|
+
*/
|
|
795
|
+
declare interface IAiToolEnablement {
|
|
796
|
+
/** Which tool type. */
|
|
797
|
+
readonly type: AiServerToolType;
|
|
798
|
+
/** Whether this tool is enabled by default for this provider. */
|
|
799
|
+
readonly enabled: boolean;
|
|
800
|
+
/** Optional tool-specific configuration. */
|
|
801
|
+
readonly config?: AiServerToolConfig;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* Configuration specific to web search tools.
|
|
806
|
+
* @public
|
|
807
|
+
*/
|
|
808
|
+
declare interface IAiWebSearchToolConfig {
|
|
809
|
+
readonly type: 'web_search';
|
|
810
|
+
/** Optional: restrict search to these domains. */
|
|
811
|
+
readonly allowedDomains?: ReadonlyArray<string>;
|
|
812
|
+
/** Optional: exclude these domains from search. */
|
|
813
|
+
readonly blockedDomains?: ReadonlyArray<string>;
|
|
814
|
+
/** Optional: max number of searches per request. */
|
|
815
|
+
readonly maxUses?: number;
|
|
816
|
+
/**
|
|
817
|
+
* Optional: enable image understanding during web search.
|
|
818
|
+
* When true, the model can view and analyze images found during search.
|
|
819
|
+
* Currently supported by xAI only; ignored by other providers.
|
|
820
|
+
*/
|
|
821
|
+
readonly enableImageUnderstanding?: boolean;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
/**
|
|
825
|
+
* A single chat message in OpenAI format.
|
|
826
|
+
* @public
|
|
827
|
+
*/
|
|
828
|
+
declare interface IChatMessage {
|
|
829
|
+
/** Message role */
|
|
830
|
+
readonly role: 'system' | 'user' | 'assistant';
|
|
831
|
+
/** Message content */
|
|
832
|
+
readonly content: string;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* Result of context validation, containing details about missing variables.
|
|
837
|
+
* @public
|
|
838
|
+
*/
|
|
839
|
+
declare interface IContextValidationResult {
|
|
840
|
+
/**
|
|
841
|
+
* Whether the context is valid (has all required variables)
|
|
842
|
+
*/
|
|
843
|
+
readonly isValid: boolean;
|
|
844
|
+
/**
|
|
845
|
+
* Variables that are present in the context
|
|
846
|
+
*/
|
|
847
|
+
readonly presentVariables: readonly string[];
|
|
848
|
+
/**
|
|
849
|
+
* Variables that are missing from the context
|
|
850
|
+
*/
|
|
851
|
+
readonly missingVariables: readonly string[];
|
|
852
|
+
/**
|
|
853
|
+
* Detailed information about each missing variable
|
|
854
|
+
*/
|
|
855
|
+
readonly missingDetails: readonly IMissingVariableDetail[];
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
/**
|
|
859
|
+
* Parameters for creating an {@link CryptoUtils.IEncryptedFile | encrypted file}.
|
|
860
|
+
* @typeParam TMetadata - Type of optional unencrypted metadata
|
|
861
|
+
* @public
|
|
862
|
+
*/
|
|
863
|
+
declare interface ICreateEncryptedFileParams<TMetadata = JsonValue> {
|
|
864
|
+
/**
|
|
865
|
+
* The JSON content to encrypt.
|
|
866
|
+
*/
|
|
867
|
+
readonly content: JsonValue;
|
|
868
|
+
/**
|
|
869
|
+
* Name of the secret used for encryption.
|
|
870
|
+
*/
|
|
871
|
+
readonly secretName: string;
|
|
872
|
+
/**
|
|
873
|
+
* The encryption key (32 bytes for AES-256).
|
|
874
|
+
*/
|
|
875
|
+
readonly key: Uint8Array;
|
|
876
|
+
/**
|
|
877
|
+
* {@link CryptoUtils.ICryptoProvider | Crypto provider} to use for encryption.
|
|
878
|
+
*/
|
|
879
|
+
readonly cryptoProvider: ICryptoProvider;
|
|
880
|
+
/**
|
|
881
|
+
* Optional metadata to include unencrypted.
|
|
882
|
+
*/
|
|
883
|
+
readonly metadata?: TMetadata;
|
|
884
|
+
/**
|
|
885
|
+
* Optional converter to validate metadata before including.
|
|
886
|
+
* If provided, metadata will be validated before encryption.
|
|
887
|
+
*/
|
|
888
|
+
readonly metadataConverter?: Converter<TMetadata>;
|
|
889
|
+
/**
|
|
890
|
+
* Optional {@link CryptoUtils.IKeyDerivationParams | key derivation parameters}.
|
|
891
|
+
* If provided, stores the salt and iterations used to derive the key from a password.
|
|
892
|
+
* This allows decryption using only a password (the salt/iterations are read from the file).
|
|
893
|
+
*/
|
|
894
|
+
readonly keyDerivation?: IKeyDerivationParams;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
/**
|
|
898
|
+
* Options for creating a zip file from text files.
|
|
899
|
+
* @public
|
|
900
|
+
*/
|
|
901
|
+
declare interface ICreateZipOptions {
|
|
902
|
+
readonly level?: ZipCompressionLevel;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* Crypto provider interface for cross-platform encryption.
|
|
907
|
+
* Implementations provided for Node.js (crypto module) and browser (Web Crypto API).
|
|
908
|
+
* @public
|
|
909
|
+
*/
|
|
910
|
+
declare interface ICryptoProvider {
|
|
911
|
+
/**
|
|
912
|
+
* Encrypts plaintext using AES-256-GCM.
|
|
913
|
+
* @param plaintext - UTF-8 string to encrypt
|
|
914
|
+
* @param key - 32-byte encryption key
|
|
915
|
+
* @returns Success with encryption result, or Failure with error
|
|
916
|
+
*/
|
|
917
|
+
encrypt(plaintext: string, key: Uint8Array): Promise<Result<IEncryptionResult>>;
|
|
918
|
+
/**
|
|
919
|
+
* Decrypts ciphertext using AES-256-GCM.
|
|
920
|
+
* @param encryptedData - Encrypted bytes
|
|
921
|
+
* @param key - 32-byte decryption key
|
|
922
|
+
* @param iv - Initialization vector (12 bytes)
|
|
923
|
+
* @param authTag - GCM authentication tag (16 bytes)
|
|
924
|
+
* @returns Success with decrypted UTF-8 string, or Failure with error
|
|
925
|
+
*/
|
|
926
|
+
decrypt(encryptedData: Uint8Array, key: Uint8Array, iv: Uint8Array, authTag: Uint8Array): Promise<Result<string>>;
|
|
927
|
+
/**
|
|
928
|
+
* Generates a random 32-byte key suitable for AES-256.
|
|
929
|
+
* @returns Success with generated key, or Failure with error
|
|
930
|
+
*/
|
|
931
|
+
generateKey(): Promise<Result<Uint8Array>>;
|
|
932
|
+
/**
|
|
933
|
+
* Derives a key from a password using PBKDF2.
|
|
934
|
+
* @param password - Password string
|
|
935
|
+
* @param salt - Salt bytes (should be at least 16 bytes)
|
|
936
|
+
* @param iterations - Number of iterations (recommend 100000+)
|
|
937
|
+
* @returns Success with derived 32-byte key, or Failure with error
|
|
938
|
+
*/
|
|
939
|
+
deriveKey(password: string, salt: Uint8Array, iterations: number): Promise<Result<Uint8Array>>;
|
|
940
|
+
/**
|
|
941
|
+
* Generates cryptographically secure random bytes.
|
|
942
|
+
* @param length - Number of bytes to generate
|
|
943
|
+
* @returns Success with random bytes, or Failure with error
|
|
944
|
+
*/
|
|
945
|
+
generateRandomBytes(length: number): Result<Uint8Array>;
|
|
946
|
+
/**
|
|
947
|
+
* Encodes binary data to base64 string.
|
|
948
|
+
* @param data - Binary data to encode
|
|
949
|
+
* @returns Base64-encoded string
|
|
950
|
+
*/
|
|
951
|
+
toBase64(data: Uint8Array): string;
|
|
952
|
+
/**
|
|
953
|
+
* Decodes base64 string to binary data.
|
|
954
|
+
* @param base64 - Base64-encoded string
|
|
955
|
+
* @returns Success with decoded bytes, or Failure if invalid base64
|
|
956
|
+
*/
|
|
957
|
+
fromBase64(base64: string): Result<Uint8Array>;
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
/**
|
|
961
|
+
* Parameters for creating a {@link DirectEncryptionProvider}.
|
|
962
|
+
* @public
|
|
963
|
+
*/
|
|
964
|
+
declare interface IDirectEncryptionProviderParams {
|
|
965
|
+
/**
|
|
966
|
+
* The crypto provider to use for encryption operations.
|
|
967
|
+
*/
|
|
968
|
+
readonly cryptoProvider: ICryptoProvider;
|
|
969
|
+
/**
|
|
970
|
+
* The encryption key (32 bytes for AES-256).
|
|
971
|
+
*/
|
|
972
|
+
readonly key: Uint8Array;
|
|
973
|
+
/**
|
|
974
|
+
* Optional bound secret name.
|
|
975
|
+
* When set, `encryptByName` will fail if called with a different name.
|
|
976
|
+
* When unset, any secret name is accepted.
|
|
977
|
+
*/
|
|
978
|
+
readonly boundSecretName?: string;
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
/**
|
|
982
|
+
* Generic encrypted file format.
|
|
983
|
+
* This is the JSON structure stored in encrypted files.
|
|
984
|
+
* @typeParam TMetadata - Type of optional unencrypted metadata
|
|
985
|
+
* @public
|
|
986
|
+
*/
|
|
987
|
+
declare interface IEncryptedFile<TMetadata = JsonValue> {
|
|
988
|
+
/**
|
|
989
|
+
* Format identifier for versioning.
|
|
990
|
+
*/
|
|
991
|
+
readonly format: EncryptedFileFormat;
|
|
992
|
+
/**
|
|
993
|
+
* Name of the secret required to decrypt (references INamedSecret.name).
|
|
994
|
+
*/
|
|
995
|
+
readonly secretName: string;
|
|
996
|
+
/**
|
|
997
|
+
* Algorithm used for encryption.
|
|
998
|
+
*/
|
|
999
|
+
readonly algorithm: EncryptionAlgorithm;
|
|
1000
|
+
/**
|
|
1001
|
+
* Base64-encoded initialization vector.
|
|
1002
|
+
*/
|
|
1003
|
+
readonly iv: string;
|
|
1004
|
+
/**
|
|
1005
|
+
* Base64-encoded authentication tag (for GCM mode).
|
|
1006
|
+
*/
|
|
1007
|
+
readonly authTag: string;
|
|
1008
|
+
/**
|
|
1009
|
+
* Base64-encoded encrypted data (JSON string when decrypted).
|
|
1010
|
+
*/
|
|
1011
|
+
readonly encryptedData: string;
|
|
1012
|
+
/**
|
|
1013
|
+
* Optional unencrypted metadata for display/filtering.
|
|
1014
|
+
*/
|
|
1015
|
+
readonly metadata?: TMetadata;
|
|
1016
|
+
/**
|
|
1017
|
+
* Optional key derivation parameters.
|
|
1018
|
+
* If present, allows decryption using a password with these parameters.
|
|
1019
|
+
* If absent, a pre-derived key must be provided.
|
|
1020
|
+
*/
|
|
1021
|
+
readonly keyDerivation?: IKeyDerivationParams;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
/**
|
|
1025
|
+
* Configuration for encrypted file handling during loading.
|
|
1026
|
+
* @public
|
|
1027
|
+
*/
|
|
1028
|
+
declare interface IEncryptionConfig {
|
|
1029
|
+
/**
|
|
1030
|
+
* Named secrets available for decryption.
|
|
1031
|
+
*/
|
|
1032
|
+
readonly secrets?: ReadonlyArray<INamedSecret>;
|
|
1033
|
+
/**
|
|
1034
|
+
* Alternative: dynamic secret provider function.
|
|
1035
|
+
* Called when a secret is not found in the secrets array.
|
|
1036
|
+
*/
|
|
1037
|
+
readonly secretProvider?: SecretProvider;
|
|
1038
|
+
/**
|
|
1039
|
+
* Crypto provider implementation (Node.js or browser).
|
|
1040
|
+
*/
|
|
1041
|
+
readonly cryptoProvider: ICryptoProvider;
|
|
1042
|
+
/**
|
|
1043
|
+
* Behavior when decryption key is missing (default: 'fail').
|
|
1044
|
+
*/
|
|
1045
|
+
readonly onMissingKey?: EncryptedFileErrorMode;
|
|
1046
|
+
/**
|
|
1047
|
+
* Behavior when decryption fails (default: 'fail').
|
|
1048
|
+
*/
|
|
1049
|
+
readonly onDecryptionError?: EncryptedFileErrorMode;
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
* High-level interface for encrypting JSON content by secret name.
|
|
1054
|
+
*
|
|
1055
|
+
* This abstraction unifies two common encryption workflows:
|
|
1056
|
+
* - **KeyStore**: looks up the named secret and crypto provider from the vault
|
|
1057
|
+
* - **DirectEncryptionProvider**: uses a pre-supplied key and crypto provider,
|
|
1058
|
+
* optionally bound to a specific secret name for safety
|
|
1059
|
+
*
|
|
1060
|
+
* Callers that need to encrypt (e.g. `EditableCollection.save()`) depend on
|
|
1061
|
+
* this interface rather than on `KeyStore` directly, allowing mix-and-match.
|
|
1062
|
+
*
|
|
1063
|
+
* @public
|
|
1064
|
+
*/
|
|
1065
|
+
declare interface IEncryptionProvider {
|
|
1066
|
+
/**
|
|
1067
|
+
* Encrypts JSON content under a named secret.
|
|
1068
|
+
*
|
|
1069
|
+
* @param secretName - Name of the secret to encrypt with
|
|
1070
|
+
* @param content - JSON-safe content to encrypt
|
|
1071
|
+
* @param metadata - Optional unencrypted metadata to include in the encrypted file
|
|
1072
|
+
* @returns Success with encrypted file structure, or Failure with error context
|
|
1073
|
+
*/
|
|
1074
|
+
encryptByName<TMetadata = JsonValue>(secretName: string, content: JsonValue, metadata?: TMetadata): Promise<Result<IEncryptedFile<TMetadata>>>;
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
/**
|
|
1078
|
+
* Result of an encryption operation.
|
|
1079
|
+
* @public
|
|
1080
|
+
*/
|
|
1081
|
+
declare interface IEncryptionResult {
|
|
1082
|
+
/**
|
|
1083
|
+
* Initialization vector used for encryption (12 bytes for GCM).
|
|
1084
|
+
*/
|
|
1085
|
+
readonly iv: Uint8Array;
|
|
1086
|
+
/**
|
|
1087
|
+
* Authentication tag from GCM mode (16 bytes).
|
|
1088
|
+
*/
|
|
1089
|
+
readonly authTag: Uint8Array;
|
|
1090
|
+
/**
|
|
1091
|
+
* The encrypted data.
|
|
1092
|
+
*/
|
|
1093
|
+
readonly encryptedData: Uint8Array;
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
/**
|
|
1097
|
+
* Options for importing a secret.
|
|
1098
|
+
* @public
|
|
1099
|
+
*/
|
|
1100
|
+
declare interface IImportSecretOptions extends IAddSecretOptions {
|
|
1101
|
+
/**
|
|
1102
|
+
* Whether to replace an existing secret with the same name.
|
|
1103
|
+
*/
|
|
1104
|
+
readonly replace?: boolean;
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
/**
|
|
1108
|
+
* Key derivation parameters stored in encrypted files.
|
|
1109
|
+
* Allows decryption with password without needing to know the original salt/iterations.
|
|
1110
|
+
* @public
|
|
1111
|
+
*/
|
|
1112
|
+
declare interface IKeyDerivationParams {
|
|
1113
|
+
/**
|
|
1114
|
+
* Key derivation function used.
|
|
1115
|
+
*/
|
|
1116
|
+
readonly kdf: KeyDerivationFunction;
|
|
1117
|
+
/**
|
|
1118
|
+
* Base64-encoded salt used for key derivation.
|
|
1119
|
+
*/
|
|
1120
|
+
readonly salt: string;
|
|
1121
|
+
/**
|
|
1122
|
+
* Number of iterations used for key derivation.
|
|
1123
|
+
*/
|
|
1124
|
+
readonly iterations: number;
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
/**
|
|
1128
|
+
* Parameters for creating a new key store.
|
|
1129
|
+
* @public
|
|
1130
|
+
*/
|
|
1131
|
+
declare interface IKeyStoreCreateParams {
|
|
1132
|
+
/**
|
|
1133
|
+
* Crypto provider to use.
|
|
1134
|
+
*/
|
|
1135
|
+
readonly cryptoProvider: ICryptoProvider;
|
|
1136
|
+
/**
|
|
1137
|
+
* PBKDF2 iterations (defaults to DEFAULT_KEYSTORE_ITERATIONS).
|
|
1138
|
+
*/
|
|
1139
|
+
readonly iterations?: number;
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
/**
|
|
1143
|
+
* The encrypted key store file format.
|
|
1144
|
+
* @public
|
|
1145
|
+
*/
|
|
1146
|
+
declare interface IKeyStoreFile {
|
|
1147
|
+
/**
|
|
1148
|
+
* Format identifier.
|
|
1149
|
+
*/
|
|
1150
|
+
readonly format: KeyStoreFormat;
|
|
1151
|
+
/**
|
|
1152
|
+
* Algorithm used for encryption.
|
|
1153
|
+
*/
|
|
1154
|
+
readonly algorithm: EncryptionAlgorithm;
|
|
1155
|
+
/**
|
|
1156
|
+
* Base64-encoded initialization vector.
|
|
1157
|
+
*/
|
|
1158
|
+
readonly iv: string;
|
|
1159
|
+
/**
|
|
1160
|
+
* Base64-encoded authentication tag.
|
|
1161
|
+
*/
|
|
1162
|
+
readonly authTag: string;
|
|
1163
|
+
/**
|
|
1164
|
+
* Base64-encoded encrypted vault contents.
|
|
1165
|
+
*/
|
|
1166
|
+
readonly encryptedData: string;
|
|
1167
|
+
/**
|
|
1168
|
+
* Key derivation parameters (required for key store - always password-derived).
|
|
1169
|
+
*/
|
|
1170
|
+
readonly keyDerivation: IKeyDerivationParams;
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
/**
|
|
1174
|
+
* Parameters for opening an existing key store.
|
|
1175
|
+
* @public
|
|
1176
|
+
*/
|
|
1177
|
+
declare interface IKeyStoreOpenParams {
|
|
1178
|
+
/**
|
|
1179
|
+
* Crypto provider to use.
|
|
1180
|
+
*/
|
|
1181
|
+
readonly cryptoProvider: ICryptoProvider;
|
|
1182
|
+
/**
|
|
1183
|
+
* The encrypted key store file content.
|
|
1184
|
+
*/
|
|
1185
|
+
readonly keystoreFile: IKeyStoreFile;
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
/**
|
|
1189
|
+
* A secret entry stored in the vault (in-memory representation).
|
|
1190
|
+
* @public
|
|
1191
|
+
*/
|
|
1192
|
+
declare interface IKeyStoreSecretEntry {
|
|
1193
|
+
/**
|
|
1194
|
+
* Unique name for this secret (used as lookup key).
|
|
1195
|
+
*/
|
|
1196
|
+
readonly name: string;
|
|
1197
|
+
/**
|
|
1198
|
+
* Secret type discriminator.
|
|
1199
|
+
* Defaults to `'encryption-key'` for backwards compatibility.
|
|
1200
|
+
*/
|
|
1201
|
+
readonly type: KeyStoreSecretType;
|
|
1202
|
+
/**
|
|
1203
|
+
* The secret data.
|
|
1204
|
+
* - For `'encryption-key'`: 32-byte AES-256 key.
|
|
1205
|
+
* - For `'api-key'`: UTF-8 encoded API key string (arbitrary length).
|
|
1206
|
+
*/
|
|
1207
|
+
readonly key: Uint8Array;
|
|
1208
|
+
/**
|
|
1209
|
+
* Optional description for this secret.
|
|
1210
|
+
*/
|
|
1211
|
+
readonly description?: string;
|
|
1212
|
+
/**
|
|
1213
|
+
* When this secret was added (ISO 8601).
|
|
1214
|
+
*/
|
|
1215
|
+
readonly createdAt: string;
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
/**
|
|
1219
|
+
* JSON-serializable version of secret entry (for storage).
|
|
1220
|
+
* @public
|
|
1221
|
+
*/
|
|
1222
|
+
declare interface IKeyStoreSecretEntryJson {
|
|
1223
|
+
/**
|
|
1224
|
+
* Unique name for this secret.
|
|
1225
|
+
*/
|
|
1226
|
+
readonly name: string;
|
|
1227
|
+
/**
|
|
1228
|
+
* Secret type discriminator.
|
|
1229
|
+
* Optional for backwards compatibility — missing means `'encryption-key'`.
|
|
1230
|
+
*/
|
|
1231
|
+
readonly type?: KeyStoreSecretType;
|
|
1232
|
+
/**
|
|
1233
|
+
* Base64-encoded secret data.
|
|
1234
|
+
*/
|
|
1235
|
+
readonly key: string;
|
|
1236
|
+
/**
|
|
1237
|
+
* Optional description.
|
|
1238
|
+
*/
|
|
1239
|
+
readonly description?: string;
|
|
1240
|
+
/**
|
|
1241
|
+
* When this secret was added (ISO 8601).
|
|
1242
|
+
*/
|
|
1243
|
+
readonly createdAt: string;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
/**
|
|
1247
|
+
* The decrypted vault contents - a versioned map of secrets.
|
|
1248
|
+
* @public
|
|
1249
|
+
*/
|
|
1250
|
+
declare interface IKeyStoreVaultContents {
|
|
1251
|
+
/**
|
|
1252
|
+
* Format version for vault contents.
|
|
1253
|
+
*/
|
|
1254
|
+
readonly version: KeyStoreFormat;
|
|
1255
|
+
/**
|
|
1256
|
+
* Map of secret name to secret entry.
|
|
1257
|
+
*/
|
|
1258
|
+
readonly secrets: Record<string, IKeyStoreSecretEntryJson>;
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
/**
|
|
1262
|
+
* Details about a missing variable in context validation.
|
|
1263
|
+
* @public
|
|
1264
|
+
*/
|
|
1265
|
+
declare interface IMissingVariableDetail {
|
|
1266
|
+
/**
|
|
1267
|
+
* The variable reference that is missing
|
|
1268
|
+
*/
|
|
1269
|
+
readonly variable: IVariableRef;
|
|
1270
|
+
/**
|
|
1271
|
+
* The path segment where the lookup failed
|
|
1272
|
+
* (e.g., for 'user.profile.name' if 'profile' is missing, this would be 'profile')
|
|
1273
|
+
*/
|
|
1274
|
+
readonly failedAtSegment?: string;
|
|
1275
|
+
/**
|
|
1276
|
+
* The parent path that exists (e.g., ['user'] if 'user' exists but 'user.profile' does not)
|
|
1277
|
+
*/
|
|
1278
|
+
readonly existingPath: readonly string[];
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
/**
|
|
1282
|
+
* A model specification: either a simple model string or a record mapping
|
|
1283
|
+
* context keys to nested model specs.
|
|
1284
|
+
*
|
|
1285
|
+
* @remarks
|
|
1286
|
+
* A bare string is equivalent to `{ base: string }`. This keeps the simple
|
|
1287
|
+
* case simple while allowing context-aware model selection (e.g. different
|
|
1288
|
+
* models for tool-augmented vs. base completions).
|
|
1289
|
+
*
|
|
1290
|
+
* @example
|
|
1291
|
+
* ```typescript
|
|
1292
|
+
* // Simple — same model for all contexts:
|
|
1293
|
+
* const simple: ModelSpec = 'grok-4-1-fast';
|
|
1294
|
+
*
|
|
1295
|
+
* // Context-aware — reasoning model when tools are active:
|
|
1296
|
+
* const split: ModelSpec = { base: 'grok-4-1-fast', tools: 'grok-4-1-fast-reasoning' };
|
|
1297
|
+
*
|
|
1298
|
+
* // Future nested — per-tool model selection:
|
|
1299
|
+
* const nested: ModelSpec = { base: 'grok-fast', tools: { base: 'grok-r', image: 'grok-v' } };
|
|
1300
|
+
* ```
|
|
1301
|
+
* @public
|
|
1302
|
+
*/
|
|
1303
|
+
declare interface IModelSpecMap {
|
|
1304
|
+
readonly [key: string]: ModelSpec;
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
/**
|
|
1308
|
+
* Options for template parsing and validation.
|
|
1309
|
+
* @public
|
|
1310
|
+
*/
|
|
1311
|
+
declare interface IMustacheTemplateOptions {
|
|
1312
|
+
/**
|
|
1313
|
+
* Custom opening and closing tags (default: `['{{', '}}']`)
|
|
1314
|
+
*/
|
|
1315
|
+
readonly tags?: readonly [string, string];
|
|
1316
|
+
/**
|
|
1317
|
+
* Whether to include comment tokens in variable extraction (default: false)
|
|
1318
|
+
*/
|
|
1319
|
+
readonly includeComments?: boolean;
|
|
1320
|
+
/**
|
|
1321
|
+
* Whether to include partial references in variable extraction (default: false)
|
|
1322
|
+
*/
|
|
1323
|
+
readonly includePartials?: boolean;
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
/**
|
|
1327
|
+
* Named secret for encryption/decryption.
|
|
1328
|
+
* @public
|
|
1329
|
+
*/
|
|
1330
|
+
declare interface INamedSecret {
|
|
1331
|
+
/**
|
|
1332
|
+
* Unique name for this secret (referenced in encrypted files).
|
|
1333
|
+
*/
|
|
1334
|
+
readonly name: string;
|
|
1335
|
+
/**
|
|
1336
|
+
* The actual secret key (32 bytes for AES-256).
|
|
1337
|
+
*/
|
|
1338
|
+
readonly key: Uint8Array;
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
/**
|
|
1342
|
+
* Parameters for a provider completion request.
|
|
1343
|
+
* @public
|
|
1344
|
+
*/
|
|
1345
|
+
declare interface IProviderCompletionParams {
|
|
1346
|
+
/** The provider descriptor */
|
|
1347
|
+
readonly descriptor: IAiProviderDescriptor;
|
|
1348
|
+
/** API key for authentication */
|
|
1349
|
+
readonly apiKey: string;
|
|
1350
|
+
/** The structured prompt to send */
|
|
1351
|
+
readonly prompt: AiPrompt;
|
|
1352
|
+
/**
|
|
1353
|
+
* Additional messages to append after system+user (e.g. for correction retries).
|
|
1354
|
+
* These are appended in order after the initial system and user messages.
|
|
1355
|
+
*/
|
|
1356
|
+
readonly additionalMessages?: ReadonlyArray<IChatMessage>;
|
|
1357
|
+
/** Sampling temperature (default: 0.7) */
|
|
1358
|
+
readonly temperature?: number;
|
|
1359
|
+
/** Optional model override — string or context-aware map (uses descriptor.defaultModel otherwise) */
|
|
1360
|
+
readonly modelOverride?: ModelSpec;
|
|
1361
|
+
/** Optional logger for request/response observability. */
|
|
1362
|
+
readonly logger?: Logging.ILogger;
|
|
1363
|
+
/** Server-side tools to include in the request. Overrides settings-level tool config when provided. */
|
|
1364
|
+
readonly tools?: ReadonlyArray<AiServerToolConfig>;
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
/**
|
|
1368
|
+
* Required version of options with all fields populated.
|
|
1369
|
+
* @internal
|
|
1370
|
+
*/
|
|
1371
|
+
declare interface IRequiredMustacheTemplateOptions {
|
|
1372
|
+
readonly tags: [string, string];
|
|
1373
|
+
readonly includeComments: boolean;
|
|
1374
|
+
readonly includePartials: boolean;
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
/**
|
|
1378
|
+
* Checks if a JSON object appears to be an encrypted file.
|
|
1379
|
+
* Uses the format field as a discriminator.
|
|
1380
|
+
* @param json - JSON object to check
|
|
1381
|
+
* @returns true if the object has the encrypted file format field
|
|
1382
|
+
* @public
|
|
1383
|
+
*/
|
|
1384
|
+
declare function isEncryptedFile(json: unknown): boolean;
|
|
1385
|
+
|
|
1386
|
+
/**
|
|
1387
|
+
* Checks if a JSON object appears to be a key store file.
|
|
1388
|
+
* Uses the format field as a discriminator.
|
|
1389
|
+
* @param json - JSON object to check
|
|
1390
|
+
* @returns true if the object has the key store format field
|
|
1391
|
+
* @public
|
|
1392
|
+
*/
|
|
1393
|
+
declare function isKeyStoreFile(json: unknown): boolean;
|
|
1394
|
+
|
|
1395
|
+
/**
|
|
1396
|
+
* A `Converter` which converts an iso formatted string, a number or a `Date` object to
|
|
1397
|
+
* a `Date` object.
|
|
1398
|
+
* @public
|
|
1399
|
+
*/
|
|
1400
|
+
declare const isoDate: Converter<Date, unknown>;
|
|
1401
|
+
|
|
1402
|
+
/**
|
|
1403
|
+
* Represents a variable reference extracted from a Mustache template.
|
|
1404
|
+
* @public
|
|
1405
|
+
*/
|
|
1406
|
+
declare interface IVariableRef {
|
|
1407
|
+
/**
|
|
1408
|
+
* The raw variable name as it appears in the template (e.g., 'user.name')
|
|
1409
|
+
*/
|
|
1410
|
+
readonly name: string;
|
|
1411
|
+
/**
|
|
1412
|
+
* The path segments parsed from the variable name (e.g., ['user', 'name'])
|
|
1413
|
+
*/
|
|
1414
|
+
readonly path: readonly string[];
|
|
1415
|
+
/**
|
|
1416
|
+
* The type of token this variable was extracted from
|
|
1417
|
+
*/
|
|
1418
|
+
readonly tokenType: MustacheTokenType;
|
|
1419
|
+
/**
|
|
1420
|
+
* Whether this variable is used in a section context (# or ^)
|
|
1421
|
+
* Section variables may reference arrays/objects for iteration
|
|
1422
|
+
*/
|
|
1423
|
+
readonly isSection: boolean;
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
/**
|
|
1427
|
+
* Simple interface for a file to be added to a zip file.
|
|
1428
|
+
* @public
|
|
1429
|
+
*/
|
|
1430
|
+
declare interface IZipTextFile {
|
|
1431
|
+
readonly path: string;
|
|
1432
|
+
readonly contents: string;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
/**
|
|
1436
|
+
* @public
|
|
1437
|
+
*/
|
|
1438
|
+
declare type JarFieldPicker<T extends JarRecord = JarRecord> = (record: T) => (keyof T)[];
|
|
1439
|
+
|
|
1440
|
+
/**
|
|
1441
|
+
* Represents a single record in a JAR file
|
|
1442
|
+
* @public
|
|
1443
|
+
*/
|
|
1444
|
+
declare type JarRecord = Record<string, string | string[]>;
|
|
1445
|
+
|
|
1446
|
+
/**
|
|
1447
|
+
* Options for a JAR record parser.
|
|
1448
|
+
* @public
|
|
1449
|
+
*/
|
|
1450
|
+
declare interface JarRecordParserOptions {
|
|
1451
|
+
readonly arrayFields?: string[] | JarFieldPicker;
|
|
1452
|
+
readonly fixedContinuationSize?: number;
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
/**
|
|
1456
|
+
* Supported key derivation functions.
|
|
1457
|
+
* @public
|
|
1458
|
+
*/
|
|
1459
|
+
declare type KeyDerivationFunction = 'pbkdf2';
|
|
1460
|
+
|
|
1461
|
+
/**
|
|
1462
|
+
* Converter for {@link CryptoUtils.KeyDerivationFunction | key derivation function} type.
|
|
1463
|
+
* @public
|
|
1464
|
+
*/
|
|
1465
|
+
declare const keyDerivationFunction: Converter<KeyDerivationFunction>;
|
|
1466
|
+
|
|
1467
|
+
/**
|
|
1468
|
+
* Converter for {@link CryptoUtils.IKeyDerivationParams | key derivation parameters}.
|
|
1469
|
+
* @public
|
|
1470
|
+
*/
|
|
1471
|
+
declare const keyDerivationParams: Converter<IKeyDerivationParams>;
|
|
1472
|
+
|
|
1473
|
+
declare namespace KeyStore {
|
|
1474
|
+
export {
|
|
1475
|
+
Converters_2 as Converters,
|
|
1476
|
+
KeyStore_2 as KeyStore,
|
|
1477
|
+
isKeyStoreFile,
|
|
1478
|
+
KeyStoreFormat,
|
|
1479
|
+
KEYSTORE_FORMAT,
|
|
1480
|
+
DEFAULT_KEYSTORE_ITERATIONS,
|
|
1481
|
+
MIN_SALT_LENGTH,
|
|
1482
|
+
KeyStoreSecretType,
|
|
1483
|
+
allKeyStoreSecretTypes,
|
|
1484
|
+
IKeyStoreSecretEntry,
|
|
1485
|
+
IKeyStoreSecretEntryJson,
|
|
1486
|
+
IKeyStoreVaultContents,
|
|
1487
|
+
IKeyStoreFile,
|
|
1488
|
+
KeyStoreLockState,
|
|
1489
|
+
IKeyStoreCreateParams,
|
|
1490
|
+
IKeyStoreOpenParams,
|
|
1491
|
+
IAddSecretResult,
|
|
1492
|
+
IAddSecretOptions,
|
|
1493
|
+
IImportSecretOptions,
|
|
1494
|
+
IAddSecretFromPasswordOptions,
|
|
1495
|
+
DEFAULT_SECRET_ITERATIONS,
|
|
1496
|
+
IAddSecretFromPasswordResult
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
/**
|
|
1501
|
+
* Password-protected key store for managing encryption secrets.
|
|
1502
|
+
*
|
|
1503
|
+
* The KeyStore provides a secure vault for storing named encryption keys.
|
|
1504
|
+
* The vault is encrypted at rest using a master password via PBKDF2 key derivation.
|
|
1505
|
+
*
|
|
1506
|
+
* @example
|
|
1507
|
+
* ```typescript
|
|
1508
|
+
* // Create new key store
|
|
1509
|
+
* const keystore = KeyStore.create({ cryptoProvider: nodeCryptoProvider }).orThrow();
|
|
1510
|
+
* await keystore.initialize('master-password');
|
|
1511
|
+
*
|
|
1512
|
+
* // Add secrets
|
|
1513
|
+
* await keystore.addSecret('my-key', { description: 'Production key' });
|
|
1514
|
+
*
|
|
1515
|
+
* // Save to file
|
|
1516
|
+
* const fileContent = await keystore.save();
|
|
1517
|
+
*
|
|
1518
|
+
* // Later: Open existing key store
|
|
1519
|
+
* const keystore2 = KeyStore.open({
|
|
1520
|
+
* cryptoProvider: nodeCryptoProvider,
|
|
1521
|
+
* keystoreFile: fileContent.value
|
|
1522
|
+
* }).orThrow();
|
|
1523
|
+
* await keystore2.unlock('master-password');
|
|
1524
|
+
*
|
|
1525
|
+
* // Use as secret provider for encrypted file loading
|
|
1526
|
+
* const encryptionConfig = keystore2.getEncryptionConfig().orThrow();
|
|
1527
|
+
* ```
|
|
1528
|
+
*
|
|
1529
|
+
* @public
|
|
1530
|
+
*/
|
|
1531
|
+
declare class KeyStore_2 implements IEncryptionProvider {
|
|
1532
|
+
private readonly _cryptoProvider;
|
|
1533
|
+
private readonly _iterations;
|
|
1534
|
+
private _keystoreFile;
|
|
1535
|
+
private _salt;
|
|
1536
|
+
private _secrets;
|
|
1537
|
+
private _state;
|
|
1538
|
+
private _dirty;
|
|
1539
|
+
private _isNew;
|
|
1540
|
+
private constructor();
|
|
1541
|
+
/**
|
|
1542
|
+
* Creates a new, empty key store.
|
|
1543
|
+
* Call `initialize(password)` to set the master password.
|
|
1544
|
+
* @param params - Creation parameters
|
|
1545
|
+
* @returns Success with new KeyStore instance, or Failure if parameters invalid
|
|
1546
|
+
* @public
|
|
1547
|
+
*/
|
|
1548
|
+
static create(params: IKeyStoreCreateParams): Result<KeyStore_2>;
|
|
1549
|
+
/**
|
|
1550
|
+
* Opens an existing encrypted key store.
|
|
1551
|
+
* Call `unlock(password)` to decrypt and access secrets.
|
|
1552
|
+
* @param params - Open parameters including the encrypted file
|
|
1553
|
+
* @returns Success with KeyStore instance, or Failure if file format invalid
|
|
1554
|
+
* @public
|
|
1555
|
+
*/
|
|
1556
|
+
static open(params: IKeyStoreOpenParams): Result<KeyStore_2>;
|
|
1557
|
+
/**
|
|
1558
|
+
* Initializes a new key store with the master password.
|
|
1559
|
+
* Generates a random salt for key derivation.
|
|
1560
|
+
* Only valid for newly created (not opened) key stores.
|
|
1561
|
+
* @param password - The master password
|
|
1562
|
+
* @returns Success with this instance when initialized, Failure if already initialized or opened
|
|
1563
|
+
* @public
|
|
1564
|
+
*/
|
|
1565
|
+
initialize(password: string): Promise<Result<KeyStore_2>>;
|
|
1566
|
+
/**
|
|
1567
|
+
* Unlocks an existing key store with the master password.
|
|
1568
|
+
* Decrypts the vault and loads secrets into memory.
|
|
1569
|
+
* @param password - The master password
|
|
1570
|
+
* @returns Success with this instance when unlocked, Failure if password incorrect
|
|
1571
|
+
* @public
|
|
1572
|
+
*/
|
|
1573
|
+
unlock(password: string): Promise<Result<KeyStore_2>>;
|
|
1574
|
+
/**
|
|
1575
|
+
* Locks the key store, clearing all secrets from memory.
|
|
1576
|
+
* @param force - If true, discards unsaved changes
|
|
1577
|
+
* @returns Success when locked, Failure if unsaved changes and !force
|
|
1578
|
+
* @public
|
|
1579
|
+
*/
|
|
1580
|
+
lock(force?: boolean): Result<KeyStore_2>;
|
|
1581
|
+
/**
|
|
1582
|
+
* Checks if the key store is unlocked.
|
|
1583
|
+
* @public
|
|
1584
|
+
*/
|
|
1585
|
+
get isUnlocked(): boolean;
|
|
1586
|
+
/**
|
|
1587
|
+
* Checks if there are unsaved changes.
|
|
1588
|
+
* @public
|
|
1589
|
+
*/
|
|
1590
|
+
get isDirty(): boolean;
|
|
1591
|
+
/**
|
|
1592
|
+
* Whether this is a newly created key store (not opened from a file).
|
|
1593
|
+
* A new key store must be initialized with a password before use.
|
|
1594
|
+
* An opened key store must be unlocked with the existing password.
|
|
1595
|
+
* @public
|
|
1596
|
+
*/
|
|
1597
|
+
get isNew(): boolean;
|
|
1598
|
+
/**
|
|
1599
|
+
* Gets the current lock state.
|
|
1600
|
+
* @public
|
|
1601
|
+
*/
|
|
1602
|
+
get state(): KeyStoreLockState;
|
|
1603
|
+
/**
|
|
1604
|
+
* Gets the crypto provider used by this key store.
|
|
1605
|
+
* Available regardless of lock state.
|
|
1606
|
+
* @public
|
|
1607
|
+
*/
|
|
1608
|
+
get cryptoProvider(): ICryptoProvider;
|
|
1609
|
+
/**
|
|
1610
|
+
* Lists all secret names in the key store.
|
|
1611
|
+
* @returns Success with array of secret names, Failure if locked
|
|
1612
|
+
* @public
|
|
1613
|
+
*/
|
|
1614
|
+
listSecrets(): Result<readonly string[]>;
|
|
1615
|
+
/**
|
|
1616
|
+
* Gets a secret by name.
|
|
1617
|
+
* @param name - Name of the secret
|
|
1618
|
+
* @returns Success with secret entry, Failure if not found or locked
|
|
1619
|
+
* @public
|
|
1620
|
+
*/
|
|
1621
|
+
getSecret(name: string): Result<IKeyStoreSecretEntry>;
|
|
1622
|
+
/**
|
|
1623
|
+
* Checks if a secret exists.
|
|
1624
|
+
* @param name - Name of the secret
|
|
1625
|
+
* @returns Success with boolean, Failure if locked
|
|
1626
|
+
* @public
|
|
74
1627
|
*/
|
|
75
|
-
|
|
1628
|
+
hasSecret(name: string): Result<boolean>;
|
|
76
1629
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* @param
|
|
80
|
-
* @returns
|
|
81
|
-
*
|
|
1630
|
+
* Adds a new secret with a randomly generated key.
|
|
1631
|
+
* @param name - Unique name for the secret
|
|
1632
|
+
* @param options - Optional description
|
|
1633
|
+
* @returns Success with the generated entry, Failure if locked or name invalid
|
|
1634
|
+
* @public
|
|
82
1635
|
*/
|
|
83
|
-
|
|
1636
|
+
addSecret(name: string, options?: IAddSecretOptions): Promise<Result<IAddSecretResult>>;
|
|
84
1637
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* @param
|
|
88
|
-
* @
|
|
89
|
-
*
|
|
90
|
-
*
|
|
1638
|
+
* Imports an existing secret key.
|
|
1639
|
+
* @param name - Unique name for the secret
|
|
1640
|
+
* @param key - The 32-byte AES-256 key
|
|
1641
|
+
* @param options - Optional description, whether to replace existing
|
|
1642
|
+
* @returns Success with entry, Failure if locked, key invalid, or exists and !replace
|
|
1643
|
+
* @public
|
|
91
1644
|
*/
|
|
92
|
-
|
|
1645
|
+
importSecret(name: string, key: Uint8Array, options?: IImportSecretOptions): Result<IAddSecretResult>;
|
|
93
1646
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
1647
|
+
* Adds a secret derived from a password using PBKDF2.
|
|
1648
|
+
*
|
|
1649
|
+
* Generates a random salt, derives a 32-byte AES-256 key from the password,
|
|
1650
|
+
* and stores it in the vault. Returns the key derivation parameters so they
|
|
1651
|
+
* can be stored alongside encrypted files, enabling decryption with just the
|
|
1652
|
+
* password (without unlocking the keystore).
|
|
1653
|
+
*
|
|
1654
|
+
* @param name - Unique name for the secret
|
|
1655
|
+
* @param password - Password to derive the key from
|
|
1656
|
+
* @param options - Optional description, iterations, replace flag
|
|
1657
|
+
* @returns Success with entry and keyDerivation params, Failure if locked or invalid
|
|
1658
|
+
* @public
|
|
99
1659
|
*/
|
|
100
|
-
|
|
1660
|
+
addSecretFromPassword(name: string, password: string, options?: IAddSecretFromPasswordOptions): Promise<Result<IAddSecretFromPasswordResult>>;
|
|
101
1661
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
* @
|
|
105
|
-
* @
|
|
106
|
-
* containing the elements of this array, or `Failure<T>` with an error message
|
|
107
|
-
* if the array is empty.
|
|
1662
|
+
* Removes a secret by name.
|
|
1663
|
+
* @param name - Name of the secret to remove
|
|
1664
|
+
* @returns Success with removed entry, Failure if not found or locked
|
|
1665
|
+
* @public
|
|
108
1666
|
*/
|
|
109
|
-
|
|
1667
|
+
removeSecret(name: string): Result<IKeyStoreSecretEntry>;
|
|
110
1668
|
/**
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* @
|
|
1669
|
+
* Imports an API key string into the vault.
|
|
1670
|
+
* The string is UTF-8 encoded and stored with type `'api-key'`.
|
|
1671
|
+
* @param name - Unique name for the secret
|
|
1672
|
+
* @param apiKey - The API key string
|
|
1673
|
+
* @param options - Optional description, whether to replace existing
|
|
1674
|
+
* @returns Success with entry, Failure if locked, empty, or exists and !replace
|
|
1675
|
+
* @public
|
|
114
1676
|
*/
|
|
115
|
-
|
|
1677
|
+
importApiKey(name: string, apiKey: string, options?: IImportSecretOptions): Result<IAddSecretResult>;
|
|
1678
|
+
/**
|
|
1679
|
+
* Retrieves an API key string by name.
|
|
1680
|
+
* Only works for secrets with type `'api-key'`.
|
|
1681
|
+
* @param name - Name of the secret
|
|
1682
|
+
* @returns Success with the API key string, Failure if not found, locked, or wrong type
|
|
1683
|
+
* @public
|
|
1684
|
+
*/
|
|
1685
|
+
getApiKey(name: string): Result<string>;
|
|
1686
|
+
/**
|
|
1687
|
+
* Lists secret names filtered by type.
|
|
1688
|
+
* @param type - The secret type to filter by
|
|
1689
|
+
* @returns Success with array of matching secret names, Failure if locked
|
|
1690
|
+
* @public
|
|
1691
|
+
*/
|
|
1692
|
+
listSecretsByType(type: KeyStoreSecretType): Result<readonly string[]>;
|
|
1693
|
+
/**
|
|
1694
|
+
* Renames a secret.
|
|
1695
|
+
* @param oldName - Current name
|
|
1696
|
+
* @param newName - New name
|
|
1697
|
+
* @returns Success with updated entry, Failure if source not found, target exists, or locked
|
|
1698
|
+
* @public
|
|
1699
|
+
*/
|
|
1700
|
+
renameSecret(oldName: string, newName: string): Result<IKeyStoreSecretEntry>;
|
|
1701
|
+
/**
|
|
1702
|
+
* Saves the key store, returning the encrypted file content.
|
|
1703
|
+
* Requires the master password to encrypt.
|
|
1704
|
+
* @param password - The master password
|
|
1705
|
+
* @returns Success with IKeyStoreFile, Failure if locked
|
|
1706
|
+
* @public
|
|
1707
|
+
*/
|
|
1708
|
+
save(password: string): Promise<Result<IKeyStoreFile>>;
|
|
1709
|
+
/**
|
|
1710
|
+
* Changes the master password.
|
|
1711
|
+
* Re-encrypts the vault with the new password-derived key.
|
|
1712
|
+
* @param currentPassword - Current master password (for verification)
|
|
1713
|
+
* @param newPassword - New master password
|
|
1714
|
+
* @returns Success when password changed, Failure if locked or current password incorrect
|
|
1715
|
+
* @public
|
|
1716
|
+
*/
|
|
1717
|
+
changePassword(currentPassword: string, newPassword: string): Promise<Result<KeyStore_2>>;
|
|
1718
|
+
/** {@inheritDoc IEncryptionProvider.encryptByName} */
|
|
1719
|
+
encryptByName<TMetadata = JsonValue>(secretName: string, content: JsonValue, metadata?: TMetadata): Promise<Result<IEncryptedFile<TMetadata>>>;
|
|
1720
|
+
/**
|
|
1721
|
+
* Creates a SecretProvider function for use with IEncryptionConfig.
|
|
1722
|
+
* The returned function looks up secrets from this key store.
|
|
1723
|
+
* @returns Success with SecretProvider, Failure if locked
|
|
1724
|
+
* @public
|
|
1725
|
+
*/
|
|
1726
|
+
getSecretProvider(): Result<SecretProvider>;
|
|
1727
|
+
/**
|
|
1728
|
+
* Creates a partial IEncryptionConfig using this key store as the secret source.
|
|
1729
|
+
* @returns Partial config that can be spread into a full IEncryptionConfig
|
|
1730
|
+
* @public
|
|
1731
|
+
*/
|
|
1732
|
+
getEncryptionConfig(): Result<Pick<IEncryptionConfig, 'secretProvider' | 'cryptoProvider'>>;
|
|
116
1733
|
}
|
|
117
1734
|
|
|
118
1735
|
/**
|
|
119
|
-
*
|
|
120
|
-
* @
|
|
121
|
-
* If `onError` is `'failOnError'` (default), then the entire conversion fails if any element cannot
|
|
122
|
-
* be converted. If `onError` is `'ignoreErrors'`, then failing elements are silently ignored.
|
|
123
|
-
* @param converter - `Converter` used to convert each item in the array
|
|
124
|
-
* @param ignoreErrors - Specifies treatment of unconvertible elements
|
|
125
|
-
* @beta
|
|
1736
|
+
* Current format version constant.
|
|
1737
|
+
* @public
|
|
126
1738
|
*/
|
|
127
|
-
declare
|
|
1739
|
+
declare const KEYSTORE_FORMAT: KeyStoreFormat;
|
|
128
1740
|
|
|
129
1741
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* @param format - A mustache template used to format each item.
|
|
133
|
-
* @param items - The items to be formatted.
|
|
134
|
-
* @param itemFormatter - The {@link Experimental.Formatter | Formatter<T>} used to format each item.
|
|
135
|
-
* @returns The resulting string.
|
|
136
|
-
* @beta
|
|
1742
|
+
* Converter for {@link CryptoUtils.KeyStore.IKeyStoreFile | encrypted key store file}.
|
|
1743
|
+
* @public
|
|
137
1744
|
*/
|
|
138
|
-
declare
|
|
1745
|
+
declare const keystoreFile: Converter<IKeyStoreFile>;
|
|
139
1746
|
|
|
140
1747
|
/**
|
|
141
|
-
*
|
|
142
|
-
* @
|
|
1748
|
+
* Format version for key store files.
|
|
1749
|
+
* @public
|
|
143
1750
|
*/
|
|
144
|
-
declare
|
|
145
|
-
/**
|
|
146
|
-
* Formats an object using the supplied mustache template.
|
|
147
|
-
* @param format - A mustache template used to format the object.
|
|
148
|
-
* @returns `Success<string>` with the resulting string, or `Failure<string>`
|
|
149
|
-
* with an error message if an error occurs.
|
|
150
|
-
*/
|
|
151
|
-
format(format: string): Result<string>;
|
|
152
|
-
}
|
|
1751
|
+
declare type KeyStoreFormat = 'keystore-v1';
|
|
153
1752
|
|
|
154
1753
|
/**
|
|
155
|
-
*
|
|
156
|
-
* @
|
|
1754
|
+
* Converter for {@link CryptoUtils.KeyStore.KeyStoreFormat | key store format} version.
|
|
1755
|
+
* @public
|
|
157
1756
|
*/
|
|
158
|
-
declare
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
1757
|
+
declare const keystoreFormat: Converter<KeyStoreFormat>;
|
|
1758
|
+
|
|
1759
|
+
/**
|
|
1760
|
+
* Key store lock state.
|
|
1761
|
+
* @public
|
|
1762
|
+
*/
|
|
1763
|
+
declare type KeyStoreLockState = 'locked' | 'unlocked';
|
|
1764
|
+
|
|
1765
|
+
/**
|
|
1766
|
+
* Converter for {@link CryptoUtils.KeyStore.IKeyStoreSecretEntryJson | key store secret entry} in JSON format.
|
|
1767
|
+
* The `type` field is optional for backwards compatibility — missing means `'encryption-key'`.
|
|
1768
|
+
* @public
|
|
1769
|
+
*/
|
|
1770
|
+
declare const keystoreSecretEntryJson: Converter<IKeyStoreSecretEntryJson>;
|
|
1771
|
+
|
|
1772
|
+
/**
|
|
1773
|
+
* Discriminator for secret types stored in the vault.
|
|
1774
|
+
* - `'encryption-key'`: A 32-byte AES-256 encryption key.
|
|
1775
|
+
* - `'api-key'`: An arbitrary-length API key string (UTF-8 encoded).
|
|
1776
|
+
* @public
|
|
1777
|
+
*/
|
|
1778
|
+
declare type KeyStoreSecretType = 'encryption-key' | 'api-key';
|
|
1779
|
+
|
|
1780
|
+
/**
|
|
1781
|
+
* Converter for {@link CryptoUtils.KeyStore.KeyStoreSecretType | key store secret type} discriminator.
|
|
1782
|
+
* @public
|
|
1783
|
+
*/
|
|
1784
|
+
declare const keystoreSecretType: Converter<KeyStoreSecretType>;
|
|
1785
|
+
|
|
1786
|
+
/**
|
|
1787
|
+
* Converter for {@link CryptoUtils.KeyStore.IKeyStoreVaultContents | key store vault contents} (decrypted state).
|
|
1788
|
+
* @public
|
|
1789
|
+
*/
|
|
1790
|
+
declare const keystoreVaultContents: Converter<IKeyStoreVaultContents>;
|
|
1791
|
+
|
|
1792
|
+
/**
|
|
1793
|
+
* A hashing normalizer which computes object
|
|
1794
|
+
* hash using the MD5 algorithm.
|
|
1795
|
+
* @public
|
|
1796
|
+
*/
|
|
1797
|
+
declare class Md5Normalizer extends Hash_2.HashingNormalizer {
|
|
1798
|
+
constructor();
|
|
1799
|
+
static md5Hash(parts: string[]): string;
|
|
171
1800
|
}
|
|
172
1801
|
|
|
173
1802
|
/**
|
|
174
|
-
*
|
|
175
|
-
* @
|
|
1803
|
+
* Minimum salt length for key derivation.
|
|
1804
|
+
* @public
|
|
176
1805
|
*/
|
|
177
|
-
declare
|
|
1806
|
+
declare const MIN_SALT_LENGTH: number;
|
|
178
1807
|
|
|
179
1808
|
/**
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
* @beta
|
|
1809
|
+
* Default context key used as fallback when resolving a {@link ModelSpec}.
|
|
1810
|
+
* @public
|
|
183
1811
|
*/
|
|
184
|
-
declare
|
|
1812
|
+
declare const MODEL_SPEC_BASE_KEY: ModelSpecKey;
|
|
185
1813
|
|
|
186
1814
|
/**
|
|
187
|
-
*
|
|
188
|
-
* different format methods per output target.
|
|
189
|
-
* @beta
|
|
1815
|
+
* @public
|
|
190
1816
|
*/
|
|
191
|
-
declare type
|
|
1817
|
+
declare type ModelSpec = string | IModelSpecMap;
|
|
192
1818
|
|
|
193
1819
|
/**
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
* @
|
|
1820
|
+
* Recursive converter for {@link ModelSpec}.
|
|
1821
|
+
* Accepts a string or an object whose values are themselves ModelSpec values,
|
|
1822
|
+
* with keys constrained to known {@link ModelSpecKey} values.
|
|
1823
|
+
* Uses the `self` parameter from `Converters.generic` for recursion.
|
|
1824
|
+
* @public
|
|
197
1825
|
*/
|
|
198
|
-
declare
|
|
1826
|
+
declare const modelSpec: Converter<ModelSpec>;
|
|
199
1827
|
|
|
200
|
-
|
|
1828
|
+
/**
|
|
1829
|
+
* Known context keys for model specification maps.
|
|
1830
|
+
* @public
|
|
1831
|
+
*/
|
|
1832
|
+
declare type ModelSpecKey = 'base' | 'tools' | 'image';
|
|
1833
|
+
|
|
1834
|
+
/**
|
|
1835
|
+
* Converter for {@link ModelSpecKey}.
|
|
1836
|
+
* @public
|
|
1837
|
+
*/
|
|
1838
|
+
declare const modelSpecKey: Converter<ModelSpecKey>;
|
|
1839
|
+
|
|
1840
|
+
declare namespace Mustache {
|
|
201
1841
|
export {
|
|
202
|
-
|
|
1842
|
+
IContextValidationResult,
|
|
1843
|
+
IMissingVariableDetail,
|
|
1844
|
+
IMustacheTemplateOptions,
|
|
1845
|
+
IVariableRef,
|
|
1846
|
+
MustacheTokenType,
|
|
1847
|
+
MustacheTemplate
|
|
203
1848
|
}
|
|
204
1849
|
}
|
|
205
|
-
export {
|
|
1850
|
+
export { Mustache }
|
|
206
1851
|
|
|
207
1852
|
/**
|
|
208
|
-
* A
|
|
209
|
-
*
|
|
1853
|
+
* A helper class for working with Mustache templates that provides
|
|
1854
|
+
* validation, variable extraction, and context validation utilities.
|
|
210
1855
|
* @public
|
|
211
1856
|
*/
|
|
212
|
-
declare
|
|
1857
|
+
declare class MustacheTemplate {
|
|
1858
|
+
/**
|
|
1859
|
+
* The original template string
|
|
1860
|
+
*/
|
|
1861
|
+
readonly template: string;
|
|
1862
|
+
/**
|
|
1863
|
+
* The options used for parsing this template
|
|
1864
|
+
*/
|
|
1865
|
+
readonly options: Readonly<IRequiredMustacheTemplateOptions>;
|
|
1866
|
+
private readonly _tokens;
|
|
1867
|
+
private _variables?;
|
|
1868
|
+
private constructor();
|
|
1869
|
+
/**
|
|
1870
|
+
* Creates a new MustacheTemplate instance.
|
|
1871
|
+
* @param template - The Mustache template string to parse
|
|
1872
|
+
* @param options - Optional parsing options
|
|
1873
|
+
* @returns Success with the template instance, or Failure if parsing fails
|
|
1874
|
+
*/
|
|
1875
|
+
static create(template: string, options?: IMustacheTemplateOptions): Result<MustacheTemplate>;
|
|
1876
|
+
/**
|
|
1877
|
+
* Validates that a template string has valid Mustache syntax.
|
|
1878
|
+
* @param template - The template string to validate
|
|
1879
|
+
* @param options - Optional parsing options
|
|
1880
|
+
* @returns Success with true if valid, or Failure with a descriptive error message
|
|
1881
|
+
*/
|
|
1882
|
+
static validate(template: string, options?: IMustacheTemplateOptions): Result<true>;
|
|
1883
|
+
/**
|
|
1884
|
+
* Checks if this template instance has valid syntax.
|
|
1885
|
+
* Always returns Success(true) since parsing succeeded in create().
|
|
1886
|
+
* @returns Success with true
|
|
1887
|
+
*/
|
|
1888
|
+
validate(): Result<true>;
|
|
1889
|
+
/**
|
|
1890
|
+
* Extracts all variable references from the template.
|
|
1891
|
+
* @returns An array of variable references found in the template
|
|
1892
|
+
*/
|
|
1893
|
+
extractVariables(): readonly IVariableRef[];
|
|
1894
|
+
/**
|
|
1895
|
+
* Extracts unique variable names from the template.
|
|
1896
|
+
* @returns An array of unique variable name strings (e.g., ['user.name', 'items'])
|
|
1897
|
+
*/
|
|
1898
|
+
extractVariableNames(): readonly string[];
|
|
1899
|
+
/**
|
|
1900
|
+
* Validates that a context object has all required variables.
|
|
1901
|
+
* @param context - The context object to validate
|
|
1902
|
+
* @returns Success with validation result containing details about present/missing variables
|
|
1903
|
+
*/
|
|
1904
|
+
validateContext(context: unknown): Result<IContextValidationResult>;
|
|
1905
|
+
/**
|
|
1906
|
+
* Renders the template with the given context.
|
|
1907
|
+
* Use this for pre-validated contexts where you've already checked
|
|
1908
|
+
* that all required variables are present.
|
|
1909
|
+
* @param context - The context object for template rendering
|
|
1910
|
+
* @returns Success with the rendered string, or Failure if rendering fails
|
|
1911
|
+
*/
|
|
1912
|
+
render(context: unknown): Result<string>;
|
|
1913
|
+
/**
|
|
1914
|
+
* Validates the context and renders the template if validation passes.
|
|
1915
|
+
* @param context - The context object to validate and render with
|
|
1916
|
+
* @returns Success with the rendered string, or Failure with validation or render errors
|
|
1917
|
+
*/
|
|
1918
|
+
validateAndRender(context: unknown): Result<string>;
|
|
1919
|
+
private static _resolveOptions;
|
|
1920
|
+
private static _parseTokens;
|
|
1921
|
+
private _extractVariablesFromTokens;
|
|
1922
|
+
private _parsePath;
|
|
1923
|
+
private _lookupPath;
|
|
1924
|
+
}
|
|
213
1925
|
|
|
214
1926
|
/**
|
|
1927
|
+
* Type of a Mustache token as returned by Mustache.parse()
|
|
215
1928
|
* @public
|
|
216
1929
|
*/
|
|
217
|
-
declare type
|
|
1930
|
+
declare type MustacheTokenType = 'text' | 'name' | '&' | '#' | '^' | '!' | '>' | '=';
|
|
218
1931
|
|
|
219
1932
|
/**
|
|
220
|
-
*
|
|
1933
|
+
* Converter for {@link CryptoUtils.INamedSecret | named secret} from JSON representation.
|
|
1934
|
+
* Expects key as base64 string in JSON, converts to Uint8Array.
|
|
221
1935
|
* @public
|
|
222
1936
|
*/
|
|
223
|
-
declare
|
|
1937
|
+
declare const namedSecret: Converter<INamedSecret>;
|
|
224
1938
|
|
|
225
1939
|
/**
|
|
226
|
-
*
|
|
1940
|
+
* Node.js implementation of {@link CryptoUtils.ICryptoProvider} using the built-in crypto module.
|
|
1941
|
+
* Uses AES-256-GCM for authenticated encryption.
|
|
227
1942
|
* @public
|
|
228
1943
|
*/
|
|
229
|
-
declare
|
|
230
|
-
|
|
231
|
-
|
|
1944
|
+
declare class NodeCryptoProvider implements ICryptoProvider {
|
|
1945
|
+
/**
|
|
1946
|
+
* Encrypts plaintext using AES-256-GCM.
|
|
1947
|
+
* @param plaintext - UTF-8 string to encrypt
|
|
1948
|
+
* @param key - 32-byte encryption key
|
|
1949
|
+
* @returns `Success` with encryption result, or `Failure` with an error.
|
|
1950
|
+
*/
|
|
1951
|
+
encrypt(plaintext: string, key: Uint8Array): Promise<Result<IEncryptionResult>>;
|
|
1952
|
+
/**
|
|
1953
|
+
* Decrypts ciphertext using AES-256-GCM.
|
|
1954
|
+
* @param encryptedData - Encrypted bytes
|
|
1955
|
+
* @param key - 32-byte decryption key
|
|
1956
|
+
* @param iv - Initialization vector (12 bytes)
|
|
1957
|
+
* @param authTag - GCM authentication tag (16 bytes)
|
|
1958
|
+
* @returns `Success` with decrypted UTF-8 string, or `Failure` with an error.
|
|
1959
|
+
*/
|
|
1960
|
+
decrypt(encryptedData: Uint8Array, key: Uint8Array, iv: Uint8Array, authTag: Uint8Array): Promise<Result<string>>;
|
|
1961
|
+
/**
|
|
1962
|
+
* Generates a random 32-byte key suitable for AES-256.
|
|
1963
|
+
* @returns `Success` with generated key, or `Failure` with an error.
|
|
1964
|
+
*/
|
|
1965
|
+
generateKey(): Promise<Result<Uint8Array>>;
|
|
1966
|
+
/**
|
|
1967
|
+
* Derives a key from a password using PBKDF2.
|
|
1968
|
+
* @param password - Password string
|
|
1969
|
+
* @param salt - Salt bytes (should be at least 16 bytes)
|
|
1970
|
+
* @param iterations - Number of iterations (recommend 100000+)
|
|
1971
|
+
* @returns `Success` with derived 32-byte key, or `Failure` with an error.
|
|
1972
|
+
*/
|
|
1973
|
+
deriveKey(password: string, salt: Uint8Array, iterations: number): Promise<Result<Uint8Array>>;
|
|
1974
|
+
/**
|
|
1975
|
+
* Generates cryptographically secure random bytes.
|
|
1976
|
+
* @param length - Number of bytes to generate
|
|
1977
|
+
* @returns Success with random bytes, or Failure with error
|
|
1978
|
+
*/
|
|
1979
|
+
generateRandomBytes(length: number): Result<Uint8Array>;
|
|
1980
|
+
/**
|
|
1981
|
+
* Encodes binary data to base64 string.
|
|
1982
|
+
* @param data - Binary data to encode
|
|
1983
|
+
* @returns Base64-encoded string
|
|
1984
|
+
*/
|
|
1985
|
+
toBase64(data: Uint8Array): string;
|
|
1986
|
+
/**
|
|
1987
|
+
* Decodes base64 string to binary data.
|
|
1988
|
+
* @param base64 - Base64-encoded string
|
|
1989
|
+
* @returns Success with decoded bytes, or Failure if invalid base64
|
|
1990
|
+
*/
|
|
1991
|
+
fromBase64(base64: string): Result<Uint8Array>;
|
|
232
1992
|
}
|
|
233
1993
|
|
|
234
1994
|
/**
|
|
235
|
-
*
|
|
236
|
-
* hash using the MD5 algorithm.
|
|
1995
|
+
* Singleton instance of {@link CryptoUtils.NodeCryptoProvider}.
|
|
237
1996
|
* @public
|
|
238
1997
|
*/
|
|
239
|
-
declare
|
|
240
|
-
constructor();
|
|
241
|
-
static md5Hash(parts: string[]): string;
|
|
242
|
-
}
|
|
1998
|
+
declare const nodeCryptoProvider: NodeCryptoProvider;
|
|
243
1999
|
|
|
244
2000
|
/**
|
|
245
2001
|
* Parses CSV data from a string.
|
|
@@ -446,6 +2202,45 @@ declare namespace RecordJar {
|
|
|
446
2202
|
}
|
|
447
2203
|
export { RecordJar }
|
|
448
2204
|
|
|
2205
|
+
/**
|
|
2206
|
+
* Resolves the effective tools for a completion call.
|
|
2207
|
+
*
|
|
2208
|
+
* - If per-call tools are provided, they override settings-level tools entirely.
|
|
2209
|
+
* - Otherwise, settings-level enabled tools are used.
|
|
2210
|
+
* - Only tools supported by the provider are included.
|
|
2211
|
+
* - Returns an empty array if no tools are enabled (= no tools sent).
|
|
2212
|
+
*
|
|
2213
|
+
* @param descriptor - The provider descriptor (used to filter by supported tools)
|
|
2214
|
+
* @param settingsTools - Tool enablement from provider settings (optional)
|
|
2215
|
+
* @param perCallTools - Per-call tool override (optional)
|
|
2216
|
+
* @returns The resolved list of tool configs to include in the request
|
|
2217
|
+
* @public
|
|
2218
|
+
*/
|
|
2219
|
+
declare function resolveEffectiveTools(descriptor: IAiProviderDescriptor, settingsTools?: ReadonlyArray<IAiToolEnablement>, perCallTools?: ReadonlyArray<AiServerToolConfig>): ReadonlyArray<AiServerToolConfig>;
|
|
2220
|
+
|
|
2221
|
+
/**
|
|
2222
|
+
* Resolves a {@link ModelSpec} to a concrete model string given an optional context key.
|
|
2223
|
+
*
|
|
2224
|
+
* @remarks
|
|
2225
|
+
* Resolution rules:
|
|
2226
|
+
* 1. If the spec is a string, return it directly (context is irrelevant).
|
|
2227
|
+
* 2. If the spec is an object and the context key exists, recurse into that branch.
|
|
2228
|
+
* 3. Otherwise, fall back to the {@link MODEL_SPEC_BASE_KEY | 'base'} key.
|
|
2229
|
+
* 4. If neither context nor `'base'` exists, use the first available value.
|
|
2230
|
+
*
|
|
2231
|
+
* @param spec - The model specification to resolve
|
|
2232
|
+
* @param context - Optional context key (e.g. `'tools'`)
|
|
2233
|
+
* @returns The resolved model string
|
|
2234
|
+
* @public
|
|
2235
|
+
*/
|
|
2236
|
+
declare function resolveModel(spec: ModelSpec, context?: string): string;
|
|
2237
|
+
|
|
2238
|
+
/**
|
|
2239
|
+
* Function type for dynamic secret retrieval.
|
|
2240
|
+
* @public
|
|
2241
|
+
*/
|
|
2242
|
+
declare type SecretProvider = (secretName: string) => Promise<Result<Uint8Array>>;
|
|
2243
|
+
|
|
449
2244
|
/**
|
|
450
2245
|
* Helper function to create a `StringConverter` which converts
|
|
451
2246
|
* `unknown` to `string`, applying template conversions supplied at construction time or at
|
|
@@ -458,6 +2253,55 @@ export { RecordJar }
|
|
|
458
2253
|
*/
|
|
459
2254
|
declare function templateString(defaultContext?: unknown): Conversion.StringConverter<string, unknown>;
|
|
460
2255
|
|
|
2256
|
+
/**
|
|
2257
|
+
* Encodes a `Uint8Array` to a base64 string.
|
|
2258
|
+
* @param bytes - Bytes to encode
|
|
2259
|
+
* @returns Base64 string
|
|
2260
|
+
* @public
|
|
2261
|
+
*/
|
|
2262
|
+
declare function toBase64(bytes: Uint8Array): string;
|
|
2263
|
+
|
|
2264
|
+
/**
|
|
2265
|
+
* Attempts to parse and decrypt a JSON object as an {@link CryptoUtils.IEncryptedFile | encrypted file}.
|
|
2266
|
+
* @typeParam TPayload - Expected type of decrypted content
|
|
2267
|
+
* @typeParam TMetadata - Type of optional unencrypted metadata
|
|
2268
|
+
* @param json - JSON object that may be an encrypted file
|
|
2269
|
+
* @param key - The decryption key (32 bytes for AES-256)
|
|
2270
|
+
* @param cryptoProvider - {@link CryptoUtils.ICryptoProvider | Crypto provider} to use for decryption
|
|
2271
|
+
* @param payloadConverter - Optional converter to validate and convert decrypted content
|
|
2272
|
+
* @param metadataConverter - Optional converter to validate metadata before decryption
|
|
2273
|
+
* @returns `Success` with decrypted content, or `Failure` with an error (including if not encrypted)
|
|
2274
|
+
* @public
|
|
2275
|
+
*/
|
|
2276
|
+
declare function tryDecryptFile<TPayload extends JsonValue = JsonValue, TMetadata = JsonValue>(json: JsonValue, key: Uint8Array, cryptoProvider: ICryptoProvider, payloadConverter?: Converter<TPayload>, metadataConverter?: Converter<TMetadata>): Promise<Result<TPayload>>;
|
|
2277
|
+
|
|
2278
|
+
/**
|
|
2279
|
+
* Converter which converts a base64 string to a Uint8Array.
|
|
2280
|
+
* @public
|
|
2281
|
+
*/
|
|
2282
|
+
declare const uint8ArrayFromBase64: Converter<Uint8Array>;
|
|
2283
|
+
|
|
2284
|
+
declare namespace Yaml {
|
|
2285
|
+
export {
|
|
2286
|
+
yamlConverter
|
|
2287
|
+
}
|
|
2288
|
+
}
|
|
2289
|
+
export { Yaml }
|
|
2290
|
+
|
|
2291
|
+
/**
|
|
2292
|
+
* Creates a converter that parses YAML string content and then applies the supplied converter.
|
|
2293
|
+
* @param converter - Converter to apply to the parsed YAML
|
|
2294
|
+
* @returns Converter that parses YAML then validates
|
|
2295
|
+
* @public
|
|
2296
|
+
*/
|
|
2297
|
+
declare function yamlConverter<T>(converter: Converter<T>): Converter<T>;
|
|
2298
|
+
|
|
2299
|
+
/**
|
|
2300
|
+
* Supported compression levels for zip files.
|
|
2301
|
+
* @public
|
|
2302
|
+
*/
|
|
2303
|
+
declare type ZipCompressionLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
2304
|
+
|
|
461
2305
|
/**
|
|
462
2306
|
* Implementation of `IFileTreeDirectoryItem` for directories in a ZIP archive.
|
|
463
2307
|
* @public
|
|
@@ -493,6 +2337,8 @@ declare class ZipDirectoryItem<TCT extends string = string> implements FileTree.
|
|
|
493
2337
|
|
|
494
2338
|
/**
|
|
495
2339
|
* Implementation of `FileTree.IFileTreeFileItem` for files in a ZIP archive.
|
|
2340
|
+
* ZIP files are read-only, so this item does not support mutation.
|
|
2341
|
+
* Use {@link FileTree.isMutableFileItem | isMutableFileItem} to check before attempting mutations.
|
|
496
2342
|
* @public
|
|
497
2343
|
*/
|
|
498
2344
|
declare class ZipFileItem<TCT extends string = string> implements FileTree.IFileTreeFileItem<TCT> {
|
|
@@ -563,13 +2409,19 @@ declare namespace ZipFileTree {
|
|
|
563
2409
|
export {
|
|
564
2410
|
ZipFileTreeAccessors,
|
|
565
2411
|
ZipFileItem,
|
|
566
|
-
ZipDirectoryItem
|
|
2412
|
+
ZipDirectoryItem,
|
|
2413
|
+
createZipFromTextFiles,
|
|
2414
|
+
IZipTextFile,
|
|
2415
|
+
ZipCompressionLevel,
|
|
2416
|
+
ICreateZipOptions
|
|
567
2417
|
}
|
|
568
2418
|
}
|
|
569
2419
|
export { ZipFileTree }
|
|
570
2420
|
|
|
571
2421
|
/**
|
|
572
|
-
*
|
|
2422
|
+
* Read-only file tree accessors for ZIP archives.
|
|
2423
|
+
* ZIP archives are read-only by design — use {@link FileTree.isMutableAccessors | isMutableAccessors}
|
|
2424
|
+
* to check before attempting mutations.
|
|
573
2425
|
* @public
|
|
574
2426
|
*/
|
|
575
2427
|
declare class ZipFileTreeAccessors<TCT extends string = string> implements FileTree.IFileTreeAccessors<TCT> {
|