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