libmodulor 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -1
- package/README.md +3 -3
- package/dist/esm/app/workers/AppSrcFilePathBuilder.d.ts +16 -0
- package/dist/esm/app/workers/AppSrcFilePathBuilder.js +6 -4
- package/dist/esm/apps/Helper/index.js +1 -0
- package/dist/esm/apps/Helper/src/ucds/GenerateAppsTestsUCD.js +3 -2
- package/dist/esm/bundlers/vite/StripUCDLifecycleServerPlugin.js +3 -0
- package/dist/esm/convention.d.ts +1 -0
- package/dist/esm/convention.js +17 -4
- package/dist/esm/dt/Validation.d.ts +8 -0
- package/dist/esm/dt/Validation.js +8 -0
- package/dist/esm/dt/base/TBase.d.ts +2 -1
- package/dist/esm/dt/base/TBoolean.js +2 -0
- package/dist/esm/dt/base/TInt.js +3 -0
- package/dist/esm/dt/base/TNumber.js +2 -0
- package/dist/esm/dt/base/TObject.d.ts +15 -0
- package/dist/esm/dt/base/TObject.js +14 -0
- package/dist/esm/dt/base/TString.js +1 -1
- package/dist/esm/dt/final/TAmount.js +1 -0
- package/dist/esm/dt/final/TCountryISO3166Alpha2.js +1 -0
- package/dist/esm/dt/final/TCurrencyISO4217.js +1 -0
- package/dist/esm/dt/final/TDateTimeFormat.js +1 -0
- package/dist/esm/dt/final/TEmail.js +2 -0
- package/dist/esm/dt/final/TEmoji.js +4 -0
- package/dist/esm/dt/final/TFile.js +3 -0
- package/dist/esm/dt/final/THostAddress.js +2 -0
- package/dist/esm/dt/final/TIPv6.js +1 -0
- package/dist/esm/dt/final/TJWT.js +8 -0
- package/dist/esm/dt/final/TPercentage.js +5 -0
- package/dist/esm/dt/final/TSQLQuery.js +1 -0
- package/dist/esm/dt/final/TSSHPrivateKey.js +3 -1
- package/dist/esm/dt/final/TSemVerVersion.js +1 -0
- package/dist/esm/dt/final/TShellCommand.js +1 -0
- package/dist/esm/dt/final/TURL.js +2 -0
- package/dist/esm/dt/final/TUUID.js +1 -0
- package/dist/esm/dt/final/TYesNo.js +1 -1
- package/dist/esm/i18n/WordingManager.d.ts +16 -0
- package/dist/esm/i18n/types.d.ts +5 -0
- package/dist/esm/icon/Icon.d.ts +7 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/product/manifest.d.ts +15 -0
- package/dist/esm/products/Helper/index.js +3 -0
- package/dist/esm/products/Helper/manifest.d.ts +6 -1
- package/dist/esm/std/BufferManager.d.ts +18 -0
- package/dist/esm/std/ClockManager.d.ts +5 -0
- package/dist/esm/std/EnvironmentManager.d.ts +10 -0
- package/dist/esm/std/HTTPAPICaller.d.ts +6 -0
- package/dist/esm/std/I18nManager.d.ts +26 -0
- package/dist/esm/std/JWTManager.d.ts +26 -0
- package/dist/esm/std/JobManager.d.ts +6 -0
- package/dist/esm/std/LLMManager.d.ts +25 -0
- package/dist/esm/std/LLMManager.js +1 -0
- package/dist/esm/std/PromptManager.d.ts +8 -0
- package/dist/esm/std/SettingsManager.d.ts +19 -0
- package/dist/esm/std/SettingsManager.js +9 -0
- package/dist/esm/std/impl/ConsoleLogger.js +7 -1
- package/dist/esm/std/impl/FakeEmailManager.js +1 -0
- package/dist/esm/std/impl/FakeJobManager.js +1 -0
- package/dist/esm/std/impl/FetchHTTPAPICallExecutor.d.ts +9 -0
- package/dist/esm/std/impl/FetchHTTPAPICallExecutor.js +11 -0
- package/dist/esm/std/impl/MistralAILLMManager.d.ts +17 -0
- package/dist/esm/std/impl/MistralAILLMManager.js +56 -0
- package/dist/esm/std/impl/NodeCryptoManager.js +6 -1
- package/dist/esm/std/impl/NodeDeterministicCryptoManager.d.ts +14 -0
- package/dist/esm/std/impl/NodeDeterministicCryptoManager.js +17 -3
- package/dist/esm/std/impl/NodeFSManager.js +10 -0
- package/dist/esm/std/impl/NodeHTTPAPICallExecutorAgentBuilder.js +2 -0
- package/dist/esm/std/impl/NodePromptManager.js +3 -0
- package/dist/esm/std/impl/OllamaLLMManager.d.ts +20 -0
- package/dist/esm/std/impl/OllamaLLMManager.js +56 -0
- package/dist/esm/std/impl/OpenAILLMManager.d.ts +17 -0
- package/dist/esm/std/impl/OpenAILLMManager.js +51 -0
- package/dist/esm/std/impl/SimpleHTTPAPICaller.js +14 -0
- package/dist/esm/std/impl/SimpleMapI18nManager.js +4 -2
- package/dist/esm/std/impl/StdDateClockManager.js +3 -0
- package/dist/esm/std/impl/UCDataStoreExternalResourceManager.js +3 -0
- package/dist/esm/std/impl/WebCryptoManager.js +9 -0
- package/dist/esm/std/index.d.ts +1 -0
- package/dist/esm/std/index.js +1 -0
- package/dist/esm/target/lib/cli/renderer.js +3 -0
- package/dist/esm/target/lib/client/consts.d.ts +3 -0
- package/dist/esm/target/lib/client/consts.js +3 -0
- package/dist/esm/target/lib/mcp-server/MCPServerBooter.js +1 -0
- package/dist/esm/target/lib/react/UCContainer.js +1 -0
- package/dist/esm/target/lib/react/UCPanel.js +4 -0
- package/dist/esm/target/lib/react/useUC.d.ts +8 -0
- package/dist/esm/target/lib/react/useUC.js +22 -0
- package/dist/esm/target/lib/react/useUCOR.d.ts +15 -0
- package/dist/esm/target/lib/react/useUCOR.js +45 -0
- package/dist/esm/target/lib/rn/input.d.ts +7 -0
- package/dist/esm/target/lib/rn/input.js +2 -0
- package/dist/esm/target/lib/server/AuthenticationChecker.js +2 -1
- package/dist/esm/target/lib/server/BasicAuthenticationChecker.js +1 -0
- package/dist/esm/target/lib/server/CSPDirectivesBuilder.js +13 -0
- package/dist/esm/target/lib/server/CustomerFacingErrorBuilder.js +3 -0
- package/dist/esm/target/lib/server/PrivateApiKeyAuthenticationChecker.js +1 -0
- package/dist/esm/target/lib/server/PublicApiKeyChecker.js +1 -1
- package/dist/esm/target/lib/server/RequestChecker.js +5 -4
- package/dist/esm/target/lib/server/RequestHandler.d.ts +5 -0
- package/dist/esm/target/lib/server/RequestLogger.js +5 -0
- package/dist/esm/target/lib/server/ServerManager.d.ts +19 -0
- package/dist/esm/target/lib/server/consts.d.ts +3 -0
- package/dist/esm/target/lib/server/consts.js +3 -0
- package/dist/esm/target/lib/web/input.d.ts +21 -0
- package/dist/esm/target/lib/web/input.js +4 -0
- package/dist/esm/target/node-core-cli/NodeCoreCLIManager.js +2 -2
- package/dist/esm/target/node-express-server/NodeExpressServerManager.js +5 -0
- package/dist/esm/target/node-express-server/lib/AuthCookieCreator.js +1 -1
- package/dist/esm/target/node-express-server/middlewares/AuthenticationCheckerMiddlewareBuilder.js +1 -0
- package/dist/esm/target/node-express-server/middlewares/PublicApiKeyCheckerMiddlewareBuilder.js +1 -0
- package/dist/esm/target/node-express-server/middlewares/RequestCheckerMiddlewareBuilder.js +1 -0
- package/dist/esm/target/node-express-server/middlewares/RequestHandlerMiddlewareBuilder.js +8 -0
- package/dist/esm/target/node-express-server/middlewares/RequestLoggerMiddlewareBuilder.js +1 -0
- package/dist/esm/target/node-mcp-server/NodeLocalStdioMCPServerManager.d.ts +10 -0
- package/dist/esm/target/node-mcp-server/NodeLocalStdioMCPServerManager.js +14 -0
- package/dist/esm/target/react-native-pure/UCFormFieldControl.js +1 -0
- package/dist/esm/testing/AppTester.d.ts +4 -0
- package/dist/esm/testing/AppTester.js +16 -0
- package/dist/esm/testing/AppTesterConfigurator.d.ts +68 -0
- package/dist/esm/testing/UCDataStoreTester.d.ts +9 -0
- package/dist/esm/testing/UCDataStoreTester.js +13 -0
- package/dist/esm/testing/impl/SimpleAppDocsEmitter.js +22 -2
- package/dist/esm/testing/impl/SimpleAppTesterConfigurator.js +1 -0
- package/dist/esm/testing/impl/SimpleHTMLAppTestReportEmitter.js +9 -3
- package/dist/esm/testing/impl/TypeScriptLibUCDefASTParser.js +12 -4
- package/dist/esm/testing/impl/VitestAppTestSuiteEmitter.js +6 -0
- package/dist/esm/testing/opts.d.ts +38 -0
- package/dist/esm/testing/opts.js +1 -1
- package/dist/esm/testing/uc-input.js +2 -0
- package/dist/esm/testing/workers/AppTesterCtxInitializer.js +7 -0
- package/dist/esm/testing/workers/UCExecutor.js +1 -0
- package/dist/esm/testing/workers/checkers/AppIndexChecker.js +1 -0
- package/dist/esm/testing/workers/checkers/UCDefSourcesChecker.js +4 -0
- package/dist/esm/uc/UC.js +19 -1
- package/dist/esm/uc/UCInputField.d.ts +28 -0
- package/dist/esm/uc/UCInputField.js +42 -0
- package/dist/esm/uc/data.d.ts +3 -0
- package/dist/esm/uc/def.d.ts +7 -0
- package/dist/esm/uc/exec.d.ts +39 -0
- package/dist/esm/uc/exec.js +29 -0
- package/dist/esm/uc/ext.d.ts +30 -1
- package/dist/esm/uc/helpers/UCOutputBuilder.js +5 -0
- package/dist/esm/uc/helpers/UCOutputReader.js +3 -1
- package/dist/esm/uc/impl/HTTPUCTransporter.js +4 -0
- package/dist/esm/uc/impl/InMemoryUCDataStore.js +7 -0
- package/dist/esm/uc/impl/KnexUCDataStore.d.ts +4 -0
- package/dist/esm/uc/impl/KnexUCDataStore.js +14 -0
- package/dist/esm/uc/impl/SimpleUCManager.js +6 -0
- package/dist/esm/uc/input-field.d.ts +60 -0
- package/dist/esm/uc/input-field.js +33 -0
- package/dist/esm/uc/input.d.ts +24 -0
- package/dist/esm/uc/lifecycle/client/IdleClientMain.js +1 -0
- package/dist/esm/uc/lifecycle/server/IdleServerMain.js +2 -0
- package/dist/esm/uc/manager.d.ts +11 -0
- package/dist/esm/uc/metadata.d.ts +10 -0
- package/dist/esm/uc/opi-layout.d.ts +3 -0
- package/dist/esm/uc/opi.d.ts +8 -0
- package/dist/esm/uc/output-field.d.ts +9 -0
- package/dist/esm/uc/output-part.d.ts +22 -0
- package/dist/esm/uc/output.d.ts +3 -0
- package/dist/esm/uc/policies/RoleRegularUCPolicy.js +1 -0
- package/dist/esm/uc/policies/funcs.js +1 -0
- package/dist/esm/uc/policy.d.ts +22 -0
- package/dist/esm/uc/sec.d.ts +9 -0
- package/dist/esm/uc/server.d.ts +10 -0
- package/dist/esm/uc/settings.d.ts +25 -0
- package/dist/esm/uc/side-effect.d.ts +16 -0
- package/dist/esm/uc/side-effect.js +16 -0
- package/dist/esm/uc/utils/rInput.d.ts +12 -0
- package/dist/esm/uc/utils/rInput.js +2 -0
- package/dist/esm/uc/utils/rVal.d.ts +25 -0
- package/dist/esm/uc/utils/rVal.js +27 -0
- package/dist/esm/uc/utils/recIs.d.ts +9 -0
- package/dist/esm/uc/utils/recIs.js +12 -1
- package/dist/esm/uc/utils/stripUCDLifecycleServer.d.ts +13 -0
- package/dist/esm/uc/utils/stripUCDLifecycleServer.js +17 -0
- package/dist/esm/uc/utils/ucifcoIsForArray.d.ts +6 -0
- package/dist/esm/uc/utils/ucifcoIsForArray.js +6 -0
- package/dist/esm/uc/workers/SimpleAggregateFinder.d.ts +12 -0
- package/dist/esm/uc/workers/SimpleAggregateFinder.js +12 -0
- package/dist/esm/uc/workers/UCBuilder.d.ts +7 -0
- package/dist/esm/uc/workers/UCBuilder.js +7 -0
- package/dist/esm/uc/workers/UCExecChecker.js +2 -0
- package/dist/esm/uc/workers/UCInputFilesProcessor.js +10 -4
- package/dist/esm/uc/workers/UCOutputFilesProcessor.js +6 -2
- package/dist/esm/utils/async/sleep.d.ts +10 -0
- package/dist/esm/utils/async/sleep.js +10 -0
- package/dist/esm/utils/http/appendData.js +5 -1
- package/dist/esm/utils/ioc/ContainerPrinter.js +2 -0
- package/dist/esm/utils/ioc/bindCommon.js +4 -0
- package/dist/esm/utils/ioc/bindNodeCLI.js +2 -0
- package/dist/esm/utils/ioc/bindNodeCore.js +1 -0
- package/dist/esm/utils/ioc/bindProduct.js +2 -0
- package/dist/esm/utils/ioc/bindRN.js +1 -0
- package/dist/esm/utils/ioc/bindServer.js +1 -0
- package/dist/esm/utils/ioc/bindWeb.js +2 -0
- package/dist/esm/utils/ioc/container.js +6 -0
- package/dist/esm/utils/numbers/units.js +3 -0
- package/dist/esm/utils/types/funcs.d.ts +35 -0
- package/dist/esm/utils/types/funcs.js +35 -0
- package/dist/esm/utils/types/utility-types.d.ts +17 -0
- package/dist/esm/utils/types/utility-types.js +1 -0
- package/package.json +9 -9
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
import type { AppName } from '../app/index.js';
|
|
2
2
|
import type { UCName } from '../uc/index.js';
|
|
3
3
|
export interface ProductAppReg {
|
|
4
|
+
/**
|
|
5
|
+
* It must correspond to the app folder name in the {@link APPS_ROOT_PATH}.
|
|
6
|
+
*/
|
|
4
7
|
name: AppName;
|
|
8
|
+
/**
|
|
9
|
+
* By default, a product mounts all the enabled use cases of an app.
|
|
10
|
+
*
|
|
11
|
+
* With this, you can override this default behavior.
|
|
12
|
+
*/
|
|
5
13
|
ucds?: {
|
|
14
|
+
/**
|
|
15
|
+
* Use Cases to exclude from the product
|
|
16
|
+
*
|
|
17
|
+
* For example, you can have a generic `Auth` app, used in multiple products.
|
|
18
|
+
* Some of them will require `SignUp` while others won't. With this setting,
|
|
19
|
+
* you can exclude the use cases that you don't want. In this case, they won't be mounted.
|
|
20
|
+
*/
|
|
6
21
|
exclude?: UCName[];
|
|
7
22
|
} | undefined;
|
|
8
23
|
}
|
|
@@ -3,6 +3,9 @@ import { NodeCoreCLIManager } from '../../target/node-core-cli/NodeCoreCLIManage
|
|
|
3
3
|
import container from './container.js';
|
|
4
4
|
const i18nManager = container.get('I18nManager');
|
|
5
5
|
await i18nManager.init();
|
|
6
|
+
// Before screaming, yes, this is not using any powerful CLI library.
|
|
7
|
+
// The goal is to reduce the usage of dependencies as much as possible.
|
|
8
|
+
// As long as the built-in Node.js API allows to build it without too many workarounds, let's keep it this way.
|
|
6
9
|
await container.resolve(NodeCoreCLIManager).handleCommand({
|
|
7
10
|
appsRootPath: container
|
|
8
11
|
.get('FSManager')
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
export type BufferManagerBase64String = string;
|
|
2
|
+
/**
|
|
3
|
+
* The `Buffer` api is available in Node and similar server side environments. But it's not in browsers.
|
|
4
|
+
*
|
|
5
|
+
* Hence the need for this interface to provide multiple implementations (e.g. using https://github.com/feross/buffer).
|
|
6
|
+
*
|
|
7
|
+
* But the problem is that both implementations are redundant.
|
|
8
|
+
*
|
|
9
|
+
* TODO : Consider alternatives to BufferManager
|
|
10
|
+
*
|
|
11
|
+
* Possible solutions :
|
|
12
|
+
*
|
|
13
|
+
* - Import the buffer lib as a polyfill
|
|
14
|
+
* - Use only ECMAScript compatible primitives (`ArrayBuffer`, `Uint8Array`, `DataView`, etc.)
|
|
15
|
+
* - Use BinaryJS
|
|
16
|
+
* - Use Fast-Buffer
|
|
17
|
+
*
|
|
18
|
+
* Note that for the last two, keeping this interface makes actually sense since other impl. not `Buffer`-like can be used.
|
|
19
|
+
*/
|
|
2
20
|
export interface BufferManager {
|
|
3
21
|
decodeBase64<T extends string>(value: BufferManagerBase64String): T;
|
|
4
22
|
decodeUint8Array<T extends string>(value: Uint8Array): T;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { Timestamp } from '../dt/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* A key representing the date (e.g. 20241125141012)
|
|
4
|
+
*
|
|
5
|
+
* Useful to set a prefix when naming files in order to sort them
|
|
6
|
+
*/
|
|
2
7
|
export type ClockManagerDateKey = string;
|
|
3
8
|
export interface ClockManager {
|
|
4
9
|
now(): Date;
|
|
@@ -3,6 +3,16 @@ export type EnvironmentManagerEnvVarName = string;
|
|
|
3
3
|
type Browser = 'chrome' | 'edge' | 'firefox' | 'opera' | 'safari';
|
|
4
4
|
type MobileOS = 'android' | 'ios';
|
|
5
5
|
type OS = 'darwin' | 'linux' | 'macos' | 'windows' | 'windows_nt';
|
|
6
|
+
/**
|
|
7
|
+
* The type of environment
|
|
8
|
+
*
|
|
9
|
+
* The goal of this is not to give the final platform where the runtime is executed.
|
|
10
|
+
* For instance, in the context of a browser, we want to know that it's running on 'firefox' and not 'macos'.
|
|
11
|
+
*
|
|
12
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Navigator/platform
|
|
13
|
+
* @see https://reactnative.dev/docs/platform#os
|
|
14
|
+
* @see https://nodejs.org/api/os.html#ostype
|
|
15
|
+
*/
|
|
6
16
|
export type EnvironmentManagerType = Browser | MobileOS | OS | (string & {});
|
|
7
17
|
export interface EnvironmentManager {
|
|
8
18
|
cwd(): FilePath;
|
|
@@ -18,6 +18,9 @@ export interface HTTPAPICallerInputOpts {
|
|
|
18
18
|
xml?: XMLManagerParseOpts;
|
|
19
19
|
}
|
|
20
20
|
export interface HTTPAPICallerInput<AH extends object | undefined, Req extends object, ResBad, ResGood, O> {
|
|
21
|
+
/**
|
|
22
|
+
* They are the last ones to be set so they will override any other header already set by `authorizationHeader` or `basicAuth` if any.
|
|
23
|
+
*/
|
|
21
24
|
additionalHeadersBuilder?: AdditionalHeadersBuilder<AH> | undefined;
|
|
22
25
|
authorizationHeader?: HTTPAPICallerAuthorizationHeader | undefined;
|
|
23
26
|
basicAuth?: HTTPAPICallerBasicAuth | undefined;
|
|
@@ -25,6 +28,9 @@ export interface HTTPAPICallerInput<AH extends object | undefined, Req extends o
|
|
|
25
28
|
errBuilder: ErrBuilder<ResBad>;
|
|
26
29
|
method: HTTPMethod;
|
|
27
30
|
opts?: HTTPAPICallerInputOpts | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* If not set, it will assume that `ResGood` and `O` are the same and thus return `ResGood` as is.
|
|
33
|
+
*/
|
|
28
34
|
outputBuilder?: OutputBuilder<ResGood, O> | undefined;
|
|
29
35
|
req?: {
|
|
30
36
|
builder: ReqBuilder<Req>;
|
|
@@ -7,8 +7,34 @@ export interface I18nManagerTOpts {
|
|
|
7
7
|
vars?: Record<string, string>;
|
|
8
8
|
}
|
|
9
9
|
export interface I18nManager extends Initializable {
|
|
10
|
+
/**
|
|
11
|
+
* Add a translation key
|
|
12
|
+
*
|
|
13
|
+
* It might not work for all the implementations, depending on where the translations are stored.
|
|
14
|
+
*
|
|
15
|
+
* @param key
|
|
16
|
+
* @param value
|
|
17
|
+
*/
|
|
10
18
|
add<K extends I18nTranslationKey>(key: K, value: string): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Get the current lang code
|
|
21
|
+
*/
|
|
11
22
|
l(): I18nLanguageCode;
|
|
23
|
+
/**
|
|
24
|
+
* Get the translation for the given key
|
|
25
|
+
*
|
|
26
|
+
* If the key is missing, it should return `opts.fallback` if any. Otherwise, it should return the key itself.
|
|
27
|
+
*
|
|
28
|
+
* Optionally it can fail (by throwing) but that is not recommended since it impacts end users.
|
|
29
|
+
*
|
|
30
|
+
* @param key
|
|
31
|
+
* @param opts
|
|
32
|
+
*/
|
|
12
33
|
t<T extends I18nTranslationKey>(key: T, opts?: I18nManagerTOpts): string;
|
|
34
|
+
/**
|
|
35
|
+
* Get the translation for the given key, otherwise `null`
|
|
36
|
+
* @param key
|
|
37
|
+
* @param opts
|
|
38
|
+
*/
|
|
13
39
|
tOrNull<T extends I18nTranslationKey>(key: T, opts?: I18nManagerTOpts): string | null;
|
|
14
40
|
}
|
|
@@ -16,6 +16,9 @@ export interface JWTManagerSettings extends Settings {
|
|
|
16
16
|
jwt_manager_subject: string | null;
|
|
17
17
|
}
|
|
18
18
|
export type JWTManagerDecodeOpts = Pick<JWTManagerEncodeOpts, 'secret'> & {
|
|
19
|
+
/**
|
|
20
|
+
* The public key to verify JWTs using an `alg` of type `RS*`
|
|
21
|
+
*/
|
|
19
22
|
spki?: SSHPublicKey;
|
|
20
23
|
};
|
|
21
24
|
export interface JWTManagerEncodeOpts {
|
|
@@ -28,7 +31,30 @@ export interface JWTManagerEncodeOpts {
|
|
|
28
31
|
sub?: JWTManagerSettings['jwt_manager_subject'];
|
|
29
32
|
}
|
|
30
33
|
export interface JWTManager {
|
|
34
|
+
/**
|
|
35
|
+
* Decode the token
|
|
36
|
+
*
|
|
37
|
+
* Pass the ad-hoc opts when using a specific `alg` (e.g. `spki` when decoding a `RS*` token).
|
|
38
|
+
* If invalid, it must throw an {@link UnauthorizedError} (no errors related to the impl. should be thrown).
|
|
39
|
+
*
|
|
40
|
+
* @param value
|
|
41
|
+
* @param opts
|
|
42
|
+
*/
|
|
31
43
|
decode<T extends JWTManagerPayload>(value: JWT, opts?: JWTManagerDecodeOpts): Promise<T>;
|
|
44
|
+
/**
|
|
45
|
+
* Encode the payload
|
|
46
|
+
*
|
|
47
|
+
* It uses the global {@link JWTManagerSettings} or the ones provided via `opts`.
|
|
48
|
+
*
|
|
49
|
+
* @param payload
|
|
50
|
+
* @param opts
|
|
51
|
+
*/
|
|
32
52
|
encode<T extends object>(payload: T, opts?: JWTManagerEncodeOpts): Promise<JWT>;
|
|
53
|
+
/**
|
|
54
|
+
* Check whether the token is usable or not
|
|
55
|
+
*
|
|
56
|
+
* Note that the signature is not checked. Indeed, the main purpose of this method is to be used client side to save some requests (e.g. when the token is expired).
|
|
57
|
+
* In this case, no need to send a request that will trigger an error. Better to renew the token at the client's initiative.
|
|
58
|
+
*/
|
|
33
59
|
isUsable(value: JWT): Promise<boolean>;
|
|
34
60
|
}
|
|
@@ -13,5 +13,11 @@ export interface JobManagerSettings extends Settings {
|
|
|
13
13
|
}[];
|
|
14
14
|
}
|
|
15
15
|
export interface JobManager extends Clearable, Initializable {
|
|
16
|
+
/**
|
|
17
|
+
* Send a new job on the queue for processing
|
|
18
|
+
* @param queueName
|
|
19
|
+
* @param jobName
|
|
20
|
+
* @param input
|
|
21
|
+
*/
|
|
16
22
|
dispatch<I>(queueName: JobManagerQueueName, jobName: JobManagerJobName, input: I): Promise<void>;
|
|
17
23
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { FreeTextLong } from '../dt/index.js';
|
|
2
|
+
export type LLMManagerModel = string;
|
|
3
|
+
export type LLMManagerTemperature = number;
|
|
4
|
+
export interface LLMManagerSendReq {
|
|
5
|
+
messages: {
|
|
6
|
+
content: FreeTextLong;
|
|
7
|
+
/**
|
|
8
|
+
* In the case of OpenAI :
|
|
9
|
+
* > With o1 models and newer, developer messages replace the previous system messages
|
|
10
|
+
*/
|
|
11
|
+
role: 'assistant' | 'developer' | 'system' | 'user';
|
|
12
|
+
}[];
|
|
13
|
+
model: LLMManagerModel;
|
|
14
|
+
temperature?: LLMManagerTemperature;
|
|
15
|
+
}
|
|
16
|
+
export interface LLMManagerSendRes {
|
|
17
|
+
choices: {
|
|
18
|
+
message: {
|
|
19
|
+
content: string;
|
|
20
|
+
};
|
|
21
|
+
}[];
|
|
22
|
+
}
|
|
23
|
+
export interface LLMManager {
|
|
24
|
+
send(req: LLMManagerSendReq): Promise<LLMManagerSendRes>;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
export interface PromptManagerPromptOpts<T extends string> {
|
|
2
|
+
/**
|
|
3
|
+
* Predicate to validate the input
|
|
4
|
+
*
|
|
5
|
+
* It keeps asking while the value is not valid, unless the user presses `Ctrl+C`.
|
|
6
|
+
*
|
|
7
|
+
* @param value
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
2
10
|
validate?: (value: T) => Promise<boolean>;
|
|
3
11
|
}
|
|
4
12
|
export interface PromptManager {
|
|
@@ -1,10 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Placeholder for string settings that must be defined explicitly at runtime (e.g. secrets).
|
|
3
|
+
*/
|
|
1
4
|
export declare const SettingsManagerMandatoryPlaceholder = "!<>!";
|
|
5
|
+
/**
|
|
6
|
+
* Placeholder for array settings that must be defined explicitly at runtime (e.g. secrets).
|
|
7
|
+
*/
|
|
2
8
|
export declare const SettingsManagerMandatoryPlaceholderForArray: string[];
|
|
9
|
+
/**
|
|
10
|
+
* Placeholder for object settings that must be defined explicitly at runtime (e.g. secrets).
|
|
11
|
+
*/
|
|
3
12
|
export declare const SettingsManagerMandatoryPlaceholderForObject: {
|
|
4
13
|
'0': string;
|
|
5
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* A group of settings
|
|
17
|
+
*
|
|
18
|
+
* Prefix them with the thing that is configurable to avoid conflicts when defining settings together for a product and/or a target.
|
|
19
|
+
*/
|
|
6
20
|
export interface Settings {
|
|
7
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Interface to implement by the classes that needs settings
|
|
24
|
+
*
|
|
25
|
+
* As `S`, pass the subset of settings that the class needs (e.g. `Pick<SomeSettings, 'setting_1'>`).
|
|
26
|
+
*/
|
|
8
27
|
export interface Configurable<S> {
|
|
9
28
|
s(): S;
|
|
10
29
|
}
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Placeholder for string settings that must be defined explicitly at runtime (e.g. secrets).
|
|
3
|
+
*/
|
|
1
4
|
export const SettingsManagerMandatoryPlaceholder = '!<>!';
|
|
5
|
+
/**
|
|
6
|
+
* Placeholder for array settings that must be defined explicitly at runtime (e.g. secrets).
|
|
7
|
+
*/
|
|
2
8
|
export const SettingsManagerMandatoryPlaceholderForArray = [
|
|
3
9
|
SettingsManagerMandatoryPlaceholder,
|
|
4
10
|
];
|
|
11
|
+
/**
|
|
12
|
+
* Placeholder for object settings that must be defined explicitly at runtime (e.g. secrets).
|
|
13
|
+
*/
|
|
5
14
|
export const SettingsManagerMandatoryPlaceholderForObject = {
|
|
6
15
|
'0': SettingsManagerMandatoryPlaceholder,
|
|
7
16
|
};
|
|
@@ -15,6 +15,7 @@ import { inject, injectable } from 'inversify';
|
|
|
15
15
|
let ConsoleLogger = class ConsoleLogger {
|
|
16
16
|
static { ConsoleLogger_1 = this; }
|
|
17
17
|
settingsManager;
|
|
18
|
+
// Ordered by level
|
|
18
19
|
static LEVELS = [
|
|
19
20
|
'trace',
|
|
20
21
|
'debug',
|
|
@@ -34,30 +35,35 @@ let ConsoleLogger = class ConsoleLogger {
|
|
|
34
35
|
if (!this.shouldLog('debug')) {
|
|
35
36
|
return;
|
|
36
37
|
}
|
|
38
|
+
// biome-ignore lint/suspicious/noConsole: we want it
|
|
37
39
|
console.debug(`${this.t()} [debug] ${message}`, ...meta);
|
|
38
40
|
}
|
|
39
41
|
error(err) {
|
|
40
42
|
if (!this.shouldLog('error')) {
|
|
41
43
|
return;
|
|
42
44
|
}
|
|
45
|
+
// biome-ignore lint/suspicious/noConsole: we want it
|
|
43
46
|
console.error(err);
|
|
44
47
|
}
|
|
45
48
|
info(message, ...meta) {
|
|
46
49
|
if (!this.shouldLog('info')) {
|
|
47
50
|
return;
|
|
48
51
|
}
|
|
52
|
+
// biome-ignore lint/suspicious/noConsole: we want it
|
|
49
53
|
console.info(`${this.t()} [info] ${message}`, ...meta);
|
|
50
54
|
}
|
|
51
55
|
trace(message, ...meta) {
|
|
52
56
|
if (!this.shouldLog('trace')) {
|
|
53
57
|
return;
|
|
54
58
|
}
|
|
55
|
-
|
|
59
|
+
// biome-ignore lint/suspicious/noConsole: we want it
|
|
60
|
+
console.trace(`${this.t()} [trace] ${message}`, ...meta);
|
|
56
61
|
}
|
|
57
62
|
warn(message, ...meta) {
|
|
58
63
|
if (!this.shouldLog('warn')) {
|
|
59
64
|
return;
|
|
60
65
|
}
|
|
66
|
+
// biome-ignore lint/suspicious/noConsole: we want it
|
|
61
67
|
console.warn(`${this.t()} [warn] ${message}`, ...meta);
|
|
62
68
|
}
|
|
63
69
|
shouldLog(level) {
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import type { HTTPAPICallExecutor, HTTPAPICallExecutorFunc } from '../HTTPAPICallExecutor.js';
|
|
2
|
+
/**
|
|
3
|
+
* Nowadays, most platforms include it as a global :
|
|
4
|
+
*
|
|
5
|
+
* - Node : https://nodejs.org/api/globals.html#fetch
|
|
6
|
+
* - RN : https://reactnative.dev/docs/network#using-fetch
|
|
7
|
+
* - Web : https://developer.mozilla.org/fr/docs/Web/API/Fetch_API
|
|
8
|
+
*
|
|
9
|
+
* So we should be safe using it almost everywhere.
|
|
10
|
+
*/
|
|
2
11
|
export declare class FetchHTTPAPICallExecutor implements HTTPAPICallExecutor {
|
|
3
12
|
fn<Res>(): HTTPAPICallExecutorFunc<Res>;
|
|
4
13
|
}
|
|
@@ -5,8 +5,19 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { injectable } from 'inversify';
|
|
8
|
+
/**
|
|
9
|
+
* Nowadays, most platforms include it as a global :
|
|
10
|
+
*
|
|
11
|
+
* - Node : https://nodejs.org/api/globals.html#fetch
|
|
12
|
+
* - RN : https://reactnative.dev/docs/network#using-fetch
|
|
13
|
+
* - Web : https://developer.mozilla.org/fr/docs/Web/API/Fetch_API
|
|
14
|
+
*
|
|
15
|
+
* So we should be safe using it almost everywhere.
|
|
16
|
+
*/
|
|
8
17
|
let FetchHTTPAPICallExecutor = class FetchHTTPAPICallExecutor {
|
|
9
18
|
fn() {
|
|
19
|
+
// The generalization in HTTPAPICallExecutor is not exactly the same as the actual implementation
|
|
20
|
+
// @ts-ignore
|
|
10
21
|
return fetch;
|
|
11
22
|
}
|
|
12
23
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ApiKey } from '../../dt/index.js';
|
|
2
|
+
import type { HTTPAPICaller } from '../HTTPAPICaller.js';
|
|
3
|
+
import type { LLMManager, LLMManagerSendReq, LLMManagerSendRes } from '../LLMManager.js';
|
|
4
|
+
import type { Configurable, Settings, SettingsManager } from '../SettingsManager.js';
|
|
5
|
+
export interface MistralAILLMManagerSettings extends Settings {
|
|
6
|
+
mai_api_key: ApiKey;
|
|
7
|
+
}
|
|
8
|
+
type S = MistralAILLMManagerSettings;
|
|
9
|
+
export declare class MistralAILLMManager implements Configurable<S>, LLMManager {
|
|
10
|
+
private httpAPICaller;
|
|
11
|
+
private settingsManager;
|
|
12
|
+
private static BASE_URL;
|
|
13
|
+
constructor(httpAPICaller: HTTPAPICaller, settingsManager: SettingsManager<S>);
|
|
14
|
+
s(): MistralAILLMManagerSettings;
|
|
15
|
+
send(req: LLMManagerSendReq): Promise<LLMManagerSendRes>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
var MistralAILLMManager_1;
|
|
14
|
+
import { inject, injectable } from 'inversify';
|
|
15
|
+
let MistralAILLMManager = class MistralAILLMManager {
|
|
16
|
+
static { MistralAILLMManager_1 = this; }
|
|
17
|
+
httpAPICaller;
|
|
18
|
+
settingsManager;
|
|
19
|
+
static BASE_URL = 'https://api.mistral.ai/v1';
|
|
20
|
+
constructor(httpAPICaller, settingsManager) {
|
|
21
|
+
this.httpAPICaller = httpAPICaller;
|
|
22
|
+
this.settingsManager = settingsManager;
|
|
23
|
+
}
|
|
24
|
+
s() {
|
|
25
|
+
return {
|
|
26
|
+
mai_api_key: this.settingsManager.get()('mai_api_key'),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
async send(req) {
|
|
30
|
+
return await this.httpAPICaller.exec({
|
|
31
|
+
authorizationHeader: {
|
|
32
|
+
value: this.s().mai_api_key,
|
|
33
|
+
prefix: 'Bearer',
|
|
34
|
+
},
|
|
35
|
+
errBuilder: async (error) => {
|
|
36
|
+
if ('message' in error) {
|
|
37
|
+
return error.message;
|
|
38
|
+
}
|
|
39
|
+
return error.detail.map((d) => d.msg).join('\n');
|
|
40
|
+
},
|
|
41
|
+
method: 'POST',
|
|
42
|
+
req: {
|
|
43
|
+
envelope: 'json',
|
|
44
|
+
builder: async () => req,
|
|
45
|
+
},
|
|
46
|
+
urlBuilder: async () => `${MistralAILLMManager_1.BASE_URL}/chat/completions`,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
MistralAILLMManager = MistralAILLMManager_1 = __decorate([
|
|
51
|
+
injectable(),
|
|
52
|
+
__param(0, inject('HTTPAPICaller')),
|
|
53
|
+
__param(1, inject('SettingsManager')),
|
|
54
|
+
__metadata("design:paramtypes", [Object, Object])
|
|
55
|
+
], MistralAILLMManager);
|
|
56
|
+
export { MistralAILLMManager };
|
|
@@ -7,10 +7,13 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import crypto from 'node:crypto';
|
|
8
8
|
import { promisify } from 'node:util';
|
|
9
9
|
import { injectable } from 'inversify';
|
|
10
|
+
// https://nodejs.org/api/crypto.html#cryptopbkdf2password-salt-iterations-keylen-digest-callback
|
|
10
11
|
const pbkdf2 = promisify(crypto.pbkdf2);
|
|
12
|
+
// https://nodejs.org/api/crypto.html#cryptoscryptpassword-salt-keylen-options-callback
|
|
11
13
|
const scrypt = promisify(crypto.scrypt);
|
|
12
14
|
let NodeCryptoManager = class NodeCryptoManager {
|
|
13
15
|
async clear() {
|
|
16
|
+
// Nothing to do
|
|
14
17
|
}
|
|
15
18
|
hash(algorithm, base, binaryToTextEncoding) {
|
|
16
19
|
return crypto
|
|
@@ -35,9 +38,11 @@ let NodeCryptoManager = class NodeCryptoManager {
|
|
|
35
38
|
return Uint8Array.from(result);
|
|
36
39
|
}
|
|
37
40
|
async randomString(length) {
|
|
41
|
+
// Not perfect in terms of randomness (because of Math.random() but pretty fine for now)
|
|
38
42
|
let res = '';
|
|
39
43
|
while (res.length < length) {
|
|
40
44
|
const next = Math.random().toString(36).slice(2, 3);
|
|
45
|
+
// For now, we want only chars at the beginning, so it can be used as an identifier (i.e. in a database)
|
|
41
46
|
if (res.length === 0 &&
|
|
42
47
|
Number.isInteger(Number.parseInt(next, 10))) {
|
|
43
48
|
continue;
|
|
@@ -50,7 +55,7 @@ let NodeCryptoManager = class NodeCryptoManager {
|
|
|
50
55
|
return crypto.randomUUID();
|
|
51
56
|
}
|
|
52
57
|
async scrypt(password, salt, keyLength) {
|
|
53
|
-
const buffer = (await scrypt(password, salt, keyLength));
|
|
58
|
+
const buffer = (await scrypt(password, salt, keyLength)); // Forced to cast because it seems to be not typed correctly
|
|
54
59
|
return buffer.toString('hex');
|
|
55
60
|
}
|
|
56
61
|
};
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import type { UIntQuantity, UUID } from '../../dt/index.js';
|
|
2
2
|
import type { CryptoManagerRandomString } from '../CryptoManager.js';
|
|
3
3
|
import { NodeCryptoManager } from './NodeCryptoManager.js';
|
|
4
|
+
/**
|
|
5
|
+
* A deterministic {@link CryptoManager} based on {@link NodeCryptoManager}
|
|
6
|
+
*
|
|
7
|
+
* The main purpose is to have an implementation that generates always the
|
|
8
|
+
* same data deterministically to make snapshot assertions in tests easier.
|
|
9
|
+
*
|
|
10
|
+
* WARNING : it keeps internal "seeds" to generate always the same data.
|
|
11
|
+
*
|
|
12
|
+
* In our case, it's an auto-incremented integer.
|
|
13
|
+
*
|
|
14
|
+
* So if the same implementation is used in multiple places
|
|
15
|
+
* (e.g. in concurrent tests within the same test suite),
|
|
16
|
+
* be ready for "race conditions" and inconsistencies.
|
|
17
|
+
*/
|
|
4
18
|
export declare class NodeDeterministicCryptoManager extends NodeCryptoManager {
|
|
5
19
|
private randomStringIdx;
|
|
6
20
|
private uuidIdx;
|
|
@@ -7,6 +7,20 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { createHash } from 'node:crypto';
|
|
8
8
|
import { injectable } from 'inversify';
|
|
9
9
|
import { NodeCryptoManager } from './NodeCryptoManager.js';
|
|
10
|
+
/**
|
|
11
|
+
* A deterministic {@link CryptoManager} based on {@link NodeCryptoManager}
|
|
12
|
+
*
|
|
13
|
+
* The main purpose is to have an implementation that generates always the
|
|
14
|
+
* same data deterministically to make snapshot assertions in tests easier.
|
|
15
|
+
*
|
|
16
|
+
* WARNING : it keeps internal "seeds" to generate always the same data.
|
|
17
|
+
*
|
|
18
|
+
* In our case, it's an auto-incremented integer.
|
|
19
|
+
*
|
|
20
|
+
* So if the same implementation is used in multiple places
|
|
21
|
+
* (e.g. in concurrent tests within the same test suite),
|
|
22
|
+
* be ready for "race conditions" and inconsistencies.
|
|
23
|
+
*/
|
|
10
24
|
let NodeDeterministicCryptoManager = class NodeDeterministicCryptoManager extends NodeCryptoManager {
|
|
11
25
|
randomStringIdx = 0;
|
|
12
26
|
uuidIdx = 0;
|
|
@@ -33,14 +47,14 @@ let NodeDeterministicCryptoManager = class NodeDeterministicCryptoManager extend
|
|
|
33
47
|
const hashBytes = hash.digest().subarray(0, 16);
|
|
34
48
|
const bytes = Array.from(hashBytes);
|
|
35
49
|
if (bytes[6] !== undefined) {
|
|
36
|
-
bytes[6] = (bytes[6] & 0x0f) | 0x40;
|
|
50
|
+
bytes[6] = (bytes[6] & 0x0f) | 0x40; // Set the version to 4 (UUID v4)
|
|
37
51
|
}
|
|
38
52
|
if (bytes[8] !== undefined) {
|
|
39
|
-
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
|
53
|
+
bytes[8] = (bytes[8] & 0x3f) | 0x80; // Set the variant to the correct RFC 4122 variant
|
|
40
54
|
}
|
|
41
55
|
const raw = bytes
|
|
42
56
|
.map((byte) => {
|
|
43
|
-
return (byte + 0x1_00).toString(16).substring(1);
|
|
57
|
+
return (byte + 0x1_00).toString(16).substring(1); // Convert byte to hex
|
|
44
58
|
})
|
|
45
59
|
.join('');
|
|
46
60
|
const uuid = [
|
|
@@ -13,6 +13,9 @@ let NodeFSManager = class NodeFSManager {
|
|
|
13
13
|
return true;
|
|
14
14
|
}
|
|
15
15
|
async cat(path, opts) {
|
|
16
|
+
// Be careful : omitting to pass an encoding makes it return a Buffer and not a string
|
|
17
|
+
// This can be problematic in some callers, manipulating the file as a string (e.g. startsWith, includes, etc.)
|
|
18
|
+
// So make sure to fallback on a default encoding
|
|
16
19
|
return readFile(path, opts?.encoding ?? 'utf8');
|
|
17
20
|
}
|
|
18
21
|
async chmod(path, mode) {
|
|
@@ -25,6 +28,8 @@ let NodeFSManager = class NodeFSManager {
|
|
|
25
28
|
await appendFile(src, content);
|
|
26
29
|
}
|
|
27
30
|
async exists(path) {
|
|
31
|
+
// Before, we could use fs.exists(path) but it's been deprecated : @deprecated since v1.0.0 Use `fs.stat()` or `fs.access()` instead
|
|
32
|
+
// Both functions are very unpractical to use because we need to wrap everything in a try/catch. It's too verbose !
|
|
28
33
|
try {
|
|
29
34
|
await stat(path);
|
|
30
35
|
return true;
|
|
@@ -45,6 +50,11 @@ let NodeFSManager = class NodeFSManager {
|
|
|
45
50
|
const parsedPath = parse(path);
|
|
46
51
|
const stats = await stat(path);
|
|
47
52
|
const { birthtime, size } = stats;
|
|
53
|
+
// For now there is nothing in the standard library to detect it.
|
|
54
|
+
// There are 3rd party packages like mime, mime-type, etc. but we prefer
|
|
55
|
+
// limiting the external dependencies.
|
|
56
|
+
// One can also call `file -b --mime-type /some/path` via exec/spawn if their
|
|
57
|
+
// system has this utility.
|
|
48
58
|
const mimeType = null;
|
|
49
59
|
const type = this.determineType(stats);
|
|
50
60
|
return {
|
|
@@ -21,6 +21,8 @@ let NodeHTTPAPICallExecutorAgentBuilder = class NodeHTTPAPICallExecutorAgentBuil
|
|
|
21
21
|
exec({ url, }) {
|
|
22
22
|
if (url.protocol.startsWith('https')) {
|
|
23
23
|
return new https.Agent({
|
|
24
|
+
// We allow self-signed certificates in non-prod environments
|
|
25
|
+
// This is useful when testing the CLI calling a the server from a docker container for example
|
|
24
26
|
rejectUnauthorized: this.environmentManager.isProd(),
|
|
25
27
|
});
|
|
26
28
|
}
|
|
@@ -9,10 +9,13 @@ import { createInterface } from 'node:readline/promises';
|
|
|
9
9
|
import { injectable } from 'inversify';
|
|
10
10
|
let NodePromptManager = class NodePromptManager {
|
|
11
11
|
async prompt(invite, opts) {
|
|
12
|
+
// TODO : Add keypress handling to hide when sensitive data is typed
|
|
12
13
|
const readLine = createInterface({
|
|
13
14
|
input: stdin,
|
|
14
15
|
output: stdout,
|
|
15
16
|
});
|
|
17
|
+
// To avoid "Warning: Detected unsettled top-level await at file:///[...]/dist/esm/xxx.js"
|
|
18
|
+
// when pressing Ctrl+C while being prompted
|
|
16
19
|
readLine.on('SIGINT', () => {
|
|
17
20
|
readLine.close();
|
|
18
21
|
process.exit(0);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { URL } from '../../dt/index.js';
|
|
2
|
+
import type { HTTPAPICaller } from '../HTTPAPICaller.js';
|
|
3
|
+
import type { LLMManager, LLMManagerSendReq, LLMManagerSendRes } from '../LLMManager.js';
|
|
4
|
+
import type { Configurable, Settings, SettingsManager } from '../SettingsManager.js';
|
|
5
|
+
/**
|
|
6
|
+
* Unlike the "commercial" APIs, Ollama does not secure the API with an API key
|
|
7
|
+
* @see https://github.com/ollama/ollama/issues/849
|
|
8
|
+
*/
|
|
9
|
+
export interface OllamaLLMManagerSettings extends Settings {
|
|
10
|
+
oll_base_url: URL;
|
|
11
|
+
}
|
|
12
|
+
type S = OllamaLLMManagerSettings;
|
|
13
|
+
export declare class OllamaLLMManager implements Configurable<S>, LLMManager {
|
|
14
|
+
private httpAPICaller;
|
|
15
|
+
private settingsManager;
|
|
16
|
+
constructor(httpAPICaller: HTTPAPICaller, settingsManager: SettingsManager<S>);
|
|
17
|
+
s(): OllamaLLMManagerSettings;
|
|
18
|
+
send(req: LLMManagerSendReq): Promise<LLMManagerSendRes>;
|
|
19
|
+
}
|
|
20
|
+
export {};
|