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