@promptbook/remote-server 0.66.0 → 0.67.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 (60) hide show
  1. package/esm/index.es.js +400 -95
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/core.index.d.ts +4 -4
  4. package/esm/typings/src/_packages/types.index.d.ts +7 -1
  5. package/esm/typings/src/_packages/utils.index.d.ts +14 -8
  6. package/esm/typings/src/commands/EXPECT/ExpectFormatCommand.d.ts +2 -0
  7. package/esm/typings/src/errors/{ReferenceError.d.ts → PipelineUrlError.d.ts} +2 -2
  8. package/esm/typings/src/errors/index.d.ts +27 -0
  9. package/esm/typings/src/errors/utils/ErrorJson.d.ts +20 -0
  10. package/esm/typings/src/errors/utils/deserializeError.d.ts +7 -0
  11. package/esm/typings/src/errors/utils/deserializeError.test.d.ts +1 -0
  12. package/esm/typings/src/errors/utils/serializeError.d.ts +7 -0
  13. package/esm/typings/src/errors/utils/serializeError.test.d.ts +1 -0
  14. package/esm/typings/src/execution/ExecutionTools.d.ts +4 -1
  15. package/esm/typings/src/execution/PipelineExecutor.d.ts +1 -47
  16. package/esm/typings/src/execution/PipelineExecutorResult.d.ts +49 -0
  17. package/esm/typings/src/execution/PromptResult.d.ts +4 -4
  18. package/esm/typings/src/execution/PromptResultUsage.d.ts +4 -0
  19. package/esm/typings/src/execution/UncertainNumber.d.ts +1 -0
  20. package/esm/typings/src/execution/assertsExecutionSuccessful.d.ts +2 -2
  21. package/esm/typings/src/llm-providers/_common/utils/cache/CacheItem.d.ts +0 -1
  22. package/esm/typings/src/llm-providers/mocked/$fakeTextToExpectations.d.ts +2 -2
  23. package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +3 -3
  24. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -0
  25. package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_Error.d.ts +2 -6
  26. package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -0
  27. package/esm/typings/src/personas/preparePersona.d.ts +1 -0
  28. package/esm/typings/src/prepare/isPipelinePrepared.d.ts +1 -0
  29. package/esm/typings/src/scripting/javascript/JavascriptExecutionToolsOptions.d.ts +2 -2
  30. package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +1 -1
  31. package/esm/typings/src/types/ModelRequirements.d.ts +5 -5
  32. package/esm/typings/src/types/PipelineJson/Expectations.d.ts +3 -1
  33. package/esm/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +2 -0
  34. package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +4 -0
  35. package/esm/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +2 -0
  36. package/esm/typings/src/types/PipelineJson/PersonaJson.d.ts +4 -0
  37. package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +2 -0
  38. package/esm/typings/src/types/PipelineJson/PromptDialogJson.d.ts +1 -0
  39. package/esm/typings/src/types/PipelineJson/PromptTemplateJson.d.ts +2 -0
  40. package/esm/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +2 -2
  41. package/esm/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +2 -0
  42. package/esm/typings/src/types/PipelineJson/ScriptJson.d.ts +1 -0
  43. package/esm/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +1 -0
  44. package/esm/typings/src/types/Prompt.d.ts +7 -7
  45. package/esm/typings/src/types/ScriptLanguage.d.ts +2 -0
  46. package/esm/typings/src/types/execution-report/ExecutionPromptReportJson.d.ts +24 -0
  47. package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +3 -20
  48. package/esm/typings/src/types/typeAliases.d.ts +7 -0
  49. package/esm/typings/src/utils/environment/$getGlobalScope.d.ts +1 -4
  50. package/esm/typings/src/utils/serialization/$asDeeplyFrozenSerializableJson.d.ts +17 -0
  51. package/esm/typings/src/utils/{deepFreeze.d.ts → serialization/$deepFreeze.d.ts} +0 -10
  52. package/esm/typings/src/utils/serialization/checkSerializableAsJson.d.ts +27 -0
  53. package/esm/typings/src/utils/{clonePipeline.d.ts → serialization/clonePipeline.d.ts} +1 -1
  54. package/esm/typings/src/utils/serialization/isSerializableAsJson.d.ts +24 -0
  55. package/esm/typings/src/utils/serialization/isSerializableAsJson.test.d.ts +1 -0
  56. package/package.json +2 -2
  57. package/umd/index.umd.js +400 -95
  58. package/umd/index.umd.js.map +1 -1
  59. package/esm/typings/src/errors/VersionMismatchError.d.ts +0 -10
  60. /package/esm/typings/src/utils/{deepClone.d.ts → serialization/deepClone.d.ts} +0 -0
