@promptbook/utils 0.104.0-1 → 0.104.0-3
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 +25 -21
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +8 -2
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +6 -1
- package/esm/typings/src/book-components/Chat/Chat/ChatMessageItem.d.ts +5 -1
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/CodeBlock/CodeBlock.d.ts +13 -0
- package/esm/typings/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +1 -0
- package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +7 -11
- package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +2 -2
- package/esm/typings/src/book-components/_common/MenuHoisting/MenuHoistingContext.d.ts +56 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +13 -7
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +6 -0
- package/esm/typings/src/commitments/DICTIONARY/DICTIONARY.d.ts +46 -0
- package/esm/typings/src/commitments/index.d.ts +2 -1
- package/esm/typings/src/llm-providers/ollama/OllamaExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/createOpenAiCompatibleExecutionTools.d.ts +1 -1
- package/esm/typings/src/types/Message.d.ts +49 -0
- package/esm/typings/src/types/typeAliases.d.ts +12 -0
- package/esm/typings/src/utils/environment/$detectRuntimeEnvironment.d.ts +4 -4
- package/esm/typings/src/utils/environment/$isRunningInBrowser.d.ts +1 -1
- package/esm/typings/src/utils/environment/$isRunningInJest.d.ts +1 -1
- package/esm/typings/src/utils/environment/$isRunningInNode.d.ts +1 -1
- package/esm/typings/src/utils/environment/$isRunningInWebWorker.d.ts +1 -1
- package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +2 -2
- package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +2 -2
- package/esm/typings/src/utils/random/$randomBase58.d.ts +12 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +31 -27
- package/umd/index.umd.js.map +1 -1
|
@@ -29,11 +29,15 @@ type ChatMessageItemProps = Pick<ChatProps, 'onMessage' | 'participants'> & {
|
|
|
29
29
|
* Called when the copy button is pressed.
|
|
30
30
|
*/
|
|
31
31
|
onCopy?: () => void;
|
|
32
|
+
/**
|
|
33
|
+
* Called when the create agent button is pressed for book code blocks.
|
|
34
|
+
*/
|
|
35
|
+
onCreateAgent?: (bookContent: string) => void;
|
|
32
36
|
};
|
|
33
37
|
/**
|
|
34
38
|
* Renders a single chat message item with avatar, content, buttons, and rating.
|
|
35
39
|
*
|
|
36
40
|
* @private internal subcomponent of `<Chat>` component
|
|
37
41
|
*/
|
|
38
|
-
export declare const ChatMessageItem: import("react").MemoExoticComponent<({ message, participant, participants, isLastMessage, onMessage, setExpandedMessageId, isExpanded, currentRating, handleRating, mode, isCopyButtonEnabled, isFeedbackEnabled, onCopy, }: ChatMessageItemProps) => import("react/jsx-runtime").JSX.Element>;
|
|
42
|
+
export declare const ChatMessageItem: import("react").MemoExoticComponent<({ message, participant, participants, isLastMessage, onMessage, setExpandedMessageId, isExpanded, currentRating, handleRating, mode, isCopyButtonEnabled, isFeedbackEnabled, onCopy, onCreateAgent, }: ChatMessageItemProps) => import("react/jsx-runtime").JSX.Element>;
|
|
39
43
|
export {};
|
|
@@ -187,6 +187,11 @@ export type ChatProps = {
|
|
|
187
187
|
* @default true
|
|
188
188
|
*/
|
|
189
189
|
isCopyButtonEnabled?: boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Optional callback for creating an agent from a book code block.
|
|
192
|
+
* When provided, "Create Agent" buttons will be shown for book code blocks.
|
|
193
|
+
*/
|
|
194
|
+
onCreateAgent?: (bookContent: string) => void;
|
|
190
195
|
};
|
|
191
196
|
/**
|
|
192
197
|
* TODO: [☁️] Export component prop types only to `@promptbook/components` (not `@promptbook/types`)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type CodeBlockProps = {
|
|
2
|
+
code: string;
|
|
3
|
+
language?: string;
|
|
4
|
+
className?: string;
|
|
5
|
+
onCreateAgent?: (bookContent: string) => void;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Component to render a code block with syntax highlighting, copy, download, and create agent options.
|
|
9
|
+
*
|
|
10
|
+
* @private Internal utility of `<ChatMessage />` component
|
|
11
|
+
*/
|
|
12
|
+
export declare function CodeBlock({ code, language, className, onCreateAgent }: CodeBlockProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -2,6 +2,7 @@ import type { string_markdown } from '../../../types/typeAliases';
|
|
|
2
2
|
type MarkdownContentProps = {
|
|
3
3
|
content: string_markdown;
|
|
4
4
|
className?: string;
|
|
5
|
+
onCreateAgent?: (bookContent: string) => void;
|
|
5
6
|
};
|
|
6
7
|
/**
|
|
7
8
|
* Renders markdown content with support for code highlighting, math, and tables.
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
+
import { Message } from '../../../types/Message';
|
|
1
2
|
import type { id, string_markdown } from '../../../types/typeAliases';
|
|
2
3
|
/**
|
|
3
4
|
* A message in the chat
|
|
4
5
|
*
|
|
5
6
|
* @public exported from `@promptbook/components`
|
|
6
7
|
*/
|
|
7
|
-
export type ChatMessage = {
|
|
8
|
+
export type ChatMessage = Omit<Message<id>, 'direction' | 'recipients' | 'threadId' | 'metadata'> & {
|
|
8
9
|
/**
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Date when the message was created
|
|
14
|
-
*/
|
|
15
|
-
date?: Date;
|
|
16
|
-
/**
|
|
17
|
-
* The name of the participant who sent the message
|
|
10
|
+
* Force the channel to be 'PROMPTBOOK_CHAT'
|
|
11
|
+
*
|
|
12
|
+
* @default 'PROMPTBOOK_CHAT'
|
|
18
13
|
*/
|
|
19
|
-
|
|
14
|
+
channel?: 'PROMPTBOOK_CHAT';
|
|
20
15
|
/**
|
|
21
16
|
* The content of the message with optional markdown formatting
|
|
22
17
|
*/
|
|
@@ -37,6 +32,7 @@ export type ChatMessage = {
|
|
|
37
32
|
isVoiceCall?: boolean;
|
|
38
33
|
};
|
|
39
34
|
/**
|
|
35
|
+
* TODO: Make all fields readonly
|
|
40
36
|
* TODO: Delete `expectedAnswer` from ChatMessage
|
|
41
37
|
* TODO: Rename `date` into `created`+`modified`
|
|
42
38
|
*/
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Item that can be hoisted to the top menu
|
|
4
|
+
*
|
|
5
|
+
* @private mechanism inside Promptbook
|
|
6
|
+
*/
|
|
7
|
+
export type HoistedMenuItem = {
|
|
8
|
+
/**
|
|
9
|
+
* Unique key for the menu item
|
|
10
|
+
*/
|
|
11
|
+
key?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Icon to display
|
|
14
|
+
*/
|
|
15
|
+
icon: ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* Name/Tooltip of the item
|
|
18
|
+
*/
|
|
19
|
+
name: string;
|
|
20
|
+
/**
|
|
21
|
+
* Action to perform when clicked
|
|
22
|
+
*/
|
|
23
|
+
onClick: () => void;
|
|
24
|
+
/**
|
|
25
|
+
* If true, the item is active/toggled
|
|
26
|
+
*/
|
|
27
|
+
isActive?: boolean;
|
|
28
|
+
};
|
|
29
|
+
type MenuHoistingContextType = {
|
|
30
|
+
/**
|
|
31
|
+
* The currently hoisted menu items
|
|
32
|
+
*/
|
|
33
|
+
menu: HoistedMenuItem[];
|
|
34
|
+
/**
|
|
35
|
+
* Set the hoisted menu items
|
|
36
|
+
*/
|
|
37
|
+
setMenu: (items: HoistedMenuItem[]) => void;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Provider for menu hoisting
|
|
41
|
+
*
|
|
42
|
+
* @private mechanism inside Promptbook
|
|
43
|
+
*/
|
|
44
|
+
export declare function MenuHoistingProvider({ children }: {
|
|
45
|
+
children: ReactNode;
|
|
46
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
47
|
+
/**
|
|
48
|
+
* Hook to use the menu hoisting system
|
|
49
|
+
*
|
|
50
|
+
* @private mechanism inside Promptbook
|
|
51
|
+
*/
|
|
52
|
+
export declare function useMenuHoisting(): MenuHoistingContextType | null;
|
|
53
|
+
export {};
|
|
54
|
+
/**
|
|
55
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
56
|
+
*/
|
|
@@ -34,15 +34,15 @@ export declare class AgentCollectionInSupabase {
|
|
|
34
34
|
*
|
|
35
35
|
* Note: You can set 'PARENT' in the agent source to inherit from another agent in the collection.
|
|
36
36
|
*/
|
|
37
|
-
createAgent(agentSource: string_book): Promise<AgentBasicInformation
|
|
37
|
+
createAgent(agentSource: string_book): Promise<AgentBasicInformation & Required<Pick<AgentBasicInformation, 'permanentId'>>>;
|
|
38
38
|
/**
|
|
39
39
|
* Updates an existing agent in the collection
|
|
40
40
|
*/
|
|
41
41
|
updateAgentSource(agentName: string_agent_name, agentSource: string_book): Promise<void>;
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
43
|
+
* List agents that are soft deleted (deletedAt IS NOT NULL)
|
|
44
44
|
*/
|
|
45
|
-
|
|
45
|
+
listDeletedAgents(): Promise<ReadonlyArray<AgentBasicInformation>>;
|
|
46
46
|
/**
|
|
47
47
|
* List history of an agent
|
|
48
48
|
*/
|
|
@@ -53,13 +53,19 @@ export declare class AgentCollectionInSupabase {
|
|
|
53
53
|
promptbookEngineVersion: string;
|
|
54
54
|
}>>;
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
56
|
+
* Restore a soft-deleted agent by setting deletedAt to NULL
|
|
57
57
|
*/
|
|
58
|
-
|
|
58
|
+
restoreAgent(agentIdentifier: string): Promise<void>;
|
|
59
59
|
/**
|
|
60
|
-
* Restore an agent from history
|
|
60
|
+
* Restore an agent from a specific history entry
|
|
61
|
+
*
|
|
62
|
+
* This will update the current agent with the source from the history entry
|
|
63
|
+
*/
|
|
64
|
+
restoreAgentFromHistory(historyId: number): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Soft delete an agent by setting deletedAt to current timestamp
|
|
61
67
|
*/
|
|
62
|
-
|
|
68
|
+
deleteAgent(agentIdentifier: string): Promise<void>;
|
|
63
69
|
/**
|
|
64
70
|
* Get the Supabase table name with prefix
|
|
65
71
|
*
|
|
@@ -22,6 +22,7 @@ export type AgentsDatabaseSchema = {
|
|
|
22
22
|
agentName: string;
|
|
23
23
|
createdAt: string;
|
|
24
24
|
updatedAt: string | null;
|
|
25
|
+
permanentId: string | null;
|
|
25
26
|
agentHash: string;
|
|
26
27
|
agentSource: string;
|
|
27
28
|
agentProfile: Json;
|
|
@@ -29,12 +30,14 @@ export type AgentsDatabaseSchema = {
|
|
|
29
30
|
usage: Json | null;
|
|
30
31
|
preparedModelRequirements: Json | null;
|
|
31
32
|
preparedExternals: Json | null;
|
|
33
|
+
deletedAt: string | null;
|
|
32
34
|
};
|
|
33
35
|
Insert: {
|
|
34
36
|
id?: number;
|
|
35
37
|
agentName: string;
|
|
36
38
|
createdAt: string;
|
|
37
39
|
updatedAt?: string | null;
|
|
40
|
+
permanentId?: string | null;
|
|
38
41
|
agentHash: string;
|
|
39
42
|
agentSource: string;
|
|
40
43
|
agentProfile: Json;
|
|
@@ -42,12 +45,14 @@ export type AgentsDatabaseSchema = {
|
|
|
42
45
|
usage?: Json | null;
|
|
43
46
|
preparedModelRequirements?: Json | null;
|
|
44
47
|
preparedExternals?: Json | null;
|
|
48
|
+
deletedAt?: string | null;
|
|
45
49
|
};
|
|
46
50
|
Update: {
|
|
47
51
|
id?: number;
|
|
48
52
|
agentName?: string;
|
|
49
53
|
createdAt?: string;
|
|
50
54
|
updatedAt?: string | null;
|
|
55
|
+
permanentId?: string | null;
|
|
51
56
|
agentHash?: string;
|
|
52
57
|
agentSource?: string;
|
|
53
58
|
agentProfile?: Json;
|
|
@@ -55,6 +60,7 @@ export type AgentsDatabaseSchema = {
|
|
|
55
60
|
usage?: Json | null;
|
|
56
61
|
preparedModelRequirements?: Json | null;
|
|
57
62
|
preparedExternals?: Json | null;
|
|
63
|
+
deletedAt?: string | null;
|
|
58
64
|
};
|
|
59
65
|
Relationships: [];
|
|
60
66
|
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { AgentModelRequirements } from '../../book-2.0/agent-source/AgentModelRequirements';
|
|
2
|
+
import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
|
|
3
|
+
/**
|
|
4
|
+
* DICTIONARY commitment definition
|
|
5
|
+
*
|
|
6
|
+
* The DICTIONARY commitment defines specific terms and their meanings that the agent should use correctly
|
|
7
|
+
* in its reasoning and responses. This ensures consistent terminology usage.
|
|
8
|
+
*
|
|
9
|
+
* Key features:
|
|
10
|
+
* - Multiple DICTIONARY commitments are automatically merged into one
|
|
11
|
+
* - Content is placed in a dedicated section of the system message
|
|
12
|
+
* - Terms and definitions are stored in metadata.DICTIONARY for debugging
|
|
13
|
+
* - Agent should use the defined terms correctly in responses
|
|
14
|
+
*
|
|
15
|
+
* Example usage in agent source:
|
|
16
|
+
*
|
|
17
|
+
* ```book
|
|
18
|
+
* Legal Assistant
|
|
19
|
+
*
|
|
20
|
+
* PERSONA You are a knowledgeable legal assistant
|
|
21
|
+
* DICTIONARY Misdemeanor is a minor wrongdoing or criminal offense
|
|
22
|
+
* DICTIONARY Felony is a serious crime usually punishable by imprisonment for more than one year
|
|
23
|
+
* DICTIONARY Tort is a civil wrong that causes harm or loss to another person, leading to legal liability
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
27
|
+
*/
|
|
28
|
+
export declare class DictionaryCommitmentDefinition extends BaseCommitmentDefinition<'DICTIONARY'> {
|
|
29
|
+
constructor();
|
|
30
|
+
/**
|
|
31
|
+
* Short one-line description of DICTIONARY.
|
|
32
|
+
*/
|
|
33
|
+
get description(): string;
|
|
34
|
+
/**
|
|
35
|
+
* Icon for this commitment.
|
|
36
|
+
*/
|
|
37
|
+
get icon(): string;
|
|
38
|
+
/**
|
|
39
|
+
* Markdown documentation for DICTIONARY commitment.
|
|
40
|
+
*/
|
|
41
|
+
get documentation(): string;
|
|
42
|
+
applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
46
|
+
*/
|
|
@@ -4,6 +4,7 @@ import { ActionCommitmentDefinition } from './ACTION/ACTION';
|
|
|
4
4
|
import { ClosedCommitmentDefinition } from './CLOSED/CLOSED';
|
|
5
5
|
import { ComponentCommitmentDefinition } from './COMPONENT/COMPONENT';
|
|
6
6
|
import { DeleteCommitmentDefinition } from './DELETE/DELETE';
|
|
7
|
+
import { DictionaryCommitmentDefinition } from './DICTIONARY/DICTIONARY';
|
|
7
8
|
import { FormatCommitmentDefinition } from './FORMAT/FORMAT';
|
|
8
9
|
import { FromCommitmentDefinition } from './FROM/FROM';
|
|
9
10
|
import { GoalCommitmentDefinition } from './GOAL/GOAL';
|
|
@@ -39,7 +40,7 @@ import { NotYetImplementedCommitmentDefinition } from './_base/NotYetImplemented
|
|
|
39
40
|
*
|
|
40
41
|
* @private Use functions to access commitments instead of this array directly
|
|
41
42
|
*/
|
|
42
|
-
export declare const COMMITMENT_REGISTRY: readonly [PersonaCommitmentDefinition, PersonaCommitmentDefinition, KnowledgeCommitmentDefinition, MemoryCommitmentDefinition, MemoryCommitmentDefinition, StyleCommitmentDefinition, StyleCommitmentDefinition, RuleCommitmentDefinition, RuleCommitmentDefinition, LanguageCommitmentDefinition, LanguageCommitmentDefinition, SampleCommitmentDefinition, SampleCommitmentDefinition, FormatCommitmentDefinition, FormatCommitmentDefinition, FromCommitmentDefinition, ModelCommitmentDefinition, ModelCommitmentDefinition, ActionCommitmentDefinition, ActionCommitmentDefinition, ComponentCommitmentDefinition, MetaImageCommitmentDefinition, MetaColorCommitmentDefinition, MetaFontCommitmentDefinition, MetaLinkCommitmentDefinition, MetaCommitmentDefinition, NoteCommitmentDefinition, NoteCommitmentDefinition, NoteCommitmentDefinition, NoteCommitmentDefinition, GoalCommitmentDefinition, GoalCommitmentDefinition, InitialMessageCommitmentDefinition, UserMessageCommitmentDefinition, AgentMessageCommitmentDefinition, MessageCommitmentDefinition, MessageCommitmentDefinition, ScenarioCommitmentDefinition, ScenarioCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, OpenCommitmentDefinition, ClosedCommitmentDefinition, UseBrowserCommitmentDefinition, UseSearchEngineCommitmentDefinition, UseMcpCommitmentDefinition, UseCommitmentDefinition, NotYetImplementedCommitmentDefinition<"EXPECT">, NotYetImplementedCommitmentDefinition<"BEHAVIOUR">, NotYetImplementedCommitmentDefinition<"BEHAVIOURS">, NotYetImplementedCommitmentDefinition<"AVOID">, NotYetImplementedCommitmentDefinition<"AVOIDANCE">, NotYetImplementedCommitmentDefinition<"CONTEXT">];
|
|
43
|
+
export declare const COMMITMENT_REGISTRY: readonly [PersonaCommitmentDefinition, PersonaCommitmentDefinition, KnowledgeCommitmentDefinition, MemoryCommitmentDefinition, MemoryCommitmentDefinition, StyleCommitmentDefinition, StyleCommitmentDefinition, RuleCommitmentDefinition, RuleCommitmentDefinition, LanguageCommitmentDefinition, LanguageCommitmentDefinition, SampleCommitmentDefinition, SampleCommitmentDefinition, FormatCommitmentDefinition, FormatCommitmentDefinition, FromCommitmentDefinition, ModelCommitmentDefinition, ModelCommitmentDefinition, ActionCommitmentDefinition, ActionCommitmentDefinition, ComponentCommitmentDefinition, MetaImageCommitmentDefinition, MetaColorCommitmentDefinition, MetaFontCommitmentDefinition, MetaLinkCommitmentDefinition, MetaCommitmentDefinition, NoteCommitmentDefinition, NoteCommitmentDefinition, NoteCommitmentDefinition, NoteCommitmentDefinition, GoalCommitmentDefinition, GoalCommitmentDefinition, InitialMessageCommitmentDefinition, UserMessageCommitmentDefinition, AgentMessageCommitmentDefinition, MessageCommitmentDefinition, MessageCommitmentDefinition, ScenarioCommitmentDefinition, ScenarioCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, DictionaryCommitmentDefinition, OpenCommitmentDefinition, ClosedCommitmentDefinition, UseBrowserCommitmentDefinition, UseSearchEngineCommitmentDefinition, UseMcpCommitmentDefinition, UseCommitmentDefinition, NotYetImplementedCommitmentDefinition<"EXPECT">, NotYetImplementedCommitmentDefinition<"BEHAVIOUR">, NotYetImplementedCommitmentDefinition<"BEHAVIOURS">, NotYetImplementedCommitmentDefinition<"AVOID">, NotYetImplementedCommitmentDefinition<"AVOIDANCE">, NotYetImplementedCommitmentDefinition<"CONTEXT">];
|
|
43
44
|
/**
|
|
44
45
|
* Gets a commitment definition by its type
|
|
45
46
|
* @param type The commitment type to look up
|
|
@@ -39,7 +39,7 @@ export declare class OllamaExecutionTools extends OpenAiCompatibleExecutionTools
|
|
|
39
39
|
*/
|
|
40
40
|
protected getDefaultEmbeddingModel(): AvailableModel;
|
|
41
41
|
/**
|
|
42
|
-
* Default model for
|
|
42
|
+
* Default model for completion variant.
|
|
43
43
|
*/
|
|
44
44
|
protected getDefaultImageGenerationModel(): AvailableModel;
|
|
45
45
|
}
|
|
@@ -64,7 +64,7 @@ export declare class HardcodedOpenAiCompatibleExecutionTools extends OpenAiCompa
|
|
|
64
64
|
*/
|
|
65
65
|
protected getDefaultEmbeddingModel(): AvailableModel;
|
|
66
66
|
/**
|
|
67
|
-
* Default model for
|
|
67
|
+
* Default model for completion variant.
|
|
68
68
|
*/
|
|
69
69
|
protected getDefaultImageGenerationModel(): AvailableModel;
|
|
70
70
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Arrayable } from 'type-fest';
|
|
2
|
+
import { really_any } from '../_packages/types.index';
|
|
3
|
+
import { id, string_date_iso8601, string_markdown } from './typeAliases';
|
|
4
|
+
/**
|
|
5
|
+
* A generic message structure for various communication channels
|
|
6
|
+
*/
|
|
7
|
+
export type Message<TParticipant> = {
|
|
8
|
+
/**
|
|
9
|
+
* Unique identifier of the message
|
|
10
|
+
*/
|
|
11
|
+
readonly id?: id;
|
|
12
|
+
/**
|
|
13
|
+
* Date when the message was created
|
|
14
|
+
*/
|
|
15
|
+
readonly createdAt?: Date | string_date_iso8601;
|
|
16
|
+
/**
|
|
17
|
+
* The communication channel of the message
|
|
18
|
+
*/
|
|
19
|
+
readonly channel?: 'PROMPTBOOK_CHAT' | 'EMAIL' | 'SMS' | 'WHATSAPP' | 'TELEGRAM' | 'SIGNAL' | string | 'UNKNOWN';
|
|
20
|
+
/**
|
|
21
|
+
* Is the message send from the Promptbook or to the Promptbook
|
|
22
|
+
*/
|
|
23
|
+
readonly direction?: 'INBOUND' | 'OUTBOUND' | 'INTERNAL' | 'INITIAL';
|
|
24
|
+
/**
|
|
25
|
+
* Who sent the message
|
|
26
|
+
*/
|
|
27
|
+
readonly sender: TParticipant;
|
|
28
|
+
/**
|
|
29
|
+
* Who are the recipients of the message
|
|
30
|
+
*/
|
|
31
|
+
readonly recipients?: Readonly<Arrayable<TParticipant>>;
|
|
32
|
+
/**
|
|
33
|
+
* The content of the message as markdown
|
|
34
|
+
*
|
|
35
|
+
* Note: We are converting all message content to markdown for consistency
|
|
36
|
+
*/
|
|
37
|
+
readonly content: string_markdown;
|
|
38
|
+
/**
|
|
39
|
+
* The thread identifier the message belongs to
|
|
40
|
+
*
|
|
41
|
+
* - `null` means the message is not part of any thread
|
|
42
|
+
* - `undefined` means that we don't know if the message is part of a thread or not
|
|
43
|
+
*/
|
|
44
|
+
readonly threadId?: id | null;
|
|
45
|
+
/**
|
|
46
|
+
* Arbitrary metadata associated with the message
|
|
47
|
+
*/
|
|
48
|
+
readonly metadata?: Readonly<Record<string, really_any>>;
|
|
49
|
+
};
|
|
@@ -154,6 +154,12 @@ export type string_agent_name_in_book = string;
|
|
|
154
154
|
* For example `"b126926439c5fcb83609888a11283723c1ef137c0ad599a77a1be81812bd221d"`
|
|
155
155
|
*/
|
|
156
156
|
export type string_agent_hash = string_sha256;
|
|
157
|
+
/**
|
|
158
|
+
* Semantic helper
|
|
159
|
+
*
|
|
160
|
+
* For example `"3mJr7AoUXx2Wqd"`
|
|
161
|
+
*/
|
|
162
|
+
export type string_agent_permanent_id = string_base_58;
|
|
157
163
|
/**
|
|
158
164
|
* Unstructured description of the persona
|
|
159
165
|
*
|
|
@@ -499,6 +505,12 @@ export type string_user_id = id | string_email;
|
|
|
499
505
|
* For example `"b126926439c5fcb83609888a11283723c1ef137c0ad599a77a1be81812bd221d"`
|
|
500
506
|
*/
|
|
501
507
|
export type string_sha256 = string;
|
|
508
|
+
/**
|
|
509
|
+
* Semantic helper
|
|
510
|
+
*
|
|
511
|
+
* For example `"4JmF3b2J5dGVz"`
|
|
512
|
+
*/
|
|
513
|
+
export type string_base_58 = string;
|
|
502
514
|
/**
|
|
503
515
|
* Semantic helper
|
|
504
516
|
*
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
* @public exported from `@promptbook/utils`
|
|
7
7
|
*/
|
|
8
8
|
export declare function $detectRuntimeEnvironment(): {
|
|
9
|
-
isRunningInBrowser:
|
|
10
|
-
isRunningInJest:
|
|
11
|
-
isRunningInNode:
|
|
12
|
-
isRunningInWebWorker:
|
|
9
|
+
isRunningInBrowser: boolean;
|
|
10
|
+
isRunningInJest: boolean;
|
|
11
|
+
isRunningInNode: boolean;
|
|
12
|
+
isRunningInWebWorker: boolean;
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
15
|
* TODO: [🎺] Also detect and report node version here
|
|
@@ -2,7 +2,7 @@ import type { string_markdown } from '../../types/typeAliases';
|
|
|
2
2
|
/**
|
|
3
3
|
* Single code block inside markdown.
|
|
4
4
|
*/
|
|
5
|
-
export type
|
|
5
|
+
export type MarkdownCodeBlock = {
|
|
6
6
|
/**
|
|
7
7
|
* Which notation was used to open the code block
|
|
8
8
|
*/
|
|
@@ -30,7 +30,7 @@ export type CodeBlock = {
|
|
|
30
30
|
* @throws {ParseError} if block is not closed properly
|
|
31
31
|
* @public exported from `@promptbook/markdown-utils`
|
|
32
32
|
*/
|
|
33
|
-
export declare function extractAllBlocksFromMarkdown(markdown: string_markdown): ReadonlyArray<
|
|
33
|
+
export declare function extractAllBlocksFromMarkdown(markdown: string_markdown): ReadonlyArray<MarkdownCodeBlock>;
|
|
34
34
|
/**
|
|
35
35
|
* TODO: Maybe name for `blockNotation` instead of '```' and '>'
|
|
36
36
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { string_markdown } from '../../types/typeAliases';
|
|
2
|
-
import type {
|
|
2
|
+
import type { MarkdownCodeBlock } from './extractAllBlocksFromMarkdown';
|
|
3
3
|
/**
|
|
4
4
|
* Extracts exactly ONE code block from markdown.
|
|
5
5
|
*
|
|
@@ -16,7 +16,7 @@ import type { CodeBlock } from './extractAllBlocksFromMarkdown';
|
|
|
16
16
|
* @public exported from `@promptbook/markdown-utils`
|
|
17
17
|
* @throws {ParseError} if there is not exactly one code block in the markdown
|
|
18
18
|
*/
|
|
19
|
-
export declare function extractOneBlockFromMarkdown(markdown: string_markdown):
|
|
19
|
+
export declare function extractOneBlockFromMarkdown(markdown: string_markdown): MarkdownCodeBlock;
|
|
20
20
|
/***
|
|
21
21
|
* TODO: [🍓][🌻] Decide of this is internal utility, external util OR validator/postprocessor
|
|
22
22
|
*/
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates random base58 string
|
|
3
|
+
*
|
|
4
|
+
* Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
|
|
5
|
+
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
6
|
+
*
|
|
7
|
+
* @param length - length of the string
|
|
8
|
+
* @returns secure random base58 string
|
|
9
|
+
*
|
|
10
|
+
* @private internal helper function
|
|
11
|
+
*/
|
|
12
|
+
export declare function $randomBase58(length: number): string;
|
|
@@ -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.104.0-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.104.0-2`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
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.104.0-
|
|
26
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.104.0-3';
|
|
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
|
|
@@ -2790,13 +2790,14 @@
|
|
|
2790
2790
|
*
|
|
2791
2791
|
* @public exported from `@promptbook/utils`
|
|
2792
2792
|
*/
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2793
|
+
function $isRunningInBrowser() {
|
|
2794
|
+
try {
|
|
2795
|
+
return typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
2796
|
+
}
|
|
2797
|
+
catch (e) {
|
|
2798
|
+
return false;
|
|
2799
|
+
}
|
|
2798
2800
|
}
|
|
2799
|
-
`);
|
|
2800
2801
|
/**
|
|
2801
2802
|
* TODO: [🎺]
|
|
2802
2803
|
*/
|
|
@@ -2808,13 +2809,15 @@
|
|
|
2808
2809
|
*
|
|
2809
2810
|
* @public exported from `@promptbook/utils`
|
|
2810
2811
|
*/
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2812
|
+
function $isRunningInJest() {
|
|
2813
|
+
var _a;
|
|
2814
|
+
try {
|
|
2815
|
+
return typeof process !== 'undefined' && ((_a = process.env) === null || _a === void 0 ? void 0 : _a.JEST_WORKER_ID) !== undefined;
|
|
2816
|
+
}
|
|
2817
|
+
catch (e) {
|
|
2818
|
+
return false;
|
|
2819
|
+
}
|
|
2816
2820
|
}
|
|
2817
|
-
`);
|
|
2818
2821
|
/**
|
|
2819
2822
|
* TODO: [🎺]
|
|
2820
2823
|
*/
|
|
@@ -2826,13 +2829,14 @@
|
|
|
2826
2829
|
*
|
|
2827
2830
|
* @public exported from `@promptbook/utils`
|
|
2828
2831
|
*/
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2832
|
+
function $isRunningInNode() {
|
|
2833
|
+
try {
|
|
2834
|
+
return typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
|
|
2835
|
+
}
|
|
2836
|
+
catch (e) {
|
|
2837
|
+
return false;
|
|
2838
|
+
}
|
|
2834
2839
|
}
|
|
2835
|
-
`);
|
|
2836
2840
|
/**
|
|
2837
2841
|
* TODO: [🎺]
|
|
2838
2842
|
*/
|
|
@@ -2844,17 +2848,17 @@
|
|
|
2844
2848
|
*
|
|
2845
2849
|
* @public exported from `@promptbook/utils`
|
|
2846
2850
|
*/
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2851
|
+
function $isRunningInWebWorker() {
|
|
2852
|
+
try {
|
|
2853
|
+
// Note: Check for importScripts which is specific to workers
|
|
2854
|
+
// and not available in the main browser thread
|
|
2855
|
+
return (typeof self !== 'undefined' &&
|
|
2856
|
+
typeof self.importScripts === 'function');
|
|
2857
|
+
}
|
|
2858
|
+
catch (e) {
|
|
2852
2859
|
return false;
|
|
2853
2860
|
}
|
|
2854
|
-
} catch (e) {
|
|
2855
|
-
return false;
|
|
2856
2861
|
}
|
|
2857
|
-
`);
|
|
2858
2862
|
/**
|
|
2859
2863
|
* TODO: [🎺]
|
|
2860
2864
|
*/
|