@promptbook/remote-client 0.89.0-2 → 0.89.0-21
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/README.md +10 -6
- package/esm/index.es.js +98 -22
- package/esm/index.es.js.map +1 -1
- package/esm/typings/servers.d.ts +40 -0
- package/esm/typings/src/_packages/core.index.d.ts +20 -8
- package/esm/typings/src/_packages/remote-client.index.d.ts +6 -8
- package/esm/typings/src/_packages/remote-server.index.d.ts +6 -6
- package/esm/typings/src/_packages/types.index.d.ts +18 -16
- package/esm/typings/src/cli/cli-commands/login.d.ts +0 -1
- package/esm/typings/src/cli/common/$addGlobalOptionsToCommand.d.ts +7 -0
- package/esm/typings/src/cli/common/$provideLlmToolsForCli.d.ts +28 -0
- package/esm/typings/src/cli/test/ptbk.d.ts +1 -1
- package/esm/typings/src/commands/EXPECT/expectCommandParser.d.ts +2 -0
- package/esm/typings/src/config.d.ts +24 -26
- package/esm/typings/src/errors/0-index.d.ts +9 -0
- package/esm/typings/src/errors/AuthenticationError.d.ts +9 -0
- package/esm/typings/src/errors/PipelineExecutionError.d.ts +1 -1
- package/esm/typings/src/errors/PromptbookFetchError.d.ts +9 -0
- package/esm/typings/src/errors/WrappedError.d.ts +10 -0
- package/esm/typings/src/errors/assertsError.d.ts +11 -0
- package/esm/typings/src/execution/PromptbookFetch.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$provideEnvFilename.d.ts +12 -0
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +2 -8
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +2 -0
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizzardOrCli.d.ts +45 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +1 -0
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +1 -1
- package/esm/typings/src/remote-server/RemoteServer.d.ts +23 -0
- package/esm/typings/src/remote-server/socket-types/_subtypes/{PromptbookServer_Identification.d.ts → Identification.d.ts} +3 -3
- package/esm/typings/src/remote-server/socket-types/_subtypes/identificationToPromptbookToken.d.ts +11 -0
- package/esm/typings/src/remote-server/socket-types/_subtypes/promptbookTokenToIdentification.d.ts +10 -0
- package/esm/typings/src/remote-server/socket-types/listModels/PromptbookServer_ListModels_Request.d.ts +2 -2
- package/esm/typings/src/remote-server/socket-types/prepare/PromptbookServer_PreparePipeline_Request.d.ts +2 -2
- package/esm/typings/src/remote-server/socket-types/prompt/PromptbookServer_Prompt_Request.d.ts +2 -2
- package/esm/typings/src/remote-server/startRemoteServer.d.ts +3 -4
- package/esm/typings/src/remote-server/types/RemoteClientOptions.d.ts +4 -12
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +84 -9
- package/esm/typings/src/scrapers/_common/utils/{scraperFetch.d.ts → promptbookFetch.d.ts} +2 -2
- package/esm/typings/src/storage/env-storage/$EnvStorage.d.ts +40 -0
- package/esm/typings/src/types/typeAliases.d.ts +19 -0
- package/esm/typings/src/utils/organization/TODO_narrow.d.ts +6 -0
- package/package.json +7 -3
- package/umd/index.umd.js +98 -22
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/cli/test/ptbk2.d.ts +0 -5
- package/esm/typings/src/playground/BrjappConnector.d.ts +0 -67
- package/esm/typings/src/playground/brjapp-api-schema.d.ts +0 -12879
package/umd/index.umd.js
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* @generated
|
|
24
24
|
* @see https://github.com/webgptorg/promptbook
|
|
25
25
|
*/
|
|
26
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-
|
|
26
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-21';
|
|
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
|
|
@@ -59,6 +59,19 @@
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* AuthenticationError is thrown from login function which is dependency of remote server
|
|
64
|
+
*
|
|
65
|
+
* @public exported from `@promptbook/core`
|
|
66
|
+
*/
|
|
67
|
+
class AuthenticationError extends Error {
|
|
68
|
+
constructor(message) {
|
|
69
|
+
super(message);
|
|
70
|
+
this.name = 'AuthenticationError';
|
|
71
|
+
Object.setPrototypeOf(this, AuthenticationError.prototype);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
62
75
|
/**
|
|
63
76
|
* This error indicates that the pipeline collection cannot be propperly loaded
|
|
64
77
|
*
|
|
@@ -228,7 +241,7 @@
|
|
|
228
241
|
}
|
|
229
242
|
}
|
|
230
243
|
/**
|
|
231
|
-
* TODO:
|
|
244
|
+
* TODO: [🧠][🌂] Add id to all errors
|
|
232
245
|
*/
|
|
233
246
|
|
|
234
247
|
/**
|
|
@@ -257,6 +270,19 @@
|
|
|
257
270
|
}
|
|
258
271
|
}
|
|
259
272
|
|
|
273
|
+
/**
|
|
274
|
+
* Error thrown when a fetch request fails
|
|
275
|
+
*
|
|
276
|
+
* @public exported from `@promptbook/core`
|
|
277
|
+
*/
|
|
278
|
+
class PromptbookFetchError extends Error {
|
|
279
|
+
constructor(message) {
|
|
280
|
+
super(message);
|
|
281
|
+
this.name = 'PromptbookFetchError';
|
|
282
|
+
Object.setPrototypeOf(this, PromptbookFetchError.prototype);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
260
286
|
/**
|
|
261
287
|
* Returns the same value that is passed as argument.
|
|
262
288
|
* No side effects.
|
|
@@ -297,6 +323,7 @@
|
|
|
297
323
|
* @public exported from `@promptbook/core`
|
|
298
324
|
*/
|
|
299
325
|
const ADMIN_GITHUB_NAME = 'hejny';
|
|
326
|
+
// <- TODO: [🐊] Pick the best claim
|
|
300
327
|
/**
|
|
301
328
|
* When the title is not provided, the default title is used
|
|
302
329
|
*
|
|
@@ -349,7 +376,7 @@
|
|
|
349
376
|
});
|
|
350
377
|
/**
|
|
351
378
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
352
|
-
* TODO: [🧠][🧜♂️] Maybe join
|
|
379
|
+
* TODO: [🧠][🧜♂️] Maybe join remoteServerUrl and path into single value
|
|
353
380
|
*/
|
|
354
381
|
|
|
355
382
|
/**
|
|
@@ -420,6 +447,26 @@
|
|
|
420
447
|
}
|
|
421
448
|
}
|
|
422
449
|
|
|
450
|
+
/**
|
|
451
|
+
* This error type indicates that somewhere in the code non-Error object was thrown and it was wrapped into the `WrappedError`
|
|
452
|
+
*
|
|
453
|
+
* @public exported from `@promptbook/core`
|
|
454
|
+
*/
|
|
455
|
+
class WrappedError extends Error {
|
|
456
|
+
constructor(whatWasThrown) {
|
|
457
|
+
const tag = `[🤮]`;
|
|
458
|
+
console.error(tag, whatWasThrown);
|
|
459
|
+
super(spaceTrim.spaceTrim(`
|
|
460
|
+
Non-Error object was thrown
|
|
461
|
+
|
|
462
|
+
Note: Look for ${tag} in the console for more details
|
|
463
|
+
Please report issue on ${ADMIN_EMAIL}
|
|
464
|
+
`));
|
|
465
|
+
this.name = 'WrappedError';
|
|
466
|
+
Object.setPrototypeOf(this, WrappedError.prototype);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
423
470
|
/**
|
|
424
471
|
* Index of all custom errors
|
|
425
472
|
*
|
|
@@ -440,7 +487,10 @@
|
|
|
440
487
|
PipelineExecutionError,
|
|
441
488
|
PipelineLogicError,
|
|
442
489
|
PipelineUrlError,
|
|
490
|
+
AuthenticationError,
|
|
491
|
+
PromptbookFetchError,
|
|
443
492
|
UnexpectedError,
|
|
493
|
+
WrappedError,
|
|
444
494
|
// TODO: [🪑]> VersionMismatchError,
|
|
445
495
|
};
|
|
446
496
|
/**
|
|
@@ -513,22 +563,26 @@
|
|
|
513
563
|
* @private internal utility function
|
|
514
564
|
*/
|
|
515
565
|
async function createRemoteClient(options) {
|
|
516
|
-
const {
|
|
566
|
+
const { remoteServerUrl } = options;
|
|
567
|
+
console.log('!!! Connecting to socket.io server', remoteServerUrl, {
|
|
568
|
+
retries: CONNECTION_RETRIES_LIMIT,
|
|
569
|
+
timeout: CONNECTION_TIMEOUT_MS,
|
|
570
|
+
path: '/socket.io',
|
|
571
|
+
});
|
|
517
572
|
return new Promise((resolve, reject) => {
|
|
518
|
-
const socket = socket_ioClient.io(
|
|
573
|
+
const socket = socket_ioClient.io(remoteServerUrl, {
|
|
519
574
|
retries: CONNECTION_RETRIES_LIMIT,
|
|
520
575
|
timeout: CONNECTION_TIMEOUT_MS,
|
|
521
|
-
path,
|
|
522
|
-
|
|
523
|
-
transports: [/*'websocket', <- TODO: [🌬] Make websocket transport work */ 'polling'],
|
|
576
|
+
path: '/socket.io',
|
|
577
|
+
transports: ['polling', 'websocket' /*, <- TODO: [🌬] Allow to pass `transports`, add 'webtransport' */],
|
|
524
578
|
});
|
|
525
|
-
// console.log('Connecting to', this.options.
|
|
579
|
+
// console.log('Connecting to', this.options.remoteServerUrl.href, { socket });
|
|
526
580
|
socket.on('connect', () => {
|
|
527
581
|
resolve(socket);
|
|
528
582
|
});
|
|
529
583
|
// TODO: [💩] Better timeout handling
|
|
530
584
|
setTimeout(() => {
|
|
531
|
-
reject(new Error(`Timeout while connecting to ${
|
|
585
|
+
reject(new Error(`Timeout while connecting to ${remoteServerUrl}`));
|
|
532
586
|
}, CONNECTION_TIMEOUT_MS);
|
|
533
587
|
});
|
|
534
588
|
}
|
|
@@ -1510,6 +1564,34 @@
|
|
|
1510
1564
|
},
|
|
1511
1565
|
};
|
|
1512
1566
|
|
|
1567
|
+
/**
|
|
1568
|
+
* Helper used in catch blocks to assert that the error is an instance of `Error`
|
|
1569
|
+
*
|
|
1570
|
+
* @param whatWasThrown Any object that was thrown
|
|
1571
|
+
* @returns Nothing if the error is an instance of `Error`
|
|
1572
|
+
* @throws `WrappedError` or `UnexpectedError` if the error is not standard
|
|
1573
|
+
*
|
|
1574
|
+
* @private within the repository
|
|
1575
|
+
*/
|
|
1576
|
+
function assertsError(whatWasThrown) {
|
|
1577
|
+
// Case 1: Handle error which was rethrown as `WrappedError`
|
|
1578
|
+
if (whatWasThrown instanceof WrappedError) {
|
|
1579
|
+
const wrappedError = whatWasThrown;
|
|
1580
|
+
throw wrappedError;
|
|
1581
|
+
}
|
|
1582
|
+
// Case 2: Handle unexpected errors
|
|
1583
|
+
if (whatWasThrown instanceof UnexpectedError) {
|
|
1584
|
+
const unexpectedError = whatWasThrown;
|
|
1585
|
+
throw unexpectedError;
|
|
1586
|
+
}
|
|
1587
|
+
// Case 3: Handle standard errors - keep them up to consumer
|
|
1588
|
+
if (whatWasThrown instanceof Error) {
|
|
1589
|
+
return;
|
|
1590
|
+
}
|
|
1591
|
+
// Case 4: Handle non-standard errors - wrap them into `WrappedError` and throw
|
|
1592
|
+
throw new WrappedError(whatWasThrown);
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1513
1595
|
/**
|
|
1514
1596
|
* Units of text measurement
|
|
1515
1597
|
*
|
|
@@ -1590,6 +1672,8 @@
|
|
|
1590
1672
|
*/
|
|
1591
1673
|
|
|
1592
1674
|
/**
|
|
1675
|
+
import { WrappedError } from '../../errors/WrappedError';
|
|
1676
|
+
import { assertsError } from '../../errors/assertsError';
|
|
1593
1677
|
* Parses the expect command
|
|
1594
1678
|
*
|
|
1595
1679
|
* @see `documentationUrl` for more details
|
|
@@ -1681,9 +1765,7 @@
|
|
|
1681
1765
|
};
|
|
1682
1766
|
}
|
|
1683
1767
|
catch (error) {
|
|
1684
|
-
|
|
1685
|
-
throw error;
|
|
1686
|
-
}
|
|
1768
|
+
assertsError(error);
|
|
1687
1769
|
throw new ParseError(spaceTrim__default["default"]((block) => `
|
|
1688
1770
|
Invalid FORMAT command
|
|
1689
1771
|
${block(error.message)}:
|
|
@@ -1840,9 +1922,7 @@
|
|
|
1840
1922
|
return true;
|
|
1841
1923
|
}
|
|
1842
1924
|
catch (error) {
|
|
1843
|
-
|
|
1844
|
-
throw error;
|
|
1845
|
-
}
|
|
1925
|
+
assertsError(error);
|
|
1846
1926
|
if (error.message.includes('Unexpected token')) {
|
|
1847
1927
|
return false;
|
|
1848
1928
|
}
|
|
@@ -2160,9 +2240,7 @@
|
|
|
2160
2240
|
JSON.stringify(value); // <- TODO: [0]
|
|
2161
2241
|
}
|
|
2162
2242
|
catch (error) {
|
|
2163
|
-
|
|
2164
|
-
throw error;
|
|
2165
|
-
}
|
|
2243
|
+
assertsError(error);
|
|
2166
2244
|
throw new UnexpectedError(spaceTrim__default["default"]((block) => `
|
|
2167
2245
|
\`${name}\` is not serializable
|
|
2168
2246
|
|
|
@@ -4817,9 +4895,7 @@
|
|
|
4817
4895
|
}
|
|
4818
4896
|
}
|
|
4819
4897
|
catch (error) {
|
|
4820
|
-
|
|
4821
|
-
throw error;
|
|
4822
|
-
}
|
|
4898
|
+
assertsError(error);
|
|
4823
4899
|
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
4824
4900
|
Can not extract variables from the script
|
|
4825
4901
|
${block(error.stack || error.message)}
|