package/umd/index.umd.js CHANGED
@@ -14,7 +14,7 @@
14
14
  /**
15
15
  * The version of the Promptbook library
16
16
  */
17
- var PROMPTBOOK_VERSION = '0.66.0-9';
17
+ var PROMPTBOOK_VERSION = '0.67.0-0';
18
18
  // TODO: !!!! List here all the versions and annotate + put into script
19
19
 
20
20
  /*! *****************************************************************************
@@ -136,6 +136,245 @@
136
136
  return to.concat(ar || Array.prototype.slice.call(from));
137
137
  }
138
138
 
139
+ /**
140
+ * Returns the same value that is passed as argument.
141
+ * No side effects.
142
+ *
143
+ * Note: It can be usefull for:
144
+ *
145
+ * 1) Leveling indentation
146
+ * 2) Putting always-true or always-false conditions without getting eslint errors
147
+ *
148
+ * @param value any values
149
+ * @returns the same values
150
+ * @private within the repository
151
+ */
152
+ function just(value) {
153
+ if (value === undefined) {
154
+ return undefined;
155
+ }
156
+ return value;
157
+ }
158
+
159
+ /**
160
+ * @@@
161
+ *
162
+ * Note: `$` is used to indicate that this function is not a pure function - it mutates given object
163
+ * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
164
+ *
165
+ * @returns The same object as the input, but deeply frozen
166
+ * @public exported from `@promptbook/utils`
167
+ */
168
+ function $deepFreeze(objectValue) {
169
+ var e_1, _a;
170
+ var propertyNames = Object.getOwnPropertyNames(objectValue);
171
+ try {
172
+ for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
173
+ var propertyName = propertyNames_1_1.value;
174
+ var value = objectValue[propertyName];
175
+ if (value && typeof value === 'object') {
176
+ $deepFreeze(value);
177
+ }
178
+ }
179
+ }
180
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
181
+ finally {
182
+ try {
183
+ if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
184
+ }
185
+ finally { if (e_1) throw e_1.error; }
186
+ }
187
+ return Object.freeze(objectValue);
188
+ }
189
+ /**
190
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
191
+ */
192
+
193
+ /**
194
+ * This error type indicates that the error should not happen and its last check before crashing with some other error
195
+ *
196
+ * @public exported from `@promptbook/core`
197
+ */
198
+ var UnexpectedError = /** @class */ (function (_super) {
199
+ __extends(UnexpectedError, _super);
200
+ function UnexpectedError(message) {
201
+ var _this = _super.call(this, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the pipeline collection\n\n Please report issue:\n https://github.com/webgptorg/promptbook/issues\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
202
+ _this.name = 'UnexpectedError';
203
+ Object.setPrototypeOf(_this, UnexpectedError.prototype);
204
+ return _this;
205
+ }
206
+ return UnexpectedError;
207
+ }(Error));
208
+
209
+ /**
210
+ * Checks if the value is [🚉] serializable as JSON
211
+ * If not, throws an UnexpectedError with a rich error message and tracking
212
+ *
213
+ * - Almost all primitives are serializable BUT:
214
+ * - `undefined` is not serializable
215
+ * - `NaN` is not serializable
216
+ * - Objects and arrays are serializable if all their properties are serializable
217
+ * - Functions are not serializable
218
+ * - Circular references are not serializable
219
+ * - `Date` objects are not serializable
220
+ * - `Map` and `Set` objects are not serializable
221
+ * - `RegExp` objects are not serializable
222
+ * - `Error` objects are not serializable
223
+ * - `Symbol` objects are not serializable
224
+ * - And much more...
225
+ *
226
+ * @throws UnexpectedError if the value is not serializable as JSON
227
+ * @public exported from `@promptbook/utils`
228
+ */
229
+ function checkSerializableAsJson(name, value) {
230
+ var e_1, _a;
231
+ if (value === undefined) {
232
+ throw new UnexpectedError("".concat(name, " is undefined"));
233
+ }
234
+ else if (value === null) {
235
+ return;
236
+ }
237
+ else if (typeof value === 'boolean') {
238
+ return;
239
+ }
240
+ else if (typeof value === 'number' && !isNaN(value)) {
241
+ return;
242
+ }
243
+ else if (typeof value === 'string') {
244
+ return;
245
+ }
246
+ else if (typeof value === 'symbol') {
247
+ throw new UnexpectedError("".concat(name, " is symbol"));
248
+ }
249
+ else if (typeof value === 'function') {
250
+ throw new UnexpectedError("".concat(name, " is function"));
251
+ }
252
+ else if (typeof value === 'object' && Array.isArray(value)) {
253
+ for (var i = 0; i < value.length; i++) {
254
+ checkSerializableAsJson("".concat(name, "[").concat(i, "]"), value[i]);
255
+ }
256
+ }
257
+ else if (typeof value === 'object') {
258
+ if (value instanceof Date) {
259
+ throw new UnexpectedError(spaceTrim__default["default"]("\n ".concat(name, " is Date\n\n Use `string_date_iso8601` instead\n ")));
260
+ }
261
+ else if (value instanceof Map) {
262
+ throw new UnexpectedError("".concat(name, " is Map"));
263
+ }
264
+ else if (value instanceof Set) {
265
+ throw new UnexpectedError("".concat(name, " is Set"));
266
+ }
267
+ else if (value instanceof RegExp) {
268
+ throw new UnexpectedError("".concat(name, " is RegExp"));
269
+ }
270
+ else if (value instanceof Error) {
271
+ throw new UnexpectedError(spaceTrim__default["default"]("\n ".concat(name, " is unserialized Error\n\n Use function `serializeError`\n ")));
272
+ }
273
+ else {
274
+ try {
275
+ for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
276
+ var _d = __read(_c.value, 2), subName = _d[0], subValue = _d[1];
277
+ if (subValue === undefined) {
278
+ // Note: undefined in object is serializable - it is just omited
279
+ continue;
280
+ }
281
+ checkSerializableAsJson("".concat(name, ".").concat(subName), subValue);
282
+ }
283
+ }
284
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
285
+ finally {
286
+ try {
287
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
288
+ }
289
+ finally { if (e_1) throw e_1.error; }
290
+ }
291
+ try {
292
+ JSON.stringify(value); // <- TODO: [0]
293
+ }
294
+ catch (error) {
295
+ if (!(error instanceof Error)) {
296
+ throw error;
297
+ }
298
+ throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n ".concat(name, " is not serializable\n\n ").concat(block(error.toString()), "\n "); }));
299
+ }
300
+ /*
301
+ TODO: [0] Is there some more elegant way to check circular references?
302
+ const seen = new Set();
303
+ const stack = [{ value }];
304
+ while (stack.length > 0) {
305
+ const { value } = stack.pop()!;
306
+ if (typeof value === 'object' && value !== null) {
307
+ if (seen.has(value)) {
308
+ throw new UnexpectedError(`${name} has circular reference`);
309
+ }
310
+ seen.add(value);
311
+ if (Array.isArray(value)) {
312
+ stack.push(...value.map((value) => ({ value })));
313
+ } else {
314
+ stack.push(...Object.values(value).map((value) => ({ value })));
315
+ }
316
+ }
317
+ }
318
+ */
319
+ return;
320
+ }
321
+ }
322
+ else {
323
+ throw new UnexpectedError("".concat(name, " is unknown"));
324
+ }
325
+ }
326
+ /**
327
+ * TODO: [🧠][🛣] More elegant way to tracking than passing `name`
328
+ * TODO: [🧠] !!! In-memory cache of same values to prevent multiple checks
329
+ * Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
330
+ */
331
+
332
+ /**
333
+ * @@@
334
+ * @@@
335
+ *
336
+ * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
337
+ *
338
+ * @param name - Name of the object for debugging purposes
339
+ * @param objectValue - Object to be deeply frozen
340
+ * @returns The same object as the input, but deeply frozen
341
+ * @private this is in comparison to `deepFreeze` a more specific utility and maybe not very good practice to use without specific reason and considerations
342
+ */
343
+ function $asDeeplyFrozenSerializableJson(name, objectValue) {
344
+ checkSerializableAsJson(name, objectValue);
345
+ return $deepFreeze(objectValue);
346
+ }
347
+ /**
348
+ * TODO: [🧠][🛣] More elegant way to tracking than passing `name`
349
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
350
+ */
351
+
352
+ /**
353
+ * The names of the parameters that are reserved for special purposes
354
+ *
355
+ * @public exported from `@promptbook/core`
356
+ */
357
+ $asDeeplyFrozenSerializableJson('RESERVED_PARAMETER_NAMES', [
358
+ 'content',
359
+ 'context',
360
+ 'knowledge',
361
+ 'samples',
362
+ 'modelName',
363
+ 'currentDate',
364
+ // <- TODO: Add more like 'date', 'modelName',...
365
+ // <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
366
+ ]);
367
+ // <- TODO: [🧜‍♂️]
368
+ /**
369
+ * @@@
370
+ *
371
+ * @public exported from `@promptbook/core`
372
+ */
373
+ var IS_VERBOSE = false;
374
+ /**
375
+ * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
376
+ */
377
+
139
378
  /**
140
379
  * This error indicates errors during the execution of the pipeline
141
380
  *
@@ -153,21 +392,169 @@
153
392
  }(Error));
154
393
 
155
394
  /**
156
- * This error type indicates that the error should not happen and its last check before crashing with some other error
395
+ * This error indicates that the pipeline collection cannot be propperly loaded
157
396
  *
158
397
  * @public exported from `@promptbook/core`
159
398
  */
