@promptbook/wizard 0.103.0-48 โ†’ 0.103.0-50

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 (39) hide show
  1. package/esm/index.es.js +139 -23
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/servers.d.ts +1 -0
  4. package/esm/typings/src/_packages/components.index.d.ts +2 -0
  5. package/esm/typings/src/_packages/types.index.d.ts +2 -0
  6. package/esm/typings/src/_packages/utils.index.d.ts +2 -0
  7. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +12 -2
  8. package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgent.d.ts +20 -0
  9. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +14 -8
  10. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabaseOptions.d.ts +10 -0
  11. package/esm/typings/src/commitments/MESSAGE/InitialMessageCommitmentDefinition.d.ts +28 -0
  12. package/esm/typings/src/commitments/index.d.ts +2 -1
  13. package/esm/typings/src/config.d.ts +1 -0
  14. package/esm/typings/src/errors/DatabaseError.d.ts +2 -2
  15. package/esm/typings/src/errors/WrappedError.d.ts +2 -2
  16. package/esm/typings/src/execution/ExecutionTask.d.ts +2 -2
  17. package/esm/typings/src/execution/LlmExecutionTools.d.ts +6 -1
  18. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +2 -2
  19. package/esm/typings/src/llm-providers/agent/Agent.d.ts +19 -3
  20. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +13 -1
  21. package/esm/typings/src/llm-providers/agent/RemoteAgent.d.ts +11 -2
  22. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +6 -1
  23. package/esm/typings/src/remote-server/startAgentServer.d.ts +2 -2
  24. package/esm/typings/src/utils/color/Color.d.ts +7 -0
  25. package/esm/typings/src/utils/color/Color.test.d.ts +1 -0
  26. package/esm/typings/src/utils/environment/$getGlobalScope.d.ts +2 -2
  27. package/esm/typings/src/utils/misc/computeHash.d.ts +11 -0
  28. package/esm/typings/src/utils/misc/computeHash.test.d.ts +1 -0
  29. package/esm/typings/src/utils/organization/$sideEffect.d.ts +2 -2
  30. package/esm/typings/src/utils/organization/$side_effect.d.ts +2 -2
  31. package/esm/typings/src/utils/organization/TODO_USE.d.ts +2 -2
  32. package/esm/typings/src/utils/organization/keepUnused.d.ts +2 -2
  33. package/esm/typings/src/utils/organization/preserve.d.ts +3 -3
  34. package/esm/typings/src/utils/organization/really_any.d.ts +7 -0
  35. package/esm/typings/src/utils/serialization/asSerializable.d.ts +2 -2
  36. package/esm/typings/src/version.d.ts +1 -1
  37. package/package.json +2 -2
  38. package/umd/index.umd.js +139 -23
  39. package/umd/index.umd.js.map +1 -1
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Organizational helper to tell to use intentionally `any`
3
+ *
4
+ * @alias really_any
5
+ * @private within the repository
6
+ */
7
+ export type chococake = really_any;
1
8
  /**
2
9
  * Organizational helper to mark a place where to really use `any`
3
10
  *
@@ -1,4 +1,4 @@
1
- import type { really_any } from '../organization/really_any';
1
+ import type { chococake } from '../organization/really_any';
2
2
  /**
3
3
  * Function `asSerializable` will convert values which are not serializable to serializable values
4
4
  * It walks deeply through the object and converts all values
@@ -12,4 +12,4 @@ import type { really_any } from '../organization/really_any';
12
12
  *
13
13
  * @private Internal helper function
14
14
  */
