@promptbook/core 0.103.0-44 → 0.103.0-46

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 CHANGED
@@ -27,7 +27,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
27
27
  * @generated
28
28
  * @see https://github.com/webgptorg/promptbook
29
29
  */
30
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-44';
30
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-46';
31
31
  /**
32
32
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
33
33
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1542,6 +1542,8 @@ function isValidJsonString(value /* <- [👨‍⚖️] */) {
1542
1542
  * Function `validatePipelineString` will validate the if the string is a valid pipeline string
1543
1543
  * It does not check if the string is fully logically correct, but if it is a string that can be a pipeline string or the string looks completely different.
1544
1544
  *
1545
+ * Note: [🔂] This function is idempotent.
1546
+ *
1545
1547
  * @param {string} pipelineString the candidate for a pipeline string
1546
1548
  * @returns {PipelineString} the same string as input, but validated as valid
1547
1549
  * @throws {ParseError} if the string is not a valid pipeline string
@@ -2173,6 +2175,8 @@ function isValidPipelineUrl(url) {
2173
2175
  * - if it is valid json
2174
2176
  * - if it is meaningful
2175
2177
  *
2178
+ * Note: [🔂] This function is idempotent.
2179
+ *
2176
2180
  * @param pipeline valid or invalid PipelineJson
2177
2181
  * @returns the same pipeline if it is logically valid
2178
2182
  * @throws {PipelineLogicError} on logical error in the pipeline
@@ -6030,6 +6034,8 @@ function isPassingExpectations(expectations, value) {
6030
6034
  * This function provides a common abstraction for result validation that can be used
6031
6035
  * by both execution logic and caching logic to ensure consistency.
6032
6036
  *
6037
+ * Note: [🔂] This function is idempotent.
6038
+ *
6033
6039
  * @param options - The validation options including result string, expectations, and format
6034
6040
  * @returns Validation result with processed string and validity status
6035
6041
  * @private internal function of `createPipelineExecutor` and `cacheLlmTools`
@@ -9822,6 +9828,8 @@ const PADDING_LINES = 11;
9822
9828
  /**
9823
9829
  * A function that adds padding to the book content
9824
9830
  *
9831
+ * Note: [🔂] This function is idempotent.
9832
+ *
9825
9833
  * @public exported from `@promptbook/core`
9826
9834
  */
9827
9835
  function padBook(content) {
@@ -9867,6 +9875,8 @@ function isValidBook(value) {
9867
9875
  * This function should be used when you have a string that you know represents agent source
9868
9876
  * but need to convert it to the branded type for type safety
9869
9877
  *
9878
+ * Note: [🔂] This function is idempotent.
9879
+ *
9870
9880
  * @public exported from `@promptbook/core`
9871
9881
  */
9872
9882
  function validateBook(source) {
@@ -10073,6 +10083,37 @@ class AgentCollectionInSupabase /* TODO: !!!! implements AgentCollection */ {
10073
10083
  }
10074
10084
  return agentProfile;
10075
10085
  }
10086
+ /**
10087
+ * Updates an existing agent in the collection
10088
+ */
10089
+ async updateAgentSource(agentName, agentSource) {
10090
+ const agentProfile = parseAgentSource(agentSource);
10091
+ // TODO: !!!!!! What about agentName change
10092
+ console.log('!!! agentName', agentName);
10093
+ const oldAgentSource = await this.getAgentSource(agentName);
10094
+ const result = await this.supabaseClient
10095
+ .from('AgentCollection' /* <- TODO: !!!! Change to `Agent` */)
10096
+ .update({
10097
+ // TODO: !!!! Compare not update> agentName: agentProfile.agentName || '!!!!!' /* <- TODO: !!!! Remove */,
10098
+ agentProfile,
10099
+ updatedAt: new Date().toISOString(),
10100
+ agentVersion: 0,
10101
+ agentSource: agentSource,
10102
+ })
10103
+ .eq('agentName', agentName);
10104
+ const newAgentSource = await this.getAgentSource(agentName);
10105
+ console.log('!!! updateAgent', result);
10106
+ console.log('!!! old', oldAgentSource);
10107
+ console.log('!!! new', newAgentSource);
10108
+ if (result.error) {
10109
+ throw new DatabaseError(spaceTrim((block) => `
10110
+ Error updating agent "${agentName}" in Supabase:
10111
+
10112
+ ${block(result.error.message)}
10113
+ `));
10114
+ }
10115
+ }
10116
+ // TODO: !!!! getAgentSourceSubject
10076
10117
  /**
10077
10118
  * Deletes an agent from the collection
10078
10119
  */
@@ -10964,6 +11005,8 @@ function removeQuotes(text) {
10964
11005
  * Function `validateParameterName` will normalize and validate a parameter name for use in pipelines.
10965
11006
  * It removes diacritics, emojis, and quotes, normalizes to camelCase, and checks for reserved names and invalid characters.
10966
11007
  *
11008
+ * Note: [🔂] This function is idempotent.
11009
+ *
10967
11010
  * @param parameterName The parameter name to validate and normalize.
10968
11011
  * @returns The validated and normalized parameter name.
10969
11012
  * @throws {ParseError} If the parameter name is empty, reserved, or contains invalid characters.