@promptbook/vercel 0.103.0-42 → 0.103.0-44
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 +6 -18
- package/esm/index.es.js +21 -98
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +6 -0
- package/esm/typings/src/_packages/node.index.d.ts +0 -2
- package/esm/typings/src/_packages/types.index.d.ts +22 -0
- package/esm/typings/src/_packages/utils.index.d.ts +2 -0
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +2 -4
- package/esm/typings/src/book-2.0/agent-source/padBook.d.ts +1 -1
- package/esm/typings/src/book-2.0/agent-source/string_book.d.ts +1 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +6 -1
- package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/save/_common/ChatSaveFormatDefinition.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +1 -1
- package/esm/typings/src/book-components/Qr/BrandedQrCode.d.ts +1 -1
- package/esm/typings/src/book-components/Qr/useQrCode.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/_boilerplate.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/about.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/hello.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/list-models.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/list-scrapers.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/login.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/make.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/prettify.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/run.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/start-agents-server.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/start-pipelines-server.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/test-command.d.ts +1 -1
- package/esm/typings/src/cli/common/$addGlobalOptionsToCommand.d.ts +1 -1
- package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +2 -29
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +107 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +129 -0
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +1 -1
- package/esm/typings/src/config.d.ts +1 -1
- package/esm/typings/src/errors/0-index.d.ts +3 -0
- package/esm/typings/src/errors/DatabaseError.d.ts +12 -0
- package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +1 -1
- package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$registeredLlmToolsMessage.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +1 -1
- package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +5 -2
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/agent/AgentOptions.d.ts +4 -2
- package/esm/typings/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +4 -3
- package/esm/typings/src/llm-providers/agent/createAgentLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/google/google-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +1 -0
- package/esm/typings/src/remote-server/startAgentServer.d.ts +2 -2
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +0 -19
- package/esm/typings/src/storage/env-storage/$EnvStorage.d.ts +1 -1
- package/esm/typings/src/transpilers/_common/BookTranspiler.d.ts +5 -1
- package/esm/typings/src/transpilers/_common/BookTranspilerOptions.d.ts +1 -1
- package/esm/typings/src/transpilers/_common/register/$bookTranspilersRegister.d.ts +1 -1
- package/esm/typings/src/transpilers/formatted-book-in-markdown/FormattedBookInMarkdownTranspiler.d.ts +4 -1
- package/esm/typings/src/transpilers/formatted-book-in-markdown/register.d.ts +1 -1
- package/esm/typings/src/transpilers/openai-sdk/OpenAiSdkTranspiler.d.ts +4 -1
- package/esm/typings/src/transpilers/openai-sdk/register.d.ts +1 -1
- package/esm/typings/src/types/typeAliases.d.ts +19 -1
- package/esm/typings/src/utils/color/$randomColor.d.ts +1 -0
- package/esm/typings/src/utils/color/operators/darken.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/grayscale.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/lighten.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/mixWithColor.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/saturate.d.ts +1 -1
- package/esm/typings/src/utils/environment/$detectRuntimeEnvironment.d.ts +16 -0
- package/esm/typings/src/utils/execCommand/$execCommand.d.ts +1 -1
- package/esm/typings/src/utils/execCommand/$execCommands.d.ts +1 -1
- package/esm/typings/src/utils/files/$induceBookDownload.d.ts +2 -2
- package/esm/typings/src/utils/files/$induceFileDownload.d.ts +2 -2
- package/esm/typings/src/utils/files/ObjectUrl.d.ts +1 -1
- package/esm/typings/src/utils/misc/aboutPromptbookInformation.d.ts +6 -0
- package/esm/typings/src/utils/organization/$side_effect.d.ts +1 -1
- package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +25 -0
- package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +9 -0
- package/esm/typings/src/utils/random/$randomFullnameWithColor.d.ts +13 -0
- package/esm/typings/src/utils/random/$randomItem.d.ts +9 -0
- package/esm/typings/src/utils/random/$randomSeed.d.ts +3 -0
- package/esm/typings/src/utils/random/$randomToken.d.ts +2 -0
- package/esm/typings/src/utils/serialization/$deepFreeze.d.ts +1 -1
- package/esm/typings/src/utils/serialization/serializeToPromptbookJavascript.d.ts +2 -2
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +21 -98
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/collection/agent-collection/constructors/AgentCollectionInDirectory.d.ts +0 -89
- package/esm/typings/src/collection/agent-collection/constructors/AgentCollectionInDirectory.test.d.ts +0 -1
- package/esm/typings/src/commands/_common/parseCommand.test.d.ts +0 -1
- package/esm/typings/src/execution/utils/logLlmCall.d.ts +0 -8
|
@@ -11,6 +11,7 @@ import { jsonParse } from '../formats/json/utils/jsonParse';
|
|
|
11
11
|
import { isValidXmlString } from '../formats/xml/utils/isValidXmlString';
|
|
12
12
|
import { prompt } from '../pipeline/prompt-notation';
|
|
13
13
|
import { promptTemplate } from '../pipeline/prompt-notation';
|
|
14
|
+
import { $detectRuntimeEnvironment } from '../utils/environment/$detectRuntimeEnvironment';
|
|
14
15
|
import { $isRunningInBrowser } from '../utils/environment/$isRunningInBrowser';
|
|
15
16
|
import { $isRunningInJest } from '../utils/environment/$isRunningInJest';
|
|
16
17
|
import { $isRunningInNode } from '../utils/environment/$isRunningInNode';
|
|
@@ -96,6 +97,7 @@ export { jsonParse };
|
|
|
96
97
|
export { isValidXmlString };
|
|
97
98
|
export { prompt };
|
|
98
99
|
export { promptTemplate };
|
|
100
|
+
export { $detectRuntimeEnvironment };
|
|
99
101
|
export { $isRunningInBrowser };
|
|
100
102
|
export { $isRunningInJest };
|
|
101
103
|
export { $isRunningInNode };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { string_agent_name, string_url_image } from '../../types/typeAliases';
|
|
1
|
+
import type { string_agent_name, string_color, string_url_image } from '../../types/typeAliases';
|
|
2
2
|
/**
|
|
3
3
|
* Unified parameter representation that supports two different notations:
|
|
4
4
|
* 1. @Parameter - single word parameter starting with @
|
|
@@ -41,9 +41,7 @@ export type AgentBasicInformation = {
|
|
|
41
41
|
*/
|
|
42
42
|
meta: {
|
|
43
43
|
image?: string_url_image;
|
|
44
|
-
|
|
45
|
-
title?: string;
|
|
46
|
-
description?: string;
|
|
44
|
+
color?: string_color;
|
|
47
45
|
[key: string]: string | undefined;
|
|
48
46
|
};
|
|
49
47
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
1
2
|
import type { AgentBasicInformation } from '../../../book-2.0/agent-source/AgentBasicInformation';
|
|
2
3
|
import type { string_book } from '../../../book-2.0/agent-source/string_book';
|
|
3
4
|
import type { string_css_class } from '../../../types/typeAliases';
|
|
@@ -14,11 +15,15 @@ export type AvatarProfileProps = {
|
|
|
14
15
|
/**
|
|
15
16
|
* The source of the agent, which will be displayed in the BookEditor.
|
|
16
17
|
*/
|
|
17
|
-
readonly agentSource
|
|
18
|
+
readonly agentSource?: string_book;
|
|
18
19
|
/**
|
|
19
20
|
* Optional CSS class name which will be added to root <div> element
|
|
20
21
|
*/
|
|
21
22
|
readonly className?: string_css_class;
|
|
23
|
+
/**
|
|
24
|
+
* Optional CSS style which will be added to root <div/> element
|
|
25
|
+
*/
|
|
26
|
+
readonly style?: CSSProperties;
|
|
22
27
|
};
|
|
23
28
|
/**
|
|
24
29
|
* Shows a box with user avatar, name and description
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CSSProperties } from 'react';
|
|
2
2
|
import type { Promisable } from 'type-fest';
|
|
3
|
-
import {
|
|
3
|
+
import type { string_book } from '../../book-2.0/agent-source/string_book';
|
|
4
4
|
import type { number_percent, number_positive, string_css_value, string_knowledge_source_content } from '../../types/typeAliases';
|
|
5
5
|
/**
|
|
6
6
|
* Default height of the book editor
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Promisable } from 'type-fest';
|
|
2
2
|
import type { string_file_extension, string_mime_type } from '../../../../types/typeAliases';
|
|
3
3
|
import type { ChatMessage } from '../../types/ChatMessage';
|
|
4
|
-
import { ChatParticipant } from '../../types/ChatParticipant';
|
|
4
|
+
import type { ChatParticipant } from '../../types/ChatParticipant';
|
|
5
5
|
/**
|
|
6
6
|
* Plugin contract for chat export formatNames
|
|
7
7
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { string_book } from '../../../book-2.0/agent-source/string_book';
|
|
1
2
|
import type { id, string_color, string_person_fullname, string_url_image } from '../../../types/typeAliases';
|
|
2
3
|
import { Color } from '../../../utils/color/Color';
|
|
3
|
-
import type { string_book } from '../../../book-2.0/agent-source/string_book';
|
|
4
4
|
/**
|
|
5
5
|
* A participant in the chat
|
|
6
6
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { QRCodeRenderersOptions } from 'qrcode';
|
|
3
|
-
import { string_url_image } from '../../types/typeAliases';
|
|
3
|
+
import type { string_url_image } from '../../types/typeAliases';
|
|
4
4
|
export type QrCodeOptions = QRCodeRenderersOptions & {
|
|
5
5
|
value: string | number;
|
|
6
6
|
logoSrc?: string_url_image;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Command as Program } from 'commander';
|
|
2
|
-
import { $side_effect } from '../../utils/organization/$side_effect';
|
|
2
|
+
import type { $side_effect } from '../../utils/organization/$side_effect';
|
|
3
3
|
/**
|
|
4
4
|
* Initializes `boilerplate` command for Promptbook CLI utilities
|
|
5
5
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Command as Program } from 'commander';
|
|
2
|
-
import { $side_effect } from '../../utils/organization/$side_effect';
|
|
2
|
+
import type { $side_effect } from '../../utils/organization/$side_effect';
|
|
3
3
|
/**
|
|
4
4
|
* Initializes `about` command for Promptbook CLI utilities
|
|
5
5
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Command as Program } from 'commander';
|
|
2
|
-
import { $side_effect } from '../../utils/organization/$side_effect';
|
|
2
|
+
import type { $side_effect } from '../../utils/organization/$side_effect';
|
|
3
3
|
/**
|
|
4
4
|
* Initializes testing `hello` command for Promptbook CLI utilities
|
|
5
5
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Command as Program } from 'commander';
|
|
2
|
-
import { $side_effect } from '../../utils/organization/$side_effect';
|
|
2
|
+
import type { $side_effect } from '../../utils/organization/$side_effect';
|
|
3
3
|
/**
|
|
4
4
|
* Initializes `list-models` command for Promptbook CLI utilities
|
|
5
5
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Command as Program } from 'commander';
|
|
2
|
-
import { $side_effect } from '../../utils/organization/$side_effect';
|
|
2
|
+
import type { $side_effect } from '../../utils/organization/$side_effect';
|
|
3
3
|
/**
|
|
4
4
|
* Initializes `list-scrapers` command for Promptbook CLI utilities
|
|
5
5
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Command as Program } from 'commander';
|
|
2
|
-
import { $side_effect } from '../../utils/organization/$side_effect';
|
|
2
|
+
import type { $side_effect } from '../../utils/organization/$side_effect';
|
|
3
3
|
/**
|
|
4
4
|
* Initializes `login` command for Promptbook CLI utilities
|
|
5
5
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Command as Program } from 'commander';
|
|
2
|
-
import { $side_effect } from '../../utils/organization/$side_effect';
|
|
2
|
+
import type { $side_effect } from '../../utils/organization/$side_effect';
|
|
3
3
|
/**
|
|
4
4
|
* Initializes `make` command for Promptbook CLI utilities
|
|
5
5
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Command as Program } from 'commander';
|
|
2
|
-
import { $side_effect } from '../../utils/organization/$side_effect';
|
|
2
|
+
import type { $side_effect } from '../../utils/organization/$side_effect';
|
|
3
3
|
/**
|
|
4
4
|
* Initializes `prettify` command for Promptbook CLI utilities
|
|
5
5
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Command as Program } from 'commander';
|
|
2
|
-
import { $side_effect } from '../../utils/organization/$side_effect';
|
|
2
|
+
import type { $side_effect } from '../../utils/organization/$side_effect';
|
|
3
3
|
/**
|
|
4
4
|
* Initializes `run` command for Promptbook CLI utilities
|
|
5
5
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Command as Program } from 'commander';
|
|
2
|
-
import { $side_effect } from '../../utils/organization/$side_effect';
|
|
2
|
+
import type { $side_effect } from '../../utils/organization/$side_effect';
|
|
3
3
|
/**
|
|
4
4
|
* Initializes `start-agents-server` command for Promptbook CLI utilities
|
|
5
5
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Command as Program } from 'commander';
|
|
2
|
-
import { $side_effect } from '../../utils/organization/$side_effect';
|
|
2
|
+
import type { $side_effect } from '../../utils/organization/$side_effect';
|
|
3
3
|
/**
|
|
4
4
|
* Initializes `start-pipelines-server` command for Promptbook CLI utilities
|
|
5
5
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Command as Program } from 'commander';
|
|
2
|
-
import { $side_effect } from '../../utils/organization/$side_effect';
|
|
2
|
+
import type { $side_effect } from '../../utils/organization/$side_effect';
|
|
3
3
|
/**
|
|
4
4
|
* Initializes `test` command for Promptbook CLI utilities
|
|
5
5
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import { $side_effect } from '../../utils/organization/$side_effect';
|
|
2
|
+
import type { $side_effect } from '../../utils/organization/$side_effect';
|
|
3
3
|
/**
|
|
4
4
|
* Note: `$` is used to indicate that this function is not a pure function - it registers an option in the CLI
|
|
5
5
|
*
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Agent } from '../../_packages/core.index';
|
|
3
|
-
import { string_book } from '../../_packages/types.index';
|
|
4
|
-
import type { string_agent_name } from '../../types/typeAliases';
|
|
1
|
+
import { AgentCollectionInSupabase } from './constructors/agent-collection-in-supabase/AgentCollectionInSupabase';
|
|
5
2
|
/**
|
|
6
3
|
* Collection that groups together multiple AI Agents
|
|
7
4
|
*
|
|
@@ -9,31 +6,7 @@ import type { string_agent_name } from '../../types/typeAliases';
|
|
|
9
6
|
* - `AgentCollection` - which groups together AI Agents
|
|
10
7
|
* - `PipelineCollection` - which groups together *(deprecated)* pipelines
|
|
11
8
|
*/
|
|
12
|
-
export type AgentCollection =
|
|
13
|
-
/**
|
|
14
|
-
* Gets all agents in the collection
|
|
15
|
-
*/
|
|
16
|
-
listAgents(): Promisable<ReadonlyArray<string_agent_name>>;
|
|
17
|
-
/**
|
|
18
|
-
* Get one agent by its name
|
|
19
|
-
*
|
|
20
|
-
* Note: Agents are existing independently of you getting them or not, you can get the same agent multiple times.
|
|
21
|
-
* Note: Agents are changed by interacting with `Agent` objects directly. Only creation and deletion is done via the collection.
|
|
22
|
-
*/
|
|
23
|
-
getAgentByName(agentName: string_agent_name): Promisable<Agent>;
|
|
24
|
-
/**
|
|
25
|
-
* Deletes an agent from the collection
|
|
26
|
-
*
|
|
27
|
-
* Note: When you want delete an agent by name, first get the agent using `getAgentByName` and then pass it to `deleteAgent`.
|
|
28
|
-
*/
|
|
29
|
-
deleteAgent(agent: Agent): Promisable<void>;
|
|
30
|
-
/**
|
|
31
|
-
* Creates a new agent in the collection
|
|
32
|
-
*
|
|
33
|
-
* Note: You can set 'PARENT' in the agent source to inherit from another agent in the collection.
|
|
34
|
-
*/
|
|
35
|
-
createAgent(agentSource: string_book): Promisable<Agent>;
|
|
36
|
-
};
|
|
9
|
+
export type AgentCollection = AgentCollectionInSupabase;
|
|
37
10
|
/**
|
|
38
11
|
* TODO: [🧠][🚙] `AgentXxx` vs `AgentsXxx` naming convention
|
|
39
12
|
*/
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
+
import { BehaviorSubject } from 'rxjs';
|
|
3
|
+
import type { AgentBasicInformation } from '../../../../book-2.0/agent-source/AgentBasicInformation';
|
|
4
|
+
import type { string_book } from '../../../../book-2.0/agent-source/string_book';
|
|
5
|
+
import type { CommonToolsOptions } from '../../../../execution/CommonToolsOptions';
|
|
6
|
+
import type { PrepareAndScrapeOptions } from '../../../../prepare/PrepareAndScrapeOptions';
|
|
7
|
+
import type { string_agent_name } from '../../../../types/typeAliases';
|
|
8
|
+
import type { AgentsDatabaseSchema } from './AgentsDatabaseSchema';
|
|
9
|
+
/**
|
|
10
|
+
* Agent collection stored in Supabase table
|
|
11
|
+
*
|
|
12
|
+
* Note: This object can work both from Node.js and browser environment depending on the Supabase client provided
|
|
13
|
+
*
|
|
14
|
+
* @public exported from `@promptbook/core`
|
|
15
|
+
* <- TODO: !!! Move to `@promptbook/supabase` package
|
|
16
|
+
*/
|
|
17
|
+
export declare class AgentCollectionInSupabase {
|
|
18
|
+
private readonly supabaseClient;
|
|
19
|
+
readonly options?: (PrepareAndScrapeOptions & CommonToolsOptions) | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* @param rootPath - path to the directory with agents
|
|
22
|
+
* @param tools - Execution tools to be used in !!! `Agent` itself and listing the agents
|
|
23
|
+
* @param options - Options for the collection creation
|
|
24
|
+
*/
|
|
25
|
+
constructor(supabaseClient: SupabaseClient<AgentsDatabaseSchema>, options?: (PrepareAndScrapeOptions & CommonToolsOptions) | undefined);
|
|
26
|
+
/**
|
|
27
|
+
* Cached defined execution tools
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Gets all agents in the collection
|
|
31
|
+
*/
|
|
32
|
+
listAgents(): Promise<ReadonlyArray<AgentBasicInformation>>;
|
|
33
|
+
/**
|
|
34
|
+
* !!!
|
|
35
|
+
* /
|
|
36
|
+
public async spawnAgent(agentName: string_agent_name): Promise<Agent> {
|
|
37
|
+
|
|
38
|
+
// <- TODO: !!! ENOENT: no such file or directory, open 'C:\Users\me\work\ai\promptbook\agents\examples\Asistent pro LŠVP.book
|
|
39
|
+
const { isVerbose = DEFAULT_IS_VERBOSE } = this.options || {};
|
|
40
|
+
const tools = await this.getTools();
|
|
41
|
+
|
|
42
|
+
const agentSourceValue = validateBook(await tools.fs!.readFile(agentSourcePath, 'utf-8'));
|
|
43
|
+
const agentSource = new BehaviorSubject(agentSourceValue);
|
|
44
|
+
|
|
45
|
+
// Note: Write file whenever agent source changes
|
|
46
|
+
agentSource.subscribe(async (newSource) => {
|
|
47
|
+
if (isVerbose) {
|
|
48
|
+
console.info(colors.cyan(`Writing agent source to file ${agentSourcePath}`));
|
|
49
|
+
}
|
|
50
|
+
await forTime(500); // <- TODO: [🙌] !!! Remove
|
|
51
|
+
await tools.fs!.writeFile(agentSourcePath, newSource, 'utf-8');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Note: Watch file for external changes
|
|
55
|
+
for await (const event of tools.fs!.watch(agentSourcePath)) {
|
|
56
|
+
// <- TODO: !!!! Solve the memory freeing when the watching is no longer needed
|
|
57
|
+
|
|
58
|
+
if (event.eventType !== 'change') {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (isVerbose) {
|
|
63
|
+
console.info(
|
|
64
|
+
colors.cyan(`Detected external change in agent source file ${agentSourcePath}, reloading`),
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
await forTime(500); // <- TODO: [🙌] !!! Remove
|
|
68
|
+
const newSource = validateBook(await tools.fs!.readFile(agentSourcePath, 'utf-8'));
|
|
69
|
+
agentSource.next(newSource);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// TODO: [🙌] !!!! Debug the infinite loop when file is changed externally and agent source is updated which causes file to be written again
|
|
73
|
+
|
|
74
|
+
const agent = new Agent({
|
|
75
|
+
...this.options,
|
|
76
|
+
agentSource,
|
|
77
|
+
executionTools: this.tools || {},
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
if (isVerbose) {
|
|
81
|
+
console.info(colors.cyan(`Created agent "${agent.agentName}" from source file ${agentSourcePath}`));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return agent;
|
|
85
|
+
* /
|
|
86
|
+
}
|
|
87
|
+
*/
|
|
88
|
+
/**
|
|
89
|
+
* !!!@@@
|
|
90
|
+
*/
|
|
91
|
+
getAgentSource(agentName: string_agent_name): Promise<BehaviorSubject<string_book>>;
|
|
92
|
+
/**
|
|
93
|
+
* Creates a new agent in the collection
|
|
94
|
+
*
|
|
95
|
+
* Note: You can set 'PARENT' in the agent source to inherit from another agent in the collection.
|
|
96
|
+
*/
|
|
97
|
+
createAgent(agentSource: string_book): Promise<AgentBasicInformation>;
|
|
98
|
+
/**
|
|
99
|
+
* Deletes an agent from the collection
|
|
100
|
+
*/
|
|
101
|
+
deleteAgent(agentName: string_agent_name): Promise<void>;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* TODO: !!!! Implement it here correctly and update JSDoc comments here, and on interface + other implementations
|
|
105
|
+
* TODO: Write unit test
|
|
106
|
+
* TODO: [🧠][🚙] `AgentXxx` vs `AgentsXxx` naming convention
|
|
107
|
+
*/
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
export type Json = string | number | boolean | null | {
|
|
2
|
+
[key: string]: Json | undefined;
|
|
3
|
+
} | Json[];
|
|
4
|
+
export type AgentsDatabaseSchema = {
|
|
5
|
+
graphql_public: {
|
|
6
|
+
Tables: {
|
|
7
|
+
[_ in never]: never;
|
|
8
|
+
};
|
|
9
|
+
Views: {
|
|
10
|
+
[_ in never]: never;
|
|
11
|
+
};
|
|
12
|
+
Functions: {
|
|
13
|
+
graphql: {
|
|
14
|
+
Args: {
|
|
15
|
+
operationName?: string;
|
|
16
|
+
query?: string;
|
|
17
|
+
variables?: Json;
|
|
18
|
+
extensions?: Json;
|
|
19
|
+
};
|
|
20
|
+
Returns: Json;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
Enums: {
|
|
24
|
+
[_ in never]: never;
|
|
25
|
+
};
|
|
26
|
+
CompositeTypes: {
|
|
27
|
+
[_ in never]: never;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
public: {
|
|
31
|
+
Tables: {
|
|
32
|
+
AgentCollection: {
|
|
33
|
+
Row: {
|
|
34
|
+
id: number;
|
|
35
|
+
agentName: string;
|
|
36
|
+
agentProfile: Json;
|
|
37
|
+
createdAt: string;
|
|
38
|
+
updatedAt: string | null;
|
|
39
|
+
agentVersion: number;
|
|
40
|
+
promptbookEngineVersion: string;
|
|
41
|
+
usage: Json | null;
|
|
42
|
+
agentSource: string;
|
|
43
|
+
};
|
|
44
|
+
Insert: {
|
|
45
|
+
id?: number;
|
|
46
|
+
agentName: string;
|
|
47
|
+
createdAt: string;
|
|
48
|
+
updatedAt?: string | null;
|
|
49
|
+
agentVersion: number;
|
|
50
|
+
promptbookEngineVersion: string;
|
|
51
|
+
usage?: Json | null;
|
|
52
|
+
agentSource: string;
|
|
53
|
+
};
|
|
54
|
+
Update: {
|
|
55
|
+
id?: number;
|
|
56
|
+
agentName?: string;
|
|
57
|
+
createdAt?: string;
|
|
58
|
+
updatedAt?: string | null;
|
|
59
|
+
agentVersion?: number;
|
|
60
|
+
promptbookEngineVersion?: string;
|
|
61
|
+
usage?: Json | null;
|
|
62
|
+
agentSource?: string;
|
|
63
|
+
};
|
|
64
|
+
Relationships: [];
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
Views: {
|
|
68
|
+
[_ in never]: never;
|
|
69
|
+
};
|
|
70
|
+
Functions: {
|
|
71
|
+
[_ in never]: never;
|
|
72
|
+
};
|
|
73
|
+
Enums: {
|
|
74
|
+
[_ in never]: never;
|
|
75
|
+
};
|
|
76
|
+
CompositeTypes: {
|
|
77
|
+
[_ in never]: never;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
type PublicSchema = AgentsDatabaseSchema[Extract<keyof AgentsDatabaseSchema, 'public'>];
|
|
82
|
+
export type Tables<PublicTableNameOrOptions extends keyof (PublicSchema['Tables'] & PublicSchema['Views']) | {
|
|
83
|
+
schema: keyof AgentsDatabaseSchema;
|
|
84
|
+
}, TableName extends PublicTableNameOrOptions extends {
|
|
85
|
+
schema: keyof AgentsDatabaseSchema;
|
|
86
|
+
} ? keyof (AgentsDatabaseSchema[PublicTableNameOrOptions['schema']]['Tables'] & AgentsDatabaseSchema[PublicTableNameOrOptions['schema']]['Views']) : never = never> = PublicTableNameOrOptions extends {
|
|
87
|
+
schema: keyof AgentsDatabaseSchema;
|
|
88
|
+
} ? (AgentsDatabaseSchema[PublicTableNameOrOptions['schema']]['Tables'] & AgentsDatabaseSchema[PublicTableNameOrOptions['schema']]['Views'])[TableName] extends {
|
|
89
|
+
Row: infer R;
|
|
90
|
+
} ? R : never : PublicTableNameOrOptions extends keyof (PublicSchema['Tables'] & PublicSchema['Views']) ? (PublicSchema['Tables'] & PublicSchema['Views'])[PublicTableNameOrOptions] extends {
|
|
91
|
+
Row: infer R;
|
|
92
|
+
} ? R : never : never;
|
|
93
|
+
export type TablesInsert<PublicTableNameOrOptions extends keyof PublicSchema['Tables'] | {
|
|
94
|
+
schema: keyof AgentsDatabaseSchema;
|
|
95
|
+
}, TableName extends PublicTableNameOrOptions extends {
|
|
96
|
+
schema: keyof AgentsDatabaseSchema;
|
|
97
|
+
} ? keyof AgentsDatabaseSchema[PublicTableNameOrOptions['schema']]['Tables'] : never = never> = PublicTableNameOrOptions extends {
|
|
98
|
+
schema: keyof AgentsDatabaseSchema;
|
|
99
|
+
} ? AgentsDatabaseSchema[PublicTableNameOrOptions['schema']]['Tables'][TableName] extends {
|
|
100
|
+
Insert: infer I;
|
|
101
|
+
} ? I : never : PublicTableNameOrOptions extends keyof PublicSchema['Tables'] ? PublicSchema['Tables'][PublicTableNameOrOptions] extends {
|
|
102
|
+
Insert: infer I;
|
|
103
|
+
} ? I : never : never;
|
|
104
|
+
export type TablesUpdate<PublicTableNameOrOptions extends keyof PublicSchema['Tables'] | {
|
|
105
|
+
schema: keyof AgentsDatabaseSchema;
|
|
106
|
+
}, TableName extends PublicTableNameOrOptions extends {
|
|
107
|
+
schema: keyof AgentsDatabaseSchema;
|
|
108
|
+
} ? keyof AgentsDatabaseSchema[PublicTableNameOrOptions['schema']]['Tables'] : never = never> = PublicTableNameOrOptions extends {
|
|
109
|
+
schema: keyof AgentsDatabaseSchema;
|
|
110
|
+
} ? AgentsDatabaseSchema[PublicTableNameOrOptions['schema']]['Tables'][TableName] extends {
|
|
111
|
+
Update: infer U;
|
|
112
|
+
} ? U : never : PublicTableNameOrOptions extends keyof PublicSchema['Tables'] ? PublicSchema['Tables'][PublicTableNameOrOptions] extends {
|
|
113
|
+
Update: infer U;
|
|
114
|
+
} ? U : never : never;
|
|
115
|
+
export type Enums<PublicEnumNameOrOptions extends keyof PublicSchema['Enums'] | {
|
|
116
|
+
schema: keyof AgentsDatabaseSchema;
|
|
117
|
+
}, EnumName extends PublicEnumNameOrOptions extends {
|
|
118
|
+
schema: keyof AgentsDatabaseSchema;
|
|
119
|
+
} ? keyof AgentsDatabaseSchema[PublicEnumNameOrOptions['schema']]['Enums'] : never = never> = PublicEnumNameOrOptions extends {
|
|
120
|
+
schema: keyof AgentsDatabaseSchema;
|
|
121
|
+
} ? AgentsDatabaseSchema[PublicEnumNameOrOptions['schema']]['Enums'][EnumName] : PublicEnumNameOrOptions extends keyof PublicSchema['Enums'] ? PublicSchema['Enums'][PublicEnumNameOrOptions] : never;
|
|
122
|
+
export type CompositeTypes<PublicCompositeTypeNameOrOptions extends keyof PublicSchema['CompositeTypes'] | {
|
|
123
|
+
schema: keyof AgentsDatabaseSchema;
|
|
124
|
+
}, CompositeTypeName extends PublicCompositeTypeNameOrOptions extends {
|
|
125
|
+
schema: keyof AgentsDatabaseSchema;
|
|
126
|
+
} ? keyof AgentsDatabaseSchema[PublicCompositeTypeNameOrOptions['schema']]['CompositeTypes'] : never = never> = PublicCompositeTypeNameOrOptions extends {
|
|
127
|
+
schema: keyof AgentsDatabaseSchema;
|
|
128
|
+
} ? AgentsDatabaseSchema[PublicCompositeTypeNameOrOptions['schema']]['CompositeTypes'][CompositeTypeName] : PublicCompositeTypeNameOrOptions extends keyof PublicSchema['CompositeTypes'] ? PublicSchema['CompositeTypes'][PublicCompositeTypeNameOrOptions] : never;
|
|
129
|
+
export {};
|
|
@@ -3,7 +3,7 @@ import type { PipelineJson } from '../../../pipeline/PipelineJson/PipelineJson';
|
|
|
3
3
|
import type { TaskJson } from '../../../pipeline/PipelineJson/TaskJson';
|
|
4
4
|
import type { string_markdown_text, string_name, string_promptbook_documentation_url } from '../../../types/typeAliases';
|
|
5
5
|
import type { string_SCREAMING_CASE } from '../../../utils/normalization/normalizeTo_SCREAMING_CASE';
|
|
6
|
-
import { $side_effect } from '../../../utils/organization/$side_effect';
|
|
6
|
+
import type { $side_effect } from '../../../utils/organization/$side_effect';
|
|
7
7
|
import type { ___and___ } from '../../../utils/organization/___and___';
|
|
8
8
|
import type { CommandUsagePlace } from './CommandUsagePlaces';
|
|
9
9
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Color } from './_packages/color.index';
|
|
2
1
|
import type { CsvSettings } from './formats/csv/CsvSettings';
|
|
3
2
|
import type { IntermediateFilesStrategy } from './types/IntermediateFilesStrategy';
|
|
4
3
|
import type { string_app_id, string_email, string_name, string_promptbook_server_url } from './types/typeAliases';
|
|
4
|
+
import { Color } from './utils/color/Color';
|
|
5
5
|
/**
|
|
6
6
|
* Warning message for the generated sections and files files
|
|
7
7
|
*
|
|
@@ -2,6 +2,7 @@ import { CsvFormatError } from '../formats/csv/CsvFormatError';
|
|
|
2
2
|
import { AbstractFormatError } from './AbstractFormatError';
|
|
3
3
|
import { AuthenticationError } from './AuthenticationError';
|
|
4
4
|
import { CollectionError } from './CollectionError';
|
|
5
|
+
import { DatabaseError } from './DatabaseError';
|
|
5
6
|
import { EnvironmentMismatchError } from './EnvironmentMismatchError';
|
|
6
7
|
import { ExpectError } from './ExpectError';
|
|
7
8
|
import { KnowledgeScrapeError } from './KnowledgeScrapeError';
|
|
@@ -42,6 +43,7 @@ export declare const PROMPTBOOK_ERRORS: {
|
|
|
42
43
|
readonly UnexpectedError: typeof UnexpectedError;
|
|
43
44
|
readonly WrappedError: typeof WrappedError;
|
|
44
45
|
readonly NotAllowed: typeof NotAllowed;
|
|
46
|
+
readonly DatabaseError: typeof DatabaseError;
|
|
45
47
|
};
|
|
46
48
|
/**
|
|
47
49
|
* Index of all javascript errors
|
|
@@ -91,6 +93,7 @@ export declare const ALL_ERRORS: {
|
|
|
91
93
|
readonly UnexpectedError: typeof UnexpectedError;
|
|
92
94
|
readonly WrappedError: typeof WrappedError;
|
|
93
95
|
readonly NotAllowed: typeof NotAllowed;
|
|
96
|
+
readonly DatabaseError: typeof DatabaseError;
|
|
94
97
|
};
|
|
95
98
|
/**
|
|
96
99
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This error indicates error from the database
|
|
3
|
+
*
|
|
4
|
+
* @public exported from `@promptbook/core`
|
|
5
|
+
*/
|
|
6
|
+
export declare class DatabaseError extends Error {
|
|
7
|
+
readonly name = "DatabaseError";
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* TODO: !!!! Explain that NotFoundError (!!! and other specific errors) has priority over DatabaseError in some contexts
|
|
12
|
+
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { PartialDeep, Promisable, ReadonlyDeep, WritableDeep } from 'type-fest';
|
|
2
2
|
import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
|
|
3
3
|
import type { TaskJson } from '../../pipeline/PipelineJson/TaskJson';
|
|
4
|
+
import type { LlmCall } from '../../types/LlmCall';
|
|
4
5
|
import type { Parameters, string_parameter_name } from '../../types/typeAliases';
|
|
5
6
|
import type { TODO_string } from '../../utils/organization/TODO_string';
|
|
6
|
-
import type { LlmCall } from '../../types/LlmCall';
|
|
7
7
|
import type { ExecutionReportJson } from '../execution-report/ExecutionReportJson';
|
|
8
8
|
import type { PipelineExecutorResult } from '../PipelineExecutorResult';
|
|
9
9
|
import type { CreatePipelineExecutorOptions } from './00-CreatePipelineExecutorOptions';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { string_filename, string_markdown } from '../../../types/typeAliases';
|
|
2
|
-
import { $side_effect } from '../../../utils/organization/$side_effect';
|
|
2
|
+
import type { $side_effect } from '../../../utils/organization/$side_effect';
|
|
3
3
|
/**
|
|
4
4
|
* Pass the `.env` file which was used to configure LLM tools
|
|
5
5
|
*
|
|
@@ -26,7 +26,7 @@ export type LlmToolsMetadata = Registered & {
|
|
|
26
26
|
/**
|
|
27
27
|
* How is the model provider important and should be sorted in the list of available providers?
|
|
28
28
|
*/
|
|
29
|
-
readonly order: typeof MODEL_ORDERS[keyof typeof MODEL_ORDERS] | number;
|
|
29
|
+
readonly order: (typeof MODEL_ORDERS)[keyof typeof MODEL_ORDERS] | number;
|
|
30
30
|
/**
|
|
31
31
|
* List of environment variables that can be used to configure the provider
|
|
32
32
|
*
|
|
@@ -7,5 +7,6 @@ import { MultipleLlmExecutionTools } from './MultipleLlmExecutionTools';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function getSingleLlmExecutionTools(oneOrMoreLlmExecutionTools: undefined | LlmExecutionTools | ReadonlyArray<LlmExecutionTools>): LlmExecutionTools | MultipleLlmExecutionTools;
|
|
9
9
|
/**
|
|
10
|
+
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
10
11
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
11
12
|
*/
|
|
@@ -18,5 +18,6 @@ import { MultipleLlmExecutionTools } from './MultipleLlmExecutionTools';
|
|
|
18
18
|
*/
|
|
19
19
|
export declare function joinLlmExecutionTools(title: string_title & string_markdown_text, ...llmExecutionTools: ReadonlyArray<LlmExecutionTools>): MultipleLlmExecutionTools;
|
|
20
20
|
/**
|
|
21
|
+
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
21
22
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
22
23
|
*/
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { BehaviorSubject } from 'rxjs';
|
|
2
|
-
import { AgentBasicInformation, BookParameter
|
|
3
|
-
import {
|
|
2
|
+
import type { AgentBasicInformation, BookParameter } from '../../book-2.0/agent-source/AgentBasicInformation';
|
|
3
|
+
import type { string_book } from '../../book-2.0/agent-source/string_book';
|
|
4
|
+
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
5
|
+
import type { string_agent_name, string_url_image } from '../../types/typeAliases';
|
|
6
|
+
import type { AgentOptions } from './AgentOptions';
|
|
4
7
|
/**
|
|
5
8
|
* Represents one AI Agent
|
|
6
9
|
*
|