@promptbook/browser 0.105.0-6 → 0.105.0-8
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 +74 -12
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/commitments/NOTE/NOTE.d.ts +2 -2
- package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +6 -0
- package/esm/typings/src/commitments/index.d.ts +1 -1
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +1 -0
- package/esm/typings/src/llm-providers/agent/AgentOptions.d.ts +7 -0
- package/esm/typings/src/llm-providers/agent/RemoteAgentOptions.d.ts +1 -1
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +74 -12
- package/umd/index.umd.js.map +1 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { string_javascript_name } from '../../_packages/types.index';
|
|
1
2
|
import type { AgentModelRequirements } from '../../book-2.0/agent-source/AgentModelRequirements';
|
|
3
|
+
import { ToolFunction } from '../../scripting/javascript/JavascriptExecutionToolsOptions';
|
|
2
4
|
import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
|
|
3
5
|
/**
|
|
4
6
|
* USE SEARCH ENGINE commitment definition
|
|
@@ -32,6 +34,10 @@ export declare class UseSearchEngineCommitmentDefinition extends BaseCommitmentD
|
|
|
32
34
|
*/
|
|
33
35
|
get documentation(): string;
|
|
34
36
|
applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
|
|
37
|
+
/**
|
|
38
|
+
* Gets the `web_search` tool function implementation.
|
|
39
|
+
*/
|
|
40
|
+
getToolFunctions(): Record<string_javascript_name, ToolFunction>;
|
|
35
41
|
}
|
|
36
42
|
/**
|
|
37
43
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -44,7 +44,7 @@ import { NotYetImplementedCommitmentDefinition } from './_base/NotYetImplemented
|
|
|
44
44
|
*
|
|
45
45
|
* @private Use functions to access commitments instead of this array directly
|
|
46
46
|
*/
|
|
47
|
-
export declare const COMMITMENT_REGISTRY: readonly [PersonaCommitmentDefinition, PersonaCommitmentDefinition, KnowledgeCommitmentDefinition, MemoryCommitmentDefinition, MemoryCommitmentDefinition, StyleCommitmentDefinition, StyleCommitmentDefinition, RuleCommitmentDefinition, RuleCommitmentDefinition, LanguageCommitmentDefinition, LanguageCommitmentDefinition, SampleCommitmentDefinition, SampleCommitmentDefinition, FormatCommitmentDefinition, FormatCommitmentDefinition, FromCommitmentDefinition, ImportCommitmentDefinition, ImportCommitmentDefinition, ModelCommitmentDefinition, ModelCommitmentDefinition, ActionCommitmentDefinition, ActionCommitmentDefinition, ComponentCommitmentDefinition, MetaImageCommitmentDefinition, MetaColorCommitmentDefinition, MetaFontCommitmentDefinition, MetaLinkCommitmentDefinition, MetaCommitmentDefinition, NoteCommitmentDefinition, NoteCommitmentDefinition, NoteCommitmentDefinition, NoteCommitmentDefinition, GoalCommitmentDefinition, GoalCommitmentDefinition, InitialMessageCommitmentDefinition, UserMessageCommitmentDefinition, AgentMessageCommitmentDefinition, MessageCommitmentDefinition, MessageCommitmentDefinition, ScenarioCommitmentDefinition, ScenarioCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, DictionaryCommitmentDefinition, OpenCommitmentDefinition, ClosedCommitmentDefinition, UseBrowserCommitmentDefinition, UseSearchEngineCommitmentDefinition, UseTimeCommitmentDefinition, UseMcpCommitmentDefinition, UseCommitmentDefinition, NotYetImplementedCommitmentDefinition<"EXPECT">, NotYetImplementedCommitmentDefinition<"BEHAVIOUR">, NotYetImplementedCommitmentDefinition<"BEHAVIOURS">, NotYetImplementedCommitmentDefinition<"AVOID">, NotYetImplementedCommitmentDefinition<"AVOIDANCE">, NotYetImplementedCommitmentDefinition<"CONTEXT">];
|
|
47
|
+
export declare const COMMITMENT_REGISTRY: readonly [PersonaCommitmentDefinition, PersonaCommitmentDefinition, KnowledgeCommitmentDefinition, MemoryCommitmentDefinition, MemoryCommitmentDefinition, StyleCommitmentDefinition, StyleCommitmentDefinition, RuleCommitmentDefinition, RuleCommitmentDefinition, LanguageCommitmentDefinition, LanguageCommitmentDefinition, SampleCommitmentDefinition, SampleCommitmentDefinition, FormatCommitmentDefinition, FormatCommitmentDefinition, FromCommitmentDefinition, ImportCommitmentDefinition, ImportCommitmentDefinition, ModelCommitmentDefinition, ModelCommitmentDefinition, ActionCommitmentDefinition, ActionCommitmentDefinition, ComponentCommitmentDefinition, MetaImageCommitmentDefinition, MetaColorCommitmentDefinition, MetaFontCommitmentDefinition, MetaLinkCommitmentDefinition, MetaCommitmentDefinition, NoteCommitmentDefinition, NoteCommitmentDefinition, NoteCommitmentDefinition, NoteCommitmentDefinition, NoteCommitmentDefinition, GoalCommitmentDefinition, GoalCommitmentDefinition, InitialMessageCommitmentDefinition, UserMessageCommitmentDefinition, AgentMessageCommitmentDefinition, MessageCommitmentDefinition, MessageCommitmentDefinition, ScenarioCommitmentDefinition, ScenarioCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, DictionaryCommitmentDefinition, OpenCommitmentDefinition, ClosedCommitmentDefinition, UseBrowserCommitmentDefinition, UseSearchEngineCommitmentDefinition, UseTimeCommitmentDefinition, UseMcpCommitmentDefinition, UseCommitmentDefinition, NotYetImplementedCommitmentDefinition<"EXPECT">, NotYetImplementedCommitmentDefinition<"BEHAVIOUR">, NotYetImplementedCommitmentDefinition<"BEHAVIOURS">, NotYetImplementedCommitmentDefinition<"AVOID">, NotYetImplementedCommitmentDefinition<"AVOIDANCE">, NotYetImplementedCommitmentDefinition<"CONTEXT">];
|
|
48
48
|
/**
|
|
49
49
|
* Gets a commitment definition by its type
|
|
50
50
|
* @param type The commitment type to look up
|
|
@@ -72,6 +72,7 @@ export declare class Agent extends AgentLlmExecutionTools implements LlmExecutio
|
|
|
72
72
|
*/
|
|
73
73
|
get parameters(): Array<BookParameter>;
|
|
74
74
|
readonly agentSource: BehaviorSubject<string_book>;
|
|
75
|
+
private readonly teacherAgent;
|
|
75
76
|
constructor(options: AgentOptions);
|
|
76
77
|
/**
|
|
77
78
|
* Calls the chat model with agent-specific system prompt and requirements with streaming
|
|
@@ -2,6 +2,7 @@ import type { string_book } from '../../book-2.0/agent-source/string_book';
|
|
|
2
2
|
import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
|
|
3
3
|
import type { ExecutionTools } from '../../execution/ExecutionTools';
|
|
4
4
|
import type { Updatable } from '../../types/Updatable';
|
|
5
|
+
import { Agent } from './Agent';
|
|
5
6
|
/**
|
|
6
7
|
* Options for creating an Agent
|
|
7
8
|
*/
|
|
@@ -16,4 +17,10 @@ export type AgentOptions = CommonToolsOptions & {
|
|
|
16
17
|
* The source of the agent
|
|
17
18
|
*/
|
|
18
19
|
agentSource: Updatable<string_book>;
|
|
20
|
+
/**
|
|
21
|
+
* Teacher agent for self-learning
|
|
22
|
+
*
|
|
23
|
+
* Note: If provided, the agent can do full self-learning from the teacher agent during its operation.
|
|
24
|
+
*/
|
|
25
|
+
teacherAgent: Agent | null;
|
|
19
26
|
};
|
|
@@ -3,7 +3,7 @@ import type { string_agent_url } from '../../types/typeAliases';
|
|
|
3
3
|
/**
|
|
4
4
|
* Options for creating a Remote Agent
|
|
5
5
|
*/
|
|
6
|
-
export type RemoteAgentOptions = CommonToolsOptions & {
|
|
6
|
+
export type RemoteAgentOptions = Omit<CommonToolsOptions, 'teacherAgent'> & {
|
|
7
7
|
/**
|
|
8
8
|
* Url of the remote agent
|
|
9
9
|
*/
|
|
@@ -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.105.0-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.105.0-7`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/browser",
|
|
3
|
-
"version": "0.105.0-
|
|
3
|
+
"version": "0.105.0-8",
|
|
4
4
|
"description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"module": "./esm/index.es.js",
|
|
95
95
|
"typings": "./esm/typings/src/_packages/browser.index.d.ts",
|
|
96
96
|
"peerDependencies": {
|
|
97
|
-
"@promptbook/core": "0.105.0-
|
|
97
|
+
"@promptbook/core": "0.105.0-8"
|
|
98
98
|
},
|
|
99
99
|
"dependencies": {
|
|
100
100
|
"crypto": "1.0.1",
|
package/umd/index.umd.js
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* @generated
|
|
24
24
|
* @see https://github.com/webgptorg/promptbook
|
|
25
25
|
*/
|
|
26
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-
|
|
26
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-8';
|
|
27
27
|
/**
|
|
28
28
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
29
29
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -6067,6 +6067,46 @@
|
|
|
6067
6067
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
6068
6068
|
*/
|
|
6069
6069
|
|
|
6070
|
+
/**
|
|
6071
|
+
* A search engine implementation that uses the SerpApi to fetch Google search results.
|
|
6072
|
+
*
|
|
6073
|
+
* @private <- TODO: !!!! Export via some package
|
|
6074
|
+
*/
|
|
6075
|
+
class SerpSearchEngine {
|
|
6076
|
+
get title() {
|
|
6077
|
+
return 'SerpApi Search Engine';
|
|
6078
|
+
}
|
|
6079
|
+
get description() {
|
|
6080
|
+
return 'Search engine that uses SerpApi to fetch Google search results';
|
|
6081
|
+
}
|
|
6082
|
+
checkConfiguration() {
|
|
6083
|
+
if (!process.env.SERP_API_KEY) {
|
|
6084
|
+
throw new Error('SERP_API_KEY is not configured');
|
|
6085
|
+
}
|
|
6086
|
+
}
|
|
6087
|
+
async search(query) {
|
|
6088
|
+
const apiKey = process.env.SERP_API_KEY;
|
|
6089
|
+
if (!apiKey) {
|
|
6090
|
+
throw new Error('SERP_API_KEY is not configured');
|
|
6091
|
+
}
|
|
6092
|
+
const url = new URL('https://serpapi.com/search');
|
|
6093
|
+
url.searchParams.set('q', query);
|
|
6094
|
+
url.searchParams.set('api_key', apiKey);
|
|
6095
|
+
url.searchParams.set('engine', 'google');
|
|
6096
|
+
const response = await fetch(url.toString());
|
|
6097
|
+
if (!response.ok) {
|
|
6098
|
+
const body = await response.text();
|
|
6099
|
+
throw new Error(`SerpApi failed with status ${response.status}: ${response.statusText}\n${body}`);
|
|
6100
|
+
}
|
|
6101
|
+
const data = (await response.json());
|
|
6102
|
+
return (data.organic_results || []).map((item) => ({
|
|
6103
|
+
title: item.title,
|
|
6104
|
+
url: item.link,
|
|
6105
|
+
snippet: item.snippet || '',
|
|
6106
|
+
}));
|
|
6107
|
+
}
|
|
6108
|
+
}
|
|
6109
|
+
|
|
6070
6110
|
/**
|
|
6071
6111
|
* USE SEARCH ENGINE commitment definition
|
|
6072
6112
|
*
|
|
@@ -6143,18 +6183,13 @@
|
|
|
6143
6183
|
? existingTools
|
|
6144
6184
|
: [
|
|
6145
6185
|
...existingTools,
|
|
6146
|
-
{ type: 'web_search' },
|
|
6147
|
-
// <- Note: [🔰] This is just using simple native search tool by OpenAI @see https://platform.openai.com/docs/guides/tools-web-search
|
|
6148
|
-
// In future we will use proper MCP search tool:
|
|
6149
|
-
/*
|
|
6150
|
-
|
|
6151
6186
|
{
|
|
6152
6187
|
name: 'web_search',
|
|
6153
|
-
description: spaceTrim(`
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6188
|
+
description: spaceTrim$1.spaceTrim(`
|
|
6189
|
+
Search the internet for information.
|
|
6190
|
+
Use this tool when you need to find up-to-date information or facts that you don't know.
|
|
6191
|
+
${!content ? '' : `Search scope / instructions: ${content}`}
|
|
6192
|
+
`),
|
|
6158
6193
|
parameters: {
|
|
6159
6194
|
type: 'object',
|
|
6160
6195
|
properties: {
|
|
@@ -6166,7 +6201,6 @@
|
|
|
6166
6201
|
required: ['query'],
|
|
6167
6202
|
},
|
|
6168
6203
|
},
|
|
6169
|
-
*/
|
|
6170
6204
|
];
|
|
6171
6205
|
// Return requirements with updated tools and metadata
|
|
6172
6206
|
return {
|
|
@@ -6178,6 +6212,33 @@
|
|
|
6178
6212
|
},
|
|
6179
6213
|
};
|
|
6180
6214
|
}
|
|
6215
|
+
/**
|
|
6216
|
+
* Gets the `web_search` tool function implementation.
|
|
6217
|
+
*/
|
|
6218
|
+
getToolFunctions() {
|
|
6219
|
+
return {
|
|
6220
|
+
async web_search(args) {
|
|
6221
|
+
console.log('!!!! [Tool] web_search called', { args });
|
|
6222
|
+
const { query } = args;
|
|
6223
|
+
if (!query) {
|
|
6224
|
+
throw new Error('Search query is required');
|
|
6225
|
+
}
|
|
6226
|
+
const searchEngine = new SerpSearchEngine();
|
|
6227
|
+
const results = await searchEngine.search(query);
|
|
6228
|
+
return spaceTrim$1.spaceTrim((block) => `
|
|
6229
|
+
Search results for "${query}":
|
|
6230
|
+
|
|
6231
|
+
${block(results
|
|
6232
|
+
.map((result) => spaceTrim$1.spaceTrim(`
|
|
6233
|
+
- **${result.title}**
|
|
6234
|
+
${result.url}
|
|
6235
|
+
${result.snippet}
|
|
6236
|
+
`))
|
|
6237
|
+
.join('\n\n'))}
|
|
6238
|
+
`);
|
|
6239
|
+
},
|
|
6240
|
+
};
|
|
6241
|
+
}
|
|
6181
6242
|
}
|
|
6182
6243
|
/**
|
|
6183
6244
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -6421,6 +6482,7 @@
|
|
|
6421
6482
|
new NoteCommitmentDefinition('NOTES'),
|
|
6422
6483
|
new NoteCommitmentDefinition('COMMENT'),
|
|
6423
6484
|
new NoteCommitmentDefinition('NONCE'),
|
|
6485
|
+
new NoteCommitmentDefinition('TODO'),
|
|
6424
6486
|
new GoalCommitmentDefinition('GOAL'),
|
|
6425
6487
|
new GoalCommitmentDefinition('GOALS'),
|
|
6426
6488
|
new InitialMessageCommitmentDefinition(),
|