@promptbook/deepseek 0.86.10 → 0.86.22

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/esm/index.es.js CHANGED
@@ -8,138 +8,19 @@ import spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
8
8
  * @generated
9
9
  * @see https://github.com/webgptorg/book
10
10
  */
11
- var BOOK_LANGUAGE_VERSION = '1.0.0';
11
+ const BOOK_LANGUAGE_VERSION = '1.0.0';
12
12
  /**
13
13
  * The version of the Promptbook engine
14
14
  *
15
15
  * @generated
16
16
  * @see https://github.com/webgptorg/promptbook
17
17
  */
18
- var PROMPTBOOK_ENGINE_VERSION = '0.86.10';
18
+ const PROMPTBOOK_ENGINE_VERSION = '0.86.22';
19
19
  /**
20
20
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
21
21
  * Note: [💞] Ignore a discrepancy between file name and entity name
22
22
  */
23
23
 
24
- /*! *****************************************************************************
25
- Copyright (c) Microsoft Corporation.
26
-
27
- Permission to use, copy, modify, and/or distribute this software for any
28
- purpose with or without fee is hereby granted.
29
-
30
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
31
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
32
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
33
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
34
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
35
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
36
- PERFORMANCE OF THIS SOFTWARE.
37
- ***************************************************************************** */
38
- /* global Reflect, Promise */
39
-
40
- var extendStatics = function(d, b) {
41
- extendStatics = Object.setPrototypeOf ||
42
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
43
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
44
- return extendStatics(d, b);
45
- };
46
-
47
- function __extends(d, b) {
48
- if (typeof b !== "function" && b !== null)
49
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
50
- extendStatics(d, b);
51
- function __() { this.constructor = d; }
52
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
53
- }
54
-
55
- var __assign = function() {
56
- __assign = Object.assign || function __assign(t) {
57
- for (var s, i = 1, n = arguments.length; i < n; i++) {
58
- s = arguments[i];
59
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
60
- }
61
- return t;
62
- };
63
- return __assign.apply(this, arguments);
64
- };
65
-
66
- function __awaiter(thisArg, _arguments, P, generator) {
67
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
68
- return new (P || (P = Promise))(function (resolve, reject) {
69
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
70
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
71
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
72
- step((generator = generator.apply(thisArg, _arguments || [])).next());
73
- });
74
- }
75
-
76
- function __generator(thisArg, body) {
77
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
78
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
79
- function verb(n) { return function (v) { return step([n, v]); }; }
80
- function step(op) {
81
- if (f) throw new TypeError("Generator is already executing.");
82
- while (_) try {
83
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
84
- if (y = 0, t) op = [op[0] & 2, t.value];
85
- switch (op[0]) {
86
- case 0: case 1: t = op; break;
87
- case 4: _.label++; return { value: op[1], done: false };
88
- case 5: _.label++; y = op[1]; op = [0]; continue;
89
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
90
- default:
91
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
92
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
93
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
94
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
95
- if (t[2]) _.ops.pop();
96
- _.trys.pop(); continue;
97
- }
98
- op = body.call(thisArg, _);
99
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
100
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
101
- }
102
- }
103
-
104
- function __values(o) {
105
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
106
- if (m) return m.call(o);
107
- if (o && typeof o.length === "number") return {
108
- next: function () {
109
- if (o && i >= o.length) o = void 0;
110
- return { value: o && o[i++], done: !o };
111
- }
112
- };
113
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
114
- }
115
-
116
- function __read(o, n) {
117
- var m = typeof Symbol === "function" && o[Symbol.iterator];
118
- if (!m) return o;
119
- var i = m.call(o), r, ar = [], e;
120
- try {
121
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
122
- }
123
- catch (error) { e = { error: error }; }
124
- finally {
125
- try {
126
- if (r && !r.done && (m = i["return"])) m.call(i);
127
- }
128
- finally { if (e) throw e.error; }
129
- }
130
- return ar;
131
- }
132
-
133
- function __spreadArray(to, from, pack) {
134
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
135
- if (ar || !(i in from)) {
136
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
137
- ar[i] = from[i];
138
- }
139
- }
140
- return to.concat(ar || Array.prototype.slice.call(from));
141
- }
142
-
143
24
  /**
144
25
  * Detects if the code is running in jest environment
145
26
  *
@@ -147,7 +28,13 @@ function __spreadArray(to, from, pack) {
147
28
  *
148
29
  * @public exported from `@promptbook/utils`
149
30
  */
150
- var $isRunningInJest = new Function("\n try {\n return process.env.JEST_WORKER_ID !== undefined;\n } catch (e) {\n return false;\n }\n");
31
+ const $isRunningInJest = new Function(`
32
+ try {
33
+ return process.env.JEST_WORKER_ID !== undefined;
34
+ } catch (e) {
35
+ return false;
36
+ }
37
+ `);
151
38
  /**
152
39
  * TODO: [🎺]
153
40
  */
