@promptbook/editable 0.89.0-6 → 0.89.0-8

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.
@@ -1,11 +1,44 @@
1
+ import { Promisable } from 'type-fest';
2
+ import type { PromptbookServer_Identification } from '../../../remote-server/socket-types/_subtypes/PromptbookServer_Identification';
3
+ import type { really_any } from '../../../utils/organization/really_any';
4
+ import type { string_app_id } from '../../../types/typeAliases';
5
+ import type { string_url } from '../../../types/typeAliases';
1
6
  import type { CacheLlmToolsOptions } from '../utils/cache/CacheLlmToolsOptions';
2
7
  import type { LlmExecutionToolsWithTotalUsage } from '../utils/count-total-usage/LlmExecutionToolsWithTotalUsage';
8
+ type ProvideLlmToolsForWizzardOrCliOptions = Pick<CacheLlmToolsOptions, 'isCacheReloaded'> & ({
9
+ /**
10
+ * Use local keys and execute LLMs directly
11
+ */
12
+ readonly strategy: 'BRING_YOUR_OWN_KEYS';
13
+ } | {
14
+ /**
15
+ * Do not use local keys but login to Promptbook server and execute LLMs there
16
+ */
17
+ readonly strategy: 'REMOTE_SERVER';
18
+ /**
19
+ * URL of the remote server
20
+ *
21
+ * @default `DEFAULT_REMOTE_SERVER_URL`
22
+ */
23
+ readonly remoteServerUrl?: string_url;
24
+ /**
25
+ * Identifier of the application which will be passed to the remote server identification
26
+ *
27
+ * Note: This can be some id or some semantic name like "email-agent"
28
+ */
29
+ readonly appId: string_app_id;
30
+ /**
31
+ *
32
+ */
33
+ loginPrompt(): Promisable<PromptbookServer_Identification<really_any>>;
34
+ });
3
35
  /**
4
36
  * Returns LLM tools for CLI
5
37
  *
6
38
  * @private within the repository - for CLI utils
7
39
  */
8
- export declare function $provideLlmToolsForWizzardOrCli(options?: Pick<CacheLlmToolsOptions, 'isCacheReloaded'>): Promise<LlmExecutionToolsWithTotalUsage>;
40
+ export declare function $provideLlmToolsForWizzardOrCli(options?: ProvideLlmToolsForWizzardOrCliOptions): Promise<LlmExecutionToolsWithTotalUsage>;
41
+ export {};
9
42
  /**
10
43
  * Note: [ðŸŸĒ] Code in this file should never be never released in packages that could be imported into browser environment
11
44
  * TODO: [👷‍♂ïļ] @@@ Manual about construction of llmTools
@@ -25,7 +25,7 @@ export type AnthropicClaudeExecutionToolsDirectOptions = CommonToolsOptions & Cl
25
25
  */
26
26
  export type AnthropicClaudeExecutionToolsProxiedOptions = CommonToolsOptions & ClientOptions & {
27
27
  isProxied: true;
28
- } & Pick<RemoteClientOptions<undefined>, 'remoteUrl' | 'path'>;
28
+ } & Pick<RemoteClientOptions<undefined>, 'remoteServerUrl'>;
29
29
  /**
30
30
  * TODO: [🧠][ðŸĪš] Pass `userId`
31
31
  */
@@ -11,4 +11,4 @@ import type { Registration } from '../../utils/$Register';
11
11
  export declare const _AnthropicClaudeMetadataRegistration: Registration;
12
12
  /**
13
13
  * Note: [💞] Ignore a discrepancy between file name and entity name
14
- */
14
+ */
@@ -1,6 +1,5 @@
1
1
  import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
2
2
  import type { string_base_url } from '../../types/typeAliases';
3
- import type { string_uri } from '../../types/typeAliases';
4
3
  import type { PromptbookServer_Identification } from '../socket-types/_subtypes/PromptbookServer_Identification';
5
4
  /**
6
5
  * Options for `RemoteLlmExecutionTools`
@@ -12,14 +11,7 @@ export type RemoteClientOptions<TCustomOptions> = CommonToolsOptions & {
12
11
  * URL of the remote server
13
12
  * On this server will be connected to the socket.io server
14
13
  */
15
- readonly remoteUrl: string_base_url;
16
- /**
17
- * Path for the Socket.io server to listen
18
- *
19
- * @default '/socket.io'
20
- * @example '/promptbook/socket.io'
21
- */
22
- readonly path: string_uri;
14
+ readonly remoteServerUrl: string_base_url;
23
15
  /**
24
16
  * Identification of client for Socket.io remote server
25
17
  */
