@promptbook/browser 0.104.0-9 → 0.104.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -4
- package/esm/index.es.js +192 -47
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/components.index.d.ts +0 -6
- package/esm/typings/src/_packages/core.index.d.ts +8 -6
- package/esm/typings/src/_packages/types.index.d.ts +8 -0
- package/esm/typings/src/_packages/utils.index.d.ts +2 -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 +12 -2
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirements.tools.test.d.ts +1 -0
- package/esm/typings/src/book-2.0/utils/generatePlaceholderAgentProfileImageUrl.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/save/_common/string_chat_format_name.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +6 -3
- package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +5 -1
- package/esm/typings/src/book-components/_common/HamburgerMenu/HamburgerMenu.d.ts +5 -1
- package/esm/typings/src/book-components/icons/AboutIcon.d.ts +5 -1
- package/esm/typings/src/book-components/icons/AttachmentIcon.d.ts +6 -2
- package/esm/typings/src/book-components/icons/CameraIcon.d.ts +6 -2
- package/esm/typings/src/book-components/icons/DownloadIcon.d.ts +5 -1
- package/esm/typings/src/book-components/icons/MenuIcon.d.ts +5 -1
- package/esm/typings/src/book-components/icons/SaveIcon.d.ts +6 -2
- package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +1 -1
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +9 -7
- package/esm/typings/src/commands/_common/types/Command.d.ts +1 -1
- 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/commitments/_base/BookCommitment.d.ts +1 -1
- package/esm/typings/src/config.d.ts +8 -1
- package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +1 -1
- 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 +8 -4
- 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 +12 -8
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +7 -1
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/utils/mapToolsToOpenAi.d.ts +8 -0
- package/esm/typings/src/remote-server/ui/ServerApp.d.ts +5 -1
- package/esm/typings/src/scrapers/_common/utils/promptbookFetch.test.d.ts +1 -0
- 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/types/typeAliasEmoji.d.ts +2 -2
- package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +7 -2
- package/esm/typings/src/utils/random/$randomItem.d.ts +1 -1
- package/esm/typings/src/utils/random/$randomSeed.d.ts +1 -1
- package/esm/typings/src/utils/validators/url/isValidAgentUrl.d.ts +16 -0
- package/esm/typings/src/utils/validators/url/isValidAgentUrl.test.d.ts +1 -0
- package/esm/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -1
- package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +4 -3
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +192 -47
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/servers.d.ts +0 -50
package/README.md
CHANGED
|
@@ -27,10 +27,6 @@ Turn your company's scattered knowledge into AI ready Books
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
<blockquote style="color: #ff8811">
|
|
31
|
-
<b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
|
|
32
|
-
</blockquote>
|
|
33
|
-
|
|
34
30
|
## 📦 Package `@promptbook/browser`
|
|
35
31
|
|
|
36
32
|
- Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
|
package/esm/index.es.js
CHANGED
|
@@ -19,7 +19,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
19
19
|
* @generated
|
|
20
20
|
* @see https://github.com/webgptorg/promptbook
|
|
21
21
|
*/
|
|
22
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.104.0
|
|
22
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.104.0';
|
|
23
23
|
/**
|
|
24
24
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
25
25
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2208,9 +2208,10 @@ function isValidFilePath(filename) {
|
|
|
2208
2208
|
*
|
|
2209
2209
|
* Note: [🔂] This function is idempotent.
|
|
2210
2210
|
* Note: Dataurl are considered perfectly valid.
|
|
2211
|
-
* Note: There are
|
|
2212
|
-
* - `isValidUrl` which tests any URL
|
|
2213
|
-
* - `
|
|
2211
|
+
* Note: There are few similar functions:
|
|
2212
|
+
* - `isValidUrl` *(this one)* which tests any URL
|
|
2213
|
+
* - `isValidAgentUrl` which tests just agent URL
|
|
2214
|
+
* - `isValidPipelineUrl` which tests just pipeline URL
|
|
2214
2215
|
*
|
|
2215
2216
|
* @public exported from `@promptbook/utils`
|
|
2216
2217
|
*/
|
|
@@ -2488,8 +2489,8 @@ for (let i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
|
|
|
2488
2489
|
*/
|
|
2489
2490
|
function removeDiacritics(input) {
|
|
2490
2491
|
/*eslint no-control-regex: "off"*/
|
|
2491
|
-
return input.replace(/[^\u0000-\u007E]/g, (
|
|
2492
|
-
return DIACRITIC_VARIANTS_LETTERS[
|
|
2492
|
+
return input.replace(/[^\u0000-\u007E]/g, (character) => {
|
|
2493
|
+
return DIACRITIC_VARIANTS_LETTERS[character] || character;
|
|
2493
2494
|
});
|
|
2494
2495
|
}
|
|
2495
2496
|
/**
|
|
@@ -2620,6 +2621,39 @@ function titleToName(value) {
|
|
|
2620
2621
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
2621
2622
|
*/
|
|
2622
2623
|
|
|
2624
|
+
/**
|
|
2625
|
+
* Tests if given string is valid agent URL
|
|
2626
|
+
*
|
|
2627
|
+
* Note: There are few similar functions:
|
|
2628
|
+
* - `isValidUrl` which tests any URL
|
|
2629
|
+
* - `isValidAgentUrl` *(this one)* which tests just agent URL
|
|
2630
|
+
* - `isValidPipelineUrl` which tests just pipeline URL
|
|
2631
|
+
*
|
|
2632
|
+
* @public exported from `@promptbook/utils`
|
|
2633
|
+
*/
|
|
2634
|
+
function isValidAgentUrl(url) {
|
|
2635
|
+
if (!isValidUrl(url)) {
|
|
2636
|
+
return false;
|
|
2637
|
+
}
|
|
2638
|
+
if (!url.startsWith('https://') && !url.startsWith('http://') /* <- Note: [👣] */) {
|
|
2639
|
+
return false;
|
|
2640
|
+
}
|
|
2641
|
+
if (url.includes('#')) {
|
|
2642
|
+
// TODO: [🐠]
|
|
2643
|
+
return false;
|
|
2644
|
+
}
|
|
2645
|
+
/*
|
|
2646
|
+
Note: [👣][🧠] Is it secure to allow pipeline URLs on private and unsecured networks?
|
|
2647
|
+
if (isUrlOnPrivateNetwork(url)) {
|
|
2648
|
+
return false;
|
|
2649
|
+
}
|
|
2650
|
+
*/
|
|
2651
|
+
return true;
|
|
2652
|
+
}
|
|
2653
|
+
/**
|
|
2654
|
+
* TODO: [🐠] Maybe more info why the URL is invalid
|
|
2655
|
+
*/
|
|
2656
|
+
|
|
2623
2657
|
/**
|
|
2624
2658
|
* Normalizes agent name from arbitrary string to valid agent name
|
|
2625
2659
|
*
|
|
@@ -2651,8 +2685,8 @@ function createDefaultAgentName(agentSource) {
|
|
|
2651
2685
|
*/
|
|
2652
2686
|
function createCommitmentRegex(commitment, aliases = [], requiresContent = true) {
|
|
2653
2687
|
const allCommitments = [commitment, ...aliases];
|
|
2654
|
-
const patterns = allCommitments.map((
|
|
2655
|
-
const escapedCommitment =
|
|
2688
|
+
const patterns = allCommitments.map((commitment) => {
|
|
2689
|
+
const escapedCommitment = commitment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
2656
2690
|
return escapedCommitment.split(/\s+/).join('\\s+');
|
|
2657
2691
|
});
|
|
2658
2692
|
const keywordPattern = patterns.join('|');
|
|
@@ -2674,8 +2708,8 @@ function createCommitmentRegex(commitment, aliases = [], requiresContent = true)
|
|
|
2674
2708
|
*/
|
|
2675
2709
|
function createCommitmentTypeRegex(commitment, aliases = []) {
|
|
2676
2710
|
const allCommitments = [commitment, ...aliases];
|
|
2677
|
-
const patterns = allCommitments.map((
|
|
2678
|
-
const escapedCommitment =
|
|
2711
|
+
const patterns = allCommitments.map((commitment) => {
|
|
2712
|
+
const escapedCommitment = commitment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
2679
2713
|
return escapedCommitment.split(/\s+/).join('\\s+');
|
|
2680
2714
|
});
|
|
2681
2715
|
const keywordPattern = patterns.join('|');
|
|
@@ -3185,9 +3219,7 @@ class DictionaryCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
3185
3219
|
// Get existing dictionary entries from metadata
|
|
3186
3220
|
const existingDictionary = ((_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.DICTIONARY) || '';
|
|
3187
3221
|
// Merge the new dictionary entry with existing entries
|
|
3188
|
-
const mergedDictionary = existingDictionary
|
|
3189
|
-
? `${existingDictionary}\n${trimmedContent}`
|
|
3190
|
-
: trimmedContent;
|
|
3222
|
+
const mergedDictionary = existingDictionary ? `${existingDictionary}\n${trimmedContent}` : trimmedContent;
|
|
3191
3223
|
// Store the merged dictionary in metadata for debugging and inspection
|
|
3192
3224
|
const updatedMetadata = {
|
|
3193
3225
|
...requirements.metadata,
|
|
@@ -3338,21 +3370,35 @@ class FromCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
3338
3370
|
applyToAgentModelRequirements(requirements, content) {
|
|
3339
3371
|
const trimmedContent = content.trim();
|
|
3340
3372
|
if (!trimmedContent) {
|
|
3341
|
-
return
|
|
3373
|
+
return {
|
|
3374
|
+
...requirements,
|
|
3375
|
+
parentAgentUrl: undefined,
|
|
3376
|
+
};
|
|
3342
3377
|
}
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3378
|
+
if (trimmedContent.toUpperCase() === 'VOID' ||
|
|
3379
|
+
trimmedContent.toUpperCase() === 'NULL' ||
|
|
3380
|
+
trimmedContent.toUpperCase() === 'NONE' ||
|
|
3381
|
+
trimmedContent.toUpperCase() === 'NIL') {
|
|
3382
|
+
return {
|
|
3383
|
+
...requirements,
|
|
3384
|
+
parentAgentUrl: null,
|
|
3385
|
+
};
|
|
3348
3386
|
}
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3387
|
+
if (!isValidAgentUrl(trimmedContent)) {
|
|
3388
|
+
throw new Error(spaceTrim$1((block) => `
|
|
3389
|
+
Invalid agent URL in FROM commitment: "${trimmedContent}"
|
|
3390
|
+
|
|
3391
|
+
\`\`\`book
|
|
3392
|
+
${block(content)}
|
|
3393
|
+
\`\`\`
|
|
3394
|
+
|
|
3395
|
+
|
|
3396
|
+
`));
|
|
3352
3397
|
}
|
|
3398
|
+
const parentAgentUrl = trimmedContent;
|
|
3353
3399
|
return {
|
|
3354
3400
|
...requirements,
|
|
3355
|
-
parentAgentUrl
|
|
3401
|
+
parentAgentUrl,
|
|
3356
3402
|
};
|
|
3357
3403
|
}
|
|
3358
3404
|
}
|
|
@@ -5716,19 +5762,38 @@ class UseBrowserCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
5716
5762
|
`);
|
|
5717
5763
|
}
|
|
5718
5764
|
applyToAgentModelRequirements(requirements, content) {
|
|
5719
|
-
// We simply mark that browser capability is enabled in metadata
|
|
5720
|
-
// Get existing metadata
|
|
5721
|
-
const existingMetadata = requirements.metadata || {};
|
|
5722
5765
|
// Get existing tools array or create new one
|
|
5723
|
-
const existingTools =
|
|
5724
|
-
// Add '
|
|
5725
|
-
const updatedTools = existingTools.
|
|
5726
|
-
|
|
5766
|
+
const existingTools = requirements.tools || [];
|
|
5767
|
+
// Add 'web_browser' to tools if not already present
|
|
5768
|
+
const updatedTools = existingTools.some((tool) => tool.name === 'web_browser')
|
|
5769
|
+
? existingTools
|
|
5770
|
+
: [
|
|
5771
|
+
// TODO: [🔰] Use through proper MCP server
|
|
5772
|
+
...existingTools,
|
|
5773
|
+
{
|
|
5774
|
+
name: 'web_browser',
|
|
5775
|
+
description: spaceTrim$1(`
|
|
5776
|
+
A tool that can browse the web.
|
|
5777
|
+
Use this tool when you need to access specific websites or browse the internet.
|
|
5778
|
+
`),
|
|
5779
|
+
parameters: {
|
|
5780
|
+
type: 'object',
|
|
5781
|
+
properties: {
|
|
5782
|
+
url: {
|
|
5783
|
+
type: 'string',
|
|
5784
|
+
description: 'The URL to browse',
|
|
5785
|
+
},
|
|
5786
|
+
},
|
|
5787
|
+
required: ['url'],
|
|
5788
|
+
},
|
|
5789
|
+
},
|
|
5790
|
+
];
|
|
5791
|
+
// Return requirements with updated tools and metadata
|
|
5727
5792
|
return {
|
|
5728
5793
|
...requirements,
|
|
5794
|
+
tools: updatedTools,
|
|
5729
5795
|
metadata: {
|
|
5730
|
-
...
|
|
5731
|
-
tools: updatedTools,
|
|
5796
|
+
...requirements.metadata,
|
|
5732
5797
|
useBrowser: true,
|
|
5733
5798
|
},
|
|
5734
5799
|
};
|
|
@@ -5821,13 +5886,13 @@ class UseMcpCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
5821
5886
|
* The `USE SEARCH ENGINE` commitment indicates that the agent should utilize a search engine tool
|
|
5822
5887
|
* to access and retrieve up-to-date information from the internet when necessary.
|
|
5823
5888
|
*
|
|
5824
|
-
* The content following `USE SEARCH ENGINE` is
|
|
5889
|
+
* The content following `USE SEARCH ENGINE` is an arbitrary text that the agent should know (e.g. search scope or instructions).
|
|
5825
5890
|
*
|
|
5826
5891
|
* Example usage in agent source:
|
|
5827
5892
|
*
|
|
5828
5893
|
* ```book
|
|
5829
5894
|
* USE SEARCH ENGINE
|
|
5830
|
-
* USE SEARCH ENGINE
|
|
5895
|
+
* USE SEARCH ENGINE Hledej informace o Přemyslovcích
|
|
5831
5896
|
* ```
|
|
5832
5897
|
*
|
|
5833
5898
|
* @private [🪔] Maybe export the commitments through some package
|
|
@@ -5859,7 +5924,7 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
5859
5924
|
|
|
5860
5925
|
## Key aspects
|
|
5861
5926
|
|
|
5862
|
-
- The content following \`USE SEARCH ENGINE\` is
|
|
5927
|
+
- The content following \`USE SEARCH ENGINE\` is an arbitrary text that the agent should know (e.g. search scope or instructions).
|
|
5863
5928
|
- The actual search engine tool usage is handled by the agent runtime
|
|
5864
5929
|
- Allows the agent to search for current information from the web
|
|
5865
5930
|
- Useful for research tasks, finding facts, and accessing dynamic content
|
|
@@ -5884,20 +5949,45 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
5884
5949
|
`);
|
|
5885
5950
|
}
|
|
5886
5951
|
applyToAgentModelRequirements(requirements, content) {
|
|
5887
|
-
// We simply mark that search engine capability is enabled in metadata
|
|
5888
|
-
// Get existing metadata
|
|
5889
|
-
const existingMetadata = requirements.metadata || {};
|
|
5890
5952
|
// Get existing tools array or create new one
|
|
5891
|
-
const existingTools =
|
|
5892
|
-
// Add '
|
|
5893
|
-
const updatedTools = existingTools.
|
|
5894
|
-
|
|
5953
|
+
const existingTools = requirements.tools || [];
|
|
5954
|
+
// Add 'web_search' to tools if not already present
|
|
5955
|
+
const updatedTools = existingTools.some((tool) => tool.name === 'web_search')
|
|
5956
|
+
? existingTools
|
|
5957
|
+
: [
|
|
5958
|
+
...existingTools,
|
|
5959
|
+
{ type: 'web_search' },
|
|
5960
|
+
// <- Note: [🔰] This is just using simple native search tool by OpenAI @see https://platform.openai.com/docs/guides/tools-web-search
|
|
5961
|
+
// In future we will use proper MCP search tool:
|
|
5962
|
+
/*
|
|
5963
|
+
|
|
5964
|
+
{
|
|
5965
|
+
name: 'web_search',
|
|
5966
|
+
description: spaceTrim(`
|
|
5967
|
+
Search the internet for information.
|
|
5968
|
+
Use this tool when you need to find up-to-date information or facts that you don't know.
|
|
5969
|
+
${!content ? '' : `Search scope / instructions: ${content}`}
|
|
5970
|
+
`),
|
|
5971
|
+
parameters: {
|
|
5972
|
+
type: 'object',
|
|
5973
|
+
properties: {
|
|
5974
|
+
query: {
|
|
5975
|
+
type: 'string',
|
|
5976
|
+
description: 'The search query',
|
|
5977
|
+
},
|
|
5978
|
+
},
|
|
5979
|
+
required: ['query'],
|
|
5980
|
+
},
|
|
5981
|
+
},
|
|
5982
|
+
*/
|
|
5983
|
+
];
|
|
5984
|
+
// Return requirements with updated tools and metadata
|
|
5895
5985
|
return {
|
|
5896
5986
|
...requirements,
|
|
5987
|
+
tools: updatedTools,
|
|
5897
5988
|
metadata: {
|
|
5898
|
-
...
|
|
5899
|
-
|
|
5900
|
-
useSearchEngine: true,
|
|
5989
|
+
...requirements.metadata,
|
|
5990
|
+
useSearchEngine: content || true,
|
|
5901
5991
|
},
|
|
5902
5992
|
};
|
|
5903
5993
|
}
|
|
@@ -6258,8 +6348,8 @@ function parseParameters(text) {
|
|
|
6258
6348
|
return match;
|
|
6259
6349
|
});
|
|
6260
6350
|
// Remove duplicates based on name (keep the first occurrence)
|
|
6261
|
-
const uniqueParameters = parameters.filter((
|
|
6262
|
-
return array.findIndex((
|
|
6351
|
+
const uniqueParameters = parameters.filter((parameter, index, array) => {
|
|
6352
|
+
return array.findIndex((parameterItem) => parameterItem.name === parameter.name) === index;
|
|
6263
6353
|
});
|
|
6264
6354
|
return uniqueParameters;
|
|
6265
6355
|
}
|
|
@@ -6301,7 +6391,57 @@ function parseAgentSource(agentSource) {
|
|
|
6301
6391
|
}
|
|
6302
6392
|
const meta = {};
|
|
6303
6393
|
const links = [];
|
|
6394
|
+
const capabilities = [];
|
|
6304
6395
|
for (const commitment of parseResult.commitments) {
|
|
6396
|
+
if (commitment.type === 'USE BROWSER') {
|
|
6397
|
+
capabilities.push({
|
|
6398
|
+
type: 'browser',
|
|
6399
|
+
label: 'Browser',
|
|
6400
|
+
iconName: 'Globe',
|
|
6401
|
+
});
|
|
6402
|
+
continue;
|
|
6403
|
+
}
|
|
6404
|
+
if (commitment.type === 'USE SEARCH ENGINE') {
|
|
6405
|
+
capabilities.push({
|
|
6406
|
+
type: 'search-engine',
|
|
6407
|
+
label: 'Search Internet',
|
|
6408
|
+
iconName: 'Search',
|
|
6409
|
+
});
|
|
6410
|
+
continue;
|
|
6411
|
+
}
|
|
6412
|
+
if (commitment.type === 'KNOWLEDGE') {
|
|
6413
|
+
const content = spaceTrim$2(commitment.content).split('\n')[0] || '';
|
|
6414
|
+
let label = content;
|
|
6415
|
+
let iconName = 'Book';
|
|
6416
|
+
if (content.startsWith('http://') || content.startsWith('https://')) {
|
|
6417
|
+
try {
|
|
6418
|
+
const url = new URL(content);
|
|
6419
|
+
if (url.pathname.endsWith('.pdf')) {
|
|
6420
|
+
label = url.pathname.split('/').pop() || 'Document.pdf';
|
|
6421
|
+
iconName = 'FileText';
|
|
6422
|
+
}
|
|
6423
|
+
else {
|
|
6424
|
+
label = url.hostname.replace(/^www\./, '');
|
|
6425
|
+
}
|
|
6426
|
+
}
|
|
6427
|
+
catch (e) {
|
|
6428
|
+
// Invalid URL, treat as text
|
|
6429
|
+
}
|
|
6430
|
+
}
|
|
6431
|
+
else {
|
|
6432
|
+
// Text content - take first few words
|
|
6433
|
+
const words = content.split(/\s+/);
|
|
6434
|
+
if (words.length > 4) {
|
|
6435
|
+
label = words.slice(0, 4).join(' ') + '...';
|
|
6436
|
+
}
|
|
6437
|
+
}
|
|
6438
|
+
capabilities.push({
|
|
6439
|
+
type: 'knowledge',
|
|
6440
|
+
label,
|
|
6441
|
+
iconName,
|
|
6442
|
+
});
|
|
6443
|
+
continue;
|
|
6444
|
+
}
|
|
6305
6445
|
if (commitment.type === 'META LINK') {
|
|
6306
6446
|
const linkValue = spaceTrim$2(commitment.content);
|
|
6307
6447
|
links.push(linkValue);
|
|
@@ -6312,6 +6452,10 @@ function parseAgentSource(agentSource) {
|
|
|
6312
6452
|
meta.image = spaceTrim$2(commitment.content);
|
|
6313
6453
|
continue;
|
|
6314
6454
|
}
|
|
6455
|
+
if (commitment.type === 'META DESCRIPTION') {
|
|
6456
|
+
meta.description = spaceTrim$2(commitment.content);
|
|
6457
|
+
continue;
|
|
6458
|
+
}
|
|
6315
6459
|
if (commitment.type === 'META COLOR') {
|
|
6316
6460
|
meta.color = normalizeSeparator(commitment.content);
|
|
6317
6461
|
continue;
|
|
@@ -6348,6 +6492,7 @@ function parseAgentSource(agentSource) {
|
|
|
6348
6492
|
meta,
|
|
6349
6493
|
links,
|
|
6350
6494
|
parameters,
|
|
6495
|
+
capabilities,
|
|
6351
6496
|
};
|
|
6352
6497
|
}
|
|
6353
6498
|
/**
|