@promptbook/browser 0.104.0 → 0.105.0-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 +4 -0
- package/esm/index.es.js +78 -3
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +2 -0
- package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +4 -0
- package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +17 -0
- package/esm/typings/src/commitments/IMPORT/IMPORT.d.ts +34 -0
- package/esm/typings/src/commitments/index.d.ts +2 -1
- package/esm/typings/src/config.d.ts +6 -0
- package/esm/typings/src/errors/utils/deserializeError.d.ts +1 -1
- package/esm/typings/src/execution/PromptResult.d.ts +24 -1
- package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionToolsOptions.d.ts +5 -0
- package/esm/typings/src/types/LlmToolDefinition.d.ts +8 -1
- package/esm/typings/src/types/Prompt.d.ts +13 -0
- package/esm/typings/src/utils/misc/parseNumber.d.ts +1 -1
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +78 -3
- package/umd/index.umd.js.map +1 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { AgentModelRequirements } from '../../book-2.0/agent-source/AgentModelRequirements';
|
|
2
|
+
import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
|
|
3
|
+
/**
|
|
4
|
+
* IMPORT commitment definition
|
|
5
|
+
*
|
|
6
|
+
* The IMPORT commitment tells the agent to import content from another agent at the current location.
|
|
7
|
+
*
|
|
8
|
+
* Example usage in agent source:
|
|
9
|
+
*
|
|
10
|
+
* ```book
|
|
11
|
+
* IMPORT https://s6.ptbk.io/benjamin-white
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
15
|
+
*/
|
|
16
|
+
export declare class ImportCommitmentDefinition extends BaseCommitmentDefinition<'IMPORT' | 'IMPORTS'> {
|
|
17
|
+
constructor(type?: 'IMPORT' | 'IMPORTS');
|
|
18
|
+
/**
|
|
19
|
+
* Short one-line description of IMPORT.
|
|
20
|
+
*/
|
|
21
|
+
get description(): string;
|
|
22
|
+
/**
|
|
23
|
+
* Icon for this commitment.
|
|
24
|
+
*/
|
|
25
|
+
get icon(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Markdown documentation for IMPORT commitment.
|
|
28
|
+
*/
|
|
29
|
+
get documentation(): string;
|
|
30
|
+
applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
34
|
+
*/
|
|
@@ -7,6 +7,7 @@ import { DeleteCommitmentDefinition } from './DELETE/DELETE';
|
|
|
7
7
|
import { DictionaryCommitmentDefinition } from './DICTIONARY/DICTIONARY';
|
|
8
8
|
import { FormatCommitmentDefinition } from './FORMAT/FORMAT';
|
|
9
9
|
import { FromCommitmentDefinition } from './FROM/FROM';
|
|
10
|
+
import { ImportCommitmentDefinition } from './IMPORT/IMPORT';
|
|
10
11
|
import { GoalCommitmentDefinition } from './GOAL/GOAL';
|
|
11
12
|
import { KnowledgeCommitmentDefinition } from './KNOWLEDGE/KNOWLEDGE';
|
|
12
13
|
import { LanguageCommitmentDefinition } from './LANGUAGE/LANGUAGE';
|
|
@@ -40,7 +41,7 @@ import { NotYetImplementedCommitmentDefinition } from './_base/NotYetImplemented
|
|
|
40
41
|
*
|
|
41
42
|
* @private Use functions to access commitments instead of this array directly
|
|
42
43
|
*/
|
|
43
|
-
export declare const COMMITMENT_REGISTRY: readonly [PersonaCommitmentDefinition, PersonaCommitmentDefinition, KnowledgeCommitmentDefinition, MemoryCommitmentDefinition, MemoryCommitmentDefinition, StyleCommitmentDefinition, StyleCommitmentDefinition, RuleCommitmentDefinition, RuleCommitmentDefinition, LanguageCommitmentDefinition, LanguageCommitmentDefinition, SampleCommitmentDefinition, SampleCommitmentDefinition, FormatCommitmentDefinition, FormatCommitmentDefinition, FromCommitmentDefinition, 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, UseMcpCommitmentDefinition, UseCommitmentDefinition, NotYetImplementedCommitmentDefinition<"EXPECT">, NotYetImplementedCommitmentDefinition<"BEHAVIOUR">, NotYetImplementedCommitmentDefinition<"BEHAVIOURS">, NotYetImplementedCommitmentDefinition<"AVOID">, NotYetImplementedCommitmentDefinition<"AVOIDANCE">, NotYetImplementedCommitmentDefinition<"CONTEXT">];
|
|
44
|
+
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, UseMcpCommitmentDefinition, UseCommitmentDefinition, NotYetImplementedCommitmentDefinition<"EXPECT">, NotYetImplementedCommitmentDefinition<"BEHAVIOUR">, NotYetImplementedCommitmentDefinition<"BEHAVIOURS">, NotYetImplementedCommitmentDefinition<"AVOID">, NotYetImplementedCommitmentDefinition<"AVOIDANCE">, NotYetImplementedCommitmentDefinition<"CONTEXT">];
|
|
44
45
|
/**
|
|
45
46
|
* Gets a commitment definition by its type
|
|
46
47
|
* @param type The commitment type to look up
|
|
@@ -213,6 +213,12 @@ export declare const DEFAULT_INTERMEDIATE_FILES_STRATEGY: IntermediateFilesStrat
|
|
|
213
213
|
* @public exported from `@promptbook/core`
|
|
214
214
|
*/
|
|
215
215
|
export declare const DEFAULT_MAX_PARALLEL_COUNT = 5;
|
|
216
|
+
/**
|
|
217
|
+
* The maximum depth to which recursion can occur
|
|
218
|
+
*
|
|
219
|
+
* @public exported from `@promptbook/core`
|
|
220
|
+
*/
|
|
221
|
+
export declare const DEFAULT_MAX_RECURSION = 10;
|
|
216
222
|
/**
|
|
217
223
|
* The maximum number of attempts to execute LLM task before giving up
|
|
218
224
|
*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { string_date_iso8601, string_model_name, string_prompt } from '../types/typeAliases';
|
|
2
|
+
import type { TODO_any } from '../utils/organization/TODO_any';
|
|
2
3
|
import type { TODO_object } from '../utils/organization/TODO_object';
|
|
3
4
|
import type { EmbeddingVector } from './EmbeddingVector';
|
|
4
5
|
import type { Usage } from './Usage';
|
|
@@ -21,7 +22,29 @@ export type CompletionPromptResult = CommonPromptResult;
|
|
|
21
22
|
*
|
|
22
23
|
* Note: [🚉] This is fully serializable as JSON
|
|
23
24
|
*/
|
|
24
|
-
export type ChatPromptResult = CommonPromptResult & {
|
|
25
|
+
export type ChatPromptResult = CommonPromptResult & {
|
|
26
|
+
/**
|
|
27
|
+
* Optional tool calls made during the execution
|
|
28
|
+
*/
|
|
29
|
+
readonly toolCalls?: ReadonlyArray<{
|
|
30
|
+
/**
|
|
31
|
+
* Name of the tool
|
|
32
|
+
*/
|
|
33
|
+
readonly name: string;
|
|
34
|
+
/**
|
|
35
|
+
* Arguments of the tool call
|
|
36
|
+
*/
|
|
37
|
+
readonly arguments: string;
|
|
38
|
+
/**
|
|
39
|
+
* Result of the tool call
|
|
40
|
+
*/
|
|
41
|
+
readonly result: string;
|
|
42
|
+
/**
|
|
43
|
+
* Raw tool call from the model
|
|
44
|
+
*/
|
|
45
|
+
readonly rawToolCall: TODO_any;
|
|
46
|
+
}>;
|
|
47
|
+
};
|
|
25
48
|
/**
|
|
26
49
|
* Image prompt result
|
|
27
50
|
*
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ClientOptions } from 'openai';
|
|
2
2
|
import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
|
|
3
|
+
import type { ExecutionTools } from '../../execution/ExecutionTools';
|
|
3
4
|
import type { RemoteClientOptions } from '../../remote-server/types/RemoteClientOptions';
|
|
4
5
|
/**
|
|
5
6
|
* Options for `createOpenAiCompatibleExecutionTools` and `OpenAiCompatibleExecutionTools`
|
|
@@ -28,6 +29,10 @@ export type OpenAiCompatibleExecutionToolsNonProxiedOptions = CommonToolsOptions
|
|
|
28
29
|
* @example 'https://api.deepseek.com/v1' (DeepSeek)
|
|
29
30
|
*/
|
|
30
31
|
baseURL?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Tools for executing the scripts
|
|
34
|
+
*/
|
|
35
|
+
readonly executionTools?: Pick<ExecutionTools, 'script'>;
|
|
31
36
|
isProxied?: false;
|
|
32
37
|
};
|
|
33
38
|
/**
|
|
@@ -16,5 +16,12 @@ export type LlmToolDefinition = {
|
|
|
16
16
|
/**
|
|
17
17
|
* Parameters of the tool in JSON Schema format
|
|
18
18
|
*/
|
|
19
|
-
readonly parameters:
|
|
19
|
+
readonly parameters: {
|
|
20
|
+
readonly type: 'object';
|
|
21
|
+
readonly properties: Record<string, {
|
|
22
|
+
type: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
}>;
|
|
25
|
+
readonly required?: string[];
|
|
26
|
+
};
|
|
20
27
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { FormatCommand } from '../commands/FORMAT/FormatCommand';
|
|
2
2
|
import type { ChatMessage } from '../book-components/Chat/types/ChatMessage';
|
|
3
3
|
import type { Expectations } from '../pipeline/PipelineJson/Expectations';
|
|
4
|
+
import type { LlmToolDefinition } from './LlmToolDefinition';
|
|
4
5
|
import type { ChatModelRequirements } from './ModelRequirements';
|
|
5
6
|
import type { CompletionModelRequirements } from './ModelRequirements';
|
|
6
7
|
import type { EmbeddingModelRequirements } from './ModelRequirements';
|
|
@@ -44,6 +45,18 @@ export type ChatPrompt = CommonPrompt & {
|
|
|
44
45
|
* Optional chat thread (history of previous messages)
|
|
45
46
|
*/
|
|
46
47
|
thread?: ChatMessage[];
|
|
48
|
+
/**
|
|
49
|
+
* Optional file attachments
|
|
50
|
+
*/
|
|
51
|
+
attachments?: Array<{
|
|
52
|
+
name: string;
|
|
53
|
+
type: string;
|
|
54
|
+
url: string;
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* Optional tools that can be called by the model
|
|
58
|
+
*/
|
|
59
|
+
tools?: Array<LlmToolDefinition>;
|
|
47
60
|
};
|
|
48
61
|
/**
|
|
49
62
|
* Image prompt
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* @public exported from `@promptbook/utils`
|
|
12
12
|
*/
|
|
13
|
-
export declare function parseNumber(value: string | number): number;
|
|
13
|
+
export declare function parseNumber(value: string | number | null | undefined): number;
|
|
14
14
|
/**
|
|
15
15
|
* TODO: Maybe use sth. like safe-eval in fraction/calculation case @see https://www.npmjs.com/package/safe-eval
|
|
16
16
|
* TODO: [🧠][🌻] Maybe export through `@promptbook/markdown-utils` not `@promptbook/utils`
|
|
@@ -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`).
|
|
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.
|
|
3
|
+
"version": "0.105.0-0",
|
|
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.
|
|
97
|
+
"@promptbook/core": "0.105.0-0"
|
|
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.
|
|
26
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-0';
|
|
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
|
|
@@ -3410,6 +3410,79 @@
|
|
|
3410
3410
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
3411
3411
|
*/
|
|
3412
3412
|
|
|
3413
|
+
/**
|
|
3414
|
+
* IMPORT commitment definition
|
|
3415
|
+
*
|
|
3416
|
+
* The IMPORT commitment tells the agent to import content from another agent at the current location.
|
|
3417
|
+
*
|
|
3418
|
+
* Example usage in agent source:
|
|
3419
|
+
*
|
|
3420
|
+
* ```book
|
|
3421
|
+
* IMPORT https://s6.ptbk.io/benjamin-white
|
|
3422
|
+
* ```
|
|
3423
|
+
*
|
|
3424
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
3425
|
+
*/
|
|
3426
|
+
class ImportCommitmentDefinition extends BaseCommitmentDefinition {
|
|
3427
|
+
constructor(type = 'IMPORT') {
|
|
3428
|
+
super(type);
|
|
3429
|
+
}
|
|
3430
|
+
/**
|
|
3431
|
+
* Short one-line description of IMPORT.
|
|
3432
|
+
*/
|
|
3433
|
+
get description() {
|
|
3434
|
+
return 'Import content from another agent.';
|
|
3435
|
+
}
|
|
3436
|
+
/**
|
|
3437
|
+
* Icon for this commitment.
|
|
3438
|
+
*/
|
|
3439
|
+
get icon() {
|
|
3440
|
+
return '📥';
|
|
3441
|
+
}
|
|
3442
|
+
/**
|
|
3443
|
+
* Markdown documentation for IMPORT commitment.
|
|
3444
|
+
*/
|
|
3445
|
+
get documentation() {
|
|
3446
|
+
return spaceTrim$1.spaceTrim(`
|
|
3447
|
+
# ${this.type}
|
|
3448
|
+
|
|
3449
|
+
Imports content from another agent at the location of the commitment.
|
|
3450
|
+
|
|
3451
|
+
## Examples
|
|
3452
|
+
|
|
3453
|
+
\`\`\`book
|
|
3454
|
+
My AI Agent
|
|
3455
|
+
|
|
3456
|
+
IMPORT https://s6.ptbk.io/benjamin-white
|
|
3457
|
+
RULE Speak only in English.
|
|
3458
|
+
\`\`\`
|
|
3459
|
+
`);
|
|
3460
|
+
}
|
|
3461
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
3462
|
+
const trimmedContent = content.trim();
|
|
3463
|
+
if (!trimmedContent) {
|
|
3464
|
+
return requirements;
|
|
3465
|
+
}
|
|
3466
|
+
if (!isValidAgentUrl(trimmedContent)) {
|
|
3467
|
+
throw new Error(spaceTrim$1.spaceTrim((block) => `
|
|
3468
|
+
Invalid agent URL in IMPORT commitment: "${trimmedContent}"
|
|
3469
|
+
|
|
3470
|
+
\`\`\`book
|
|
3471
|
+
${block(content)}
|
|
3472
|
+
\`\`\`
|
|
3473
|
+
`));
|
|
3474
|
+
}
|
|
3475
|
+
const importedAgentUrl = trimmedContent;
|
|
3476
|
+
return {
|
|
3477
|
+
...requirements,
|
|
3478
|
+
importedAgentUrls: [...(requirements.importedAgentUrls || []), importedAgentUrl],
|
|
3479
|
+
};
|
|
3480
|
+
}
|
|
3481
|
+
}
|
|
3482
|
+
/**
|
|
3483
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
3484
|
+
*/
|
|
3485
|
+
|
|
3413
3486
|
/**
|
|
3414
3487
|
* GOAL commitment definition
|
|
3415
3488
|
*
|
|
@@ -5771,7 +5844,7 @@
|
|
|
5771
5844
|
// Add 'web_browser' to tools if not already present
|
|
5772
5845
|
const updatedTools = existingTools.some((tool) => tool.name === 'web_browser')
|
|
5773
5846
|
? existingTools
|
|
5774
|
-
: [
|
|
5847
|
+
: ([
|
|
5775
5848
|
// TODO: [🔰] Use through proper MCP server
|
|
5776
5849
|
...existingTools,
|
|
5777
5850
|
{
|
|
@@ -5791,7 +5864,7 @@
|
|
|
5791
5864
|
required: ['url'],
|
|
5792
5865
|
},
|
|
5793
5866
|
},
|
|
5794
|
-
];
|
|
5867
|
+
]);
|
|
5795
5868
|
// Return requirements with updated tools and metadata
|
|
5796
5869
|
return {
|
|
5797
5870
|
...requirements,
|
|
@@ -6093,6 +6166,8 @@
|
|
|
6093
6166
|
new FormatCommitmentDefinition('FORMAT'),
|
|
6094
6167
|
new FormatCommitmentDefinition('FORMATS'),
|
|
6095
6168
|
new FromCommitmentDefinition('FROM'),
|
|
6169
|
+
new ImportCommitmentDefinition('IMPORT'),
|
|
6170
|
+
new ImportCommitmentDefinition('IMPORTS'),
|
|
6096
6171
|
new ModelCommitmentDefinition('MODEL'),
|
|
6097
6172
|
new ModelCommitmentDefinition('MODELS'),
|
|
6098
6173
|
new ActionCommitmentDefinition('ACTION'),
|