@promptbook/remote-client 0.88.0 → 0.89.0-11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +7 -1
  2. package/esm/index.es.js +49 -15
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/core.index.d.ts +18 -6
  5. package/esm/typings/src/_packages/remote-client.index.d.ts +6 -8
  6. package/esm/typings/src/_packages/remote-server.index.d.ts +6 -6
  7. package/esm/typings/src/_packages/types.index.d.ts +18 -10
  8. package/esm/typings/src/cli/cli-commands/login.d.ts +15 -0
  9. package/esm/typings/src/cli/common/$addGlobalOptionsToCommand.d.ts +7 -0
  10. package/esm/typings/src/cli/common/$provideLlmToolsForCli.d.ts +15 -0
  11. package/esm/typings/src/config.d.ts +15 -8
  12. package/esm/typings/src/errors/0-index.d.ts +6 -0
  13. package/esm/typings/src/errors/AuthenticationError.d.ts +9 -0
  14. package/esm/typings/src/errors/PromptbookFetchError.d.ts +9 -0
  15. package/esm/typings/src/execution/PipelineExecutorResult.d.ts +2 -2
  16. package/esm/typings/src/execution/PromptResult.d.ts +2 -2
  17. package/esm/typings/src/execution/{PromptResultUsage.d.ts → Usage.d.ts} +5 -5
  18. package/esm/typings/src/execution/utils/addUsage.d.ts +2 -2
  19. package/esm/typings/src/execution/utils/computeUsageCounts.d.ts +3 -3
  20. package/esm/typings/src/execution/utils/usage-constants.d.ts +77 -60
  21. package/esm/typings/src/execution/utils/usageToHuman.d.ts +5 -5
  22. package/esm/typings/src/execution/utils/usageToWorktime.d.ts +5 -5
  23. package/esm/typings/src/llm-providers/_common/register/$provideEnvFilename.d.ts +12 -0
  24. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +2 -8
  25. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +2 -0
  26. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizzardOrCli.d.ts +36 -1
  27. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +1 -0
  28. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage.d.ts +9 -2
  29. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/{countTotalUsage.d.ts → countUsage.d.ts} +1 -1
  30. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +2 -2
  31. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +1 -1
  32. package/esm/typings/src/llm-providers/anthropic-claude/computeAnthropicClaudeUsage.d.ts +2 -2
  33. package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +1 -1
  34. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +0 -9
  35. package/esm/typings/src/llm-providers/openai/computeOpenAiUsage.d.ts +2 -2
  36. package/esm/typings/src/pipeline/PipelineJson/PreparationJson.d.ts +2 -2
  37. package/esm/typings/src/playground/playground.d.ts +5 -0
  38. package/esm/typings/src/remote-server/RemoteServer.d.ts +23 -0
  39. package/esm/typings/src/remote-server/socket-types/_subtypes/{PromptbookServer_Identification.d.ts → Identification.d.ts} +5 -4
  40. package/esm/typings/src/remote-server/socket-types/listModels/PromptbookServer_ListModels_Request.d.ts +2 -2
  41. package/esm/typings/src/remote-server/socket-types/prepare/PromptbookServer_PreparePipeline_Request.d.ts +2 -2
  42. package/esm/typings/src/remote-server/socket-types/prompt/PromptbookServer_Prompt_Request.d.ts +2 -2
  43. package/esm/typings/src/remote-server/startRemoteServer.d.ts +2 -2
  44. package/esm/typings/src/remote-server/types/RemoteClientOptions.d.ts +4 -12
  45. package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +88 -6
  46. package/esm/typings/src/scrapers/_common/utils/{scraperFetch.d.ts → promptbookFetch.d.ts} +2 -2
  47. package/esm/typings/src/storage/env-storage/$EnvStorage.d.ts +37 -0
  48. package/esm/typings/src/types/typeAliases.d.ts +8 -2
  49. package/esm/typings/src/utils/organization/TODO_narrow.d.ts +6 -0
  50. package/package.json +2 -2
  51. package/umd/index.umd.js +49 -15
  52. package/umd/index.umd.js.map +1 -1
