@promptbook/browser 0.103.0-48 → 0.103.0-49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/index.es.js +211 -4
- package/esm/index.es.js.map +1 -1
- package/esm/typings/servers.d.ts +1 -0
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/_packages/utils.index.d.ts +2 -0
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +12 -2
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +14 -8
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabaseOptions.d.ts +10 -0
- package/esm/typings/src/commitments/MESSAGE/InitialMessageCommitmentDefinition.d.ts +28 -0
- package/esm/typings/src/commitments/index.d.ts +2 -1
- package/esm/typings/src/config.d.ts +1 -0
- package/esm/typings/src/errors/DatabaseError.d.ts +2 -2
- package/esm/typings/src/errors/WrappedError.d.ts +2 -2
- package/esm/typings/src/execution/ExecutionTask.d.ts +2 -2
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +6 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +2 -2
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +11 -3
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +6 -1
- package/esm/typings/src/llm-providers/agent/RemoteAgent.d.ts +6 -2
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +6 -1
- package/esm/typings/src/remote-server/startAgentServer.d.ts +2 -2
- package/esm/typings/src/utils/color/Color.d.ts +7 -0
- package/esm/typings/src/utils/color/Color.test.d.ts +1 -0
- package/esm/typings/src/utils/environment/$getGlobalScope.d.ts +2 -2
- package/esm/typings/src/utils/misc/computeHash.d.ts +11 -0
- package/esm/typings/src/utils/misc/computeHash.test.d.ts +1 -0
- package/esm/typings/src/utils/organization/$sideEffect.d.ts +2 -2
- package/esm/typings/src/utils/organization/$side_effect.d.ts +2 -2
- package/esm/typings/src/utils/organization/TODO_USE.d.ts +2 -2
- package/esm/typings/src/utils/organization/keepUnused.d.ts +2 -2
- package/esm/typings/src/utils/organization/preserve.d.ts +3 -3
- package/esm/typings/src/utils/organization/really_any.d.ts +7 -0
- package/esm/typings/src/utils/serialization/asSerializable.d.ts +2 -2
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +211 -4
- package/umd/index.umd.js.map +1 -1
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.103.0-
|
|
26
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-49';
|
|
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
|
|
@@ -485,6 +485,9 @@
|
|
|
485
485
|
if (hex.length === 3) {
|
|
486
486
|
return Color.fromHex3(hex);
|
|
487
487
|
}
|
|
488
|
+
if (hex.length === 4) {
|
|
489
|
+
return Color.fromHex4(hex);
|
|
490
|
+
}
|
|
488
491
|
if (hex.length === 6) {
|
|
489
492
|
return Color.fromHex6(hex);
|
|
490
493
|
}
|
|
@@ -505,6 +508,19 @@
|
|
|
505
508
|
const b = parseInt(hex.substr(2, 1), 16) * 16;
|
|
506
509
|
return take(new Color(r, g, b));
|
|
507
510
|
}
|
|
511
|
+
/**
|
|
512
|
+
* Creates a new Color instance from color in hex format with 4 digits (with alpha channel)
|
|
513
|
+
*
|
|
514
|
+
* @param color in hex for example `09df`
|
|
515
|
+
* @returns Color object
|
|
516
|
+
*/
|
|
517
|
+
static fromHex4(hex) {
|
|
518
|
+
const r = parseInt(hex.substr(0, 1), 16) * 16;
|
|
519
|
+
const g = parseInt(hex.substr(1, 1), 16) * 16;
|
|
520
|
+
const b = parseInt(hex.substr(2, 1), 16) * 16;
|
|
521
|
+
const a = parseInt(hex.substr(3, 1), 16) * 16;
|
|
522
|
+
return take(new Color(r, g, b, a));
|
|
523
|
+
}
|
|
508
524
|
/**
|
|
509
525
|
* Creates a new Color instance from color in hex format with 6 color digits (without alpha channel)
|
|
510
526
|
*
|
|
@@ -695,7 +711,8 @@
|
|
|
695
711
|
* @returns true if the value is a valid hex color string (e.g., `#009edd`, `#fff`, etc.)
|
|
696
712
|
*/
|
|
697
713
|
static isHexColorString(value) {
|
|
698
|
-
return typeof value === 'string' &&
|
|
714
|
+
return (typeof value === 'string' &&
|
|
715
|
+
/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(value));
|
|
699
716
|
}
|
|
700
717
|
/**
|
|
701
718
|
* Creates new Color object
|
|
@@ -1002,6 +1019,7 @@
|
|
|
1002
1019
|
({
|
|
1003
1020
|
TITLE: Color.fromHex('#244EA8'),
|
|
1004
1021
|
LINE: Color.fromHex('#eeeeee'),
|
|
1022
|
+
SEPARATOR: Color.fromHex('#cccccc'),
|
|
1005
1023
|
COMMITMENT: Color.fromHex('#DA0F78'),
|
|
1006
1024
|
PARAMETER: Color.fromHex('#8e44ad'),
|
|
1007
1025
|
});
|
|
@@ -1030,6 +1048,27 @@
|
|
|
1030
1048
|
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
1031
1049
|
*/
|
|
1032
1050
|
const LOOP_LIMIT = 1000;
|
|
1051
|
+
/**
|
|
1052
|
+
* Strings to represent various values in the context of parameter values
|
|
1053
|
+
*
|
|
1054
|
+
* @public exported from `@promptbook/utils`
|
|
1055
|
+
*/
|
|
1056
|
+
const VALUE_STRINGS = {
|
|
1057
|
+
empty: '(nothing; empty string)',
|
|
1058
|
+
null: '(no value; null)',
|
|
1059
|
+
undefined: '(unknown value; undefined)',
|
|
1060
|
+
nan: '(not a number; NaN)',
|
|
1061
|
+
infinity: '(infinity; ∞)',
|
|
1062
|
+
negativeInfinity: '(negative infinity; -∞)',
|
|
1063
|
+
unserializable: '(unserializable value)',
|
|
1064
|
+
circular: '(circular JSON)',
|
|
1065
|
+
};
|
|
1066
|
+
/**
|
|
1067
|
+
* Small number limit
|
|
1068
|
+
*
|
|
1069
|
+
* @public exported from `@promptbook/utils`
|
|
1070
|
+
*/
|
|
1071
|
+
const SMALL_NUMBER = 0.001;
|
|
1033
1072
|
// <- TODO: [🧜♂️]
|
|
1034
1073
|
/**
|
|
1035
1074
|
* Default settings for parsing and generating CSV files in Promptbook.
|
|
@@ -1676,7 +1715,7 @@
|
|
|
1676
1715
|
TODO: [🧠] Is there a better implementation?
|
|
1677
1716
|
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
1678
1717
|
> for (const propertyName of propertyNames) {
|
|
1679
|
-
> const value = (objectValue as
|
|
1718
|
+
> const value = (objectValue as chococake)[propertyName];
|
|
1680
1719
|
> if (value && typeof value === 'object') {
|
|
1681
1720
|
> deepClone(value);
|
|
1682
1721
|
> }
|
|
@@ -1995,13 +2034,106 @@
|
|
|
1995
2034
|
* TODO: [🤹] Figure out best placeholder image generator https://i.pravatar.cc/1000?u=568
|
|
1996
2035
|
*/
|
|
1997
2036
|
|
|
2037
|
+
/**
|
|
2038
|
+
* Format either small or big number
|
|
2039
|
+
*
|
|
2040
|
+
* @public exported from `@promptbook/utils`
|
|
2041
|
+
*/
|
|
2042
|
+
function numberToString(value) {
|
|
2043
|
+
if (value === 0) {
|
|
2044
|
+
return '0';
|
|
2045
|
+
}
|
|
2046
|
+
else if (Number.isNaN(value)) {
|
|
2047
|
+
return VALUE_STRINGS.nan;
|
|
2048
|
+
}
|
|
2049
|
+
else if (value === Infinity) {
|
|
2050
|
+
return VALUE_STRINGS.infinity;
|
|
2051
|
+
}
|
|
2052
|
+
else if (value === -Infinity) {
|
|
2053
|
+
return VALUE_STRINGS.negativeInfinity;
|
|
2054
|
+
}
|
|
2055
|
+
for (let exponent = 0; exponent < 15; exponent++) {
|
|
2056
|
+
const factor = 10 ** exponent;
|
|
2057
|
+
const valueRounded = Math.round(value * factor) / factor;
|
|
2058
|
+
if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
|
|
2059
|
+
return valueRounded.toFixed(exponent);
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
return value.toString();
|
|
2063
|
+
}
|
|
2064
|
+
|
|
2065
|
+
/**
|
|
2066
|
+
* Function `valueToString` will convert the given value to string
|
|
2067
|
+
* This is useful and used in the `templateParameters` function
|
|
2068
|
+
*
|
|
2069
|
+
* Note: This function is not just calling `toString` method
|
|
2070
|
+
* It's more complex and can handle this conversion specifically for LLM models
|
|
2071
|
+
* See `VALUE_STRINGS`
|
|
2072
|
+
*
|
|
2073
|
+
* Note: There are 2 similar functions
|
|
2074
|
+
* - `valueToString` converts value to string for LLM models as human-readable string
|
|
2075
|
+
* - `asSerializable` converts value to string to preserve full information to be able to convert it back
|
|
2076
|
+
*
|
|
2077
|
+
* @public exported from `@promptbook/utils`
|
|
2078
|
+
*/
|
|
2079
|
+
function valueToString(value) {
|
|
2080
|
+
try {
|
|
2081
|
+
if (value === '') {
|
|
2082
|
+
return VALUE_STRINGS.empty;
|
|
2083
|
+
}
|
|
2084
|
+
else if (value === null) {
|
|
2085
|
+
return VALUE_STRINGS.null;
|
|
2086
|
+
}
|
|
2087
|
+
else if (value === undefined) {
|
|
2088
|
+
return VALUE_STRINGS.undefined;
|
|
2089
|
+
}
|
|
2090
|
+
else if (typeof value === 'string') {
|
|
2091
|
+
return value;
|
|
2092
|
+
}
|
|
2093
|
+
else if (typeof value === 'number') {
|
|
2094
|
+
return numberToString(value);
|
|
2095
|
+
}
|
|
2096
|
+
else if (value instanceof Date) {
|
|
2097
|
+
return value.toISOString();
|
|
2098
|
+
}
|
|
2099
|
+
else {
|
|
2100
|
+
try {
|
|
2101
|
+
return JSON.stringify(value);
|
|
2102
|
+
}
|
|
2103
|
+
catch (error) {
|
|
2104
|
+
if (error instanceof TypeError && error.message.includes('circular structure')) {
|
|
2105
|
+
return VALUE_STRINGS.circular;
|
|
2106
|
+
}
|
|
2107
|
+
throw error;
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2111
|
+
catch (error) {
|
|
2112
|
+
assertsError(error);
|
|
2113
|
+
console.error(error);
|
|
2114
|
+
return VALUE_STRINGS.unserializable;
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
|
|
2118
|
+
/**
|
|
2119
|
+
* Computes SHA-256 hash of the given object
|
|
2120
|
+
*
|
|
2121
|
+
* @public exported from `@promptbook/utils`
|
|
2122
|
+
*/
|
|
2123
|
+
function computeHash(value) {
|
|
2124
|
+
return cryptoJs.SHA256(hexEncoder__default["default"].parse(spaceTrim__default["default"](valueToString(value)))).toString( /* hex */);
|
|
2125
|
+
}
|
|
2126
|
+
/**
|
|
2127
|
+
* TODO: [🥬][🥬] Use this ACRY
|
|
2128
|
+
*/
|
|
2129
|
+
|
|
1998
2130
|
/**
|
|
1999
2131
|
* Computes SHA-256 hash of the agent source
|
|
2000
2132
|
*
|
|
2001
2133
|
* @public exported from `@promptbook/core`
|
|
2002
2134
|
*/
|
|
2003
2135
|
function computeAgentHash(agentSource) {
|
|
2004
|
-
return
|
|
2136
|
+
return computeHash(agentSource);
|
|
2005
2137
|
}
|
|
2006
2138
|
|
|
2007
2139
|
/**
|
|
@@ -3187,6 +3319,60 @@
|
|
|
3187
3319
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
3188
3320
|
*/
|
|
3189
3321
|
|
|
3322
|
+
/**
|
|
3323
|
+
* INITIAL MESSAGE commitment definition
|
|
3324
|
+
*
|
|
3325
|
+
* The INITIAL MESSAGE commitment defines the first message that the user sees when opening the chat.
|
|
3326
|
+
* It is used to greet the user and set the tone of the conversation.
|
|
3327
|
+
*
|
|
3328
|
+
* Example usage in agent source:
|
|
3329
|
+
*
|
|
3330
|
+
* ```book
|
|
3331
|
+
* INITIAL MESSAGE Hello! I am ready to help you with your tasks.
|
|
3332
|
+
* ```
|
|
3333
|
+
*
|
|
3334
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
3335
|
+
*/
|
|
3336
|
+
class InitialMessageCommitmentDefinition extends BaseCommitmentDefinition {
|
|
3337
|
+
constructor() {
|
|
3338
|
+
super('INITIAL MESSAGE');
|
|
3339
|
+
}
|
|
3340
|
+
/**
|
|
3341
|
+
* Short one-line description of INITIAL MESSAGE.
|
|
3342
|
+
*/
|
|
3343
|
+
get description() {
|
|
3344
|
+
return 'Defines the **initial message** shown to the user when the chat starts.';
|
|
3345
|
+
}
|
|
3346
|
+
/**
|
|
3347
|
+
* Markdown documentation for INITIAL MESSAGE commitment.
|
|
3348
|
+
*/
|
|
3349
|
+
get documentation() {
|
|
3350
|
+
return spaceTrim.spaceTrim(`
|
|
3351
|
+
# ${this.type}
|
|
3352
|
+
|
|
3353
|
+
Defines the first message that the user sees when opening the chat. This message is purely for display purposes in the UI and does not inherently become part of the LLM's system prompt context (unless also included via other means).
|
|
3354
|
+
|
|
3355
|
+
## Key aspects
|
|
3356
|
+
|
|
3357
|
+
- Used to greet the user.
|
|
3358
|
+
- Sets the tone of the conversation.
|
|
3359
|
+
- Displayed immediately when the chat interface loads.
|
|
3360
|
+
|
|
3361
|
+
## Examples
|
|
3362
|
+
|
|
3363
|
+
\`\`\`book
|
|
3364
|
+
Support Agent
|
|
3365
|
+
|
|
3366
|
+
PERSONA You are a helpful support agent.
|
|
3367
|
+
INITIAL MESSAGE Hi there! How can I assist you today?
|
|
3368
|
+
\`\`\`
|
|
3369
|
+
`);
|
|
3370
|
+
}
|
|
3371
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
3372
|
+
return requirements;
|
|
3373
|
+
}
|
|
3374
|
+
}
|
|
3375
|
+
|
|
3190
3376
|
/**
|
|
3191
3377
|
* MESSAGE commitment definition
|
|
3192
3378
|
*
|
|
@@ -4348,6 +4534,7 @@
|
|
|
4348
4534
|
new NoteCommitmentDefinition('NONCE'),
|
|
4349
4535
|
new GoalCommitmentDefinition('GOAL'),
|
|
4350
4536
|
new GoalCommitmentDefinition('GOALS'),
|
|
4537
|
+
new InitialMessageCommitmentDefinition(),
|
|
4351
4538
|
new MessageCommitmentDefinition('MESSAGE'),
|
|
4352
4539
|
new MessageCommitmentDefinition('MESSAGES'),
|
|
4353
4540
|
new ScenarioCommitmentDefinition('SCENARIO'),
|
|
@@ -4552,13 +4739,31 @@
|
|
|
4552
4739
|
}
|
|
4553
4740
|
personaDescription += commitment.content;
|
|
4554
4741
|
}
|
|
4742
|
+
let initialMessage = null;
|
|
4743
|
+
for (const commitment of parseResult.commitments) {
|
|
4744
|
+
if (commitment.type !== 'INITIAL MESSAGE') {
|
|
4745
|
+
continue;
|
|
4746
|
+
}
|
|
4747
|
+
// Note: Initial message override logic - later overrides earlier
|
|
4748
|
+
// Or should it append? Usually initial message is just one block.
|
|
4749
|
+
// Let's stick to "later overrides earlier" for simplicity, or just take the last one.
|
|
4750
|
+
initialMessage = commitment.content;
|
|
4751
|
+
}
|
|
4555
4752
|
const meta = {};
|
|
4753
|
+
const links = [];
|
|
4556
4754
|
for (const commitment of parseResult.commitments) {
|
|
4755
|
+
if (commitment.type === 'META LINK') {
|
|
4756
|
+
links.push(spaceTrim__default["default"](commitment.content));
|
|
4757
|
+
continue;
|
|
4758
|
+
}
|
|
4557
4759
|
if (commitment.type !== 'META') {
|
|
4558
4760
|
continue;
|
|
4559
4761
|
}
|
|
4560
4762
|
// Parse META commitments - format is "META TYPE content"
|
|
4561
4763
|
const metaTypeRaw = commitment.content.split(' ')[0] || 'NONE';
|
|
4764
|
+
if (metaTypeRaw === 'LINK') {
|
|
4765
|
+
links.push(spaceTrim__default["default"](commitment.content.substring(metaTypeRaw.length)));
|
|
4766
|
+
}
|
|
4562
4767
|
const metaType = normalizeTo_camelCase(metaTypeRaw);
|
|
4563
4768
|
meta[metaType] = spaceTrim__default["default"](commitment.content.substring(metaTypeRaw.length));
|
|
4564
4769
|
}
|
|
@@ -4574,7 +4779,9 @@
|
|
|
4574
4779
|
agentName: normalizeAgentName(parseResult.agentName || createDefaultAgentName(agentSource)),
|
|
4575
4780
|
agentHash,
|
|
4576
4781
|
personaDescription,
|
|
4782
|
+
initialMessage,
|
|
4577
4783
|
meta,
|
|
4784
|
+
links,
|
|
4578
4785
|
parameters,
|
|
4579
4786
|
};
|
|
4580
4787
|
}
|