160
- var UnexpectedError = /** @class */ (function (_super) {
161
- __extends(UnexpectedError, _super);
162
- function UnexpectedError(message) {
163
- var _this = _super.call(this, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the pipeline collection\n\n Please report issue:\n https://github.com/webgptorg/promptbook/issues\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
164
- _this.name = 'UnexpectedError';
165
- Object.setPrototypeOf(_this, UnexpectedError.prototype);
399
+ var CollectionError = /** @class */ (function (_super) {
400
+ __extends(CollectionError, _super);
401
+ function CollectionError(message) {
402
+ var _this = _super.call(this, message) || this;
403
+ _this.name = 'CollectionError';
404
+ Object.setPrototypeOf(_this, CollectionError.prototype);
166
405
  return _this;
167
406
  }
168
- return UnexpectedError;
407
+ return CollectionError;
169
408
  }(Error));
170
409
 
410
+ /**
411
+ * This error type indicates that you try to use a feature that is not available in the current environment
412
+ *
413
+ * @public exported from `@promptbook/core`
414
+ */
415
+ var EnvironmentMismatchError = /** @class */ (function (_super) {
416
+ __extends(EnvironmentMismatchError, _super);
417
+ function EnvironmentMismatchError(message) {
418
+ var _this = _super.call(this, message) || this;
419
+ _this.name = 'EnvironmentMismatchError';
420
+ Object.setPrototypeOf(_this, EnvironmentMismatchError.prototype);
421
+ return _this;
422
+ }
423
+ return EnvironmentMismatchError;
424
+ }(Error));
425
+
426
+ /**
427
+ * This error type indicates that some limit was reached
428
+ *
429
+ * @public exported from `@promptbook/core`
430
+ */
431
+ var LimitReachedError = /** @class */ (function (_super) {
432
+ __extends(LimitReachedError, _super);
433
+ function LimitReachedError(message) {
434
+ var _this = _super.call(this, message) || this;
435
+ _this.name = 'LimitReachedError';
436
+ Object.setPrototypeOf(_this, LimitReachedError.prototype);
437
+ return _this;
438
+ }
439
+ return LimitReachedError;
440
+ }(Error));
441
+
442
+ /**
443
+ * This error indicates that promptbook not found in the collection
444
+ *
445
+ * @public exported from `@promptbook/core`
446
+ */
447
+ var NotFoundError = /** @class */ (function (_super) {
448
+ __extends(NotFoundError, _super);
449
+ function NotFoundError(message) {
450
+ var _this = _super.call(this, message) || this;
451
+ _this.name = 'NotFoundError';
452
+ Object.setPrototypeOf(_this, NotFoundError.prototype);
453
+ return _this;
454
+ }
455
+ return NotFoundError;
456
+ }(Error));
457
+
458
+ /**
459
+ * This error type indicates that some part of the code is not implemented yet
460
+ *
461
+ * @public exported from `@promptbook/core`
462
+ */
463
+ var NotYetImplementedError = /** @class */ (function (_super) {
464
+ __extends(NotYetImplementedError, _super);
465
+ function NotYetImplementedError(message) {
466
+ var _this = _super.call(this, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This feature is not implemented yet but it will be soon.\n\n If you want speed up the implementation or just read more, look here:\n https://github.com/webgptorg/promptbook\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
467
+ _this.name = 'NotYetImplementedError';
468
+ Object.setPrototypeOf(_this, NotYetImplementedError.prototype);
469
+ return _this;
470
+ }
471
+ return NotYetImplementedError;
472
+ }(Error));
473
+
474
+ /**
475
+ * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
476
+ *
477
+ * @public exported from `@promptbook/core`
478
+ */
479
+ var ParsingError = /** @class */ (function (_super) {
480
+ __extends(ParsingError, _super);
481
+ function ParsingError(message) {
482
+ var _this = _super.call(this, message) || this;
483
+ _this.name = 'ParsingError';
484
+ Object.setPrototypeOf(_this, ParsingError.prototype);
485
+ return _this;
486
+ }
487
+ return ParsingError;
488
+ }(Error));
489
+
490
+ /**
491
+ * This error indicates that the promptbook object has valid syntax but contains logical errors (like circular dependencies)
492
+ *
493
+ * @public exported from `@promptbook/core`
494
+ */
495
+ var PipelineLogicError = /** @class */ (function (_super) {
496
+ __extends(PipelineLogicError, _super);
497
+ function PipelineLogicError(message) {
498
+ var _this = _super.call(this, message) || this;
499
+ _this.name = 'PipelineLogicError';
500
+ Object.setPrototypeOf(_this, PipelineLogicError.prototype);
501
+ return _this;
502
+ }
503
+ return PipelineLogicError;
504
+ }(Error));
505
+
506
+ /**
507
+ * This error indicates errors in referencing promptbooks between each other
508
+ *
509
+ * @public exported from `@promptbook/core`
510
+ */
511
+ var PipelineUrlError = /** @class */ (function (_super) {
512
+ __extends(PipelineUrlError, _super);
513
+ function PipelineUrlError(message) {
514
+ var _this = _super.call(this, message) || this;
515
+ _this.name = 'PipelineUrlError';
516
+ Object.setPrototypeOf(_this, PipelineUrlError.prototype);
517
+ return _this;
518
+ }
519
+ return PipelineUrlError;
520
+ }(Error));
521
+
522
+ /**
523
+ * Index of all custom errors
524
+ *
525
+ * @public exported from `@promptbook/core`
526
+ */
527
+ var ERRORS = {
528
+ CollectionError: CollectionError,
529
+ EnvironmentMismatchError: EnvironmentMismatchError,
530
+ LimitReachedError: LimitReachedError,
531
+ NotFoundError: NotFoundError,
532
+ NotYetImplementedError: NotYetImplementedError,
533
+ ParsingError: ParsingError,
534
+ PipelineExecutionError: PipelineExecutionError,
535
+ PipelineLogicError: PipelineLogicError,
536
+ PipelineUrlError: PipelineUrlError,
537
+ UnexpectedError: UnexpectedError,
538
+ // TODO: [🪑]> VersionMismatchError,
539
+ };
540
+
541
+ /**
542
+ * Serializes an error into a [🚉] JSON-serializable object
543
+ *
544
+ * @public exported from `@promptbook/utils`
545
+ */
546
+ function serializeError(error) {
547
+ var name = error.name, message = error.message, stack = error.stack;
548
+ if (!__spreadArray(['Error'], __read(Object.keys(ERRORS)), false).includes(name)) {
549
+ throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n \n Cannot serialize error with name \"".concat(name, "\"\n\n ").concat(block(stack || message), "\n \n "); }));
550
+ }
551
+ return {
552
+ name: name,
553
+ message: message,
554
+ stack: stack,
555
+ };
556
+ }
557
+
171
558
  /**
172
559
  * Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
173
560
  *
@@ -461,99 +848,16 @@
461
848
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
462
849
  */
463
850
 
464
- /**
465
- * @@@
466
- *
467
- * Note: `$` is used to indicate that this function is not a pure function - it mutates given object
468
- * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
469
- *
470
- * @returns The same object as the input, but deeply frozen
471
- * @public exported from `@promptbook/utils`
472
- */
473
- function $deepFreeze(objectValue) {
474
- var e_1, _a;
475
- var propertyNames = Object.getOwnPropertyNames(objectValue);
476
- try {
477
- for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
478
- var propertyName = propertyNames_1_1.value;
479
- var value = objectValue[propertyName];
480
- if (value && typeof value === 'object') {
481
- $deepFreeze(value);
482
- }
483
- }
484
- }
485
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
486
- finally {
487
- try {
488
- if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
489
- }
490
- finally { if (e_1) throw e_1.error; }
491
- }
492
- return Object.freeze(objectValue);
493
- }
494
- /**
495
- * TODO: [🧠] Is there a way how to meaningfully test this utility
496
- */
497
-
498
- /**
499
- * Returns the same value that is passed as argument.
500
- * No side effects.
501
- *
502
- * Note: It can be usefull for:
503
- *
504
- * 1) Leveling indentation
505
- * 2) Putting always-true or always-false conditions without getting eslint errors
506
- *
507
- * @param value any values
508
- * @returns the same values
509
- * @private within the repository
510
- */
511
- function just(value) {
512
- if (value === undefined) {
513
- return undefined;
514
- }
515
- return value;
516
- }
517
-
518
- /**
519
- * The names of the parameters that are reserved for special purposes
520
- *
521
- * @public exported from `@promptbook/core`
522
- */
523
- $deepFreeze([
524
- 'content',
525
- 'context',
526
- 'knowledge',
527
- 'samples',
528
- 'modelName',
529
- 'currentDate',
530
- // <- TODO: Add more like 'date', 'modelName',...
531
- // <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
532
- ]);
533
- // <- TODO: [🧜‍♂️]
534
- /**
535
- * @@@
536
- *
537
- * @public exported from `@promptbook/core`
538
- */
539
- var IS_VERBOSE = false;
540
- /**
541
- * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
542
- */
543
-
544
851
  /**
545
852
  * @@@
546
853
  *
547
854
  * Note: `$` is used to indicate that this function is not a pure function - it access global scope
548
855
  *
549
- * @public exported from `@promptbook/utils`
856
+ * @private internal function of `$Register`
550
857
  */
551
858
  function $getGlobalScope() {
552
859
  return Function('return this')();
553
860
  }
554
- /***
555
- * TODO: !!!!! Make private and promptbook registry from this
556
- */
557
861
 
558
862
  /**
559
863
  * Register is @@@
@@ -893,7 +1197,7 @@
893
1197
  if (!(error_1 instanceof Error)) {
894
1198
  throw error_1;
895
1199
  }
896
- socket.emit('error', { errorMessage: error_1.message });
1200
+ socket.emit('error', serializeError(error_1));
897
1201
  return [3 /*break*/, 16];
898
1202
  case 15:
899
1203
  socket.disconnect();
@@ -942,7 +1246,7 @@
942
1246
  if (!(error_2 instanceof Error)) {
943
1247
  throw error_2;
944
1248
  }
945
- socket.emit('error', { errorMessage: error_2.message });
1249
+ socket.emit('error', serializeError(error_2));
946
1250
  return [3 /*break*/, 5];
947
1251
  case 4:
948
1252
  socket.disconnect();
@@ -980,6 +1284,7 @@
980
1284
  };
981
1285
  }
982
1286
  /**
1287
+ * TODO: Maybe use `$asDeeplyFrozenSerializableJson`
983
1288
  * TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
984
1289
  * TODO: [⚖] Expose the collection to be able to connect to same collection via createCollectionFromUrl
985
1290
  * TODO: Handle progress - support streaming