@promptbook/node 0.110.0-3 → 0.110.0-4
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 +90 -21
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +0 -2
- package/esm/typings/src/book-components/Chat/Chat/ChatActionsBar.d.ts +4 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatMessageItem.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/Chat/ChatMessageList.d.ts +0 -2
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +0 -7
- package/esm/typings/src/book-components/Chat/SourceChip/SourceChip.d.ts +5 -1
- package/esm/typings/src/book-components/Chat/hooks/useChatActionsOverlap.d.ts +6 -3
- package/esm/typings/src/book-components/Chat/utils/collectTeamToolCallSummary.d.ts +69 -0
- package/esm/typings/src/book-components/Chat/utils/getToolCallChipletInfo.d.ts +13 -6
- package/esm/typings/src/book-components/Chat/utils/parseCitationsFromContent.d.ts +9 -0
- package/esm/typings/src/book-components/Chat/utils/toolCallParsing.d.ts +4 -0
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +0 -6
- package/esm/typings/src/llm-providers/agent/AgentOptions.d.ts +9 -0
- package/esm/typings/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +9 -0
- package/esm/typings/src/utils/agents/resolveAgentAvatarImageUrl.d.ts +29 -0
- package/package.json +3 -5
- package/umd/index.umd.js +90 -21
- package/umd/index.umd.js.map +1 -1
|
@@ -33,7 +33,6 @@ import type { SourceChipProps } from '../book-components/Chat/SourceChip/SourceC
|
|
|
33
33
|
import type { ChatToolCall } from '../book-components/Chat/types/ChatMessage';
|
|
34
34
|
import type { ChatMessage } from '../book-components/Chat/types/ChatMessage';
|
|
35
35
|
import type { ChatParticipant } from '../book-components/Chat/types/ChatParticipant';
|
|
36
|
-
import type { ToolCallChipletInfo } from '../book-components/Chat/utils/getToolCallChipletInfo';
|
|
37
36
|
import type { ParsedCitation } from '../book-components/Chat/utils/parseCitationsFromContent';
|
|
38
37
|
import type { MessageButton } from '../book-components/Chat/utils/parseMessageButtons';
|
|
39
38
|
import type { TeamToolResult } from '../book-components/Chat/utils/toolCallParsing';
|
|
@@ -436,7 +435,6 @@ export type { SourceChipProps };
|
|
|
436
435
|
export type { ChatToolCall };
|
|
437
436
|
export type { ChatMessage };
|
|
438
437
|
export type { ChatParticipant };
|
|
439
|
-
export type { ToolCallChipletInfo };
|
|
440
438
|
export type { ParsedCitation };
|
|
441
439
|
export type { MessageButton };
|
|
442
440
|
export type { TeamToolResult };
|
|
@@ -21,6 +21,10 @@ export type ChatActionsBarProps = {
|
|
|
21
21
|
saveFormats?: Array<string_chat_format_name>;
|
|
22
22
|
isSaveButtonEnabled: boolean;
|
|
23
23
|
shouldFadeActions: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Disables action interactions while scroll is active.
|
|
26
|
+
*/
|
|
27
|
+
shouldDisableActions: boolean;
|
|
24
28
|
onButtonClick: (handler?: (event: MouseEvent<HTMLButtonElement>) => void) => (event: MouseEvent<HTMLButtonElement>) => void;
|
|
25
29
|
soundSystem?: ChatSoundSystem;
|
|
26
30
|
};
|
|
@@ -9,7 +9,7 @@ import type { ChatProps } from './ChatProps';
|
|
|
9
9
|
*
|
|
10
10
|
* @private props for internal subcomponent
|
|
11
11
|
*/
|
|
12
|
-
type ChatMessageItemProps = Pick<ChatProps, 'onMessage' | 'participants'
|
|
12
|
+
type ChatMessageItemProps = Pick<ChatProps, 'onMessage' | 'participants'> & {
|
|
13
13
|
message: ChatMessage;
|
|
14
14
|
participant: ChatParticipant | undefined;
|
|
15
15
|
isLastMessage: boolean;
|
|
@@ -5,14 +5,12 @@ import type { ChatMessage } from '../types/ChatMessage';
|
|
|
5
5
|
import type { ChatParticipant } from '../types/ChatParticipant';
|
|
6
6
|
import type { ParsedCitation } from '../utils/parseCitationsFromContent';
|
|
7
7
|
import type { ChatProps } from './ChatProps';
|
|
8
|
-
import { Agent } from '../../../llm-providers/agent/Agent';
|
|
9
8
|
/**
|
|
10
9
|
* Props for the Chat message list container.
|
|
11
10
|
*
|
|
12
11
|
* @private component of `<Chat/>`
|
|
13
12
|
*/
|
|
14
13
|
export type ChatMessageListProps = {
|
|
15
|
-
agent?: Agent;
|
|
16
14
|
messages: ReadonlyArray<ChatMessage>;
|
|
17
15
|
participants: ReadonlyArray<ChatParticipant>;
|
|
18
16
|
expandedMessageId: id | null;
|
|
@@ -6,7 +6,6 @@ import { string_color } from '../../../types/typeAliases';
|
|
|
6
6
|
import type { string_chat_format_name } from '../save/_common/string_chat_format_name';
|
|
7
7
|
import type { ChatMessage } from '../types/ChatMessage';
|
|
8
8
|
import type { ChatParticipant } from '../types/ChatParticipant';
|
|
9
|
-
import type { Agent } from '../../../llm-providers/agent/Agent';
|
|
10
9
|
/**
|
|
11
10
|
* Interface for sound system that can be passed to Chat component
|
|
12
11
|
* This allows the chat to trigger sounds without tight coupling
|
|
@@ -26,12 +25,6 @@ export type ChatSoundSystem = {
|
|
|
26
25
|
* @public exported from `@promptbook/components`
|
|
27
26
|
*/
|
|
28
27
|
export type ChatProps = {
|
|
29
|
-
/**
|
|
30
|
-
* The agent that is used in the chat
|
|
31
|
-
*
|
|
32
|
-
* Note: This is not used directly but passed to subcomponents
|
|
33
|
-
*/
|
|
34
|
-
readonly agent?: Agent;
|
|
35
28
|
/**
|
|
36
29
|
* Optional callback to create a new agent from the template.
|
|
37
30
|
* If provided, renders the [Use this template] button.
|
|
@@ -15,6 +15,10 @@ export type SourceChipProps = {
|
|
|
15
15
|
* Additional CSS class name
|
|
16
16
|
*/
|
|
17
17
|
className?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Optional suffix text to display after the citation label.
|
|
20
|
+
*/
|
|
21
|
+
suffix?: string;
|
|
18
22
|
};
|
|
19
23
|
/**
|
|
20
24
|
* SourceChip component - displays a chip with source document information
|
|
@@ -32,4 +36,4 @@ export type SourceChipProps = {
|
|
|
32
36
|
*
|
|
33
37
|
* @private utility of `ChatMessageItem` component
|
|
34
38
|
*/
|
|
35
|
-
export declare function SourceChip({ citation, onClick, className }: SourceChipProps): import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
export declare function SourceChip({ citation, onClick, className, suffix }: SourceChipProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -39,10 +39,13 @@ export type ChatActionsOverlapResult = {
|
|
|
39
39
|
*/
|
|
40
40
|
handleChatScroll: (event: UIEvent<HTMLDivElement>) => void;
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
43
|
-
* now there is just one state `shouldFadeActions` which is calculated based on the scroll position and overlap.
|
|
42
|
+
* Whether the actions toolbar is currently being scrolled.
|
|
44
43
|
*/
|
|
45
|
-
|
|
44
|
+
isActionsScrolling: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Whether the actions toolbar overlaps the first visible message.
|
|
47
|
+
*/
|
|
48
|
+
isActionsOverlapping: boolean;
|
|
46
49
|
};
|
|
47
50
|
/**
|
|
48
51
|
* Tracks action toolbar overlap while coordinating with chat auto-scroll.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type ToolCall } from '../../../types/ToolCall';
|
|
2
|
+
import type { ParsedCitation } from './parseCitationsFromContent';
|
|
3
|
+
/**
|
|
4
|
+
* Origin metadata for a tool call or citation executed by a teammate.
|
|
5
|
+
*
|
|
6
|
+
* @private utility of `<Chat/>`
|
|
7
|
+
*/
|
|
8
|
+
export type ToolCallOrigin = {
|
|
9
|
+
/**
|
|
10
|
+
* Human-readable label for the teammate.
|
|
11
|
+
*/
|
|
12
|
+
label: string;
|
|
13
|
+
/**
|
|
14
|
+
* Optional teammate URL.
|
|
15
|
+
*/
|
|
16
|
+
url?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Optional tool name for the teammate.
|
|
19
|
+
*/
|
|
20
|
+
toolName?: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Tool call data enriched with its teammate origin.
|
|
24
|
+
*
|
|
25
|
+
* @private utility of `<Chat/>`
|
|
26
|
+
*/
|
|
27
|
+
export type TransitiveToolCall = {
|
|
28
|
+
/**
|
|
29
|
+
* Tool call executed by the teammate.
|
|
30
|
+
*/
|
|
31
|
+
toolCall: ToolCall;
|
|
32
|
+
/**
|
|
33
|
+
* Teammate origin metadata for the tool call.
|
|
34
|
+
*/
|
|
35
|
+
origin: ToolCallOrigin;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Citation data enriched with its teammate origin.
|
|
39
|
+
*
|
|
40
|
+
* @private utility of `<Chat/>`
|
|
41
|
+
*/
|
|
42
|
+
export type TransitiveCitation = ParsedCitation & {
|
|
43
|
+
/**
|
|
44
|
+
* Teammate origin metadata for the citation.
|
|
45
|
+
*/
|
|
46
|
+
origin: ToolCallOrigin;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Aggregated teammate tool calls and citations derived from TEAM tool results.
|
|
50
|
+
*
|
|
51
|
+
* @private utility of `<Chat/>`
|
|
52
|
+
*/
|
|
53
|
+
export type TeamToolCallSummary = {
|
|
54
|
+
/**
|
|
55
|
+
* Tool calls executed by teammates, flattened transitively.
|
|
56
|
+
*/
|
|
57
|
+
toolCalls: TransitiveToolCall[];
|
|
58
|
+
/**
|
|
59
|
+
* Citations referenced by teammates, flattened transitively.
|
|
60
|
+
*/
|
|
61
|
+
citations: TransitiveCitation[];
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Collects tool calls and citations from TEAM tool call results, resolving nested teammate chains.
|
|
65
|
+
*
|
|
66
|
+
* @param toolCalls - Tool calls from the top-level agent message.
|
|
67
|
+
* @private utility of `<Chat/>`
|
|
68
|
+
*/
|
|
69
|
+
export declare function collectTeamToolCallSummary(toolCalls: ReadonlyArray<ToolCall> | undefined): TeamToolCallSummary;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { type ToolCall } from '../../../types/ToolCall';
|
|
2
|
-
import type { Agent } from '../../../llm-providers/agent/Agent';
|
|
3
2
|
import type { AgentChipData } from '../AgentChip';
|
|
4
|
-
/**
|
|
5
|
-
* Utility to format tool call information for user-friendly display.
|
|
6
|
-
*/
|
|
7
3
|
/**
|
|
8
4
|
* Tool call chiplet information including agent data for team tools
|
|
5
|
+
*
|
|
6
|
+
* @private utility of `<Chat/>`
|
|
9
7
|
*/
|
|
10
8
|
export type ToolCallChipletInfo = {
|
|
11
9
|
/**
|
|
@@ -23,10 +21,19 @@ export type ToolCallChipletInfo = {
|
|
|
23
21
|
*/
|
|
24
22
|
wrapInBrackets?: boolean;
|
|
25
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Builds display text for a tool call chiplet.
|
|
26
|
+
*
|
|
27
|
+
* @param chipletInfo - Chiplet metadata for the tool call.
|
|
28
|
+
*
|
|
29
|
+
* @private utility of `<Chat/>`
|
|
30
|
+
*/
|
|
31
|
+
export declare function buildToolCallChipText(chipletInfo: ToolCallChipletInfo): string;
|
|
26
32
|
/**
|
|
27
33
|
* Technical to user-friendly tool names and emojis
|
|
28
34
|
*
|
|
29
|
-
* @private [🧠] Maybe public?
|
|
35
|
+
* @private utility of `<Chat/>` [🧠] Maybe public?
|
|
36
|
+
*
|
|
30
37
|
*/
|
|
31
38
|
export declare const TOOL_TITLES: Record<string, {
|
|
32
39
|
title: string;
|
|
@@ -38,4 +45,4 @@ export declare const TOOL_TITLES: Record<string, {
|
|
|
38
45
|
*
|
|
39
46
|
* @private [🧠] Maybe public?
|
|
40
47
|
*/
|
|
41
|
-
export declare function getToolCallChipletInfo(toolCall: ToolCall
|
|
48
|
+
export declare function getToolCallChipletInfo(toolCall: ToolCall): ToolCallChipletInfo;
|
|
@@ -39,6 +39,15 @@ export declare function parseCitationsFromContent(content: string): ParsedCitati
|
|
|
39
39
|
* @private utility for internal use
|
|
40
40
|
*/
|
|
41
41
|
export declare function stripCitationsFromContent(content: string): string;
|
|
42
|
+
/**
|
|
43
|
+
* Deduplicates citations by source while preserving the first-seen order.
|
|
44
|
+
*
|
|
45
|
+
* @param citations - Parsed citations to deduplicate.
|
|
46
|
+
* @returns Deduplicated citations in original order.
|
|
47
|
+
*
|
|
48
|
+
* @private utility for internal use
|
|
49
|
+
*/
|
|
50
|
+
export declare function dedupeCitationsBySource(citations: ReadonlyArray<ParsedCitation>): ParsedCitation[];
|
|
42
51
|
/**
|
|
43
52
|
* Extracts citations from a chat message if not already present
|
|
44
53
|
*
|
|
@@ -25,6 +25,10 @@ export type TeamToolResult = {
|
|
|
25
25
|
};
|
|
26
26
|
request?: string;
|
|
27
27
|
response?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Tool calls executed by the teammate while answering.
|
|
30
|
+
*/
|
|
31
|
+
toolCalls?: ReadonlyArray<ToolCall>;
|
|
28
32
|
error?: string | null;
|
|
29
33
|
conversation?: Array<{
|
|
30
34
|
sender?: string;
|
|
@@ -81,12 +81,6 @@ export declare class Agent extends AgentLlmExecutionTools implements LlmExecutio
|
|
|
81
81
|
* Human-readable titles for tool functions
|
|
82
82
|
*/
|
|
83
83
|
toolTitles: Record<string, string>;
|
|
84
|
-
/**
|
|
85
|
-
* Externals prepared for the agent, like OpenAI assistant, etc.
|
|
86
|
-
*/
|
|
87
|
-
preparedExternals: {
|
|
88
|
-
openaiAssistantId?: string;
|
|
89
|
-
};
|
|
90
84
|
/**
|
|
91
85
|
* Not used in Agent, always returns empty array
|
|
92
86
|
*/
|
|
@@ -13,6 +13,15 @@ export type AgentOptions = CommonToolsOptions & {
|
|
|
13
13
|
* Here the agent has access to various LLM models, browser, scrapers, LibreOffice, tools, etc.
|
|
14
14
|
*/
|
|
15
15
|
executionTools: ExecutionTools;
|
|
16
|
+
/**
|
|
17
|
+
* How to manage OpenAI assistant preparation when using OpenAiAssistantExecutionTools.
|
|
18
|
+
*
|
|
19
|
+
* Use `external` when an external cache manager already created the assistant and
|
|
20
|
+
* the agent should use it as-is.
|
|
21
|
+
*
|
|
22
|
+
* @default internal
|
|
23
|
+
*/
|
|
24
|
+
assistantPreparationMode?: 'internal' | 'external';
|
|
16
25
|
/**
|
|
17
26
|
* The source of the agent
|
|
18
27
|
*/
|
|
@@ -10,6 +10,15 @@ export type CreateAgentLlmExecutionToolsOptions = CommonToolsOptions & {
|
|
|
10
10
|
* The underlying LLM execution tools to wrap
|
|
11
11
|
*/
|
|
12
12
|
llmTools: LlmExecutionTools | OpenAiAssistantExecutionTools;
|
|
13
|
+
/**
|
|
14
|
+
* How to manage OpenAI assistant preparation when using OpenAiAssistantExecutionTools.
|
|
15
|
+
*
|
|
16
|
+
* Use `external` when an external cache manager already created the assistant and
|
|
17
|
+
* the agent should use it as-is.
|
|
18
|
+
*
|
|
19
|
+
* @default internal
|
|
20
|
+
*/
|
|
21
|
+
assistantPreparationMode?: 'internal' | 'external';
|
|
13
22
|
/**
|
|
14
23
|
* The agent source string that defines the agent's behavior
|
|
15
24
|
*/
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { AgentBasicInformation } from '../../book-2.0/agent-source/AgentBasicInformation';
|
|
2
|
+
import type { string_url, string_url_image } from '../../types/typeAliases';
|
|
3
|
+
/**
|
|
4
|
+
* Options for resolving agent avatar URLs.
|
|
5
|
+
*
|
|
6
|
+
* @private utility of `<Chat/>`
|
|
7
|
+
*/
|
|
8
|
+
export type ResolveAgentAvatarImageUrlOptions = {
|
|
9
|
+
/**
|
|
10
|
+
* Agent metadata used for avatar resolution.
|
|
11
|
+
*/
|
|
12
|
+
readonly agent: Pick<AgentBasicInformation, 'agentName' | 'permanentId' | 'meta'>;
|
|
13
|
+
/**
|
|
14
|
+
* Optional base URL used to resolve relative meta images and placeholders.
|
|
15
|
+
*/
|
|
16
|
+
readonly baseUrl?: string_url;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Resolve the fallback avatar URL for an agent.
|
|
20
|
+
*
|
|
21
|
+
* @private utility of `<Chat/>`
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveAgentAvatarFallbackUrl(options: ResolveAgentAvatarImageUrlOptions): string_url_image | null;
|
|
24
|
+
/**
|
|
25
|
+
* Resolve the best avatar URL for an agent, preferring META IMAGE and falling back to placeholders.
|
|
26
|
+
*
|
|
27
|
+
* @private utility of `<Chat/>`
|
|
28
|
+
*/
|
|
29
|
+
export declare function resolveAgentAvatarImageUrl(options: ResolveAgentAvatarImageUrlOptions): string_url_image | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/node",
|
|
3
|
-
"version": "0.110.0-
|
|
3
|
+
"version": "0.110.0-4",
|
|
4
4
|
"description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -89,14 +89,11 @@
|
|
|
89
89
|
"node": ">=18.18.0",
|
|
90
90
|
"npm": ">=8.0.0"
|
|
91
91
|
},
|
|
92
|
-
"overrides": {
|
|
93
|
-
"jsdom": "26.1.0"
|
|
94
|
-
},
|
|
95
92
|
"main": "./umd/index.umd.js",
|
|
96
93
|
"module": "./esm/index.es.js",
|
|
97
94
|
"typings": "./esm/typings/src/_packages/node.index.d.ts",
|
|
98
95
|
"peerDependencies": {
|
|
99
|
-
"@promptbook/core": "0.110.0-
|
|
96
|
+
"@promptbook/core": "0.110.0-4"
|
|
100
97
|
},
|
|
101
98
|
"dependencies": {
|
|
102
99
|
"@mozilla/readability": "0.6.0",
|
|
@@ -105,6 +102,7 @@
|
|
|
105
102
|
"crypto": "1.0.1",
|
|
106
103
|
"crypto-js": "4.2.0",
|
|
107
104
|
"dotenv": "16.3.2",
|
|
105
|
+
"jsdom": "25.0.1",
|
|
108
106
|
"jszip": "3.10.1",
|
|
109
107
|
"moment": "2.30.1",
|
|
110
108
|
"openai": "4.63.0",
|
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.110.0-
|
|
51
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.110.0-4';
|
|
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
|
|
@@ -16988,11 +16988,16 @@
|
|
|
16988
16988
|
const request = buildTeammateRequest(message, args.context);
|
|
16989
16989
|
let response = '';
|
|
16990
16990
|
let error = null;
|
|
16991
|
+
let toolCalls;
|
|
16991
16992
|
try {
|
|
16992
16993
|
const remoteAgent = await getRemoteTeammateAgent(entry.teammate.url);
|
|
16993
16994
|
const prompt = buildTeammatePrompt(request);
|
|
16994
16995
|
const teammateResult = await remoteAgent.callChatModel(prompt);
|
|
16995
16996
|
response = teammateResult.content || '';
|
|
16997
|
+
toolCalls =
|
|
16998
|
+
'toolCalls' in teammateResult && Array.isArray(teammateResult.toolCalls)
|
|
16999
|
+
? teammateResult.toolCalls
|
|
17000
|
+
: undefined;
|
|
16996
17001
|
}
|
|
16997
17002
|
catch (err) {
|
|
16998
17003
|
error = err instanceof Error ? err.message : String(err);
|
|
@@ -17002,6 +17007,7 @@
|
|
|
17002
17007
|
teammate: teammateMetadata,
|
|
17003
17008
|
request,
|
|
17004
17009
|
response: teammateReply,
|
|
17010
|
+
toolCalls: toolCalls && toolCalls.length > 0 ? toolCalls : undefined,
|
|
17005
17011
|
error,
|
|
17006
17012
|
conversation: [
|
|
17007
17013
|
{
|
|
@@ -24566,7 +24572,20 @@
|
|
|
24566
24572
|
const requirementsHash = cryptoJs.SHA256(JSON.stringify(modelRequirements)).toString();
|
|
24567
24573
|
const cached = AgentLlmExecutionTools.assistantCache.get(this.title);
|
|
24568
24574
|
let assistant;
|
|
24569
|
-
if (
|
|
24575
|
+
if (this.options.assistantPreparationMode === 'external') {
|
|
24576
|
+
assistant = this.options.llmTools;
|
|
24577
|
+
if (this.options.isVerbose) {
|
|
24578
|
+
console.info('[🤰]', 'Using externally managed OpenAI Assistant', {
|
|
24579
|
+
agent: this.title,
|
|
24580
|
+
assistantId: assistant.assistantId,
|
|
24581
|
+
});
|
|
24582
|
+
}
|
|
24583
|
+
AgentLlmExecutionTools.assistantCache.set(this.title, {
|
|
24584
|
+
assistantId: assistant.assistantId,
|
|
24585
|
+
requirementsHash,
|
|
24586
|
+
});
|
|
24587
|
+
}
|
|
24588
|
+
else if (cached) {
|
|
24570
24589
|
if (cached.requirementsHash === requirementsHash) {
|
|
24571
24590
|
if (this.options.isVerbose) {
|
|
24572
24591
|
console.info('[🤰]', 'Using cached OpenAI Assistant', {
|
|
@@ -24632,11 +24651,6 @@
|
|
|
24632
24651
|
requirementsHash,
|
|
24633
24652
|
});
|
|
24634
24653
|
}
|
|
24635
|
-
// [0] Expose prepared externals
|
|
24636
|
-
if (this.preparedExternals) {
|
|
24637
|
-
this /* <- TODO: !!!!!! Remove */.preparedExternals.openaiAssistantId =
|
|
24638
|
-
assistant.assistantId;
|
|
24639
|
-
}
|
|
24640
24654
|
// Create modified chat prompt with agent system message specific to OpenAI Assistant
|
|
24641
24655
|
const promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools = {
|
|
24642
24656
|
...promptWithAgentModelRequirements,
|
|
@@ -24790,6 +24804,7 @@
|
|
|
24790
24804
|
super({
|
|
24791
24805
|
isVerbose: options.isVerbose,
|
|
24792
24806
|
llmTools: getSingleLlmExecutionTools(options.executionTools.llm),
|
|
24807
|
+
assistantPreparationMode: options.assistantPreparationMode,
|
|
24793
24808
|
agentSource: agentSource.value, // <- TODO: [🐱🚀] Allow to pass BehaviorSubject<string_book> OR refresh llmExecutionTools.callChat on agentSource change
|
|
24794
24809
|
});
|
|
24795
24810
|
_Agent_instances.add(this);
|
|
@@ -24829,10 +24844,6 @@
|
|
|
24829
24844
|
* Human-readable titles for tool functions
|
|
24830
24845
|
*/
|
|
24831
24846
|
this.toolTitles = {};
|
|
24832
|
-
/**
|
|
24833
|
-
* Externals prepared for the agent, like OpenAI assistant, etc.
|
|
24834
|
-
*/
|
|
24835
|
-
this.preparedExternals = {};
|
|
24836
24847
|
// TODO: [🐱🚀] Add `Agent` simple "mocked" learning by appending to agent source
|
|
24837
24848
|
// TODO: [🐱🚀] Add `Agent` learning by promptbookAgent
|
|
24838
24849
|
this.teacherAgent = options.teacherAgent;
|
|
@@ -25069,6 +25080,63 @@
|
|
|
25069
25080
|
* TODO: [🧠][😰]Agent is not working with the parameters, should it be?
|
|
25070
25081
|
*/
|
|
25071
25082
|
|
|
25083
|
+
/**
|
|
25084
|
+
* Resolve a remote META IMAGE value into an absolute URL when possible.
|
|
25085
|
+
*/
|
|
25086
|
+
function resolveRemoteImageUrl(imageUrl, agentUrl) {
|
|
25087
|
+
if (!imageUrl) {
|
|
25088
|
+
return undefined;
|
|
25089
|
+
}
|
|
25090
|
+
if (imageUrl.startsWith('http://') ||
|
|
25091
|
+
imageUrl.startsWith('https://') ||
|
|
25092
|
+
imageUrl.startsWith('data:') ||
|
|
25093
|
+
imageUrl.startsWith('blob:')) {
|
|
25094
|
+
return imageUrl;
|
|
25095
|
+
}
|
|
25096
|
+
try {
|
|
25097
|
+
return new URL(imageUrl, agentUrl).href;
|
|
25098
|
+
}
|
|
25099
|
+
catch (_a) {
|
|
25100
|
+
return imageUrl;
|
|
25101
|
+
}
|
|
25102
|
+
}
|
|
25103
|
+
/**
|
|
25104
|
+
* Format a META commitment line when the value is provided.
|
|
25105
|
+
*/
|
|
25106
|
+
function formatMetaLine(label, value) {
|
|
25107
|
+
if (!value) {
|
|
25108
|
+
return null;
|
|
25109
|
+
}
|
|
25110
|
+
return `META ${label} ${value}`;
|
|
25111
|
+
}
|
|
25112
|
+
/**
|
|
25113
|
+
* Build a minimal agent source snapshot for remote agents.
|
|
25114
|
+
*/
|
|
25115
|
+
function buildRemoteAgentSource(profile, meta) {
|
|
25116
|
+
const metaLines = [
|
|
25117
|
+
formatMetaLine('FULLNAME', meta === null || meta === void 0 ? void 0 : meta.fullname),
|
|
25118
|
+
formatMetaLine('IMAGE', meta === null || meta === void 0 ? void 0 : meta.image),
|
|
25119
|
+
formatMetaLine('DESCRIPTION', meta === null || meta === void 0 ? void 0 : meta.description),
|
|
25120
|
+
formatMetaLine('COLOR', meta === null || meta === void 0 ? void 0 : meta.color),
|
|
25121
|
+
formatMetaLine('FONT', meta === null || meta === void 0 ? void 0 : meta.font),
|
|
25122
|
+
formatMetaLine('LINK', meta === null || meta === void 0 ? void 0 : meta.link),
|
|
25123
|
+
]
|
|
25124
|
+
.filter((line) => Boolean(line))
|
|
25125
|
+
.join('\n');
|
|
25126
|
+
const personaBlock = profile.personaDescription
|
|
25127
|
+
? spaceTrim__default["default"]((block) => `
|
|
25128
|
+
PERSONA
|
|
25129
|
+
${block(profile.personaDescription || '')}
|
|
25130
|
+
`)
|
|
25131
|
+
: '';
|
|
25132
|
+
return book `
|
|
25133
|
+
${profile.agentName}
|
|
25134
|
+
|
|
25135
|
+
${metaLines}
|
|
25136
|
+
|
|
25137
|
+
${personaBlock}
|
|
25138
|
+
`;
|
|
25139
|
+
}
|
|
25072
25140
|
/**
|
|
25073
25141
|
* Represents one AI Agent
|
|
25074
25142
|
*
|
|
@@ -25083,6 +25151,7 @@
|
|
|
25083
25151
|
*/
|
|
25084
25152
|
class RemoteAgent extends Agent {
|
|
25085
25153
|
static async connect(options) {
|
|
25154
|
+
var _a, _b, _c;
|
|
25086
25155
|
const agentProfileUrl = `${options.agentUrl}/api/profile`;
|
|
25087
25156
|
const profileResponse = await fetch(agentProfileUrl);
|
|
25088
25157
|
// <- TODO: [🐱🚀] What about closed-source agents?
|
|
@@ -25102,14 +25171,14 @@
|
|
|
25102
25171
|
|
|
25103
25172
|
`));
|
|
25104
25173
|
}
|
|
25105
|
-
const profile = await profileResponse.json();
|
|
25174
|
+
const profile = (await profileResponse.json());
|
|
25175
|
+
const resolvedMeta = {
|
|
25176
|
+
...(profile.meta || {}),
|
|
25177
|
+
image: resolveRemoteImageUrl((_a = profile.meta) === null || _a === void 0 ? void 0 : _a.image, options.agentUrl),
|
|
25178
|
+
};
|
|
25106
25179
|
// Note: We are creating dummy agent source because we don't have the source from the remote agent
|
|
25107
25180
|
// But we populate the metadata from the profile
|
|
25108
|
-
const agentSource = new rxjs.BehaviorSubject(
|
|
25109
|
-
${profile.agentName}
|
|
25110
|
-
|
|
25111
|
-
${profile.personaDescription}
|
|
25112
|
-
`);
|
|
25181
|
+
const agentSource = new rxjs.BehaviorSubject(buildRemoteAgentSource(profile, resolvedMeta));
|
|
25113
25182
|
// <- TODO: [🐱🚀] createBookFromProfile
|
|
25114
25183
|
// <- TODO: [🐱🚀] Support updating and self-updating
|
|
25115
25184
|
const remoteAgent = new RemoteAgent({
|
|
@@ -25132,10 +25201,10 @@
|
|
|
25132
25201
|
});
|
|
25133
25202
|
remoteAgent._remoteAgentName = profile.agentName;
|
|
25134
25203
|
remoteAgent._remoteAgentHash = profile.agentHash;
|
|
25135
|
-
remoteAgent.personaDescription = profile.personaDescription;
|
|
25136
|
-
remoteAgent.initialMessage = profile.initialMessage;
|
|
25137
|
-
remoteAgent.links = profile.links;
|
|
25138
|
-
remoteAgent.meta =
|
|
25204
|
+
remoteAgent.personaDescription = (_b = profile.personaDescription) !== null && _b !== void 0 ? _b : null;
|
|
25205
|
+
remoteAgent.initialMessage = (_c = profile.initialMessage) !== null && _c !== void 0 ? _c : null;
|
|
25206
|
+
remoteAgent.links = profile.links || [];
|
|
25207
|
+
remoteAgent.meta = resolvedMeta;
|
|
25139
25208
|
remoteAgent.capabilities = profile.capabilities || [];
|
|
25140
25209
|
remoteAgent.samples = profile.samples || [];
|
|
25141
25210
|
remoteAgent.toolTitles = profile.toolTitles || {};
|