@@ -157,16 +44,13 @@ var $isRunningInJest = new Function("\n try {\n return process.env.JES
157
44
  *
158
45
  * @public exported from `@promptbook/core`
159
46
  */
160
- var PipelineExecutionError = /** @class */ (function (_super) {
161
- __extends(PipelineExecutionError, _super);
162
- function PipelineExecutionError(message) {
163
- var _this = _super.call(this, message) || this;
164
- _this.name = 'PipelineExecutionError';
165
- Object.setPrototypeOf(_this, PipelineExecutionError.prototype);
166
- return _this;
47
+ class PipelineExecutionError extends Error {
48
+ constructor(message) {
49
+ super(message);
50
+ this.name = 'PipelineExecutionError';
51
+ Object.setPrototypeOf(this, PipelineExecutionError.prototype);
167
52
  }
168
- return PipelineExecutionError;
169
- }(Error));
53
+ }
170
54
 
171
55
  /**
172
56
  * Freezes the given object and all its nested objects recursively
@@ -178,26 +62,15 @@ var PipelineExecutionError = /** @class */ (function (_super) {
178
62
  * @public exported from `@promptbook/utils`
179
63
  */
180
64
  function $deepFreeze(objectValue) {
181
- var e_1, _a;
182
65
  if (Array.isArray(objectValue)) {
183
- return Object.freeze(objectValue.map(function (item) { return $deepFreeze(item); }));
66
+ return Object.freeze(objectValue.map((item) => $deepFreeze(item)));
184
67
  }
185
- var propertyNames = Object.getOwnPropertyNames(objectValue);
186
- try {
187
- for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
188
- var propertyName = propertyNames_1_1.value;
189
- var value = objectValue[propertyName];
190
- if (value && typeof value === 'object') {
191
- $deepFreeze(value);
192
- }
193
- }
194
- }
195
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
196
- finally {
197
- try {
198
- if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
68
+ const propertyNames = Object.getOwnPropertyNames(objectValue);
69
+ for (const propertyName of propertyNames) {
70
+ const value = objectValue[propertyName];
71
+ if (value && typeof value === 'object') {
72
+ $deepFreeze(value);
199
73
  }
200
- finally { if (e_1) throw e_1.error; }
201
74
  }
202
75
  Object.freeze(objectValue);
203
76
  return objectValue;
@@ -237,7 +110,7 @@ $deepFreeze({
237
110
  *
238
111
  * @public exported from `@promptbook/core`
239
112
  */
240
- var UNCERTAIN_USAGE = $deepFreeze({
113
+ const UNCERTAIN_USAGE = $deepFreeze({
241
114
  price: { value: 0, isUncertain: true },
242
115
  input: {
243
116
  tokensCount: { value: 0, isUncertain: true },
@@ -281,32 +154,32 @@ function $getCurrentDate() {
281
154
  *
282
155
  * @public exported from `@promptbook/core`
283
156
  */
284
- var NAME = "Promptbook";
157
+ const NAME = `Promptbook`;
285
158
  /**
286
159
  * Email of the responsible person
287
160
  *
288
161
  * @public exported from `@promptbook/core`
289
162
  */
290
- var ADMIN_EMAIL = 'pavol@ptbk.io';
163
+ const ADMIN_EMAIL = 'pavol@ptbk.io';
291
164
  /**
292
165
  * Name of the responsible person for the Promptbook on GitHub
293
166
  *
294
167
  * @public exported from `@promptbook/core`
295
168
  */
296
- var ADMIN_GITHUB_NAME = 'hejny';
169
+ const ADMIN_GITHUB_NAME = 'hejny';
297
170
  // <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
298
171
  /**
299
172
  * The maximum number of iterations for a loops
300
173
  *
301
174
  * @private within the repository - too low-level in comparison with other `MAX_...`
302
175
  */
303
- var LOOP_LIMIT = 1000;
176
+ const LOOP_LIMIT = 1000;
304
177
  /**
305
178
  * Strings to represent various values in the context of parameter values
306
179
  *
307
180
  * @public exported from `@promptbook/utils`
308
181
  */
309
- var VALUE_STRINGS = {
182
+ const VALUE_STRINGS = {
310
183
  empty: '(nothing; empty string)',
311
184
  null: '(no value; null)',
312
185
  undefined: '(unknown value; undefined)',
@@ -320,7 +193,7 @@ var VALUE_STRINGS = {
320
193
  *
321
194
  * @public exported from `@promptbook/utils`
322
195
  */
323
- var SMALL_NUMBER = 0.001;
196
+ const SMALL_NUMBER = 0.001;
324
197
  // <- TODO: [🧜‍♂️]
325
198
  /**
326
199
  * @@@
@@ -345,8 +218,11 @@ Object.freeze({
345
218
  * @public exported from `@promptbook/utils`
346
219
  */
347
220
  function orderJson(options) {
348
- var value = options.value, order = options.order;
349
- var orderedValue = __assign(__assign({}, (order === undefined ? {} : Object.fromEntries(order.map(function (key) { return [key, undefined]; })))), value);
221
+ const { value, order } = options;
222
+ const orderedValue = {
223
+ ...(order === undefined ? {} : Object.fromEntries(order.map((key) => [key, undefined]))),
224
+ ...value,
225
+ };
350
226
  return orderedValue;
351
227
  }
352
228
 
@@ -356,11 +232,37 @@ function orderJson(options) {
356
232
  * @private private within the repository
357
233
  */
358
234
  function getErrorReportUrl(error) {
359
- var report = {
360
- title: "\uD83D\uDC1C Error report from ".concat(NAME),
361
- body: spaceTrim(function (block) { return "\n\n\n `".concat(error.name || 'Error', "` has occurred in the [").concat(NAME, "], please look into it @").concat(ADMIN_GITHUB_NAME, ".\n\n ```\n ").concat(block(error.message || '(no error message)'), "\n ```\n\n\n ## More info:\n\n - **Promptbook engine version:** ").concat(PROMPTBOOK_ENGINE_VERSION, "\n - **Book language version:** ").concat(BOOK_LANGUAGE_VERSION, "\n - **Time:** ").concat(new Date().toISOString(), "\n\n <details>\n <summary>Stack trace:</summary>\n\n ## Stack trace:\n\n ```stacktrace\n ").concat(block(error.stack || '(empty)'), "\n ```\n </details>\n\n "); }),
235
+ const report = {
236
+ title: `🐜 Error report from ${NAME}`,
237
+ body: spaceTrim((block) => `
238
+
239
+
240
+ \`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
241
+
242
+ \`\`\`
243
+ ${block(error.message || '(no error message)')}
244
+ \`\`\`
245
+
246
+
247
+ ## More info:
248
+
249
+ - **Promptbook engine version:** ${PROMPTBOOK_ENGINE_VERSION}
250
+ - **Book language version:** ${BOOK_LANGUAGE_VERSION}
251
+ - **Time:** ${new Date().toISOString()}
252
+
253
+ <details>
254
+ <summary>Stack trace:</summary>
255
+
256
+ ## Stack trace:
257
+
258
+ \`\`\`stacktrace
259
+ ${block(error.stack || '(empty)')}
260
+ \`\`\`
261
+ </details>
262
+
263
+ `),
362
264
  };
363
- var reportUrl = new URL("https://github.com/webgptorg/promptbook/issues/new");
265
+ const reportUrl = new URL(`https://github.com/webgptorg/promptbook/issues/new`);
364
266
  reportUrl.searchParams.set('labels', 'bug');
365
267
  reportUrl.searchParams.set('assignees', ADMIN_GITHUB_NAME);
366
268
  reportUrl.searchParams.set('title', report.title);
@@ -373,16 +275,24 @@ function getErrorReportUrl(error) {
373
275
  *
374
276
  * @public exported from `@promptbook/core`
375
277
  */
376
- var UnexpectedError = /** @class */ (function (_super) {
377
- __extends(UnexpectedError, _super);
378
- function UnexpectedError(message) {
379
- var _this = _super.call(this, spaceTrim$1(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 ").concat(block(getErrorReportUrl(new Error(message)).href), "\n\n Or contact us on ").concat(ADMIN_EMAIL, "\n\n "); })) || this;
380
- _this.name = 'UnexpectedError';
381
- Object.setPrototypeOf(_this, UnexpectedError.prototype);
382
- return _this;
278
+ class UnexpectedError extends Error {
279
+ constructor(message) {
280
+ super(spaceTrim$1((block) => `
281
+ ${block(message)}
282
+
283
+ Note: This error should not happen.
284
+ It's probbably a bug in the pipeline collection
285
+
286
+ Please report issue:
287
+ ${block(getErrorReportUrl(new Error(message)).href)}
288
+
289
+ Or contact us on ${ADMIN_EMAIL}
290
+
291
+ `));
292
+ this.name = 'UnexpectedError';
293
+ Object.setPrototypeOf(this, UnexpectedError.prototype);
383
294
  }
384
- return UnexpectedError;
385
- }(Error));
295
+ }
386
296
 
387
297
  /**
388
298
  * Checks if the value is [🚉] serializable as JSON
@@ -405,10 +315,9 @@ var UnexpectedError = /** @class */ (function (_super) {
405
315
  * @public exported from `@promptbook/utils`
406
316
  */
407
317
  function checkSerializableAsJson(options) {
408
- var e_1, _a;
409
- var value = options.value, name = options.name, message = options.message;
318
+ const { value, name, message } = options;
410
319
  if (value === undefined) {
411
- throw new UnexpectedError("".concat(name, " is undefined"));
320
+ throw new UnexpectedError(`${name} is undefined`);
412
321
  }
413
322
  else if (value === null) {
414
323
  return;
@@ -423,49 +332,54 @@ function checkSerializableAsJson(options) {
423
332
  return;
424
333
  }
425
334
  else if (typeof value === 'symbol') {
426
- throw new UnexpectedError("".concat(name, " is symbol"));
335
+ throw new UnexpectedError(`${name} is symbol`);
427
336
  }
428
337
  else if (typeof value === 'function') {
429
- throw new UnexpectedError("".concat(name, " is function"));
338
+ throw new UnexpectedError(`${name} is function`);
430
339
  }
431
340
  else if (typeof value === 'object' && Array.isArray(value)) {
432
- for (var i = 0; i < value.length; i++) {
433
- checkSerializableAsJson({ name: "".concat(name, "[").concat(i, "]"), value: value[i], message: message });
341
+ for (let i = 0; i < value.length; i++) {
342
+ checkSerializableAsJson({ name: `${name}[${i}]`, value: value[i], message });
434
343
  }
435
344
  }
436
345
  else if (typeof value === 'object') {
437
346
  if (value instanceof Date) {
438
- throw new UnexpectedError(spaceTrim(function (block) { return "\n `".concat(name, "` is Date\n\n Use `string_date_iso8601` instead\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
347
+ throw new UnexpectedError(spaceTrim((block) => `
348
+ \`${name}\` is Date
349
+
350
+ Use \`string_date_iso8601\` instead
351
+
352
+ Additional message for \`${name}\`:
353
+ ${block(message || '(nothing)')}
354
+ `));
439
355
  }
440
356
  else if (value instanceof Map) {
441
- throw new UnexpectedError("".concat(name, " is Map"));
357
+ throw new UnexpectedError(`${name} is Map`);
442
358
  }
443
359
  else if (value instanceof Set) {
444
- throw new UnexpectedError("".concat(name, " is Set"));
360
+ throw new UnexpectedError(`${name} is Set`);
445
361
  }
446
362
  else if (value instanceof RegExp) {
447
- throw new UnexpectedError("".concat(name, " is RegExp"));
363
+ throw new UnexpectedError(`${name} is RegExp`);
448
364
  }
449
365
  else if (value instanceof Error) {
450
- throw new UnexpectedError(spaceTrim(function (block) { return "\n `".concat(name, "` is unserialized Error\n\n Use function `serializeError`\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n\n "); }));
366
+ throw new UnexpectedError(spaceTrim((block) => `
367
+ \`${name}\` is unserialized Error
368
+
369
+ Use function \`serializeError\`
370
+
371
+ Additional message for \`${name}\`:
372
+ ${block(message || '(nothing)')}
373
+
374
+ `));
451
375
  }
452
376
  else {
453
- try {
454
- for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
455
- var _d = __read(_c.value, 2), subName = _d[0], subValue = _d[1];
456
- if (subValue === undefined) {
457
- // Note: undefined in object is serializable - it is just omited
458
- continue;
459
- }
460
- checkSerializableAsJson({ name: "".concat(name, ".").concat(subName), value: subValue, message: message });
461
- }
462
- }
463
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
464
- finally {
465
- try {
466
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
377
+ for (const [subName, subValue] of Object.entries(value)) {
378
+ if (subValue === undefined) {
379
+ // Note: undefined in object is serializable - it is just omited
380
+ continue;
467
381
  }
468
- finally { if (e_1) throw e_1.error; }
382
+ checkSerializableAsJson({ name: `${name}.${subName}`, value: subValue, message });
469
383
  }
470
384
  try {
471
385
  JSON.stringify(value); // <- TODO: [0]
@@ -474,7 +388,14 @@ function checkSerializableAsJson(options) {
474
388
  if (!(error instanceof Error)) {
475
389
  throw error;
476
390
  }
477
- throw new UnexpectedError(spaceTrim(function (block) { return "\n `".concat(name, "` is not serializable\n\n ").concat(block(error.stack || error.message), "\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
391
+ throw new UnexpectedError(spaceTrim((block) => `
392
+ \`${name}\` is not serializable
393
+
394
+ ${block(error.stack || error.message)}
395
+
396
+ Additional message for \`${name}\`:
397
+ ${block(message || '(nothing)')}
398
+ `));
478
399
  }
479
400
  /*
480
401
  TODO: [0] Is there some more elegant way to check circular references?
@@ -499,7 +420,12 @@ function checkSerializableAsJson(options) {
499
420
  }
500
421
  }
501
422
  else {
502
- throw new UnexpectedError(spaceTrim(function (block) { return "\n `".concat(name, "` is unknown type\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
423
+ throw new UnexpectedError(spaceTrim((block) => `
424
+ \`${name}\` is unknown type
425
+
426
+ Additional message for \`${name}\`:
427
+ ${block(message || '(nothing)')}
428
+ `));
503
429
  }
504
430
  }
505
431
  /**
@@ -545,9 +471,9 @@ function deepClone(objectValue) {
545
471
  * @public exported from `@promptbook/utils`
546
472
  */
547
473
  function exportJson(options) {
548
- var name = options.name, value = options.value, order = options.order, message = options.message;
549
- checkSerializableAsJson({ name: name, value: value, message: message });
550
- var orderedValue =
474
+ const { name, value, order, message } = options;
475
+ checkSerializableAsJson({ name, value, message });
476
+ const orderedValue =
551
477
  // TODO: Fix error "Type instantiation is excessively deep and possibly infinite."
552
478
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
553
479
  // @ts-ignore
@@ -570,19 +496,19 @@ function exportJson(options) {
570
496
  *
571
497
  * @private within the repository
572
498
  */
573
- var REPLACING_NONCE = 'ptbkauk42kV2dzao34faw7FudQUHYPtW';
499
+ const REPLACING_NONCE = 'ptbkauk42kV2dzao34faw7FudQUHYPtW';
574
500
  /**
575
501
  * @@@
576
502
  *
577
503
  * @private within the repository
578
504
  */
579
- var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
505
+ const RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
580
506
  /**
581
507
  * @@@
582
508
  *
583
509
  * @private within the repository
584
510
  */
585
- var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
511
+ const RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
586
512
  /**
587
513
  * The names of the parameters that are reserved for special purposes
588
514
  *
@@ -590,7 +516,7 @@ var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
590
516
  */
591
517
  exportJson({
592
518
  name: 'RESERVED_PARAMETER_NAMES',
593
- message: "The names of the parameters that are reserved for special purposes",
519
+ message: `The names of the parameters that are reserved for special purposes`,
594
520
  value: [
595
521
  'content',
596
522
  'context',
@@ -612,16 +538,13 @@ exportJson({
612
538
  *
613
539
  * @public exported from `@promptbook/core`
614
540
  */
615
- var LimitReachedError = /** @class */ (function (_super) {
616
- __extends(LimitReachedError, _super);
617
- function LimitReachedError(message) {
618
- var _this = _super.call(this, message) || this;
619
- _this.name = 'LimitReachedError';
620
- Object.setPrototypeOf(_this, LimitReachedError.prototype);
621
- return _this;
541
+ class LimitReachedError extends Error {
542
+ constructor(message) {
543
+ super(message);
544
+ this.name = 'LimitReachedError';
545
+ Object.setPrototypeOf(this, LimitReachedError.prototype);
622
546
  }
623
- return LimitReachedError;
624
- }(Error));
547
+ }
625
548
 
626
549
  /**
627
550
  * Format either small or big number
@@ -641,9 +564,9 @@ function numberToString(value) {
641
564
  else if (value === -Infinity) {
642
565
  return VALUE_STRINGS.negativeInfinity;
643
566
  }
644
- for (var exponent = 0; exponent < 15; exponent++) {
645
- var factor = Math.pow(10, exponent);
646
- var valueRounded = Math.round(value * factor) / factor;
567
+ for (let exponent = 0; exponent < 15; exponent++) {
568
+ const factor = 10 ** exponent;
569
+ const valueRounded = Math.round(value * factor) / factor;
647
570
  if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
648
571
  return valueRounded.toFixed(exponent);
649
572
  }
@@ -711,47 +634,38 @@ function valueToString(value) {
711
634
  * @public exported from `@promptbook/utils`
712
635
  */
713
636
  function templateParameters(template, parameters) {
714
- var e_1, _a;
715
- try {
716
- for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
717
- var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
718
- if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
719
- throw new UnexpectedError("Parameter `{".concat(parameterName, "}` has missing value"));
720
- }
721
- else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
722
- // TODO: [🍵]
723
- throw new UnexpectedError("Parameter `{".concat(parameterName, "}` is restricted to use"));
724
- }
637
+ for (const [parameterName, parameterValue] of Object.entries(parameters)) {
638
+ if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
639
+ throw new UnexpectedError(`Parameter \`{${parameterName}}\` has missing value`);
725
640
  }
726
- }
727
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
728
- finally {
729
- try {
730
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
641
+ else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
642
+ // TODO: [🍵]
643
+ throw new UnexpectedError(`Parameter \`{${parameterName}}\` is restricted to use`);
731
644
  }
732
- finally { if (e_1) throw e_1.error; }
733
645
  }
734
- var replacedTemplates = template;
735
- var match;
736
- var loopLimit = LOOP_LIMIT;
737
- var _loop_1 = function () {
646
+ let replacedTemplates = template;
647
+ let match;
648
+ let loopLimit = LOOP_LIMIT;
649
+ while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
650
+ .exec(replacedTemplates))) {
738
651
  if (loopLimit-- < 0) {
739
652
  throw new LimitReachedError('Loop limit reached during parameters replacement in `templateParameters`');
740
653
  }
741
- var precol = match.groups.precol;
742
- var parameterName = match.groups.parameterName;
654
+ const precol = match.groups.precol;
655
+ const parameterName = match.groups.parameterName;
743
656
  if (parameterName === '') {
744
- return "continue";
657
+ // Note: Skip empty placeholders. It's used to avoid confusion with JSON-like strings
658
+ continue;
745
659
  }
746
660
  if (parameterName.indexOf('{') !== -1 || parameterName.indexOf('}') !== -1) {
747
661
  throw new PipelineExecutionError('Parameter is already opened or not closed');
748
662
  }
749
663
  if (parameters[parameterName] === undefined) {
750
- throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
664
+ throw new PipelineExecutionError(`Parameter \`{${parameterName}}\` is not defined`);
751
665
  }
752
- var parameterValue = parameters[parameterName];
666
+ let parameterValue = parameters[parameterName];
753
667
  if (parameterValue === undefined) {
754
- throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
668
+ throw new PipelineExecutionError(`Parameter \`{${parameterName}}\` is not defined`);
755
669
  }
756
670
  parameterValue = valueToString(parameterValue);
757
671
  // Escape curly braces in parameter values to prevent prompt-injection
@@ -759,17 +673,13 @@ function templateParameters(template, parameters) {
759
673
  if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
760
674
  parameterValue = parameterValue
761
675
  .split('\n')
762
- .map(function (line, index) { return (index === 0 ? line : "".concat(precol).concat(line)); })
676
+ .map((line, index) => (index === 0 ? line : `${precol}${line}`))
763
677
  .join('\n');
764
678
  }
765
679
  replacedTemplates =
766
680
  replacedTemplates.substring(0, match.index + precol.length) +
767
681
  parameterValue +
768
682
  replacedTemplates.substring(match.index + precol.length + parameterName.length + 2);
769
- };
770
- while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
771
- .exec(replacedTemplates))) {
772
- _loop_1();
773
683
  }
774
684
  // [💫] Check if there are parameters that are not closed properly
775
685
  if (/{\w+$/.test(replacedTemplates)) {
@@ -803,8 +713,8 @@ function asSerializable(value) {
803
713
  return value.map(asSerializable);
804
714
  }
805
715
  else if (value !== null && typeof value === 'object') {
806
- var result = {};
807
- for (var key in value) {
716
+ const result = {};
717
+ for (const key in value) {
808
718
  if (Object.prototype.hasOwnProperty.call(value, key)) {
809
719
  result[key] = asSerializable(value[key]);
810
720
  }
@@ -822,131 +732,119 @@ function asSerializable(value) {
822
732
  * @public exported from `@promptbook/vercel`
823
733
  */
824
734
  function createExecutionToolsFromVercelProvider(options) {
825
- var title = options.title, description = options.description;
826
- var vercelProvider = options.vercelProvider, availableModels = options.availableModels, userId = options.userId, _a = options.additionalChatSettings, additionalChatSettings = _a === void 0 ? {} : _a;
735
+ let { title, description } = options;
736
+ const { vercelProvider, availableModels, userId, additionalChatSettings = {} } = options;
827
737
  if (!/Vercel/i.test(title)) {
828
- title = "".concat(title, " (through Vercel)");
738
+ title = `${title} (through Vercel)`;
829
739
  } /* not else */
830
740
  if (description === undefined) {
831
- description = "Implementation of ".concat(title, " through Vercel");
741
+ description = `Implementation of ${title} through Vercel`;
832
742
  } /* not else */
833
743
  if (!/Vercel/i.test(description)) {
834
- description = "".concat(description, " (through Vercel)");
744
+ description = `${description} (through Vercel)`;
835
745
  } /* not else */
836
746
  return {
837
- title: title,
838
- description: description,
839
- checkConfiguration: function () {
747
+ title,
748
+ description,
749
+ checkConfiguration() {
840
750
  // Note: There is no way how to check configuration of Vercel provider
841
751
  return Promise.resolve();
842
752
  },
843
- listModels: function () {
844
- return __awaiter(this, void 0, void 0, function () {
845
- return __generator(this, function (_a) {
846
- return [2 /*return*/, availableModels];
847
- });
848
- });
753
+ async listModels() {
754
+ return availableModels;
849
755
  },
850
- callChatModel: function (prompt) {
756
+ async callChatModel(prompt) {
851
757
  var _a;
852
- return __awaiter(this, void 0, void 0, function () {
853
- var content, parameters, modelRequirements, modelName, model, rawPromptContent, rawRequest, start, rawResponse, complete, usage;
854
- var _this = this;
855
- return __generator(this, function (_b) {
856
- switch (_b.label) {
857
- case 0:
858
- content = prompt.content, parameters = prompt.parameters, modelRequirements = prompt.modelRequirements;
859
- if (modelRequirements.modelVariant !== 'CHAT') {
860
- throw new PipelineExecutionError('Use callChatModel only for CHAT variant');
861
- }
862
- modelName = modelRequirements.modelName ||
863
- ((_a = availableModels.find(function (_a) {
864
- var modelVariant = _a.modelVariant;
865
- return modelVariant === 'CHAT';
866
- })) === null || _a === void 0 ? void 0 : _a.modelName);
867
- if (!modelName) {
868
- throw new PipelineExecutionError(spaceTrim("\n Can not determine which model to use.\n\n You need to provide at least one of:\n 1) In `createExecutionToolsFromVercelProvider` options, provide `availableModels` with at least one model\n 2) In `prompt.modelRequirements`, provide `modelName` with the name of the model to use\n\n "));
869
- }
870
- return [4 /*yield*/, vercelProvider.chat(modelName, __assign({ user: (userId === null || userId === void 0 ? void 0 : userId.toString()) || undefined }, additionalChatSettings))];
871
- case 1:
872
- model = _b.sent();
873
- rawPromptContent = templateParameters(content, __assign(__assign({}, parameters), { modelName: modelName }));
874
- rawRequest = {
875
- // <- TODO: [☂]
876
- inputFormat: 'messages',
877
- mode: {
878
- type: 'regular',
879
- tools: [
880
- /* <- TODO: Pass the tools */
881
- ],
882
- },
883
- prompt: __spreadArray(__spreadArray([], __read((modelRequirements.systemMessage === undefined
884
- ? []
885
- : [
886
- {
887
- role: 'system',
888
- content: modelRequirements.systemMessage,
889
- },
890
- ])), false), [
891
- {
892
- role: 'user',
893
- content: [
894
- {
895
- type: 'text',
896
- text: rawPromptContent,
897
- },
898
- ],
899
- },
900
- ], false),
901
- };
902
- start = $getCurrentDate();
903
- if (options.isVerbose) {
904
- console.info(colors.bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
905
- }
906
- return [4 /*yield*/, (function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
907
- switch (_a.label) {
908
- case 0: return [4 /*yield*/, model.doGenerate(rawRequest)];
909
- case 1: return [2 /*return*/, _a.sent()];
910
- }
911
- }); }); })().catch(function (error) {
912
- // <- Note: This weird structure is here to catch errors in both sync and async `doGenerate`
913
- if (options.isVerbose) {
914
- console.info(colors.bgRed('error'), error);
915
- }
916
- throw error;
917
- })];
918
- case 2:
919
- rawResponse = _b.sent();
920
- return [4 /*yield*/, model.doGenerate(rawRequest)];
921
- case 3:
922
- _b.sent();
923
- if (options.isVerbose) {
924
- console.info(colors.bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
925
- }
926
- if (rawResponse.text === undefined) {
927
- throw new PipelineExecutionError('No response message');
928
- }
929
- complete = $getCurrentDate();
930
- usage = UNCERTAIN_USAGE;
931
- return [2 /*return*/, exportJson({
932
- name: 'promptResult',
933
- message: "Result of `createExecutionToolsFromVercelProvider.callChatModel`",
934
- value: {
935
- content: rawResponse.text,
936
- modelName: modelName,
937
- timing: {
938
- start: start,
939
- complete: complete,
940
- },
941
- usage: usage,
942
- rawPromptContent: rawPromptContent,
943
- rawRequest: rawRequest,
944
- rawResponse: asSerializable(rawResponse),
945
- // <- [🗯]
946
- },
947
- })];
948
- }
949
- });
758
+ const { content, parameters, modelRequirements } = prompt;
759
+ if (modelRequirements.modelVariant !== 'CHAT') {
760
+ throw new PipelineExecutionError('Use callChatModel only for CHAT variant');
761
+ }
762
+ const modelName = modelRequirements.modelName ||
763
+ ((_a = availableModels.find(({ modelVariant }) => modelVariant === 'CHAT')) === null || _a === void 0 ? void 0 : _a.modelName);
764
+ if (!modelName) {
765
+ throw new PipelineExecutionError(spaceTrim(`
766
+ Can not determine which model to use.
767
+
768
+ You need to provide at least one of:
769
+ 1) In \`createExecutionToolsFromVercelProvider\` options, provide \`availableModels\` with at least one model
770
+ 2) In \`prompt.modelRequirements\`, provide \`modelName\` with the name of the model to use
771
+
772
+ `));
773
+ }
774
+ const model = await vercelProvider.chat(modelName, {
775
+ user: (userId === null || userId === void 0 ? void 0 : userId.toString()) || undefined,
776
+ ...additionalChatSettings,
777
+ });
778
+ const rawPromptContent = templateParameters(content, { ...parameters, modelName });
779
+ const rawRequest = {
780
+ // <- TODO: [☂]
781
+ inputFormat: 'messages',
782
+ mode: {
783
+ type: 'regular',
784
+ tools: [
785
+ /* <- TODO: Pass the tools */
786
+ ],
787
+ },
788
+ prompt: [
789
+ ...(modelRequirements.systemMessage === undefined
790
+ ? []
791
+ : [
792
+ {
793
+ role: 'system',
794
+ content: modelRequirements.systemMessage,
795
+ },
796
+ ]),
797
+ {
798
+ role: 'user',
799
+ content: [
800
+ {
801
+ type: 'text',
802
+ text: rawPromptContent,
803
+ },
804
+ ],
805
+ },
806
+ ],
807
+ };
808
+ const start = $getCurrentDate();
809
+ if (options.isVerbose) {
810
+ console.info(colors.bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
811
+ }
812
+ const rawResponse = await (async () => await model.doGenerate(rawRequest))().catch((error) => {
813
+ // <- Note: This weird structure is here to catch errors in both sync and async `doGenerate`
814
+ if (options.isVerbose) {
815
+ console.info(colors.bgRed('error'), error);
816
+ }
817
+ throw error;
818
+ });
819
+ await model.doGenerate(rawRequest);
820
+ if (options.isVerbose) {
821
+ console.info(colors.bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
822
+ }
823
+ if (rawResponse.text === undefined) {
824
+ throw new PipelineExecutionError('No response message');
825
+ }
826
+ const complete = $getCurrentDate();
827
+ /*
828
+ TODO: [🕘] Usage count
829
+ const usage = computeOpenAiUsage(content || '', resultContent || '', rawResponse);
830
+ */
831
+ const usage = UNCERTAIN_USAGE;
832
+ return exportJson({
833
+ name: 'promptResult',
834
+ message: `Result of \`createExecutionToolsFromVercelProvider.callChatModel\``,
835
+ value: {
836
+ content: rawResponse.text,
837
+ modelName,
838
+ timing: {
839
+ start,
840
+ complete,
841
+ },
842
+ usage,
843
+ rawPromptContent,
844
+ rawRequest,
845
+ rawResponse: asSerializable(rawResponse),
846
+ // <- [🗯]
847
+ },
950
848
  });
951
849
  },
952
850
  };
@@ -957,21 +855,30 @@ function createExecutionToolsFromVercelProvider(options) {
957
855
  *
958
856
  * @public exported from `@promptbook/deepseek`
959
857
  */
960
- var createDeepseekExecutionTools = Object.assign(function (options) {
858
+ const createDeepseekExecutionTools = Object.assign((options) => {
961
859
  if ($isRunningInJest()) {
962
860
  // Note: [🔘]
963
861
  throw new Error('DeepseekExecutionTools are not supported in Jest environment');
964
862
  }
965
863
  // Note: [🔘] Maybe there is same compatibility problem as in '@ai-sdk/deepseek'
966
864
  // eslint-disable-next-line @typescript-eslint/no-var-requires
967
- var createDeepSeek = require('@ai-sdk/deepseek').createDeepSeek;
968
- var deepseekVercelProvider = createDeepSeek(__assign({}, options));
969
- return createExecutionToolsFromVercelProvider(__assign({ title: 'Deepseek', description: 'Implementation of Deepseek models', vercelProvider: deepseekVercelProvider, availableModels: [
865
+ const { createDeepSeek } = require('@ai-sdk/deepseek');
866
+ const deepseekVercelProvider = createDeepSeek({
867
+ ...options,
868
+ // apiKey: process.env.DEEPSEEK_GENERATIVE_AI_API_KEY,
869
+ });
870
+ return createExecutionToolsFromVercelProvider({
871
+ title: 'Deepseek',
872
+ description: 'Implementation of Deepseek models',
873
+ vercelProvider: deepseekVercelProvider,
874
+ availableModels: [
970
875
  // TODO: [🕘] Maybe list models in same way as in other providers - in separate file with metadata
971
876
  'deepseek-chat',
972
877
  'deepseek-reasoner',
973
878
  // <- TODO: How picking of the default model looks like in `createExecutionToolsFromVercelProvider`
974
- ].map(function (modelName) { return ({ modelName: modelName, modelVariant: 'CHAT' }); }) }, options));
879
+ ].map((modelName) => ({ modelName, modelVariant: 'CHAT' })),
880
+ ...options,
881
+ });
975
882
  }, {
976
883
  packageName: '@promptbook/deepseek',
977
884
  className: 'DeepseekExecutionTools',
@@ -985,16 +892,23 @@ var createDeepseekExecutionTools = Object.assign(function (options) {
985
892
  *
986
893
  * @public exported from `@promptbook/core`
987
894
  */
988
- var NotYetImplementedError = /** @class */ (function (_super) {
989
- __extends(NotYetImplementedError, _super);
990
- function NotYetImplementedError(message) {
991
- var _this = _super.call(this, spaceTrim$1(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 pavol@ptbk.io\n\n "); })) || this;
992
- _this.name = 'NotYetImplementedError';
993
- Object.setPrototypeOf(_this, NotYetImplementedError.prototype);
994
- return _this;
895
+ class NotYetImplementedError extends Error {
896
+ constructor(message) {
897
+ super(spaceTrim$1((block) => `
898
+ ${block(message)}
899
+
900
+ Note: This feature is not implemented yet but it will be soon.
901
+
902
+ If you want speed up the implementation or just read more, look here:
903
+ https://github.com/webgptorg/promptbook
904
+
905
+ Or contact us on pavol@ptbk.io
906
+
907
+ `));
908
+ this.name = 'NotYetImplementedError';
909
+ Object.setPrototypeOf(this, NotYetImplementedError.prototype);
995
910
  }
996
- return NotYetImplementedError;
997
- }(Error));
911
+ }
998
912
 
999
913
  /**
1000
914
  * @@@
@@ -1017,46 +931,35 @@ function $getGlobalScope() {
1017
931
  * @public exported from `@promptbook/utils`
1018
932
  */
1019
933
  function normalizeTo_SCREAMING_CASE(text) {
1020
- var e_1, _a;
1021
- var charType;
1022
- var lastCharType = 'OTHER';
1023
- var normalizedName = '';
1024
- try {
1025
- for (var text_1 = __values(text), text_1_1 = text_1.next(); !text_1_1.done; text_1_1 = text_1.next()) {
1026
- var char = text_1_1.value;
1027
- var normalizedChar = void 0;
1028
- if (/^[a-z]$/.test(char)) {
1029
- charType = 'LOWERCASE';
1030
- normalizedChar = char.toUpperCase();
1031
- }
1032
- else if (/^[A-Z]$/.test(char)) {
1033
- charType = 'UPPERCASE';
1034
- normalizedChar = char;
1035
- }
1036
- else if (/^[0-9]$/.test(char)) {
1037
- charType = 'NUMBER';
1038
- normalizedChar = char;
1039
- }
1040
- else {
1041
- charType = 'OTHER';
1042
- normalizedChar = '_';
1043
- }
1044
- if (charType !== lastCharType &&
1045
- !(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
1046
- !(lastCharType === 'NUMBER') &&
1047
- !(charType === 'NUMBER')) {
1048
- normalizedName += '_';
1049
- }
1050
- normalizedName += normalizedChar;
1051
- lastCharType = charType;
934
+ let charType;
935
+ let lastCharType = 'OTHER';
936
+ let normalizedName = '';
937
+ for (const char of text) {
938
+ let normalizedChar;
939
+ if (/^[a-z]$/.test(char)) {
940
+ charType = 'LOWERCASE';
941
+ normalizedChar = char.toUpperCase();
1052
942
  }
1053
- }
1054
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1055
- finally {
1056
- try {
1057
- if (text_1_1 && !text_1_1.done && (_a = text_1.return)) _a.call(text_1);
943
+ else if (/^[A-Z]$/.test(char)) {
944
+ charType = 'UPPERCASE';
945
+ normalizedChar = char;
946
+ }
947
+ else if (/^[0-9]$/.test(char)) {
948
+ charType = 'NUMBER';
949
+ normalizedChar = char;
950
+ }
951
+ else {
952
+ charType = 'OTHER';
953
+ normalizedChar = '_';
954
+ }
955
+ if (charType !== lastCharType &&
956
+ !(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
957
+ !(lastCharType === 'NUMBER') &&
958
+ !(charType === 'NUMBER')) {
959
+ normalizedName += '_';
1058
960
  }
1059
- finally { if (e_1) throw e_1.error; }
961
+ normalizedName += normalizedChar;
962
+ lastCharType = charType;
1060
963
  }
1061
964
  normalizedName = normalizedName.replace(/_+/g, '_');
1062
965
  normalizedName = normalizedName.replace(/_?\/_?/g, '/');
@@ -1093,27 +996,27 @@ function normalizeTo_snake_case(text) {
1093
996
  *
1094
997
  * @private internal utility, exported are only signleton instances of this class
1095
998
  */
1096
- var $Register = /** @class */ (function () {
1097
- function $Register(registerName) {
999
+ class $Register {
1000
+ constructor(registerName) {
1098
1001
  this.registerName = registerName;
1099
- var storageName = "_promptbook_".concat(normalizeTo_snake_case(registerName));
1100
- var globalScope = $getGlobalScope();
1002
+ const storageName = `_promptbook_${normalizeTo_snake_case(registerName)}`;
1003
+ const globalScope = $getGlobalScope();
1101
1004
  if (globalScope[storageName] === undefined) {
1102
1005
  globalScope[storageName] = [];
1103
1006
  }
1104
1007
  else if (!Array.isArray(globalScope[storageName])) {
1105
- throw new UnexpectedError("Expected (global) ".concat(storageName, " to be an array, but got ").concat(typeof globalScope[storageName]));
1008
+ throw new UnexpectedError(`Expected (global) ${storageName} to be an array, but got ${typeof globalScope[storageName]}`);
1106
1009
  }
1107
1010
  this.storage = globalScope[storageName];
1108
1011
  }
1109
- $Register.prototype.list = function () {
1012
+ list() {
1110
1013
  // <- TODO: ReadonlyDeep<ReadonlyArray<TRegistered>>
1111
1014
  return this.storage;
1112
- };
1113
- $Register.prototype.register = function (registered) {
1114
- var packageName = registered.packageName, className = registered.className;
1115
- var existingRegistrationIndex = this.storage.findIndex(function (item) { return item.packageName === packageName && item.className === className; });
1116
- var existingRegistration = this.storage[existingRegistrationIndex];
1015
+ }
1016
+ register(registered) {
1017
+ const { packageName, className } = registered;
1018
+ const existingRegistrationIndex = this.storage.findIndex((item) => item.packageName === packageName && item.className === className);
1019
+ const existingRegistration = this.storage[existingRegistrationIndex];
1117
1020
  if (!existingRegistration) {
1118
1021
  this.storage.push(registered);
1119
1022
  }
@@ -1122,18 +1025,17 @@ var $Register = /** @class */ (function () {
1122
1025
  }
1123
1026
  return {
1124
1027
  registerName: this.registerName,
1125
- packageName: packageName,
1126
- className: className,
1028
+ packageName,
1029
+ className,
1127
1030
  get isDestroyed() {
1128
1031
  return false;
1129
1032
  },
1130
- destroy: function () {
1131
- throw new NotYetImplementedError("Registration to ".concat(this.registerName, " is permanent in this version of Promptbook"));
1033
+ destroy() {
1034
+ throw new NotYetImplementedError(`Registration to ${this.registerName} is permanent in this version of Promptbook`);
1132
1035
  },
1133
1036
  };
1134
- };
1135
- return $Register;
1136
- }());
1037
+ }
1038
+ }
1137
1039
 
1138
1040
  /**
1139
1041
  * @@@
@@ -1142,7 +1044,7 @@ var $Register = /** @class */ (function () {
1142
1044
  * @singleton Only one instance of each register is created per build, but thare can be more @@@
1143
1045
  * @public exported from `@promptbook/core`
1144
1046
  */
1145
- var $llmToolsRegister = new $Register('llm_execution_tools_constructors');
1047
+ const $llmToolsRegister = new $Register('llm_execution_tools_constructors');
1146
1048
  /**
1147
1049
  * TODO: [®] DRY Register logic
1148
1050
  */
@@ -1156,7 +1058,7 @@ var $llmToolsRegister = new $Register('llm_execution_tools_constructors');
1156
1058
  * @public exported from `@promptbook/wizzard`
1157
1059
  * @public exported from `@promptbook/cli`
1158
1060
  */
1159
- var _DeepseekRegistration = $llmToolsRegister.register(createDeepseekExecutionTools);
1061
+ const _DeepseekRegistration = $llmToolsRegister.register(createDeepseekExecutionTools);
1160
1062
  /**
1161
1063
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
1162
1064
  * Note: [💞] Ignore a discrepancy between file name and entity name