@promptbook/remote-server 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 +92 -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 +92 -12
- package/umd/index.umd.js.map +1 -1
|
@@ -26,8 +26,8 @@ import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
|
|
|
26
26
|
*
|
|
27
27
|
* @private [🪔] Maybe export the commitments through some package
|
|
28
28
|
*/
|
|
29
|
-
export declare class NoteCommitmentDefinition extends BaseCommitmentDefinition<'NOTE' | 'NOTES' | 'COMMENT' | 'NONCE'> {
|
|
30
|
-
constructor(type?: 'NOTE' | 'NOTES' | 'COMMENT' | 'NONCE');
|
|
29
|
+
export declare class NoteCommitmentDefinition extends BaseCommitmentDefinition<'NOTE' | 'NOTES' | 'COMMENT' | 'NONCE' | 'TODO'> {
|
|
30
|
+
constructor(type?: 'NOTE' | 'NOTES' | 'COMMENT' | 'NONCE' | 'TODO');
|
|
31
31
|
/**
|
|
32
32
|
* Short one-line description of NOTE.
|
|
33
33
|
*/
|
|
@@ -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/remote-server",
|
|
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,
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"module": "./esm/index.es.js",
|
|
96
96
|
"typings": "./esm/typings/src/_packages/remote-server.index.d.ts",
|
|
97
97
|
"peerDependencies": {
|
|
98
|
-
"@promptbook/core": "0.105.0-
|
|
98
|
+
"@promptbook/core": "0.105.0-8"
|
|
99
99
|
},
|
|
100
100
|
"dependencies": {
|
|
101
101
|
"colors": "1.4.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
* @generated
|
|
48
48
|
* @see https://github.com/webgptorg/promptbook
|
|
49
49
|
*/
|
|
50
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-
|
|
50
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-8';
|
|
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
|
|
@@ -8175,6 +8175,16 @@
|
|
|
8175
8175
|
trimmedText = spaceTrim$1.spaceTrim(trimmedText);
|
|
8176
8176
|
}
|
|
8177
8177
|
let processedText = trimmedText;
|
|
8178
|
+
// Check for markdown code block
|
|
8179
|
+
const codeBlockRegex = /^```[a-z]*\n([\s\S]*?)\n```\s*$/;
|
|
8180
|
+
const codeBlockMatch = processedText.match(codeBlockRegex);
|
|
8181
|
+
if (codeBlockMatch && codeBlockMatch[1] !== undefined) {
|
|
8182
|
+
// Check if there's only one code block
|
|
8183
|
+
const codeBlockCount = (processedText.match(/```/g) || []).length / 2;
|
|
8184
|
+
if (codeBlockCount === 1) {
|
|
8185
|
+
return unwrapResult(codeBlockMatch[1], { isTrimmed: false, isIntroduceSentenceRemoved: false });
|
|
8186
|
+
}
|
|
8187
|
+
}
|
|
8178
8188
|
if (isIntroduceSentenceRemoved) {
|
|
8179
8189
|
const introduceSentenceRegex = /^[a-zěščřžýáíéúů:\s]*:\s*/i;
|
|
8180
8190
|
if (introduceSentenceRegex.test(text)) {
|
|
@@ -8182,6 +8192,14 @@
|
|
|
8182
8192
|
processedText = processedText.replace(introduceSentenceRegex, '');
|
|
8183
8193
|
}
|
|
8184
8194
|
processedText = spaceTrim$1.spaceTrim(processedText);
|
|
8195
|
+
// Check again for code block after removing introduce sentence
|
|
8196
|
+
const codeBlockMatch2 = processedText.match(codeBlockRegex);
|
|
8197
|
+
if (codeBlockMatch2 && codeBlockMatch2[1] !== undefined) {
|
|
8198
|
+
const codeBlockCount = (processedText.match(/```/g) || []).length / 2;
|
|
8199
|
+
if (codeBlockCount === 1) {
|
|
8200
|
+
return unwrapResult(codeBlockMatch2[1], { isTrimmed: false, isIntroduceSentenceRemoved: false });
|
|
8201
|
+
}
|
|
8202
|
+
}
|
|
8185
8203
|
}
|
|
8186
8204
|
if (processedText.length < 3) {
|
|
8187
8205
|
return trimmedText;
|
|
@@ -11547,6 +11565,46 @@
|
|
|
11547
11565
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
11548
11566
|
*/
|
|
11549
11567
|
|
|
11568
|
+
/**
|
|
11569
|
+
* A search engine implementation that uses the SerpApi to fetch Google search results.
|
|
11570
|
+
*
|
|
11571
|
+
* @private <- TODO: !!!! Export via some package
|
|
11572
|
+
*/
|
|
11573
|
+
class SerpSearchEngine {
|
|
11574
|
+
get title() {
|
|
11575
|
+
return 'SerpApi Search Engine';
|
|
11576
|
+
}
|
|
11577
|
+
get description() {
|
|
11578
|
+
return 'Search engine that uses SerpApi to fetch Google search results';
|
|
11579
|
+
}
|
|
11580
|
+
checkConfiguration() {
|
|
11581
|
+
if (!process.env.SERP_API_KEY) {
|
|
11582
|
+
throw new Error('SERP_API_KEY is not configured');
|
|
11583
|
+
}
|
|
11584
|
+
}
|
|
11585
|
+
async search(query) {
|
|
11586
|
+
const apiKey = process.env.SERP_API_KEY;
|
|
11587
|
+
if (!apiKey) {
|
|
11588
|
+
throw new Error('SERP_API_KEY is not configured');
|
|
11589
|
+
}
|
|
11590
|
+
const url = new URL('https://serpapi.com/search');
|
|
11591
|
+
url.searchParams.set('q', query);
|
|
11592
|
+
url.searchParams.set('api_key', apiKey);
|
|
11593
|
+
url.searchParams.set('engine', 'google');
|
|
11594
|
+
const response = await fetch(url.toString());
|
|
11595
|
+
if (!response.ok) {
|
|
11596
|
+
const body = await response.text();
|
|
11597
|
+
throw new Error(`SerpApi failed with status ${response.status}: ${response.statusText}\n${body}`);
|
|
11598
|
+
}
|
|
11599
|
+
const data = (await response.json());
|
|
11600
|
+
return (data.organic_results || []).map((item) => ({
|
|
11601
|
+
title: item.title,
|
|
11602
|
+
url: item.link,
|
|
11603
|
+
snippet: item.snippet || '',
|
|
11604
|
+
}));
|
|
11605
|
+
}
|
|
11606
|
+
}
|
|
11607
|
+
|
|
11550
11608
|
/**
|
|
11551
11609
|
* USE SEARCH ENGINE commitment definition
|
|
11552
11610
|
*
|
|
@@ -11623,18 +11681,13 @@
|
|
|
11623
11681
|
? existingTools
|
|
11624
11682
|
: [
|
|
11625
11683
|
...existingTools,
|
|
11626
|
-
{ type: 'web_search' },
|
|
11627
|
-
// <- Note: [🔰] This is just using simple native search tool by OpenAI @see https://platform.openai.com/docs/guides/tools-web-search
|
|
11628
|
-
// In future we will use proper MCP search tool:
|
|
11629
|
-
/*
|
|
11630
|
-
|
|
11631
11684
|
{
|
|
11632
11685
|
name: 'web_search',
|
|
11633
|
-
description: spaceTrim(`
|
|
11634
|
-
|
|
11635
|
-
|
|
11636
|
-
|
|
11637
|
-
|
|
11686
|
+
description: spaceTrim$1.spaceTrim(`
|
|
11687
|
+
Search the internet for information.
|
|
11688
|
+
Use this tool when you need to find up-to-date information or facts that you don't know.
|
|
11689
|
+
${!content ? '' : `Search scope / instructions: ${content}`}
|
|
11690
|
+
`),
|
|
11638
11691
|
parameters: {
|
|
11639
11692
|
type: 'object',
|
|
11640
11693
|
properties: {
|
|
@@ -11646,7 +11699,6 @@
|
|
|
11646
11699
|
required: ['query'],
|
|
11647
11700
|
},
|
|
11648
11701
|
},
|
|
11649
|
-
*/
|
|
11650
11702
|
];
|
|
11651
11703
|
// Return requirements with updated tools and metadata
|
|
11652
11704
|
return {
|
|
@@ -11658,6 +11710,33 @@
|
|
|
11658
11710
|
},
|
|
11659
11711
|
};
|
|
11660
11712
|
}
|
|
11713
|
+
/**
|
|
11714
|
+
* Gets the `web_search` tool function implementation.
|
|
11715
|
+
*/
|
|
11716
|
+
getToolFunctions() {
|
|
11717
|
+
return {
|
|
11718
|
+
async web_search(args) {
|
|
11719
|
+
console.log('!!!! [Tool] web_search called', { args });
|
|
11720
|
+
const { query } = args;
|
|
11721
|
+
if (!query) {
|
|
11722
|
+
throw new Error('Search query is required');
|
|
11723
|
+
}
|
|
11724
|
+
const searchEngine = new SerpSearchEngine();
|
|
11725
|
+
const results = await searchEngine.search(query);
|
|
11726
|
+
return spaceTrim$1.spaceTrim((block) => `
|
|
11727
|
+
Search results for "${query}":
|
|
11728
|
+
|
|
11729
|
+
${block(results
|
|
11730
|
+
.map((result) => spaceTrim$1.spaceTrim(`
|
|
11731
|
+
- **${result.title}**
|
|
11732
|
+
${result.url}
|
|
11733
|
+
${result.snippet}
|
|
11734
|
+
`))
|
|
11735
|
+
.join('\n\n'))}
|
|
11736
|
+
`);
|
|
11737
|
+
},
|
|
11738
|
+
};
|
|
11739
|
+
}
|
|
11661
11740
|
}
|
|
11662
11741
|
/**
|
|
11663
11742
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -11901,6 +11980,7 @@
|
|
|
11901
11980
|
new NoteCommitmentDefinition('NOTES'),
|
|
11902
11981
|
new NoteCommitmentDefinition('COMMENT'),
|
|
11903
11982
|
new NoteCommitmentDefinition('NONCE'),
|
|
11983
|
+
new NoteCommitmentDefinition('TODO'),
|
|
11904
11984
|
new GoalCommitmentDefinition('GOAL'),
|
|
11905
11985
|
new GoalCommitmentDefinition('GOALS'),
|
|
11906
11986
|
new InitialMessageCommitmentDefinition(),
|