15
- export declare function asSerializable(value: really_any): really_any;
15
+ export declare function asSerializable(value: chococake): chococake;
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.103.0-47`).
18
+ * It follows semantic versioning (e.g., `0.103.0-49`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/wizard",
3
- "version": "0.103.0-48",
3
+ "version": "0.103.0-50",
4
4
  "description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -95,7 +95,7 @@
95
95
  "module": "./esm/index.es.js",
96
96
  "typings": "./esm/typings/src/_packages/wizard.index.d.ts",
97
97
  "peerDependencies": {
98
- "@promptbook/core": "0.103.0-48"
98
+ "@promptbook/core": "0.103.0-50"
99
99
  },
100
100
  "dependencies": {
101
101
  "@ai-sdk/deepseek": "0.1.17",
package/umd/index.umd.js CHANGED
@@ -48,7 +48,7 @@
48
48
  * @generated
49
49
  * @see https://github.com/webgptorg/promptbook
50
50
  */
51
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-48';
51
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-50';
52
52
  /**
53
53
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
54
54
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
@@ -87,6 +87,7 @@
87
87
  */
88
88
  ];
89
89
  /**
90
+ * TODO: [๐Ÿฑโ€๐Ÿš€] Auto-federated server from url in here
90
91
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
91
92
  */
92
93
 
@@ -433,6 +434,9 @@
433
434
  if (hex.length === 3) {
434
435
  return Color.fromHex3(hex);
435
436
  }
437
+ if (hex.length === 4) {
438
+ return Color.fromHex4(hex);
439
+ }
436
440
  if (hex.length === 6) {
437
441
  return Color.fromHex6(hex);
438
442
  }
@@ -453,6 +457,19 @@
453
457
  const b = parseInt(hex.substr(2, 1), 16) * 16;
454
458
  return take(new Color(r, g, b));
455
459
  }
460
+ /**
461
+ * Creates a new Color instance from color in hex format with 4 digits (with alpha channel)
462
+ *
463
+ * @param color in hex for example `09df`
464
+ * @returns Color object
465
+ */
466
+ static fromHex4(hex) {
467
+ const r = parseInt(hex.substr(0, 1), 16) * 16;
468
+ const g = parseInt(hex.substr(1, 1), 16) * 16;
469
+ const b = parseInt(hex.substr(2, 1), 16) * 16;
470
+ const a = parseInt(hex.substr(3, 1), 16) * 16;
471
+ return take(new Color(r, g, b, a));
472
+ }
456
473
  /**
457
474
  * Creates a new Color instance from color in hex format with 6 color digits (without alpha channel)
458
475
  *
@@ -643,7 +660,8 @@
643
660
  * @returns true if the value is a valid hex color string (e.g., `#009edd`, `#fff`, etc.)
644
661
  */
645
662
  static isHexColorString(value) {
646
- return typeof value === 'string' && /^#(?:[0-9a-fA-F]{3}){1,2}$/.test(value);
663
+ return (typeof value === 'string' &&
664
+ /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(value));
647
665
  }
648
666
  /**
649
667
  * Creates new Color object
@@ -970,6 +988,7 @@
970
988
  ({
971
989
  TITLE: Color.fromHex('#244EA8'),
972
990
  LINE: Color.fromHex('#eeeeee'),
991
+ SEPARATOR: Color.fromHex('#cccccc'),
973
992
  COMMITMENT: Color.fromHex('#DA0F78'),
974
993
  PARAMETER: Color.fromHex('#8e44ad'),
975
994
  });
@@ -1535,7 +1554,7 @@
1535
1554
  TODO: [๐Ÿง ] Is there a better implementation?
1536
1555
  > const propertyNames = Object.getOwnPropertyNames(objectValue);
1537
1556
  > for (const propertyName of propertyNames) {
1538
- > const value = (objectValue as really_any)[propertyName];
1557
+ > const value = (objectValue as chococake)[propertyName];
1539
1558
  > if (value && typeof value === 'object') {
1540
1559
  > deepClone(value);
1541
1560
  > }
@@ -1965,7 +1984,7 @@
1965
1984
  }
1966
1985
  }
1967
1986
  /**
1968
- * TODO: !!!! Explain that NotFoundError (!!! and other specific errors) has priority over DatabaseError in some contexts
1987
+ * TODO: [๐Ÿฑโ€๐Ÿš€] Explain that NotFoundError ([๐Ÿฑโ€๐Ÿš€] and other specific errors) has priority over DatabaseError in some contexts
1969
1988
  */
1970
1989
 
1971
1990
  /**
@@ -6795,11 +6814,12 @@
6795
6814
  *
6796
6815
  * This is useful for calling OpenAI API with a single assistant, for more wide usage use `OpenAiExecutionTools`.
6797
6816
  *
6798
- * !!! Note: [๐Ÿฆ–] There are several different things in Promptbook:
6817
+ * Note: [๐Ÿฆ–] There are several different things in Promptbook:
6799
6818
  * - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
6800
6819
  * - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
6801
6820
  * - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
6802
6821
  * - `OpenAiAssistantExecutionTools` - which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities, recommended for usage in `Agent` or `AgentLlmExecutionTools`
6822
+ * - `RemoteAgent` - which is an `Agent` that connects to a Promptbook Agents Server
6803
6823
  *
6804
6824
  * @public exported from `@promptbook/openai`
6805
6825
  */
@@ -6834,6 +6854,12 @@
6834
6854
  * Calls OpenAI API to use a chat model.
6835
6855
  */
