@promptbook/remote-client 0.88.0-9 → 0.89.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.
Files changed (25) hide show
  1. package/README.md +35 -14
  2. package/esm/index.es.js +27 -3
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/core.index.d.ts +2 -2
  5. package/esm/typings/src/_packages/types.index.d.ts +10 -0
  6. package/esm/typings/src/config.d.ts +1 -1
  7. package/esm/typings/src/errors/PipelineExecutionError.d.ts +5 -0
  8. package/esm/typings/src/errors/utils/ErrorJson.d.ts +5 -0
  9. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage.d.ts +7 -0
  10. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/{countTotalUsage.d.ts → countUsage.d.ts} +1 -1
  11. package/esm/typings/src/playground/BrjappConnector.d.ts +64 -0
  12. package/esm/typings/src/playground/brjapp-api-schema.d.ts +12879 -0
  13. package/esm/typings/src/playground/playground.d.ts +5 -0
  14. package/esm/typings/src/remote-server/socket-types/_subtypes/PromptbookServer_Identification.d.ts +2 -1
  15. package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +15 -3
  16. package/esm/typings/src/types/typeAliases.d.ts +2 -2
  17. package/esm/typings/src/utils/expectation-counters/countCharacters.d.ts +3 -0
  18. package/esm/typings/src/utils/expectation-counters/countLines.d.ts +3 -0
  19. package/esm/typings/src/utils/expectation-counters/countPages.d.ts +3 -0
  20. package/esm/typings/src/utils/expectation-counters/countParagraphs.d.ts +3 -0
  21. package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +3 -0
  22. package/esm/typings/src/utils/expectation-counters/countWords.d.ts +3 -0
  23. package/package.json +3 -2
  24. package/umd/index.umd.js +30 -7
  25. package/umd/index.umd.js.map +1 -1
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ts-node
2
+ export {};
3
+ /**
4
+ * Note: [⚫] Code in this file should never be published in any package
5
+ */
@@ -37,7 +37,8 @@ export type PromptbookServer_AnonymousIdentification = {
37
37
  /**
38
38
  * Identifier of the end user
39
39
  *
40
- * Note: this is passed to the certain model providers to identify misuse
40
+ * Note: This can be either some id or email or any other identifier
41
+ * Note: In anonymous mode, this is passed to the certain model providers to identify misuse
41
42
  * Note: In anonymous mode, there is no need to identify yourself, nor does it change the actual configuration of LLM Tools (unlike in application mode)
42
43
  */
43
44
  readonly userId?: string_user_id;
@@ -58,15 +58,27 @@ export type ApplicationRemoteServerOptions<TCustomOptions> = {
58
58
  };
59
59
  export type ApplicationRemoteServerClientOptions<TCustomOptions> = {
60
60
  /**
61
- * @@@
61
+ * Identifier of the application
62
+ *
63
+ * 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"
64
+ * Note: This can be some id or some semantic name like "email-agent"
62
65
  */
63
66
  readonly appId: string_app_id | null;
64
67
  /**
65
- * @@@
68
+ * Identifier of the end user
69
+ *
70
+ * Note: This can be either some id or email or any other identifier
71
+ * Note: This is also passed to the certain model providers to identify misuse
66
72
  */
67
73
  readonly userId?: string_user_id;
68
74
  /**
69
- * @@@
75
+ * Token of the user to verify its identity
76
+ *
77
+ * Note: This is passed for example to `createLlmExecutionTools`
78
+ */
79
+ readonly userToken?: string_user_id;
80
+ /**
81
+ * Additional arbitrary options to identify the client or to pass custom metadata
70
82
  */
71
83
  readonly customOptions?: TCustomOptions;
72
84
  };
@@ -433,13 +433,13 @@ export type string_uuid = string & {
433
433
  *
434
434
  * @@@
435
435
  */
436
- export type string_app_id = id;
436
+ export type string_app_id = id | 'app';
437
437
  /**
438
438
  * End user identifier
439
439
  *
440
440
  * @@@
441
441
  */
442
- export type string_user_id = id;
442
+ export type string_user_id = id | string_email;
443
443
  /**
444
444
  * Semantic helper
445
445
  *
@@ -5,3 +5,6 @@ import type { ExpectationAmount } from '../../pipeline/PipelineJson/Expectations
5
5
  * @public exported from `@promptbook/utils`
6
6
  */
7
7
  export declare function countCharacters(text: string): ExpectationAmount;
8
+ /**
9
+ * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
10
+ */
@@ -7,3 +7,6 @@ import type { ExpectationAmount } from '../../pipeline/PipelineJson/Expectations
7
7
  * @public exported from `@promptbook/utils`
8
8
  */
9
9
  export declare function countLines(text: string): ExpectationAmount;
10
+ /**
11
+ * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
12
+ */
@@ -7,3 +7,6 @@ import type { ExpectationAmount } from '../../pipeline/PipelineJson/Expectations
7
7
  * @public exported from `@promptbook/utils`
8
8
  */
9
9
  export declare function countPages(text: string): ExpectationAmount;
10
+ /**
11
+ * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
12
+ */
@@ -5,3 +5,6 @@ import type { ExpectationAmount } from '../../pipeline/PipelineJson/Expectations
5
5
  * @public exported from `@promptbook/utils`
6
6
  */
7
7
  export declare function countParagraphs(text: string): ExpectationAmount;
8
+ /**
9
+ * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
10
+ */
@@ -11,3 +11,6 @@ export declare function splitIntoSentences(text: string): ReadonlyArray<string>;
11
11
  * @public exported from `@promptbook/utils`
12
12
  */
13
13
  export declare function countSentences(text: string): ExpectationAmount;
14
+ /**
15
+ * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
16
+ */
@@ -5,3 +5,6 @@ import type { ExpectationAmount } from '../../pipeline/PipelineJson/Expectations
5
5
  * @public exported from `@promptbook/utils`
6
6
  */
7
7
  export declare function countWords(text: string): ExpectationAmount;
8
+ /**
9
+ * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
10
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/remote-client",
3
- "version": "0.88.0-9",
3
+ "version": "0.89.0-1",
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,9 +47,10 @@
47
47
  "module": "./esm/index.es.js",
48
48
  "typings": "./esm/typings/src/_packages/remote-client.index.d.ts",
49
49
  "peerDependencies": {
50
- "@promptbook/core": "0.88.0-9"
50
+ "@promptbook/core": "0.89.0-1"
51
51
  },
52
52
  "dependencies": {
53
+ "crypto": "^1.0.1",
53
54
  "crypto-js": "4.2.0",
54
55
  "papaparse": "5.4.1",
55
56
  "socket.io-client": "4.7.2",
package/umd/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('socket.io-client'), require('crypto-js'), require('crypto-js/enc-hex'), require('papaparse'), require('path')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'socket.io-client', 'crypto-js', 'crypto-js/enc-hex', 'papaparse', 'path'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-remote-client"] = {}, global.spaceTrim, global.socket_ioClient, global.cryptoJs, global.hexEncoder, global.papaparse, global.path));
5
- })(this, (function (exports, spaceTrim, socket_ioClient, cryptoJs, hexEncoder, papaparse, path) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('crypto'), require('socket.io-client'), require('crypto-js'), require('crypto-js/enc-hex'), require('papaparse'), require('path')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'crypto', 'socket.io-client', 'crypto-js', 'crypto-js/enc-hex', 'papaparse', 'path'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-remote-client"] = {}, global.spaceTrim, global.crypto, global.socket_ioClient, global.cryptoJs, global.hexEncoder, global.papaparse, global.path));
5
+ })(this, (function (exports, spaceTrim, crypto, socket_ioClient, cryptoJs, hexEncoder, papaparse, path) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -23,7 +23,7 @@
23
23
  * @generated
24
24
  * @see https://github.com/webgptorg/promptbook
25
25
  */
26
- const PROMPTBOOK_ENGINE_VERSION = '0.88.0-9';
26
+ const PROMPTBOOK_ENGINE_VERSION = '0.89.0-1';
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
@@ -197,6 +197,21 @@
197
197
  * TODO: Maybe split `ParseError` and `ApplyError`
198
198
  */
199
199
 
200
+ /**
201
+ * Generates random token
202
+ *
203
+ * Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
204
+ *
205
+ * @private internal helper function
206
+ * @returns secure random token
207
+ */
208
+ function $randomToken(randomness) {
209
+ return crypto.randomBytes(randomness).toString('hex');
210
+ }
211
+ /**
212
+ * TODO: Maybe use nanoid instead https://github.com/ai/nanoid
213
+ */
214
+
200
215
  /**
201
216
  * This error indicates errors during the execution of the pipeline
202
217
  *
@@ -204,11 +219,17 @@
204
219
  */
205
220
  class PipelineExecutionError extends Error {
206
221
  constructor(message) {
222
+ // Added id parameter
207
223
  super(message);
208
224
  this.name = 'PipelineExecutionError';
225
+ // TODO: [🐙] DRY - Maybe $randomId
226
+ this.id = `error-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
209
227
  Object.setPrototypeOf(this, PipelineExecutionError.prototype);
210
228
  }
211
229
  }
230
+ /**
231
+ * TODO: !!!!!! Add id to all errors
232
+ */
212
233
 
213
234
  /**
214
235
  * This error indicates that the promptbook object has valid syntax (=can be parsed) but contains logical errors (like circular dependencies)
@@ -464,7 +485,7 @@
464
485
  * @public exported from `@promptbook/utils`
465
486
  */
466
487
  function deserializeError(error) {
467
- const { name, stack } = error;
488
+ const { name, stack, id } = error; // Added id
468
489
  let { message } = error;
469
490
  let ErrorClass = ALL_ERRORS[error.name];
470
491
  if (ErrorClass === undefined) {
@@ -479,7 +500,9 @@
479
500
  ${block(stack || '')}
480
501
  `);
481
502
  }
482
- return new ErrorClass(message);
503
+ const deserializedError = new ErrorClass(message);
504
+ deserializedError.id = id; // Assign id to the error object
505
+ return deserializedError;
483
506
  }
484
507
 
485
508
  /**