@@ -28,5 +20,5 @@ export type RemoteClientOptions<TCustomOptions> = CommonToolsOptions & {
28
20
  /**
29
21
  * TODO: Pass more options from Socket.io to `RemoteClientOptions` (like `transports`)
30
22
  * TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
31
- * TODO: [🧠][🧜‍♂ïļ] Maybe join remoteUrl and path into single value
23
+ * TODO: [🧠][🧜‍♂ïļ] Maybe join remoteServerUrl and path into single value
32
24
  */
@@ -1,10 +1,15 @@
1
+ import type { Request, Response } from 'express';
1
2
  import type { Promisable } from 'type-fest';
2
3
  import type { PipelineCollection } from '../../collection/PipelineCollection';
4
+ import { AuthenticationError } from '../../errors/AuthenticationError';
3
5
  import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
4
6
  import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
5
7
  import type { string_app_id } from '../../types/typeAliases';
8
+ import type { string_email } from '../../types/typeAliases';
9
+ import type { string_password } from '../../types/typeAliases';
6
10
  import type { string_uri } from '../../types/typeAliases';
7
11
  import type { string_user_id } from '../../types/typeAliases';
12
+ import type { PromptbookServer_Identification } from '../socket-types/_subtypes/PromptbookServer_Identification';
8
13
  /**
9
14
  * @@@
10
15
  *
@@ -16,7 +21,6 @@ import type { string_user_id } from '../../types/typeAliases';
16
21
  *
17
22
  * You can enable both modes at the same time.
18
23
  *
19
- * @public exported from `@promptbook/remote-client`
20
24
  * @public exported from `@promptbook/remote-server`
21
25
  */
22
26
  export type RemoteServerOptions<TCustomOptions> = CommonToolsOptions & {
@@ -32,8 +36,12 @@ export type RemoteServerOptions<TCustomOptions> = CommonToolsOptions & {
32
36
  * @default '/'
33
37
  * @example '/api/promptbook/'
34
38
  */
35
- readonly rootPath: string_uri;
36
- } & (AnonymousRemoteServerOptions | ApplicationRemoteServerOptions<TCustomOptions> | (AnonymousRemoteServerOptions & ApplicationRemoteServerOptions<TCustomOptions>));
39
+ readonly rootPath?: string_uri;
40
+ } & ((AnonymousRemoteServerOptions & {
41
+ readonly isApplicationModeAllowed?: false;
42
+ }) | ({
43
+ readonly isAnonymousModeAllowed?: false;
44
+ } & ApplicationRemoteServerOptions<TCustomOptions>) | (AnonymousRemoteServerOptions & ApplicationRemoteServerOptions<TCustomOptions>));
37
45
  export type AnonymousRemoteServerOptions = {
38
46
  /**
39
47
  * Enable anonymous mode
@@ -51,6 +59,43 @@ export type ApplicationRemoteServerOptions<TCustomOptions> = {
51
59
  * This is used to check validity of the prompt to prevent misuse
52
60
  */
53
61
  readonly collection: PipelineCollection;
62
+ /**
63
+ * User tries to login to the server, this function will be called verify the user and return the identification or throw an error
64
+ * This can be also doubled as a function to register the user
65
+ *
66
+ * Note: In most cases, you will return `PromptbookServer_ApplicationIdentification`
67
+ * `PromptbookServer_AnonymousIdentification` is useful only in scenarios when user stores its own api keys on the application server and
68
+ * server acts only as a api key provider
69
+ *
70
+ * Note: In most cases DO NOT THROW `AuthenticationError` but return `isSuccess: false` with message
71
+ * @throws `AuthenticationError` if the user is not allowed to login for example because of invalid credentials
72
+ */
73
+ login(credentials: {
74
+ /**
75
+ * Identifier of the application you are using
76
+ *
77
+ * Note: This is usefull when you use Promptbook remote server for multiple apps/frontends, if its used just for single app, use here just "app" or "your-app-name"
78
+ */
79
+ readonly appId: string_app_id | null;
80
+ /**
81
+ * Username (for example email) of the user
82
+ */
83
+ readonly username: string_email | string;
84
+ /**
85
+ * Password of the user
86
+ */
87
+ readonly password: string_password;
88
+ /**
89
+ * Request object from express if you want to access some request data for example headers, IP address, etc.
90
+ */
91
+ readonly rawRequest: Request;
92
+ /**
93
+ * Response object from express if you want to add some custom headers.
94
+ *
95
+ * Note: It is not recommended to use this object to send body of the response because it can confuse the client
96
+ */
97
+ readonly rawResponse: Response;
98
+ }): Promise<ApplicationRemoteServerOptionsLoginResponse<TCustomOptions>>;
54
99
  /**
55
100
  * Creates llm execution tools for each client
56
101
  */
@@ -82,6 +127,18 @@ export type ApplicationRemoteServerClientOptions<TCustomOptions> = {
82
127
  */
83
128
  readonly customOptions?: TCustomOptions;
84
129
  };
130
+ export type ApplicationRemoteServerOptionsLoginResponse<TCustomOptions> = {
131
+ /**
132
+ * Was the login successful
133
+ */
134
+ readonly isSuccess: boolean;
135
+ /**
136
+ *
137
+ */
138
+ readonly message?: string;
139
+ readonly error?: AuthenticationError;
140
+ readonly identification?: PromptbookServer_Identification<TCustomOptions>;
141
+ };
85
142
  /**
86
143
  * TODO: Constrain anonymous mode for specific models / providers
87
144
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/editable",
3
- "version": "0.89.0-6",
3
+ "version": "0.89.0-8",
4
4
  "description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -47,7 +47,7 @@
47
47
  "module": "./esm/index.es.js",
48
48
  "typings": "./esm/typings/src/_packages/editable.index.d.ts",
49
49
  "peerDependencies": {
50
- "@promptbook/core": "0.89.0-6"
50
+ "@promptbook/core": "0.89.0-8"
51
51
  },
52
52
  "dependencies": {
53
53
  "crypto-js": "4.2.0",
package/umd/index.umd.js CHANGED
@@ -23,7 +23,7 @@
23
23
  * @generated
24
24
  * @see https://github.com/webgptorg/promptbook
25
25
  */
26
- const PROMPTBOOK_ENGINE_VERSION = '0.89.0-6';
26
+ const PROMPTBOOK_ENGINE_VERSION = '0.89.0-8';
27
27
  /**
28
28
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
29
29
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -102,7 +102,7 @@
102
102
  });
103
103
  /**
104
104
  * Note: [💞] Ignore a discrepancy between file name and entity name
105
- * TODO: [🧠][🧜‍♂ïļ] Maybe join remoteUrl and path into single value
105
+ * TODO: [🧠][🧜‍♂ïļ] Maybe join remoteServerUrl and path into single value
106
106
  */
107
107
 
108
108
  /**