package/README.md CHANGED
@@ -23,6 +23,10 @@
23
23
 
24
24
 
25
25
 
26
+ <blockquote style="color: #ff8811">
27
+ <b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
28
+ </blockquote>
29
+
26
30
  ## 📦 Package `@promptbook/remote-client`
27
31
 
28
32
  - Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
@@ -196,7 +200,7 @@ Each part of the book defines one of 3 circles:
196
200
 
197
201
  ### **What:** Workflows, Tasks and Parameters
198
202
 
199
- What work needs to be done. Each book defines a workflow, which is one or more tasks. Each workflow has a fixed input and output. For example, you have a book that generates an article from a topic. Once it generates an article about AI, once about marketing, once about cooking. The workflow (= your AI program) is the same, only the input and output change.
203
+ What work needs to be done. Each book defines a [workflow *(scenario or pipeline)*](https://github.com/webgptorg/promptbook/discussions/88), which is one or more tasks. Each workflow has a fixed input and output. For example, you have a book that generates an article from a topic. Once it generates an article about AI, once about marketing, once about cooking. The workflow (= your AI program) is the same, only the input and output change.
200
204
 
201
205
  **Related commands:**
202
206
 
@@ -306,6 +310,8 @@ The following glossary is used to clarify certain concepts:
306
310
 
307
311
 
308
312
 
313
+
314
+
309
315
  _Note: This section is not complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
310
316
 
311
317
 
package/esm/index.es.js CHANGED
@@ -20,7 +20,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
20
20
  * @generated
21
21
  * @see https://github.com/webgptorg/promptbook
22
22
  */
23
- const PROMPTBOOK_ENGINE_VERSION = '0.88.0';
23
+ const PROMPTBOOK_ENGINE_VERSION = '0.89.0-11';
24
24
  /**
25
25
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
26
26
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -56,6 +56,19 @@ class CsvFormatError extends AbstractFormatError {
56
56
  }
57
57
  }
58
58
 
59
+ /**
60
+ * AuthenticationError is thrown from login function which is dependency of remote server
61
+ *
62
+ * @public exported from `@promptbook/core`
63
+ */
64
+ class AuthenticationError extends Error {
65
+ constructor(message) {
66
+ super(message);
67
+ this.name = 'AuthenticationError';
68
+ Object.setPrototypeOf(this, AuthenticationError.prototype);
69
+ }
70
+ }
71
+
59
72
  /**
60
73
  * This error indicates that the pipeline collection cannot be propperly loaded
61
74
  *
@@ -254,6 +267,19 @@ class PipelineUrlError extends Error {
254
267
  }
255
268
  }
256
269
 
270
+ /**
271
+ * Error thrown when a fetch request fails
272
+ *
273
+ * @public exported from `@promptbook/core`
274
+ */
275
+ class PromptbookFetchError extends Error {
276
+ constructor(message) {
277
+ super(message);
278
+ this.name = 'PromptbookFetchError';
279
+ Object.setPrototypeOf(this, PromptbookFetchError.prototype);
280
+ }
281
+ }
282
+
257
283
  /**
258
284
  * Returns the same value that is passed as argument.
259
285
  * No side effects.
@@ -346,7 +372,7 @@ Object.freeze({
346
372
  });
347
373
  /**
348
374
  * Note: [💞] Ignore a discrepancy between file name and entity name
349
- * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
375
+ * TODO: [🧠][🧜‍♂️] Maybe join remoteServerUrl and path into single value
350
376
  */
351
377
 
352
378
  /**
@@ -454,6 +480,8 @@ const COMMON_JAVASCRIPT_ERRORS = {
454
480
  TypeError,
455
481
  URIError,
456
482
  AggregateError,
483
+ AuthenticationError,
484
+ PromptbookFetchError,
457
485
  /*
458
486
  Note: Not widely supported
459
487
  > InternalError,
@@ -510,22 +538,26 @@ function deserializeError(error) {
510
538
  * @private internal utility function
511
539
  */
512
540
  async function createRemoteClient(options) {
513
- const { remoteUrl, path } = options;
541
+ const { remoteServerUrl } = options;
542
+ let path = new URL(remoteServerUrl).pathname;
543
+ if (path.endsWith('/')) {
544
+ path = path.slice(0, -1);
545
+ }
546
+ path = `${path}/socket.io`;
514
547
  return new Promise((resolve, reject) => {
515
- const socket = io(remoteUrl, {
548
+ const socket = io(remoteServerUrl, {
516
549
  retries: CONNECTION_RETRIES_LIMIT,
517
550
  timeout: CONNECTION_TIMEOUT_MS,
518
551
  path,
519
- // path: `${this.remoteUrl.pathname}/socket.io`,
520
552
  transports: [/*'websocket', <- TODO: [🌬] Make websocket transport work */ 'polling'],
521
553
  });
522
- // console.log('Connecting to', this.options.remoteUrl.href, { socket });
554
+ // console.log('Connecting to', this.options.remoteServerUrl.href, { socket });
523
555
  socket.on('connect', () => {
524
556
  resolve(socket);
525
557
  });
526
558
  // TODO: [💩] Better timeout handling
527
559
  setTimeout(() => {
528
- reject(new Error(`Timeout while connecting to ${remoteUrl}`));
560
+ reject(new Error(`Timeout while connecting to ${remoteServerUrl}`));
529
561
  }, CONNECTION_TIMEOUT_MS);
530
562
  });
531
563
  }
@@ -3212,7 +3244,8 @@ const modelCommandParser = {
3212
3244
  if ($pipelineJson.defaultModelRequirements[command.key] !== undefined) {
3213
3245
  if ($pipelineJson.defaultModelRequirements[command.key] === command.value) {
3214
3246
  console.warn(`Multiple commands \`MODEL ${command.key} ${command.value}\` in the pipeline head`);
3215
- // <- TODO: [🚎][💩] Some better way how to get warnings from pipeline parsing / logic
3247
+ // <- TODO: [🏮] Some better way how to get warnings from pipeline parsing / logic
3248
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
3216
3249
  }
3217
3250
  else {
3218
3251
  throw new ParseError(spaceTrim$1(`
@@ -3244,6 +3277,7 @@ const modelCommandParser = {
3244
3277
  modelVariant: 'VARIANT',
3245
3278
  maxTokens: '???',
3246
3279
  }[command.key]} ${command.value}\` in the task "${$taskJson.title || $taskJson.name}"`);
3280
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
3247
3281
  }
3248
3282
  else {
3249
3283
  throw new ParseError(spaceTrim$1(`
@@ -3523,15 +3557,15 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
3523
3557
  }
3524
3558
  console.warn(spaceTrim$1(`
3525
3559
 
3526
- Persona "${personaName}" is defined multiple times with different description:
3560
+ Persona "${personaName}" is defined multiple times with different description:
3527
3561
 
3528
- First definition:
3529
- ${persona.description}
3562
+ First definition:
3563
+ ${persona.description}
3530
3564
 
3531
- Second definition:
3532
- ${personaDescription}
3565
+ Second definition:
3566
+ ${personaDescription}
3533
3567
 
3534
- `));
3568
+ `));
3535
3569
  persona.description += spaceTrim$1('\n\n' + personaDescription);
3536
3570
  }
3537
3571
 
@@ -4895,7 +4929,7 @@ function extractParameterNamesFromTask(task) {
4895
4929
  if (parameterNames.has(subparameterName)) {
4896
4930
  parameterNames.delete(subparameterName);
4897
4931
  parameterNames.add(foreach.parameterName);
4898
- // <- TODO: [🚎] Warn/logic error when `subparameterName` not used
4932
+ // <- TODO: [🏮] Warn/logic error when `subparameterName` not used
4899
4933
  }
4900
4934
  }
4901
4935
  }