@promptbook/cli 0.104.0-2 → 0.104.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/apps/agents-server/package.json +3 -4
- package/apps/agents-server/public/swagger.json +115 -0
- package/apps/agents-server/scripts/generate-reserved-paths/generate-reserved-paths.ts +11 -7
- package/apps/agents-server/src/app/AddAgentButton.tsx +1 -2
- package/apps/agents-server/src/app/admin/chat-feedback/ChatFeedbackClient.tsx +221 -274
- package/apps/agents-server/src/app/admin/chat-history/ChatHistoryClient.tsx +94 -137
- package/apps/agents-server/src/app/admin/metadata/MetadataClient.tsx +8 -8
- package/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +15 -1
- package/apps/agents-server/src/app/agents/[agentName]/AgentOptionsMenu.tsx +1 -3
- package/apps/agents-server/src/app/agents/[agentName]/AgentProfileChat.tsx +29 -16
- package/apps/agents-server/src/app/agents/[agentName]/api/chat/route.ts +3 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/mcp/route.ts +6 -11
- package/apps/agents-server/src/app/agents/[agentName]/api/voice/route.ts +4 -1
- package/apps/agents-server/src/app/agents/[agentName]/code/api/route.ts +8 -6
- package/apps/agents-server/src/app/agents/[agentName]/code/page.tsx +33 -30
- package/apps/agents-server/src/app/api/agents/[agentName]/clone/route.ts +10 -12
- package/apps/agents-server/src/app/api/agents/[agentName]/route.ts +1 -2
- package/apps/agents-server/src/app/api/agents/route.ts +1 -1
- package/apps/agents-server/src/app/api/api-tokens/route.ts +6 -7
- package/apps/agents-server/src/app/api/docs/book.md/route.ts +3 -0
- package/apps/agents-server/src/app/api/metadata/route.ts +5 -6
- package/apps/agents-server/src/app/api/upload/route.ts +9 -0
- package/apps/agents-server/src/app/page.tsx +1 -1
- package/apps/agents-server/src/app/swagger/page.tsx +14 -0
- package/apps/agents-server/src/components/AgentProfile/AgentProfile.tsx +4 -2
- package/apps/agents-server/src/components/AgentProfile/QrCodeModal.tsx +0 -1
- package/apps/agents-server/src/components/Auth/AuthControls.tsx +5 -4
- package/apps/agents-server/src/components/Header/Header.tsx +27 -5
- package/apps/agents-server/src/components/Homepage/AgentCard.tsx +22 -3
- package/apps/agents-server/src/components/_utils/headlessParam.tsx +7 -3
- package/apps/agents-server/src/database/migrate.ts +34 -1
- package/apps/agents-server/src/database/migrations/2025-12-0402-message-table.sql +42 -0
- package/apps/agents-server/src/generated/reservedPaths.ts +6 -1
- package/apps/agents-server/src/message-providers/email/_common/Email.ts +73 -0
- package/apps/agents-server/src/message-providers/email/_common/utils/TODO.txt +1 -0
- package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddress.test.ts.todo +108 -0
- package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddress.ts +62 -0
- package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddresses.test.ts.todo +117 -0
- package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddresses.ts +19 -0
- package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddress.test.ts.todo +119 -0
- package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddress.ts +19 -0
- package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddresses.test.ts.todo +74 -0
- package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddresses.ts +14 -0
- package/apps/agents-server/src/message-providers/email/sendgrid/SendgridMessageProvider.ts +44 -0
- package/apps/agents-server/src/message-providers/email/zeptomail/ZeptomailMessageProvider.ts +43 -0
- package/apps/agents-server/src/message-providers/index.ts +13 -0
- package/apps/agents-server/src/message-providers/interfaces/MessageProvider.ts +11 -0
- package/apps/agents-server/src/middleware.ts +12 -3
- package/apps/agents-server/src/utils/auth.ts +117 -17
- package/apps/agents-server/src/utils/getUserIdFromRequest.ts +3 -1
- package/apps/agents-server/src/utils/handleChatCompletion.ts +9 -5
- package/apps/agents-server/src/utils/messages/sendMessage.ts +91 -0
- package/apps/agents-server/src/utils/normalization/filenameToPrompt.test.ts +36 -0
- package/apps/agents-server/src/utils/normalization/filenameToPrompt.ts +6 -2
- package/apps/agents-server/src/utils/validateApiKey.ts +5 -10
- package/esm/index.es.js +86 -9
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +7 -11
- package/esm/typings/src/llm-providers/_multiple/MultipleLlmExecutionTools.d.ts +6 -2
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/types/Message.d.ts +49 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +86 -9
- package/umd/index.umd.js.map +1 -1
|
@@ -185,6 +185,7 @@ import type { BookTranspiler } from '../transpilers/_common/BookTranspiler';
|
|
|
185
185
|
import type { BookTranspilerOptions } from '../transpilers/_common/BookTranspilerOptions';
|
|
186
186
|
import type { IntermediateFilesStrategy } from '../types/IntermediateFilesStrategy';
|
|
187
187
|
import type { LlmCall } from '../types/LlmCall';
|
|
188
|
+
import type { Message } from '../types/Message';
|
|
188
189
|
import type { ModelRequirements } from '../types/ModelRequirements';
|
|
189
190
|
import type { CompletionModelRequirements } from '../types/ModelRequirements';
|
|
190
191
|
import type { ChatModelRequirements } from '../types/ModelRequirements';
|
|
@@ -551,6 +552,7 @@ export type { BookTranspiler };
|
|
|
551
552
|
export type { BookTranspilerOptions };
|
|
552
553
|
export type { IntermediateFilesStrategy };
|
|
553
554
|
export type { LlmCall };
|
|
555
|
+
export type { Message };
|
|
554
556
|
export type { ModelRequirements };
|
|
555
557
|
export type { CompletionModelRequirements };
|
|
556
558
|
export type { ChatModelRequirements };
|
|
@@ -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
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ChatParticipant } from '../../book-components/Chat/types/ChatParticipant';
|
|
2
2
|
import type { AvailableModel } from '../../execution/AvailableModel';
|
|
3
3
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
4
|
-
import type { ChatPromptResult, CompletionPromptResult, EmbeddingPromptResult, PromptResult } from '../../execution/PromptResult';
|
|
5
|
-
import type { ChatPrompt, CompletionPrompt, EmbeddingPrompt, Prompt } from '../../types/Prompt';
|
|
4
|
+
import type { ChatPromptResult, CompletionPromptResult, EmbeddingPromptResult, ImagePromptResult, PromptResult } from '../../execution/PromptResult';
|
|
5
|
+
import type { ChatPrompt, CompletionPrompt, EmbeddingPrompt, ImagePrompt, Prompt } from '../../types/Prompt';
|
|
6
6
|
import type { string_markdown, string_markdown_text, string_title } from '../../types/typeAliases';
|
|
7
7
|
/**
|
|
8
8
|
* Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
|
|
@@ -43,6 +43,10 @@ export declare class MultipleLlmExecutionTools implements LlmExecutionTools {
|
|
|
43
43
|
* Calls the best available embedding model
|
|
44
44
|
*/
|
|
45
45
|
callEmbeddingModel(prompt: EmbeddingPrompt): Promise<EmbeddingPromptResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Calls the best available embedding model
|
|
48
|
+
*/
|
|
49
|
+
callImageGenerationModel(prompt: ImagePrompt): Promise<ImagePromptResult>;
|
|
46
50
|
/**
|
|
47
51
|
* Calls the best available model
|
|
48
52
|
*
|
|
@@ -46,6 +46,7 @@ export declare class RemoteLlmExecutionTools<TCustomOptions = undefined> impleme
|
|
|
46
46
|
private callCommonModel;
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
|
+
* TODO: !!!! Deprecate pipeline server and all of its components
|
|
49
50
|
* TODO: Maybe use `$exportJson`
|
|
50
51
|
* TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
|
|
51
52
|
* TODO: [🍓] Allow to list compatible models with each variant
|
|
@@ -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
|
+
};
|
|
@@ -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-3`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
* @generated
|
|
57
57
|
* @see https://github.com/webgptorg/promptbook
|
|
58
58
|
*/
|
|
59
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.104.0-
|
|
59
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.104.0-4';
|
|
60
60
|
/**
|
|
61
61
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
62
62
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -3730,6 +3730,7 @@
|
|
|
3730
3730
|
}
|
|
3731
3731
|
}
|
|
3732
3732
|
/**
|
|
3733
|
+
* TODO: !!!! Deprecate pipeline server and all of its components
|
|
3733
3734
|
* TODO: Maybe use `$exportJson`
|
|
3734
3735
|
* TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
|
|
3735
3736
|
* TODO: [🍓] Allow to list compatible models with each variant
|
|
@@ -4258,6 +4259,9 @@
|
|
|
4258
4259
|
case 'EMBEDDING':
|
|
4259
4260
|
promptResult = await llmTools.callEmbeddingModel(prompt);
|
|
4260
4261
|
break variant;
|
|
4262
|
+
case 'IMAGE_GENERATION':
|
|
4263
|
+
promptResult = await llmTools.callImageGenerationModel(prompt);
|
|
4264
|
+
break variant;
|
|
4261
4265
|
// <- case [🤖]:
|
|
4262
4266
|
default:
|
|
4263
4267
|
throw new PipelineExecutionError(`Unknown model variant "${prompt.modelRequirements.modelVariant}"`);
|
|
@@ -4345,6 +4349,11 @@
|
|
|
4345
4349
|
return /* not await */ callCommonModel(prompt);
|
|
4346
4350
|
};
|
|
4347
4351
|
}
|
|
4352
|
+
if (llmTools.callImageGenerationModel !== undefined) {
|
|
4353
|
+
proxyTools.callImageGenerationModel = async (prompt) => {
|
|
4354
|
+
return /* not await */ callCommonModel(prompt);
|
|
4355
|
+
};
|
|
4356
|
+
}
|
|
4348
4357
|
// <- Note: [🤖]
|
|
4349
4358
|
return proxyTools;
|
|
4350
4359
|
}
|
|
@@ -4533,6 +4542,15 @@
|
|
|
4533
4542
|
return promptResult;
|
|
4534
4543
|
};
|
|
4535
4544
|
}
|
|
4545
|
+
if (llmTools.callImageGenerationModel !== undefined) {
|
|
4546
|
+
proxyTools.callImageGenerationModel = async (prompt) => {
|
|
4547
|
+
// console.info('[🚕] callImageGenerationModel through countTotalUsage');
|
|
4548
|
+
const promptResult = await llmTools.callImageGenerationModel(prompt);
|
|
4549
|
+
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
4550
|
+
spending.next(promptResult.usage);
|
|
4551
|
+
return promptResult;
|
|
4552
|
+
};
|
|
4553
|
+
}
|
|
4536
4554
|
// <- Note: [🤖]
|
|
4537
4555
|
return proxyTools;
|
|
4538
4556
|
}
|
|
@@ -4655,6 +4673,12 @@
|
|
|
4655
4673
|
callEmbeddingModel(prompt) {
|
|
4656
4674
|
return this.callCommonModel(prompt);
|
|
4657
4675
|
}
|
|
4676
|
+
/**
|
|
4677
|
+
* Calls the best available embedding model
|
|
4678
|
+
*/
|
|
4679
|
+
callImageGenerationModel(prompt) {
|
|
4680
|
+
return this.callCommonModel(prompt);
|
|
4681
|
+
}
|
|
4658
4682
|
// <- Note: [🤖]
|
|
4659
4683
|
/**
|
|
4660
4684
|
* Calls the best available model
|
|
@@ -4681,6 +4705,11 @@
|
|
|
4681
4705
|
continue llm;
|
|
4682
4706
|
}
|
|
4683
4707
|
return await llmExecutionTools.callEmbeddingModel(prompt);
|
|
4708
|
+
case 'IMAGE_GENERATION':
|
|
4709
|
+
if (llmExecutionTools.callImageGenerationModel === undefined) {
|
|
4710
|
+
continue llm;
|
|
4711
|
+
}
|
|
4712
|
+
return await llmExecutionTools.callImageGenerationModel(prompt);
|
|
4684
4713
|
// <- case [🤖]:
|
|
4685
4714
|
default:
|
|
4686
4715
|
throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}" in ${llmExecutionTools.title}`);
|
|
@@ -7603,8 +7632,9 @@
|
|
|
7603
7632
|
$ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
|
|
7604
7633
|
break variant;
|
|
7605
7634
|
case 'EMBEDDING':
|
|
7635
|
+
case 'IMAGE_GENERATION':
|
|
7606
7636
|
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
7607
|
-
|
|
7637
|
+
${modelRequirements.modelVariant} model can not be used in pipeline
|
|
7608
7638
|
|
|
7609
7639
|
This should be catched during parsing
|
|
7610
7640
|
|
|
@@ -19457,7 +19487,7 @@
|
|
|
19457
19487
|
let threadMessages = [];
|
|
19458
19488
|
if ('thread' in prompt && Array.isArray(prompt.thread)) {
|
|
19459
19489
|
threadMessages = prompt.thread.map((msg) => ({
|
|
19460
|
-
role: msg.
|
|
19490
|
+
role: msg.sender === 'assistant' ? 'assistant' : 'user',
|
|
19461
19491
|
content: msg.content,
|
|
19462
19492
|
}));
|
|
19463
19493
|
}
|
|
@@ -26123,17 +26153,64 @@
|
|
|
26123
26153
|
};
|
|
26124
26154
|
}
|
|
26125
26155
|
const lines = agentSource.split('\n');
|
|
26126
|
-
|
|
26156
|
+
let agentName = null;
|
|
26157
|
+
let agentNameLineIndex = -1;
|
|
26158
|
+
// Find the agent name: first non-empty line that is not a commitment and not a horizontal line
|
|
26159
|
+
for (let i = 0; i < lines.length; i++) {
|
|
26160
|
+
const line = lines[i];
|
|
26161
|
+
if (line === undefined) {
|
|
26162
|
+
continue;
|
|
26163
|
+
}
|
|
26164
|
+
const trimmed = line.trim();
|
|
26165
|
+
if (!trimmed) {
|
|
26166
|
+
continue;
|
|
26167
|
+
}
|
|
26168
|
+
const isHorizontal = HORIZONTAL_LINE_PATTERN.test(line);
|
|
26169
|
+
if (isHorizontal) {
|
|
26170
|
+
continue;
|
|
26171
|
+
}
|
|
26172
|
+
let isCommitment = false;
|
|
26173
|
+
for (const definition of COMMITMENT_REGISTRY) {
|
|
26174
|
+
const typeRegex = definition.createTypeRegex();
|
|
26175
|
+
const match = typeRegex.exec(trimmed);
|
|
26176
|
+
if (match && ((_a = match.groups) === null || _a === void 0 ? void 0 : _a.type)) {
|
|
26177
|
+
isCommitment = true;
|
|
26178
|
+
break;
|
|
26179
|
+
}
|
|
26180
|
+
}
|
|
26181
|
+
if (!isCommitment) {
|
|
26182
|
+
agentName = trimmed;
|
|
26183
|
+
agentNameLineIndex = i;
|
|
26184
|
+
break;
|
|
26185
|
+
}
|
|
26186
|
+
}
|
|
26127
26187
|
const commitments = [];
|
|
26128
26188
|
const nonCommitmentLines = [];
|
|
26129
|
-
//
|
|
26130
|
-
|
|
26131
|
-
|
|
26189
|
+
// Add lines before agentName that are horizontal lines (they are non-commitment)
|
|
26190
|
+
for (let i = 0; i < agentNameLineIndex; i++) {
|
|
26191
|
+
const line = lines[i];
|
|
26192
|
+
if (line === undefined) {
|
|
26193
|
+
continue;
|
|
26194
|
+
}
|
|
26195
|
+
const trimmed = line.trim();
|
|
26196
|
+
if (!trimmed) {
|
|
26197
|
+
continue;
|
|
26198
|
+
}
|
|
26199
|
+
const isHorizontal = HORIZONTAL_LINE_PATTERN.test(line);
|
|
26200
|
+
if (isHorizontal) {
|
|
26201
|
+
nonCommitmentLines.push(line);
|
|
26202
|
+
}
|
|
26203
|
+
// Note: Commitments before agentName are not added to nonCommitmentLines
|
|
26204
|
+
}
|
|
26205
|
+
// Add the agent name line to non-commitment lines
|
|
26206
|
+
if (agentNameLineIndex >= 0) {
|
|
26207
|
+
nonCommitmentLines.push(lines[agentNameLineIndex]);
|
|
26132
26208
|
}
|
|
26133
26209
|
// Parse commitments with multiline support
|
|
26134
26210
|
let currentCommitment = null;
|
|
26135
|
-
// Process lines starting from the
|
|
26136
|
-
|
|
26211
|
+
// Process lines starting from after the agent name line
|
|
26212
|
+
const startIndex = agentNameLineIndex >= 0 ? agentNameLineIndex + 1 : 0;
|
|
26213
|
+
for (let i = startIndex; i < lines.length; i++) {
|
|
26137
26214
|
const line = lines[i];
|
|
26138
26215
|
if (line === undefined) {
|
|
26139
26216
|
continue;
|