@promptbook/core 0.78.3 → 0.79.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import type { WritableDeep } from 'type-fest';
1
+ import type { SetOptional, WritableDeep } from 'type-fest';
2
2
  import type { PipelineJson } from '../../../pipeline/PipelineJson/PipelineJson';
3
3
  import type { TaskJson } from '../../../pipeline/PipelineJson/TaskJson';
4
4
  import type { string_markdown_text } from '../../../types/typeAliases';
@@ -140,7 +140,7 @@ export type $TaskJson = {
140
140
  *
141
141
  * @private internal helper for command parsers
142
142
  */
143
- export type $PipelineJson = WritableDeep<PipelineJson>;
143
+ export type $PipelineJson = WritableDeep<SetOptional<PipelineJson, 'formfactorName'>>;
144
144
  /**
145
145
  * @@@
146
146
  */
@@ -8,7 +8,12 @@ export declare const GeneratorFormfactorDefinition: {
8
8
  readonly description: "@@@";
9
9
  readonly documentationUrl: "https://github.com/webgptorg/promptbook/discussions/184";
10
10
  readonly pipelineInterface: {
11
- readonly inputParameters: readonly [];
11
+ readonly inputParameters: readonly [{
12
+ readonly name: "nonce";
13
+ readonly description: "Just to prevent GENERATOR to be set as implicit formfactor";
14
+ readonly isInput: true;
15
+ readonly isOutput: false;
16
+ }];
12
17
  readonly outputParameters: readonly [];
13
18
  };
14
19
  };
@@ -96,7 +96,12 @@ export declare const FORMFACTOR_DEFINITIONS: readonly [{
96
96
  readonly description: "@@@";
97
97
  readonly documentationUrl: "https://github.com/webgptorg/promptbook/discussions/177";
98
98
  readonly pipelineInterface: {
99
- readonly inputParameters: readonly [];
99
+ readonly inputParameters: readonly [{
100
+ readonly name: "nonce";
101
+ readonly description: "Just to prevent EXPERIMENTAL_MATCHER to be set as implicit formfactor";
102
+ readonly isInput: true;
103
+ readonly isOutput: false;
104
+ }];
100
105
  readonly outputParameters: readonly [];
101
106
  };
102
107
  }, {
@@ -104,7 +109,12 @@ export declare const FORMFACTOR_DEFINITIONS: readonly [{
104
109
  readonly description: "@@@";
105
110
  readonly documentationUrl: "https://github.com/webgptorg/promptbook/discussions/184";
106
111
  readonly pipelineInterface: {
107
- readonly inputParameters: readonly [];
112
+ readonly inputParameters: readonly [{
113
+ readonly name: "nonce";
114
+ readonly description: "Just to prevent GENERATOR to be set as implicit formfactor";
115
+ readonly isInput: true;
116
+ readonly isOutput: false;
117
+ }];
108
118
  readonly outputParameters: readonly [];
109
119
  };
110
120
  }];
@@ -8,7 +8,12 @@ export declare const MatcherFormfactorDefinition: {
8
8
  readonly description: "@@@";
9
9
  readonly documentationUrl: "https://github.com/webgptorg/promptbook/discussions/177";
10
10
  readonly pipelineInterface: {
11
- readonly inputParameters: readonly [];
11
+ readonly inputParameters: readonly [{
12
+ readonly name: "nonce";
13
+ readonly description: "Just to prevent EXPERIMENTAL_MATCHER to be set as implicit formfactor";
14
+ readonly isInput: true;
15
+ readonly isOutput: false;
16
+ }];
12
17
  readonly outputParameters: readonly [];
13
18
  };
14
19
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/core",
3
- "version": "0.78.3",
3
+ "version": "0.79.0",
4
4
  "description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
5
5
  "--note-0": " <- [🐊]",
6
6
  "private": false,
package/umd/index.umd.js CHANGED
@@ -25,7 +25,7 @@
25
25
  *
26
26
  * @see https://github.com/webgptorg/promptbook
27
27
  */
28
- var PROMPTBOOK_ENGINE_VERSION = '0.78.2';
28
+ var PROMPTBOOK_ENGINE_VERSION = '0.78.4';
29
29
  /**
30
30
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
31
31
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1249,6 +1249,9 @@
1249
1249
  */
1250
1250
  function $deepFreeze(objectValue) {
1251
1251
  var e_1, _a;
1252
+ if (Array.isArray(objectValue)) {
1253
+ return Object.freeze(objectValue.map(function (item) { return $deepFreeze(item); }));
1254
+ }
1252
1255
  var propertyNames = Object.getOwnPropertyNames(objectValue);
1253
1256
  try {
1254
1257
  for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
@@ -5950,6 +5953,133 @@
5950
5953
  * @see https://docs.anthropic.com/en/docs/test-and-evaluate/strengthen-guardrails/increase-consistency#specify-the-desired-output-format
5951
5954
  */
5952
5955
 
5956
+ /**
5957
+ * @@@
5958
+ *
5959
+ * @deprecated https://github.com/webgptorg/promptbook/pull/186
5960
+ * @see https://github.com/webgptorg/promptbook/discussions/171
5961
+ *
5962
+ * @public exported from `@promptbook/core`
5963
+ */
5964
+ function getPipelineInterface(pipeline) {
5965
+ var e_1, _a, e_2, _b;
5966
+ var pipelineInterface = {
5967
+ inputParameters: [],
5968
+ outputParameters: [],
5969
+ };
5970
+ try {
5971
+ for (var _c = __values(pipeline.parameters), _d = _c.next(); !_d.done; _d = _c.next()) {
5972
+ var parameter = _d.value;
5973
+ var isInput = parameter.isInput, isOutput = parameter.isOutput;
5974
+ if (isInput) {
5975
+ pipelineInterface.inputParameters.push(deepClone(parameter));
5976
+ }
5977
+ if (isOutput) {
5978
+ pipelineInterface.outputParameters.push(deepClone(parameter));
5979
+ }
5980
+ }
5981
+ }
5982
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
5983
+ finally {
5984
+ try {
5985
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
5986
+ }
5987
+ finally { if (e_1) throw e_1.error; }
5988
+ }
5989
+ try {
5990
+ for (var _e = __values(['inputParameters', 'outputParameters']), _f = _e.next(); !_f.done; _f = _e.next()) {
5991
+ var key = _f.value;
5992
+ pipelineInterface[key].sort(function (_a, _b) {
5993
+ var name1 = _a.name;
5994
+ var name2 = _b.name;
5995
+ return name1.localeCompare(name2);
5996
+ });
5997
+ }
5998
+ }
5999
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
6000
+ finally {
6001
+ try {
6002
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
6003
+ }
6004
+ finally { if (e_2) throw e_2.error; }
6005
+ }
6006
+ return $deepFreeze(pipelineInterface);
6007
+ }
6008
+
6009
+ /**
6010
+ * @@@
6011
+ *
6012
+ * @deprecated https://github.com/webgptorg/promptbook/pull/186
6013
+ * @see https://github.com/webgptorg/promptbook/discussions/171
6014
+ *
6015
+ * @public exported from `@promptbook/core`
6016
+ */
6017
+ function isPipelineInterfacesEqual(pipelineInterface1, pipelineInterface2) {
6018
+ var e_1, _a, e_2, _b;
6019
+ try {
6020
+ for (var _c = __values(['inputParameters', 'outputParameters']), _d = _c.next(); !_d.done; _d = _c.next()) {
6021
+ var whichParameters = _d.value;
6022
+ var parameters1 = pipelineInterface1[whichParameters]; // <- Note: `isPipelineInterfacesEqual` is just temporary solution, no need to fix this
6023
+ var parameters2 = pipelineInterface2[whichParameters];
6024
+ if (parameters1.length !== parameters2.length) {
6025
+ return false;
6026
+ }
6027
+ var _loop_1 = function (parameter) {
6028
+ var matchingParameter = parameters2.find(function (_a) {
6029
+ var name = _a.name;
6030
+ return name === parameter.name;
6031
+ });
6032
+ if (!matchingParameter) {
6033
+ return { value: false };
6034
+ }
6035
+ // Note: Do not compare description, it is not relevant for compatibility
6036
+ if (matchingParameter.isInput !== parameter.isInput) {
6037
+ return { value: false };
6038
+ }
6039
+ if (matchingParameter.isOutput !== parameter.isOutput) {
6040
+ return { value: false };
6041
+ }
6042
+ };
6043
+ try {
6044
+ for (var parameters1_1 = (e_2 = void 0, __values(parameters1)), parameters1_1_1 = parameters1_1.next(); !parameters1_1_1.done; parameters1_1_1 = parameters1_1.next()) {
6045
+ var parameter = parameters1_1_1.value;
6046
+ var state_1 = _loop_1(parameter);
6047
+ if (typeof state_1 === "object")
6048
+ return state_1.value;
6049
+ }
6050
+ }
6051
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
6052
+ finally {
6053
+ try {
6054
+ if (parameters1_1_1 && !parameters1_1_1.done && (_b = parameters1_1.return)) _b.call(parameters1_1);
6055
+ }
6056
+ finally { if (e_2) throw e_2.error; }
6057
+ }
6058
+ }
6059
+ }
6060
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
6061
+ finally {
6062
+ try {
6063
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
6064
+ }
6065
+ finally { if (e_1) throw e_1.error; }
6066
+ }
6067
+ return true;
6068
+ }
6069
+
6070
+ /**
6071
+ * @@@
6072
+ *
6073
+ * @deprecated https://github.com/webgptorg/promptbook/pull/186
6074
+ * @see https://github.com/webgptorg/promptbook/discussions/171
6075
+ *
6076
+ * @public exported from `@promptbook/core`
6077
+ */
6078
+ function isPipelineImplementingInterface(options) {
6079
+ var pipeline = options.pipeline, pipelineInterface = options.pipelineInterface;
6080
+ return isPipelineInterfacesEqual(getPipelineInterface(pipeline), pipelineInterface);
6081
+ }
6082
+
5953
6083
  /**
5954
6084
  * All available task types
5955
6085
  *
@@ -7109,7 +7239,13 @@
7109
7239
  documentationUrl: "https://github.com/webgptorg/promptbook/discussions/184",
7110
7240
  pipelineInterface: {
7111
7241
  inputParameters: [
7112
- /* @@@ */
7242
+ /* @@@ */
7243
+ {
7244
+ name: 'nonce',
7245
+ description: 'Just to prevent GENERATOR to be set as implicit formfactor',
7246
+ isInput: true,
7247
+ isOutput: false,
7248
+ },
7113
7249
  ],
7114
7250
  outputParameters: [
7115
7251
  /* @@@ */
@@ -7155,7 +7291,13 @@
7155
7291
  documentationUrl: "https://github.com/webgptorg/promptbook/discussions/177",
7156
7292
  pipelineInterface: {
7157
7293
  inputParameters: [
7158
- /* @@@ */
7294
+ /* @@@ */
7295
+ {
7296
+ name: 'nonce',
7297
+ description: 'Just to prevent EXPERIMENTAL_MATCHER to be set as implicit formfactor',
7298
+ isInput: true,
7299
+ isOutput: false,
7300
+ },
7159
7301
  ],
7160
7302
  outputParameters: [
7161
7303
  /* @@@ */
@@ -7304,6 +7446,9 @@
7304
7446
  * Note: `$` is used to indicate that this function mutates given `pipelineJson`
7305
7447
  */
7306
7448
  $applyToPipelineJson: function (command, $pipelineJson) {
7449
+ if ($pipelineJson.formfactorName !== undefined && $pipelineJson.formfactorName !== command.formfactorName) {
7450
+ throw new ParseError(spaceTrim__default["default"]("\n Redefinition of `FORMFACTOR` in the pipeline head\n\n You have used:\n 1) FORMFACTOR `".concat($pipelineJson.formfactorName, "`\n 2) FORMFACTOR `").concat(command.formfactorName, "`\n ")));
7451
+ }
7307
7452
  $pipelineJson.formfactorName = command.formfactorName;
7308
7453
  },
7309
7454
  /**
@@ -7491,7 +7636,7 @@
7491
7636
  // <- TODO: [🚎][💩] Some better way how to get warnings from pipeline parsing / logic
7492
7637
  }
7493
7638
  else {
7494
- throw new ParseError(spaceTrim__default["default"]("\n Redefinition of MODEL `".concat(command.key, "` in the pipeline head\n\n You have used:\n - MODEL ").concat(command.key, " ").concat($pipelineJson.defaultModelRequirements[command.key], "\n - MODEL ").concat(command.key, " ").concat(command.value, "\n ")));
7639
+ throw new ParseError(spaceTrim__default["default"]("\n Redefinition of `MODEL ".concat(command.key, "` in the pipeline head\n\n You have used:\n 1) `MODEL ").concat(command.key, " ").concat($pipelineJson.defaultModelRequirements[command.key], "`\n 2) `MODEL ").concat(command.key, " ").concat(command.value, "`\n ")));
7495
7640
  }
7496
7641
  }
7497
7642
  $pipelineJson.defaultModelRequirements[command.key] = command.value;
@@ -8584,20 +8729,15 @@
8584
8729
  * @public exported from `@promptbook/core`
8585
8730
  */
8586
8731
  function pipelineStringToJsonSync(pipelineString) {
8587
- var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e;
8732
+ var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
8588
8733
  var $pipelineJson = {
8589
- title: undefined /* <- Note: [🍙] Putting here placeholder to keep `title` on top at final JSON */,
8590
- pipelineUrl: undefined /* <- Note: Putting here placeholder to keep `pipelineUrl` on top at final JSON */,
8591
- bookVersion: undefined /* <- Note: By default no explicit version */,
8592
- description: undefined /* <- Note: [🍙] Putting here placeholder to keep `description` on top at final JSON */,
8593
- formfactorName: 'GENERIC',
8734
+ title: DEFAULT_TITLE,
8594
8735
  parameters: [],
8595
8736
  tasks: [],
8596
8737
  knowledgeSources: [],
8597
8738
  knowledgePieces: [],
8598
8739
  personas: [],
8599
8740
  preparations: [],
8600
- // <- TODO: [🍙] Some standard order of properties
8601
8741
  };
8602
8742
  function getPipelineIdentification() {
8603
8743
  // Note: This is a 😐 implementation of [🚞]
@@ -8613,7 +8753,7 @@
8613
8753
  // =============================================================
8614
8754
  // Note: 1️⃣ Parsing of the markdown into object
8615
8755
  if (pipelineString.startsWith('#!')) {
8616
- var _f = __read(pipelineString.split('\n')), shebangLine_1 = _f[0], restLines = _f.slice(1);
8756
+ var _g = __read(pipelineString.split('\n')), shebangLine_1 = _g[0], restLines = _g.slice(1);
8617
8757
  if (!(shebangLine_1 || '').includes('ptbk')) {
8618
8758
  throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n It seems that you try to parse a book file which has non-standard shebang line for book files:\n Shebang line must contain 'ptbk'\n\n You have:\n ".concat(block(shebangLine_1 || '(empty line)'), "\n\n It should look like this:\n #!/usr/bin/env ptbk\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
8619
8759
  }
@@ -8623,7 +8763,7 @@
8623
8763
  pipelineString = flattenMarkdown(pipelineString) /* <- Note: [🥞] */;
8624
8764
  pipelineString = pipelineString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
8625
8765
  pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
8626
- var _g = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _g[0], pipelineSections = _g.slice(1); /* <- Note: [🥞] */
8766
+ var _h = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _h[0], pipelineSections = _h.slice(1); /* <- Note: [🥞] */
8627
8767
  if (pipelineHead === undefined) {
8628
8768
  throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Pipeline head is not defined\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
8629
8769
  }
@@ -8745,10 +8885,10 @@
8745
8885
  return nameWithSuffix;
8746
8886
  };
8747
8887
  var _loop_2 = function (section) {
8748
- var e_6, _m, e_7, _o;
8888
+ var e_7, _o, e_8, _p;
8749
8889
  // TODO: Parse section's description (the content out of the codeblock and lists)
8750
8890
  var listItems_2 = extractAllListItemsFromMarkdown(section.content);
8751
- var _p = extractOneBlockFromMarkdown(section.content), language = _p.language, content = _p.content;
8891
+ var _q = extractOneBlockFromMarkdown(section.content), language = _q.language, content = _q.content;
8752
8892
  // TODO: [🎾][1] DRY description
8753
8893
  var description_1 = section.content;
8754
8894
  // Note: Remove codeblocks - TODO: [🎾]
@@ -8812,17 +8952,17 @@
8812
8952
  };
8813
8953
  try {
8814
8954
  // TODO [♓️] List commands and before apply order them to achieve order-agnostic commands
8815
- for (var commands_1 = (e_6 = void 0, __values(commands)), commands_1_1 = commands_1.next(); !commands_1_1.done; commands_1_1 = commands_1.next()) {
8816
- var _q = commands_1_1.value, listItem = _q.listItem, command = _q.command;
8955
+ for (var commands_1 = (e_7 = void 0, __values(commands)), commands_1_1 = commands_1.next(); !commands_1_1.done; commands_1_1 = commands_1.next()) {
8956
+ var _r = commands_1_1.value, listItem = _r.listItem, command = _r.command;
8817
8957
  _loop_4(listItem, command);
8818
8958
  }
8819
8959
  }
8820
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
8960
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
8821
8961
  finally {
8822
8962
  try {
8823
- if (commands_1_1 && !commands_1_1.done && (_m = commands_1.return)) _m.call(commands_1);
8963
+ if (commands_1_1 && !commands_1_1.done && (_o = commands_1.return)) _o.call(commands_1);
8824
8964
  }
8825
- finally { if (e_6) throw e_6.error; }
8965
+ finally { if (e_7) throw e_7.error; }
8826
8966
  }
8827
8967
  // TODO: [🍧] Should be done in SECTION command
8828
8968
  if ($taskJson.taskType === 'SCRIPT_TASK') {
@@ -8836,8 +8976,8 @@
8836
8976
  }
8837
8977
  $taskJson.dependentParameterNames = Array.from(extractParameterNamesFromTask($taskJson));
8838
8978
  try {
8839
- for (var _r = (e_7 = void 0, __values($taskJson.dependentParameterNames)), _s = _r.next(); !_s.done; _s = _r.next()) {
8840
- var parameterName = _s.value;
8979
+ for (var _s = (e_8 = void 0, __values($taskJson.dependentParameterNames)), _t = _s.next(); !_t.done; _t = _s.next()) {
8980
+ var parameterName = _t.value;
8841
8981
  // TODO: [🧠] This definition should be made first in the task
8842
8982
  defineParam({
8843
8983
  parameterName: parameterName,
@@ -8848,12 +8988,12 @@
8848
8988
  });
8849
8989
  }
8850
8990
  }
8851
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
8991
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
8852
8992
  finally {
8853
8993
  try {
8854
- if (_s && !_s.done && (_o = _r.return)) _o.call(_r);
8994
+ if (_t && !_t.done && (_p = _s.return)) _p.call(_s);
8855
8995
  }
8856
- finally { if (e_7) throw e_7.error; }
8996
+ finally { if (e_8) throw e_8.error; }
8857
8997
  }
8858
8998
  /*
8859
8999
  // TODO: [🍧] This should be checked in `MODEL` command + better error message
@@ -8902,18 +9042,22 @@
8902
9042
  var isThisParameterResulting = $pipelineJson.tasks.some(function (task) { return task.resultingParameterName === parameter.name; });
8903
9043
  if (!isThisParameterResulting) {
8904
9044
  parameter.isInput = true;
9045
+ // <- TODO: [💔] Why this is making typescript error in vscode but not in cli
9046
+ // > Type 'true' is not assignable to type 'false'.ts(2322)
9047
+ // > (property) isInput: false
9048
+ // > The parameter is input of the pipeline The parameter is NOT input of the pipeline
8905
9049
  }
8906
9050
  };
8907
9051
  try {
8908
- for (var _h = __values($pipelineJson.parameters), _j = _h.next(); !_j.done; _j = _h.next()) {
8909
- var parameter = _j.value;
9052
+ for (var _j = __values($pipelineJson.parameters), _k = _j.next(); !_k.done; _k = _j.next()) {
9053
+ var parameter = _k.value;
8910
9054
  _loop_3(parameter);
8911
9055
  }
8912
9056
  }
8913
9057
  catch (e_4_1) { e_4 = { error: e_4_1 }; }
8914
9058
  finally {
8915
9059
  try {
8916
- if (_j && !_j.done && (_d = _h.return)) _d.call(_h);
9060
+ if (_k && !_k.done && (_d = _j.return)) _d.call(_j);
8917
9061
  }
8918
9062
  finally { if (e_4) throw e_4.error; }
8919
9063
  }
@@ -8922,17 +9066,18 @@
8922
9066
  // Note: 7️⃣ Mark all non-INPUT parameters as OUTPUT if any OUTPUT is not set
8923
9067
  if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isOutput; })) {
8924
9068
  try {
8925
- for (var _k = __values($pipelineJson.parameters), _l = _k.next(); !_l.done; _l = _k.next()) {
8926
- var parameter = _l.value;
9069
+ for (var _l = __values($pipelineJson.parameters), _m = _l.next(); !_m.done; _m = _l.next()) {
9070
+ var parameter = _m.value;
8927
9071
  if (!parameter.isInput) {
8928
9072
  parameter.isOutput = true;
9073
+ // <- TODO: [💔]
8929
9074
  }
8930
9075
  }
8931
9076
  }
8932
9077
  catch (e_5_1) { e_5 = { error: e_5_1 }; }
8933
9078
  finally {
8934
9079
  try {
8935
- if (_l && !_l.done && (_e = _k.return)) _e.call(_k);
9080
+ if (_m && !_m.done && (_e = _l.return)) _e.call(_l);
8936
9081
  }
8937
9082
  finally { if (e_5) throw e_5.error; }
8938
9083
  }
@@ -8940,7 +9085,7 @@
8940
9085
  // =============================================================
8941
9086
  // Note: 8️⃣ Cleanup of undefined values
8942
9087
  $pipelineJson.tasks.forEach(function (tasks) {
8943
- var e_8, _a;
9088
+ var e_9, _a;
8944
9089
  try {
8945
9090
  for (var _b = __values(Object.entries(tasks)), _c = _b.next(); !_c.done; _c = _b.next()) {
8946
9091
  var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
@@ -8949,16 +9094,16 @@
8949
9094
  }
8950
9095
  }
8951
9096
  }
8952
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
9097
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
8953
9098
  finally {
8954
9099
  try {
8955
9100
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
8956
9101
  }
8957
- finally { if (e_8) throw e_8.error; }
9102
+ finally { if (e_9) throw e_9.error; }
8958
9103
  }
8959
9104
  });
8960
9105
  $pipelineJson.parameters.forEach(function (parameter) {
8961
- var e_9, _a;
9106
+ var e_10, _a;
8962
9107
  try {
8963
9108
  for (var _b = __values(Object.entries(parameter)), _c = _b.next(); !_c.done; _c = _b.next()) {
8964
9109
  var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
@@ -8967,17 +9112,61 @@
8967
9112
  }
8968
9113
  }
8969
9114
  }
8970
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
9115
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
8971
9116
  finally {
8972
9117
  try {
8973
9118
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
8974
9119
  }
8975
- finally { if (e_9) throw e_9.error; }
9120
+ finally { if (e_10) throw e_10.error; }
8976
9121
  }
8977
9122
  });
9123
+ try {
9124
+ // =============================================================
9125
+ // Note: 9️⃣ Implicit and default formfactor
9126
+ for (var FORMFACTOR_DEFINITIONS_1 = __values(FORMFACTOR_DEFINITIONS), FORMFACTOR_DEFINITIONS_1_1 = FORMFACTOR_DEFINITIONS_1.next(); !FORMFACTOR_DEFINITIONS_1_1.done; FORMFACTOR_DEFINITIONS_1_1 = FORMFACTOR_DEFINITIONS_1.next()) {
9127
+ var formfactorDefinition = FORMFACTOR_DEFINITIONS_1_1.value;
9128
+ // <- Note: [♓️][💩] This is the order of the formfactors, make some explicit priority
9129
+ var name_2 = formfactorDefinition.name, pipelineInterface = formfactorDefinition.pipelineInterface;
9130
+ // Note: Skip GENERIC formfactor, it will be used as a fallback if no other formfactor is compatible
9131
+ if (name_2 === 'GENERIC') {
9132
+ continue;
9133
+ }
9134
+ var isCompatible = isPipelineImplementingInterface({
9135
+ pipeline: __assign({ formfactorName: name_2 }, $pipelineJson),
9136
+ pipelineInterface: pipelineInterface,
9137
+ });
9138
+ /*/
9139
+ console.log({
9140
+ subject: `${$pipelineJson.title} implements ${name}`,
9141
+ pipelineTitle: $pipelineJson.title,
9142
+ formfactorName: name,
9143
+ isCompatible,
9144
+ formfactorInterface: pipelineInterface,
9145
+ pipelineInterface: getPipelineInterface($pipelineJson as PipelineJson),
9146
+ });
9147
+ /**/
9148
+ if (isCompatible) {
9149
+ $pipelineJson.formfactorName = name_2;
9150
+ break;
9151
+ }
9152
+ }
9153
+ }
9154
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
9155
+ finally {
9156
+ try {
9157
+ if (FORMFACTOR_DEFINITIONS_1_1 && !FORMFACTOR_DEFINITIONS_1_1.done && (_f = FORMFACTOR_DEFINITIONS_1.return)) _f.call(FORMFACTOR_DEFINITIONS_1);
9158
+ }
9159
+ finally { if (e_6) throw e_6.error; }
9160
+ }
9161
+ // Note: [🔆] If formfactor is still not set, set it to 'GENERIC'
9162
+ if ($pipelineJson.formfactorName === undefined) {
9163
+ $pipelineJson.formfactorName = 'GENERIC';
9164
+ }
8978
9165
  // =============================================================
8979
9166
  // TODO: [🍙] Maybe do reorder of `$pipelineJson` here
8980
- return $asDeeplyFrozenSerializableJson('pipelineJson', $pipelineJson);
9167
+ return $asDeeplyFrozenSerializableJson('pipelineJson', __assign({ title: DEFAULT_TITLE, pipelineUrl: undefined, bookVersion: undefined, description: undefined, formfactorName: 'GENERIC',
9168
+ // <- Note: [🔆] Setting `formfactorName` is redundant to satisfy the typescript
9169
+ parameters: [], tasks: [], knowledgeSources: [], knowledgePieces: [], personas: [], preparations: [] }, $pipelineJson));
8981
9170
  }
8982
9171
  /**
8983
9172
  * TODO: [main] !!!! Warn if used only sync version
@@ -10496,133 +10685,6 @@
10496
10685
  * Note: [💞] Ignore a discrepancy between file name and entity name
10497
10686
  */
10498
10687
 
10499
- /**
10500
- * @@@
10501
- *
10502
- * @deprecated https://github.com/webgptorg/promptbook/pull/186
10503
- * @see https://github.com/webgptorg/promptbook/discussions/171
10504
- *
10505
- * @public exported from `@promptbook/core`
10506
- */
10507
- function getPipelineInterface(pipeline) {
10508
- var e_1, _a, e_2, _b;
10509
- var pipelineInterface = {
10510
- inputParameters: [],
10511
- outputParameters: [],
10512
- };
10513
- try {
10514
- for (var _c = __values(pipeline.parameters), _d = _c.next(); !_d.done; _d = _c.next()) {
10515
- var parameter = _d.value;
10516
- var isInput = parameter.isInput, isOutput = parameter.isOutput;
10517
- if (isInput) {
10518
- pipelineInterface.inputParameters.push(parameter);
10519
- }
10520
- if (isOutput) {
10521
- pipelineInterface.outputParameters.push(parameter);
10522
- }
10523
- }
10524
- }
10525
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
10526
- finally {
10527
- try {
10528
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
10529
- }
10530
- finally { if (e_1) throw e_1.error; }
10531
- }
10532
- try {
10533
- for (var _e = __values(['inputParameters', 'outputParameters']), _f = _e.next(); !_f.done; _f = _e.next()) {
10534
- var key = _f.value;
10535
- pipelineInterface[key].sort(function (_a, _b) {
10536
- var name1 = _a.name;
10537
- var name2 = _b.name;
10538
- return name1.localeCompare(name2);
10539
- });
10540
- }
10541
- }
10542
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
10543
- finally {
10544
- try {
10545
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
10546
- }
10547
- finally { if (e_2) throw e_2.error; }
10548
- }
10549
- return $deepFreeze(pipelineInterface);
10550
- }
10551
-
10552
- /**
10553
- * @@@
10554
- *
10555
- * @deprecated https://github.com/webgptorg/promptbook/pull/186
10556
- * @see https://github.com/webgptorg/promptbook/discussions/171
10557
- *
10558
- * @public exported from `@promptbook/core`
10559
- */
10560
- function isPipelineInterfacesEqual(pipelineInterface1, pipelineInterface2) {
10561
- var e_1, _a, e_2, _b;
10562
- try {
10563
- for (var _c = __values(['inputParameters', 'outputParameters']), _d = _c.next(); !_d.done; _d = _c.next()) {
10564
- var whichParameters = _d.value;
10565
- var parameters1 = pipelineInterface1[whichParameters]; // <- Note: `isPipelineInterfacesEqual` is just temporary solution, no need to fix this
10566
- var parameters2 = pipelineInterface2[whichParameters];
10567
- if (parameters1.length !== parameters2.length) {
10568
- return false;
10569
- }
10570
- var _loop_1 = function (parameter) {
10571
- var matchingParameter = parameters2.find(function (_a) {
10572
- var name = _a.name;
10573
- return name === parameter.name;
10574
- });
10575
- if (!matchingParameter) {
10576
- return { value: false };
10577
- }
10578
- // Note: Do not compare description, it is not relevant for compatibility
10579
- if (matchingParameter.isInput !== parameter.isInput) {
10580
- return { value: false };
10581
- }
10582
- if (matchingParameter.isOutput !== parameter.isOutput) {
10583
- return { value: false };
10584
- }
10585
- };
10586
- try {
10587
- for (var parameters1_1 = (e_2 = void 0, __values(parameters1)), parameters1_1_1 = parameters1_1.next(); !parameters1_1_1.done; parameters1_1_1 = parameters1_1.next()) {
10588
- var parameter = parameters1_1_1.value;
10589
- var state_1 = _loop_1(parameter);
10590
- if (typeof state_1 === "object")
10591
- return state_1.value;
10592
- }
10593
- }
10594
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
10595
- finally {
10596
- try {
10597
- if (parameters1_1_1 && !parameters1_1_1.done && (_b = parameters1_1.return)) _b.call(parameters1_1);
10598
- }
10599
- finally { if (e_2) throw e_2.error; }
10600
- }
10601
- }
10602
- }
10603
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
10604
- finally {
10605
- try {
10606
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
10607
- }
10608
- finally { if (e_1) throw e_1.error; }
10609
- }
10610
- return true;
10611
- }
10612
-
10613
- /**
10614
- * @@@
10615
- *
10616
- * @deprecated https://github.com/webgptorg/promptbook/pull/186
10617
- * @see https://github.com/webgptorg/promptbook/discussions/171
10618
- *
10619
- * @public exported from `@promptbook/core`
10620
- */
10621
- function isPipelineImplementingInterface(options) {
10622
- var pipeline = options.pipeline, pipelineInterface = options.pipelineInterface;
10623
- return isPipelineInterfacesEqual(getPipelineInterface(pipeline), pipelineInterface);
10624
- }
10625
-
10626
10688
  /**
10627
10689
  * Metadata of the scraper
10628
10690
  *