6836
6856
  async callChatModel(prompt) {
6857
+ return this.callChatModelStream(prompt, () => { });
6858
+ }
6859
+ /**
6860
+ * Calls OpenAI API to use a chat model with streaming.
6861
+ */
6862
+ async callChatModelStream(prompt, onProgress) {
6837
6863
  var _a, _b, _c;
6838
6864
  if (this.options.isVerbose) {
6839
6865
  console.info('๐Ÿ’ฌ OpenAI callChatModel call', { prompt });
@@ -6901,21 +6927,24 @@
6901
6927
  console.info('connect', stream.currentEvent);
6902
6928
  }
6903
6929
  });
6904
- /*
6905
- stream.on('messageDelta', (messageDelta) => {
6906
- if (
6907
- this.options.isVerbose &&
6908
- messageDelta &&
6909
- messageDelta.content &&
6910
- messageDelta.content[0] &&
6911
- messageDelta.content[0].type === 'text'
6912
- ) {
6913
- console.info('messageDelta', messageDelta.content[0].text?.value);
6930
+ stream.on('textDelta', (textDelta, snapshot) => {
6931
+ if (this.options.isVerbose && textDelta.value) {
6932
+ console.info('textDelta', textDelta.value);
6914
6933
  }
6915
-
6916
- // <- TODO: [๐Ÿš] Make streaming and running tasks working
6934
+ const chunk = {
6935
+ content: textDelta.value || '',
6936
+ modelName: 'assistant',
6937
+ timing: {
6938
+ start,
6939
+ complete: $getCurrentDate(),
6940
+ },
6941
+ usage: UNCERTAIN_USAGE,
6942
+ rawPromptContent,
6943
+ rawRequest,
6944
+ rawResponse: snapshot,
6945
+ };
6946
+ onProgress(chunk);
6917
6947
  });
6918
- */
6919
6948
  stream.on('messageCreated', (message) => {
6920
6949
  if (this.options.isVerbose) {
6921
6950
  console.info('messageCreated', message);
@@ -6951,7 +6980,7 @@
6951
6980
  }
6952
6981
  return exportJson({
6953
6982
  name: 'promptResult',
6954
- message: `Result of \`OpenAiAssistantExecutionTools.callChatModel\``,
6983
+ message: `Result of \`OpenAiAssistantExecutionTools.callChatModelStream\``,
6955
6984
  order: [],
6956
6985
  value: {
6957
6986
  content: resultContent,
@@ -7090,9 +7119,9 @@
7090
7119
  }
7091
7120
  const assistant = await client.beta.assistants.create(assistantConfig);
7092
7121
  console.log(`โœ… Assistant created: ${assistant.id}`);
7093
- // TODO: !!!! Try listing existing assistants
7094
- // TODO: !!!! Try marking existing assistants by DISCRIMINANT
7095
- // TODO: !!!! Allow to update and reconnect to existing assistants
7122
+ // TODO: [๐Ÿฑโ€๐Ÿš€] Try listing existing assistants
7123
+ // TODO: [๐Ÿฑโ€๐Ÿš€] Try marking existing assistants by DISCRIMINANT
7124
+ // TODO: [๐Ÿฑโ€๐Ÿš€] Allow to update and reconnect to existing assistants
7096
7125
  return new OpenAiAssistantExecutionTools({
7097
7126
  ...this.options,
7098
7127
  isCreatingNewAssistantsAllowed: false,
@@ -14056,6 +14085,60 @@
14056
14085
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
14057
14086
  */
14058
14087
 
14088
+ /**
14089
+ * INITIAL MESSAGE commitment definition
14090
+ *
14091
+ * The INITIAL MESSAGE commitment defines the first message that the user sees when opening the chat.
14092
+ * It is used to greet the user and set the tone of the conversation.
14093
+ *
14094
+ * Example usage in agent source:
14095
+ *
14096
+ * ```book
14097
+ * INITIAL MESSAGE Hello! I am ready to help you with your tasks.
14098
+ * ```
14099
+ *
14100
+ * @private [๐Ÿช”] Maybe export the commitments through some package
14101
+ */
14102
+ class InitialMessageCommitmentDefinition extends BaseCommitmentDefinition {
14103
+ constructor() {
14104
+ super('INITIAL MESSAGE');
14105
+ }
14106
+ /**
14107
+ * Short one-line description of INITIAL MESSAGE.
14108
+ */
14109
+ get description() {
14110
+ return 'Defines the **initial message** shown to the user when the chat starts.';
14111
+ }
14112
+ /**
14113
+ * Markdown documentation for INITIAL MESSAGE commitment.
14114
+ */
14115
+ get documentation() {
14116
+ return spaceTrim.spaceTrim(`
14117
+ # ${this.type}
14118
+
14119
+ 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).
14120
+
14121
+ ## Key aspects
14122
+
14123
+ - Used to greet the user.
14124
+ - Sets the tone of the conversation.
14125
+ - Displayed immediately when the chat interface loads.
14126
+
14127
+ ## Examples
14128
+
14129
+ \`\`\`book
14130
+ Support Agent
14131
+
14132
+ PERSONA You are a helpful support agent.
14133
+ INITIAL MESSAGE Hi there! How can I assist you today?
14134
+ \`\`\`
14135
+ `);
14136
+ }
14137
+ applyToAgentModelRequirements(requirements, content) {
14138
+ return requirements;
14139
+ }
14140
+ }
14141
+
14059
14142
  /**
14060
14143
  * MESSAGE commitment definition
14061
14144
  *
@@ -15217,6 +15300,7 @@
15217
15300
  new NoteCommitmentDefinition('NONCE'),
15218
15301
  new GoalCommitmentDefinition('GOAL'),
15219
15302
  new GoalCommitmentDefinition('GOALS'),
15303
+ new InitialMessageCommitmentDefinition(),
15220
15304
  new MessageCommitmentDefinition('MESSAGE'),
15221
15305
  new MessageCommitmentDefinition('MESSAGES'),
15222
15306
  new ScenarioCommitmentDefinition('SCENARIO'),
@@ -15643,13 +15727,25 @@
15643
15727
  * TODO: [๐Ÿคน] Figure out best placeholder image generator https://i.pravatar.cc/1000?u=568
15644
15728
  */
15645
15729
 
15730
+ /**
15731
+ * Computes SHA-256 hash of the given object
15732
+ *
15733
+ * @public exported from `@promptbook/utils`
15734
+ */
15735
+ function computeHash(value) {
15736
+ return cryptoJs.SHA256(hexEncoder__default["default"].parse(spaceTrim__default["default"](valueToString(value)))).toString( /* hex */);
15737
+ }
15738
+ /**
15739
+ * TODO: [๐Ÿฅฌ][๐Ÿฅฌ] Use this ACRY
15740
+ */
15741
+
15646
15742
  /**
15647
15743
  * Computes SHA-256 hash of the agent source
15648
15744
  *
15649
15745
  * @public exported from `@promptbook/core`
15650
15746
  */
15651
15747
  function computeAgentHash(agentSource) {
15652
- return cryptoJs.SHA256(hexEncoder__default["default"].parse(agentSource /* <- TODO: !!!!! spaceTrim */)).toString( /* hex */);
15748
+ return computeHash(agentSource);
15653
15749
  }
15654
15750
 
15655
15751
  /**
@@ -16013,13 +16109,31 @@
16013
16109
  }
16014
16110
  personaDescription += commitment.content;
16015
16111
  }
16112
+ let initialMessage = null;
16113
+ for (const commitment of parseResult.commitments) {
16114
+ if (commitment.type !== 'INITIAL MESSAGE') {
16115
+ continue;
16116
+ }
16117
+ // Note: Initial message override logic - later overrides earlier
16118
+ // Or should it append? Usually initial message is just one block.
16119
+ // Let's stick to "later overrides earlier" for simplicity, or just take the last one.
16120
+ initialMessage = commitment.content;
16121
+ }
16016
16122
  const meta = {};
16123
+ const links = [];
16017
16124
  for (const commitment of parseResult.commitments) {
16125
+ if (commitment.type === 'META LINK') {
16126
+ links.push(spaceTrim__default["default"](commitment.content));
16127
+ continue;
16128
+ }
16018
16129
  if (commitment.type !== 'META') {
16019
16130
  continue;
16020
16131
  }
16021
16132
  // Parse META commitments - format is "META TYPE content"
16022
16133
  const metaTypeRaw = commitment.content.split(' ')[0] || 'NONE';
16134
+ if (metaTypeRaw === 'LINK') {
16135
+ links.push(spaceTrim__default["default"](commitment.content.substring(metaTypeRaw.length)));
16136
+ }
16023
16137
  const metaType = normalizeTo_camelCase(metaTypeRaw);
16024
16138
  meta[metaType] = spaceTrim__default["default"](commitment.content.substring(metaTypeRaw.length));
16025
16139
  }
@@ -16035,7 +16149,9 @@
16035
16149
  agentName: normalizeAgentName(parseResult.agentName || createDefaultAgentName(agentSource)),
16036
16150
  agentHash,
16037
16151
  personaDescription,
16152
+ initialMessage,
16038
16153
  meta,
16154
+ links,
16039
16155
  parameters,
16040
16156
  };
16041
16157
  }