@promptbook/cli 0.104.0-10 → 0.104.0-12
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/src/app/admin/files/FilesGalleryClient.tsx +263 -0
- package/apps/agents-server/src/app/admin/files/actions.ts +61 -0
- package/apps/agents-server/src/app/admin/files/page.tsx +13 -0
- package/apps/agents-server/src/app/admin/image-generator-test/ImageGeneratorTestClient.tsx +169 -0
- package/apps/agents-server/src/app/admin/image-generator-test/page.tsx +13 -0
- package/apps/agents-server/src/app/admin/images/ImagesGalleryClient.tsx +256 -0
- package/apps/agents-server/src/app/admin/images/actions.ts +60 -0
- package/apps/agents-server/src/app/admin/images/page.tsx +13 -0
- package/apps/agents-server/src/app/admin/search-engine-test/SearchEngineTestClient.tsx +109 -0
- package/apps/agents-server/src/app/admin/search-engine-test/actions.ts +17 -0
- package/apps/agents-server/src/app/admin/search-engine-test/page.tsx +13 -0
- package/apps/agents-server/src/app/api/images/[filename]/route.ts +22 -1
- package/apps/agents-server/src/app/api/upload/route.ts +4 -2
- package/apps/agents-server/src/components/AgentProfile/AgentCapabilityChips.tsx +38 -0
- package/apps/agents-server/src/components/AgentProfile/AgentProfile.tsx +4 -1
- package/apps/agents-server/src/components/Header/Header.tsx +16 -0
- package/apps/agents-server/src/components/Homepage/AgentCard.tsx +13 -8
- package/apps/agents-server/src/database/$getTableName.ts +1 -0
- package/apps/agents-server/src/database/migrations/2025-12-0830-image-purpose.sql +5 -0
- package/apps/agents-server/src/database/migrations/2025-12-0890-file-agent-id.sql +5 -0
- package/apps/agents-server/src/database/schema.ts +14 -1
- package/apps/agents-server/src/utils/messages/sendMessage.ts +6 -5
- package/esm/index.es.js +141 -28
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +8 -0
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +24 -0
- package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +5 -0
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirements.tools.test.d.ts +1 -0
- package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +2 -2
- package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +1 -1
- package/esm/typings/src/book-components/_common/HamburgerMenu/HamburgerMenu.d.ts +1 -1
- package/esm/typings/src/book-components/icons/AboutIcon.d.ts +1 -1
- package/esm/typings/src/book-components/icons/AttachmentIcon.d.ts +1 -1
- package/esm/typings/src/book-components/icons/CameraIcon.d.ts +1 -1
- package/esm/typings/src/book-components/icons/DownloadIcon.d.ts +1 -1
- package/esm/typings/src/book-components/icons/MenuIcon.d.ts +1 -1
- package/esm/typings/src/book-components/icons/SaveIcon.d.ts +1 -1
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +2 -2
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +0 -54
- package/esm/typings/src/commitments/META/META_DESCRIPTION.d.ts +41 -0
- package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +2 -2
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/countUsage.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +1 -1
- package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +6 -1
- package/esm/typings/src/llm-providers/openai/utils/mapToolsToOpenAi.d.ts +8 -0
- package/esm/typings/src/remote-server/ui/ServerApp.d.ts +1 -1
- package/esm/typings/src/search-engines/SearchEngine.d.ts +9 -0
- package/esm/typings/src/search-engines/SearchResult.d.ts +18 -0
- package/esm/typings/src/search-engines/bing/BingSearchEngine.d.ts +15 -0
- package/esm/typings/src/search-engines/dummy/DummySearchEngine.d.ts +15 -0
- package/esm/typings/src/types/LlmToolDefinition.d.ts +20 -0
- package/esm/typings/src/types/ModelRequirements.d.ts +13 -0
- package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +3 -2
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +141 -28
- package/umd/index.umd.js.map +1 -1
|
@@ -5,16 +5,17 @@ import { really_any } from '@promptbook-local/types';
|
|
|
5
5
|
import { EyeIcon, EyeOffIcon, RotateCcwIcon } from 'lucide-react';
|
|
6
6
|
import Link from 'next/link';
|
|
7
7
|
import { AgentBasicInformation } from '../../../../../src/book-2.0/agent-source/AgentBasicInformation';
|
|
8
|
+
import { AgentCapabilityChips } from '../AgentProfile/AgentCapabilityChips';
|
|
8
9
|
import { useAgentBackground } from '../AgentProfile/useAgentBackground';
|
|
9
10
|
|
|
10
11
|
type AgentCardProps = {
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
+
* The basic information of the agent to display
|
|
13
14
|
*/
|
|
14
15
|
readonly agent: AgentBasicInformation;
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
+
* The URL to navigate to when the card is clicked
|
|
18
19
|
*/
|
|
19
20
|
readonly href: string;
|
|
20
21
|
|
|
@@ -24,32 +25,32 @@ type AgentCardProps = {
|
|
|
24
25
|
readonly publicUrl: URL;
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
|
-
*
|
|
28
|
+
* Whether the current user has admin privileges
|
|
28
29
|
*/
|
|
29
30
|
readonly isAdmin?: boolean;
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
|
-
*
|
|
33
|
+
* Callback function to delete the agent
|
|
33
34
|
*/
|
|
34
35
|
readonly onDelete?: (agentIdentifier: string) => void;
|
|
35
36
|
|
|
36
37
|
/**
|
|
37
|
-
*
|
|
38
|
+
* Callback function to clone the agent
|
|
38
39
|
*/
|
|
39
40
|
readonly onClone?: (agentIdentifier: string) => void;
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
|
-
*
|
|
43
|
+
* Callback function to toggle the agent's visibility
|
|
43
44
|
*/
|
|
44
45
|
readonly onToggleVisibility?: (agentIdentifier: string) => void;
|
|
45
46
|
|
|
46
47
|
/**
|
|
47
|
-
*
|
|
48
|
+
* Callback function to restore a deleted agent
|
|
48
49
|
*/
|
|
49
50
|
readonly onRestore?: (agentIdentifier: string) => void;
|
|
50
51
|
|
|
51
52
|
/**
|
|
52
|
-
*
|
|
53
|
+
* The current visibility status of the agent
|
|
53
54
|
*/
|
|
54
55
|
readonly visibility?: 'PUBLIC' | 'PRIVATE';
|
|
55
56
|
};
|
|
@@ -122,6 +123,10 @@ export function AgentCard({
|
|
|
122
123
|
<p className="text-sm text-gray-800 text-center line-clamp-3 leading-relaxed font-medium mix-blend-hard-light">
|
|
123
124
|
{personaDescription}
|
|
124
125
|
</p>
|
|
126
|
+
|
|
127
|
+
<div className="flex justify-center w-full">
|
|
128
|
+
<AgentCapabilityChips agent={agent} className="justify-center mt-3 opacity-90 scale-90" />
|
|
129
|
+
</div>
|
|
125
130
|
</div>
|
|
126
131
|
</div>
|
|
127
132
|
</Link>
|
|
@@ -15,4 +15,5 @@ type string_table_name = keyof AgentsServerDatabase['public']['Tables'];
|
|
|
15
15
|
export async function $getTableName<TTable extends string_table_name>(tableName: TTable): Promise<TTable> {
|
|
16
16
|
const { tablePrefix } = await $provideServer();
|
|
17
17
|
return `${tablePrefix}${tableName}` as TTable;
|
|
18
|
+
// <- TODO: [🏧] DRY
|
|
18
19
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
ALTER TABLE "prefix_Image" ADD COLUMN "agentId" BIGINT REFERENCES "prefix_Agent"("id") ON DELETE CASCADE;
|
|
2
|
+
ALTER TABLE "prefix_Image" ADD COLUMN "purpose" TEXT CHECK ("purpose" IN ('AVATAR', 'TESTING'));
|
|
3
|
+
|
|
4
|
+
COMMENT ON COLUMN "prefix_Image"."agentId" IS 'The agent this image belongs to (nullable for testing images)';
|
|
5
|
+
COMMENT ON COLUMN "prefix_Image"."purpose" IS 'The purpose of the image (AVATAR or TESTING)';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
-- Add agentId column to associate files with agents
|
|
2
|
+
ALTER TABLE "prefix_File" ADD COLUMN IF NOT EXISTS "agentId" INTEGER NULL;
|
|
3
|
+
|
|
4
|
+
-- Add foreign key constraint to Agent table
|
|
5
|
+
ALTER TABLE "prefix_File" ADD CONSTRAINT "File_agentId_fkey" FOREIGN KEY ("agentId") REFERENCES "prefix_Agent" ("id") ON DELETE SET NULL;
|
|
@@ -389,6 +389,8 @@ export type AgentsServerDatabase = {
|
|
|
389
389
|
prompt: string;
|
|
390
390
|
cdnUrl: string;
|
|
391
391
|
cdnKey: string;
|
|
392
|
+
agentId: number | null;
|
|
393
|
+
purpose: 'AVATAR' | 'TESTING' | null;
|
|
392
394
|
};
|
|
393
395
|
Insert: {
|
|
394
396
|
id?: number;
|
|
@@ -398,6 +400,8 @@ export type AgentsServerDatabase = {
|
|
|
398
400
|
prompt: string;
|
|
399
401
|
cdnUrl: string;
|
|
400
402
|
cdnKey: string;
|
|
403
|
+
agentId?: number | null;
|
|
404
|
+
purpose?: 'AVATAR' | 'TESTING' | null;
|
|
401
405
|
};
|
|
402
406
|
Update: {
|
|
403
407
|
id?: number;
|
|
@@ -407,8 +411,17 @@ export type AgentsServerDatabase = {
|
|
|
407
411
|
prompt?: string;
|
|
408
412
|
cdnUrl?: string;
|
|
409
413
|
cdnKey?: string;
|
|
414
|
+
agentId?: number | null;
|
|
415
|
+
purpose?: 'AVATAR' | 'TESTING' | null;
|
|
410
416
|
};
|
|
411
|
-
Relationships: [
|
|
417
|
+
Relationships: [
|
|
418
|
+
{
|
|
419
|
+
foreignKeyName: 'Image_agentId_fkey';
|
|
420
|
+
columns: ['agentId'];
|
|
421
|
+
referencedRelation: 'Agent';
|
|
422
|
+
referencedColumns: ['id'];
|
|
423
|
+
},
|
|
424
|
+
];
|
|
412
425
|
};
|
|
413
426
|
File: {
|
|
414
427
|
Row: {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PostgrestSingleResponse, SupabaseClient } from '@supabase/supabase-js';
|
|
1
2
|
import type { really_any } from '@promptbook-local/types';
|
|
2
3
|
import { serializeError } from '@promptbook-local/utils';
|
|
3
4
|
import { assertsError } from '../../../../../src/errors/assertsError';
|
|
@@ -5,15 +6,16 @@ import { $getTableName } from '../../database/$getTableName';
|
|
|
5
6
|
import { $provideSupabaseForServer } from '../../database/$provideSupabaseForServer';
|
|
6
7
|
import { EMAIL_PROVIDERS } from '../../message-providers';
|
|
7
8
|
import { OutboundEmail } from '../../message-providers/email/_common/Email';
|
|
9
|
+
import type { AgentsServerDatabase } from '../../database/schema';
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* Sends a message
|
|
11
13
|
*/
|
|
12
14
|
export async function sendMessage(message: OutboundEmail): Promise<void> {
|
|
13
|
-
const supabase = await $provideSupabaseForServer();
|
|
15
|
+
const supabase: SupabaseClient<AgentsServerDatabase> = await $provideSupabaseForServer();
|
|
14
16
|
|
|
15
17
|
// 1. Insert message
|
|
16
|
-
const { data: insertedMessage, error: insertError } = await supabase
|
|
18
|
+
const { data: insertedMessage, error: insertError }: PostgrestSingleResponse<AgentsServerDatabase['public']['Tables']['Message']['Row']> = await supabase
|
|
17
19
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
20
|
.from(await $getTableName('Message'))
|
|
19
21
|
.insert({
|
|
@@ -46,11 +48,11 @@ export async function sendMessage(message: OutboundEmail): Promise<void> {
|
|
|
46
48
|
return;
|
|
47
49
|
}
|
|
48
50
|
|
|
49
|
-
let isSent = false;
|
|
51
|
+
let isSent: boolean = false;
|
|
50
52
|
|
|
51
53
|
for (const providerName of providers) {
|
|
52
54
|
const provider = EMAIL_PROVIDERS[providerName];
|
|
53
|
-
let isSuccessful = false;
|
|
55
|
+
let isSuccessful: boolean = false;
|
|
54
56
|
let raw: really_any = null;
|
|
55
57
|
|
|
56
58
|
try {
|
|
@@ -67,7 +69,6 @@ export async function sendMessage(message: OutboundEmail): Promise<void> {
|
|
|
67
69
|
// 3. Log attempt
|
|
68
70
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
71
|
await supabase.from(await $getTableName('MessageSendAttempt')).insert({
|
|
70
|
-
// @ts-expect-error: insertedMessage is any
|
|
71
72
|
messageId: insertedMessage.id,
|
|
72
73
|
providerName,
|
|
73
74
|
isSuccessful,
|
package/esm/index.es.js
CHANGED
|
@@ -47,7 +47,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
47
47
|
* @generated
|
|
48
48
|
* @see https://github.com/webgptorg/promptbook
|
|
49
49
|
*/
|
|
50
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.104.0-
|
|
50
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.104.0-12';
|
|
51
51
|
/**
|
|
52
52
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
53
53
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -5410,7 +5410,7 @@ function countUsage(llmTools) {
|
|
|
5410
5410
|
* TODO: [🧠] Is there some meaningfull way how to test this util
|
|
5411
5411
|
* TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
|
|
5412
5412
|
* > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
|
|
5413
|
-
* TODO: [👷♂️]
|
|
5413
|
+
* TODO: [👷♂️] Write a comprehensive manual explaining the construction and usage of LLM tools in the Promptbook ecosystem
|
|
5414
5414
|
*/
|
|
5415
5415
|
|
|
5416
5416
|
/**
|
|
@@ -5663,7 +5663,7 @@ function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
|
5663
5663
|
}
|
|
5664
5664
|
/**
|
|
5665
5665
|
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
5666
|
-
* TODO: [👷♂️]
|
|
5666
|
+
* TODO: [👷♂️] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
|
|
5667
5667
|
*/
|
|
5668
5668
|
|
|
5669
5669
|
/**
|
|
@@ -5848,7 +5848,7 @@ async function $provideLlmToolsForWizardOrCli(options) {
|
|
|
5848
5848
|
}
|
|
5849
5849
|
/**
|
|
5850
5850
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
5851
|
-
* TODO: [👷♂️]
|
|
5851
|
+
* TODO: [👷♂️] Write a comprehensive manual about the construction of LLM tools
|
|
5852
5852
|
* TODO: [🥃] Allow `ptbk make` without llm tools
|
|
5853
5853
|
* TODO: This should be maybe not under `_common` but under `utils-internal` / `utils/internal`
|
|
5854
5854
|
* TODO: [®] DRY Register logic
|
|
@@ -8005,7 +8005,7 @@ function getSingleLlmExecutionTools(oneOrMoreLlmExecutionTools) {
|
|
|
8005
8005
|
}
|
|
8006
8006
|
/**
|
|
8007
8007
|
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
8008
|
-
* TODO: [👷♂️]
|
|
8008
|
+
* TODO: [👷♂️] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
|
|
8009
8009
|
*/
|
|
8010
8010
|
|
|
8011
8011
|
/**
|
|
@@ -19302,6 +19302,22 @@ resultContent, rawResponse) {
|
|
|
19302
19302
|
* TODO: [🤝] DRY Maybe some common abstraction between `computeOpenAiUsage` and `computeAnthropicClaudeUsage`
|
|
19303
19303
|
*/
|
|
19304
19304
|
|
|
19305
|
+
/**
|
|
19306
|
+
* Maps Promptbook tools to OpenAI tools.
|
|
19307
|
+
*
|
|
19308
|
+
* @private
|
|
19309
|
+
*/
|
|
19310
|
+
function mapToolsToOpenAi(tools) {
|
|
19311
|
+
return tools.map((tool) => ({
|
|
19312
|
+
type: 'function',
|
|
19313
|
+
function: {
|
|
19314
|
+
name: tool.name,
|
|
19315
|
+
description: tool.description,
|
|
19316
|
+
parameters: tool.parameters,
|
|
19317
|
+
},
|
|
19318
|
+
}));
|
|
19319
|
+
}
|
|
19320
|
+
|
|
19305
19321
|
/**
|
|
19306
19322
|
* Parses an OpenAI error message to identify which parameter is unsupported
|
|
19307
19323
|
*
|
|
@@ -19499,6 +19515,9 @@ class OpenAiCompatibleExecutionTools {
|
|
|
19499
19515
|
},
|
|
19500
19516
|
],
|
|
19501
19517
|
user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
19518
|
+
tools: currentModelRequirements.tools === undefined
|
|
19519
|
+
? undefined
|
|
19520
|
+
: mapToolsToOpenAi(currentModelRequirements.tools),
|
|
19502
19521
|
};
|
|
19503
19522
|
const start = $getCurrentDate();
|
|
19504
19523
|
if (this.options.isVerbose) {
|
|
@@ -19643,6 +19662,7 @@ class OpenAiCompatibleExecutionTools {
|
|
|
19643
19662
|
const rawPromptContent = templateParameters(content, { ...parameters, modelName });
|
|
19644
19663
|
const rawRequest = {
|
|
19645
19664
|
...modelSettings,
|
|
19665
|
+
model: modelName,
|
|
19646
19666
|
prompt: rawPromptContent,
|
|
19647
19667
|
user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
19648
19668
|
};
|
|
@@ -19897,8 +19917,8 @@ class OpenAiCompatibleExecutionTools {
|
|
|
19897
19917
|
const rawPromptContent = templateParameters(content, { ...parameters, modelName });
|
|
19898
19918
|
const rawRequest = {
|
|
19899
19919
|
...modelSettings,
|
|
19900
|
-
size: modelSettings.size || '1024x1024',
|
|
19901
19920
|
prompt: rawPromptContent,
|
|
19921
|
+
size: modelSettings.size || '1024x1024',
|
|
19902
19922
|
user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
19903
19923
|
response_format: 'url', // TODO: [🧠] Maybe allow b64_json
|
|
19904
19924
|
};
|
|
@@ -20796,6 +20816,7 @@ class OpenAiAssistantExecutionTools extends OpenAiExecutionTools {
|
|
|
20796
20816
|
thread: {
|
|
20797
20817
|
messages: threadMessages,
|
|
20798
20818
|
},
|
|
20819
|
+
tools: modelRequirements.tools === undefined ? undefined : mapToolsToOpenAi(modelRequirements.tools),
|
|
20799
20820
|
// <- TODO: Add user identification here> user: this.options.user,
|
|
20800
20821
|
};
|
|
20801
20822
|
const start = $getCurrentDate();
|
|
@@ -25749,19 +25770,37 @@ class UseBrowserCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
25749
25770
|
`);
|
|
25750
25771
|
}
|
|
25751
25772
|
applyToAgentModelRequirements(requirements, content) {
|
|
25752
|
-
// We simply mark that browser capability is enabled in metadata
|
|
25753
|
-
// Get existing metadata
|
|
25754
|
-
const existingMetadata = requirements.metadata || {};
|
|
25755
25773
|
// Get existing tools array or create new one
|
|
25756
|
-
const existingTools =
|
|
25757
|
-
// Add '
|
|
25758
|
-
const updatedTools = existingTools.
|
|
25759
|
-
|
|
25774
|
+
const existingTools = requirements.tools || [];
|
|
25775
|
+
// Add 'web_browser' to tools if not already present
|
|
25776
|
+
const updatedTools = existingTools.some((tool) => tool.name === 'web_browser')
|
|
25777
|
+
? existingTools
|
|
25778
|
+
: [
|
|
25779
|
+
...existingTools,
|
|
25780
|
+
{
|
|
25781
|
+
name: 'web_browser',
|
|
25782
|
+
description: spaceTrim$1(`
|
|
25783
|
+
A tool that can browse the web.
|
|
25784
|
+
Use this tool when you need to access specific websites or browse the internet.
|
|
25785
|
+
`),
|
|
25786
|
+
parameters: {
|
|
25787
|
+
type: 'object',
|
|
25788
|
+
properties: {
|
|
25789
|
+
url: {
|
|
25790
|
+
type: 'string',
|
|
25791
|
+
description: 'The URL to browse',
|
|
25792
|
+
},
|
|
25793
|
+
},
|
|
25794
|
+
required: ['url'],
|
|
25795
|
+
},
|
|
25796
|
+
},
|
|
25797
|
+
];
|
|
25798
|
+
// Return requirements with updated tools and metadata
|
|
25760
25799
|
return {
|
|
25761
25800
|
...requirements,
|
|
25801
|
+
tools: updatedTools,
|
|
25762
25802
|
metadata: {
|
|
25763
|
-
...
|
|
25764
|
-
tools: updatedTools,
|
|
25803
|
+
...requirements.metadata,
|
|
25765
25804
|
useBrowser: true,
|
|
25766
25805
|
},
|
|
25767
25806
|
};
|
|
@@ -25854,13 +25893,13 @@ class UseMcpCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
25854
25893
|
* The `USE SEARCH ENGINE` commitment indicates that the agent should utilize a search engine tool
|
|
25855
25894
|
* to access and retrieve up-to-date information from the internet when necessary.
|
|
25856
25895
|
*
|
|
25857
|
-
* The content following `USE SEARCH ENGINE` is
|
|
25896
|
+
* The content following `USE SEARCH ENGINE` is an arbitrary text that the agent should know (e.g. search scope or instructions).
|
|
25858
25897
|
*
|
|
25859
25898
|
* Example usage in agent source:
|
|
25860
25899
|
*
|
|
25861
25900
|
* ```book
|
|
25862
25901
|
* USE SEARCH ENGINE
|
|
25863
|
-
* USE SEARCH ENGINE
|
|
25902
|
+
* USE SEARCH ENGINE Hledej informace o Přemyslovcích
|
|
25864
25903
|
* ```
|
|
25865
25904
|
*
|
|
25866
25905
|
* @private [🪔] Maybe export the commitments through some package
|
|
@@ -25892,7 +25931,7 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
25892
25931
|
|
|
25893
25932
|
## Key aspects
|
|
25894
25933
|
|
|
25895
|
-
- The content following \`USE SEARCH ENGINE\` is
|
|
25934
|
+
- The content following \`USE SEARCH ENGINE\` is an arbitrary text that the agent should know (e.g. search scope or instructions).
|
|
25896
25935
|
- The actual search engine tool usage is handled by the agent runtime
|
|
25897
25936
|
- Allows the agent to search for current information from the web
|
|
25898
25937
|
- Useful for research tasks, finding facts, and accessing dynamic content
|
|
@@ -25917,20 +25956,39 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
25917
25956
|
`);
|
|
25918
25957
|
}
|
|
25919
25958
|
applyToAgentModelRequirements(requirements, content) {
|
|
25920
|
-
// We simply mark that search engine capability is enabled in metadata
|
|
25921
|
-
// Get existing metadata
|
|
25922
|
-
const existingMetadata = requirements.metadata || {};
|
|
25923
25959
|
// Get existing tools array or create new one
|
|
25924
|
-
const existingTools =
|
|
25925
|
-
// Add '
|
|
25926
|
-
const updatedTools = existingTools.
|
|
25927
|
-
|
|
25960
|
+
const existingTools = requirements.tools || [];
|
|
25961
|
+
// Add 'web_search' to tools if not already present
|
|
25962
|
+
const updatedTools = existingTools.some((tool) => tool.name === 'web_search')
|
|
25963
|
+
? existingTools
|
|
25964
|
+
: [
|
|
25965
|
+
...existingTools,
|
|
25966
|
+
{
|
|
25967
|
+
name: 'web_search',
|
|
25968
|
+
description: spaceTrim$1(`
|
|
25969
|
+
Search the internet for information.
|
|
25970
|
+
Use this tool when you need to find up-to-date information or facts that you don't know.
|
|
25971
|
+
${!content ? '' : `Search scope / instructions: ${content}`}
|
|
25972
|
+
`),
|
|
25973
|
+
parameters: {
|
|
25974
|
+
type: 'object',
|
|
25975
|
+
properties: {
|
|
25976
|
+
query: {
|
|
25977
|
+
type: 'string',
|
|
25978
|
+
description: 'The search query',
|
|
25979
|
+
},
|
|
25980
|
+
},
|
|
25981
|
+
required: ['query'],
|
|
25982
|
+
},
|
|
25983
|
+
},
|
|
25984
|
+
];
|
|
25985
|
+
// Return requirements with updated tools and metadata
|
|
25928
25986
|
return {
|
|
25929
25987
|
...requirements,
|
|
25988
|
+
tools: updatedTools,
|
|
25930
25989
|
metadata: {
|
|
25931
|
-
...
|
|
25932
|
-
|
|
25933
|
-
useSearchEngine: true,
|
|
25990
|
+
...requirements.metadata,
|
|
25991
|
+
useSearchEngine: content || true,
|
|
25934
25992
|
},
|
|
25935
25993
|
};
|
|
25936
25994
|
}
|
|
@@ -26534,7 +26592,57 @@ function parseAgentSource(agentSource) {
|
|
|
26534
26592
|
}
|
|
26535
26593
|
const meta = {};
|
|
26536
26594
|
const links = [];
|
|
26595
|
+
const capabilities = [];
|
|
26537
26596
|
for (const commitment of parseResult.commitments) {
|
|
26597
|
+
if (commitment.type === 'USE BROWSER') {
|
|
26598
|
+
capabilities.push({
|
|
26599
|
+
type: 'browser',
|
|
26600
|
+
label: 'Browser',
|
|
26601
|
+
iconName: 'Globe',
|
|
26602
|
+
});
|
|
26603
|
+
continue;
|
|
26604
|
+
}
|
|
26605
|
+
if (commitment.type === 'USE SEARCH ENGINE') {
|
|
26606
|
+
capabilities.push({
|
|
26607
|
+
type: 'search-engine',
|
|
26608
|
+
label: 'Search Internet',
|
|
26609
|
+
iconName: 'Search',
|
|
26610
|
+
});
|
|
26611
|
+
continue;
|
|
26612
|
+
}
|
|
26613
|
+
if (commitment.type === 'KNOWLEDGE') {
|
|
26614
|
+
const content = spaceTrim$2(commitment.content).split('\n')[0] || '';
|
|
26615
|
+
let label = content;
|
|
26616
|
+
let iconName = 'Book';
|
|
26617
|
+
if (content.startsWith('http://') || content.startsWith('https://')) {
|
|
26618
|
+
try {
|
|
26619
|
+
const url = new URL(content);
|
|
26620
|
+
if (url.pathname.endsWith('.pdf')) {
|
|
26621
|
+
label = url.pathname.split('/').pop() || 'Document.pdf';
|
|
26622
|
+
iconName = 'FileText';
|
|
26623
|
+
}
|
|
26624
|
+
else {
|
|
26625
|
+
label = url.hostname.replace(/^www\./, '');
|
|
26626
|
+
}
|
|
26627
|
+
}
|
|
26628
|
+
catch (e) {
|
|
26629
|
+
// Invalid URL, treat as text
|
|
26630
|
+
}
|
|
26631
|
+
}
|
|
26632
|
+
else {
|
|
26633
|
+
// Text content - take first few words
|
|
26634
|
+
const words = content.split(/\s+/);
|
|
26635
|
+
if (words.length > 4) {
|
|
26636
|
+
label = words.slice(0, 4).join(' ') + '...';
|
|
26637
|
+
}
|
|
26638
|
+
}
|
|
26639
|
+
capabilities.push({
|
|
26640
|
+
type: 'knowledge',
|
|
26641
|
+
label,
|
|
26642
|
+
iconName,
|
|
26643
|
+
});
|
|
26644
|
+
continue;
|
|
26645
|
+
}
|
|
26538
26646
|
if (commitment.type === 'META LINK') {
|
|
26539
26647
|
const linkValue = spaceTrim$2(commitment.content);
|
|
26540
26648
|
links.push(linkValue);
|
|
@@ -26545,6 +26653,10 @@ function parseAgentSource(agentSource) {
|
|
|
26545
26653
|
meta.image = spaceTrim$2(commitment.content);
|
|
26546
26654
|
continue;
|
|
26547
26655
|
}
|
|
26656
|
+
if (commitment.type === 'META DESCRIPTION') {
|
|
26657
|
+
meta.description = spaceTrim$2(commitment.content);
|
|
26658
|
+
continue;
|
|
26659
|
+
}
|
|
26548
26660
|
if (commitment.type === 'META COLOR') {
|
|
26549
26661
|
meta.color = normalizeSeparator(commitment.content);
|
|
26550
26662
|
continue;
|
|
@@ -26581,6 +26693,7 @@ function parseAgentSource(agentSource) {
|
|
|
26581
26693
|
meta,
|
|
26582
26694
|
links,
|
|
26583
26695
|
parameters,
|
|
26696
|
+
capabilities,
|
|
26584
26697
|
};
|
|
26585
26698
|
}
|
|
26586
26699
|
/**
|