@promptbook/cli 0.112.0-114 → 0.112.0-117
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 +35 -32
- package/esm/index.es.js.map +1 -1
- package/esm/src/_packages/components.index.d.ts +2 -0
- package/esm/src/_packages/node.index.d.ts +10 -0
- package/esm/src/book-3.0/CliAgent.d.ts +8 -15
- package/esm/src/book-3.0/agentFolderPaths.d.ts +30 -0
- package/esm/src/book-components/BookEditor/BookEditorBrowserConfig.d.ts +2 -0
- package/esm/src/book-components/BookEditor/BookEditorForClient.d.ts +7 -0
- package/esm/src/book-components/BookEditor/createDeprecatedCommitmentDiagnostics.browser.d.ts +9 -0
- package/esm/src/cli/cli-commands/agent-folder/agentProjectPaths.d.ts +2 -30
- package/esm/src/scrapers/website/utils/createShowdownConverter.d.ts +2 -2
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/_packages/components.index.ts +2 -0
- package/src/_packages/node.index.ts +10 -0
- package/src/book-3.0/CliAgent.ts +23 -85
- package/src/book-3.0/agentFolderPaths.ts +38 -0
- package/src/book-components/BookEditor/BookEditor.tsx +1 -1
- package/src/book-components/BookEditor/BookEditorAboutPromptbookInformation.tsx +2 -4
- package/src/book-components/BookEditor/BookEditorActionbar.tsx +32 -2
- package/src/book-components/BookEditor/BookEditorBrowserConfig.ts +11 -0
- package/src/book-components/BookEditor/BookEditorForClient.tsx +33 -0
- package/src/book-components/BookEditor/BookEditorMonaco.tsx +1 -1
- package/src/book-components/BookEditor/BookEditorMonacoTokenization.ts +83 -15
- package/src/book-components/BookEditor/createDeprecatedCommitmentDiagnostics.browser.ts +11 -0
- package/src/book-components/BookEditor/useBookEditorMonacoLanguage.ts +32 -46
- package/src/book-components/BookEditor/useBookEditorMonacoStyles.ts +1 -1
- package/src/book-components/BookEditor/useBookEditorMonacoUploads.ts +1 -1
- package/src/book-components/Chat/utils/renderMarkdown.ts +3 -2
- package/src/cli/cli-commands/agent-folder/agentProjectPaths.ts +15 -35
- package/src/commands/KNOWLEDGE/utils/knowledgeSourceContentToName.ts +2 -2
- package/src/commitments/_common/teamInternalAgentAccess.ts +2 -2
- package/src/formats/csv/CsvFormatParser.ts +4 -4
- package/src/formats/csv/utils/csvParse.ts +2 -2
- package/src/llm-providers/agent/AgentLlmExecutionTools.ts +2 -2
- package/src/llm-providers/agent/AgentLlmExecutionToolsAgentKitRunner.ts +2 -2
- package/src/llm-providers/agent/AgentLlmExecutionToolsOpenAiAssistantRunner.ts +2 -2
- package/src/other/templates/getTemplatesPipelineCollection.ts +719 -752
- package/src/scrapers/_common/utils/getScraperIntermediateSource.ts +2 -2
- package/src/scrapers/website/WebsiteScraper.ts +1 -1
- package/src/scrapers/website/utils/createShowdownConverter.ts +2 -2
- package/src/utils/misc/computeHash.ts +2 -2
- package/src/utils/random/$randomToken.ts +2 -2
- package/src/version.ts +2 -2
- package/src/versions.txt +3 -0
- package/umd/index.umd.js +37 -31
- package/umd/index.umd.js.map +1 -1
- package/umd/src/_packages/components.index.d.ts +2 -0
- package/umd/src/_packages/node.index.d.ts +10 -0
- package/umd/src/book-3.0/CliAgent.d.ts +8 -15
- package/umd/src/book-3.0/agentFolderPaths.d.ts +30 -0
- package/umd/src/book-components/BookEditor/BookEditorBrowserConfig.d.ts +2 -0
- package/umd/src/book-components/BookEditor/BookEditorForClient.d.ts +7 -0
- package/umd/src/book-components/BookEditor/createDeprecatedCommitmentDiagnostics.browser.d.ts +9 -0
- package/umd/src/cli/cli-commands/agent-folder/agentProjectPaths.d.ts +2 -30
- package/umd/src/scrapers/website/utils/createShowdownConverter.d.ts +2 -2
- package/umd/src/version.d.ts +1 -1
|
@@ -12,6 +12,7 @@ import type { BookEditorUploadProgressCallback } from '../book-components/BookEd
|
|
|
12
12
|
import type { BookEditorUploadOptions } from '../book-components/BookEditor/BookEditor';
|
|
13
13
|
import type { BookEditorProps } from '../book-components/BookEditor/BookEditor';
|
|
14
14
|
import { BookEditor } from '../book-components/BookEditor/BookEditor';
|
|
15
|
+
import { BookEditorForClient } from '../book-components/BookEditor/BookEditorForClient';
|
|
15
16
|
import { AgentChat } from '../book-components/Chat/AgentChat/AgentChat';
|
|
16
17
|
import type { AgentChatProps } from '../book-components/Chat/AgentChat/AgentChatProps';
|
|
17
18
|
import { Chat } from '../book-components/Chat/Chat/Chat';
|
|
@@ -95,6 +96,7 @@ export type { BookEditorUploadProgressCallback };
|
|
|
95
96
|
export type { BookEditorUploadOptions };
|
|
96
97
|
export type { BookEditorProps };
|
|
97
98
|
export { BookEditor };
|
|
99
|
+
export { BookEditorForClient };
|
|
98
100
|
export { AgentChat };
|
|
99
101
|
export type { AgentChatProps };
|
|
100
102
|
export { Chat };
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';
|
|
2
|
+
import { AGENT_BOOK_FILE_PATH } from '../book-3.0/agentFolderPaths';
|
|
3
|
+
import { AGENT_MESSAGES_DIRECTORY_PATH } from '../book-3.0/agentFolderPaths';
|
|
4
|
+
import { AGENT_QUEUED_MESSAGES_DIRECTORY_PATH } from '../book-3.0/agentFolderPaths';
|
|
5
|
+
import { AGENT_FINISHED_MESSAGES_DIRECTORY_PATH } from '../book-3.0/agentFolderPaths';
|
|
6
|
+
import { AGENT_FAILED_MESSAGES_DIRECTORY_PATH } from '../book-3.0/agentFolderPaths';
|
|
2
7
|
import type { BookNodeAgentSource } from '../book-3.0/BookNodeAgentSource';
|
|
3
8
|
import type { BookNodeAgentSourceOptions } from '../book-3.0/BookNodeAgentSource';
|
|
4
9
|
import type { CliAgentHarness } from '../book-3.0/CliAgent';
|
|
@@ -22,6 +27,11 @@ import { FileCacheStorage } from '../storage/file-cache-storage/FileCacheStorage
|
|
|
22
27
|
import { $execCommand } from '../utils/execCommand/$execCommand';
|
|
23
28
|
import { $execCommands } from '../utils/execCommand/$execCommands';
|
|
24
29
|
export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
|
|
30
|
+
export { AGENT_BOOK_FILE_PATH };
|
|
31
|
+
export { AGENT_MESSAGES_DIRECTORY_PATH };
|
|
32
|
+
export { AGENT_QUEUED_MESSAGES_DIRECTORY_PATH };
|
|
33
|
+
export { AGENT_FINISHED_MESSAGES_DIRECTORY_PATH };
|
|
34
|
+
export { AGENT_FAILED_MESSAGES_DIRECTORY_PATH };
|
|
25
35
|
export type { BookNodeAgentSource };
|
|
26
36
|
export type { BookNodeAgentSourceOptions };
|
|
27
37
|
export type { CliAgentHarness };
|
|
@@ -31,19 +31,12 @@ export type CliAgentRunOptions = {
|
|
|
31
31
|
*
|
|
32
32
|
* @public exported from `@promptbook/node`
|
|
33
33
|
*/
|
|
34
|
-
export type CliAgentOptions = BookNodeAgentSourceOptions & CliAgentRunOptions
|
|
35
|
-
/**
|
|
36
|
-
* Executable used for the wrapper command.
|
|
37
|
-
*
|
|
38
|
-
* @default ptbk
|
|
39
|
-
*/
|
|
40
|
-
readonly command?: string;
|
|
41
|
-
};
|
|
34
|
+
export type CliAgentOptions = BookNodeAgentSourceOptions & CliAgentRunOptions;
|
|
42
35
|
/**
|
|
43
|
-
* Lightweight JavaScript wrapper around
|
|
36
|
+
* Lightweight JavaScript wrapper around the Promptbook agent execution pipeline.
|
|
44
37
|
*
|
|
45
|
-
* It uses the same
|
|
46
|
-
*
|
|
38
|
+
* It uses the same harnesses and execution path as `ptbk agent exec`, running the runner
|
|
39
|
+
* in-process instead of spawning a separate CLI process.
|
|
47
40
|
*
|
|
48
41
|
* @public exported from `@promptbook/node`
|
|
49
42
|
*/
|
|
@@ -52,15 +45,15 @@ export declare class CliAgent {
|
|
|
52
45
|
private temporaryAgentPath;
|
|
53
46
|
constructor(options: CliAgentOptions);
|
|
54
47
|
/**
|
|
55
|
-
* Runs one non-interactive agent turn through
|
|
48
|
+
* Runs one non-interactive agent turn through the selected harness.
|
|
56
49
|
*
|
|
57
50
|
* @param message - User message sent to the agent.
|
|
58
|
-
* @param options - Optional per-run
|
|
59
|
-
* @returns
|
|
51
|
+
* @param options - Optional per-run overrides.
|
|
52
|
+
* @returns Final agent answer.
|
|
60
53
|
*/
|
|
61
54
|
run(message: string, options?: CliAgentRunOptions): Promise<string>;
|
|
62
55
|
/**
|
|
63
|
-
* Resolves the agent path passed to the
|
|
56
|
+
* Resolves the agent path passed to the runner, materializing one temporary `.book` file when needed.
|
|
64
57
|
*
|
|
65
58
|
* @private internal utility of `CliAgent`
|
|
66
59
|
*/
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Relative path to the local agent source used by the agent folder convention.
|
|
3
|
+
*
|
|
4
|
+
* @public exported from `@promptbook/node`
|
|
5
|
+
*/
|
|
6
|
+
export declare const AGENT_BOOK_FILE_PATH = "agent.book";
|
|
7
|
+
/**
|
|
8
|
+
* Relative path to the message queue root used by the agent folder convention.
|
|
9
|
+
*
|
|
10
|
+
* @public exported from `@promptbook/node`
|
|
11
|
+
*/
|
|
12
|
+
export declare const AGENT_MESSAGES_DIRECTORY_PATH = "messages";
|
|
13
|
+
/**
|
|
14
|
+
* Relative path to queued user messages consumed by the agent runner.
|
|
15
|
+
*
|
|
16
|
+
* @public exported from `@promptbook/node`
|
|
17
|
+
*/
|
|
18
|
+
export declare const AGENT_QUEUED_MESSAGES_DIRECTORY_PATH: string;
|
|
19
|
+
/**
|
|
20
|
+
* Relative path to answered messages written by the agent runner.
|
|
21
|
+
*
|
|
22
|
+
* @public exported from `@promptbook/node`
|
|
23
|
+
*/
|
|
24
|
+
export declare const AGENT_FINISHED_MESSAGES_DIRECTORY_PATH: string;
|
|
25
|
+
/**
|
|
26
|
+
* Relative path to messages that the agent runner stopped retrying.
|
|
27
|
+
*
|
|
28
|
+
* @public exported from `@promptbook/node`
|
|
29
|
+
*/
|
|
30
|
+
export declare const AGENT_FAILED_MESSAGES_DIRECTORY_PATH: string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-compatible stub for `createDeprecatedCommitmentDiagnostics`.
|
|
3
|
+
*
|
|
4
|
+
* In the browser build the full Node.js implementation is not available,
|
|
5
|
+
* so this stub always returns an empty array to keep the editor functional.
|
|
6
|
+
*
|
|
7
|
+
* @private internal utility of `BookEditorMonaco`
|
|
8
|
+
*/
|
|
9
|
+
export declare function createDeprecatedCommitmentDiagnostics(_agentSource?: string): [];
|
|
@@ -1,39 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* @private internal utility of `ptbk agent-folder`
|
|
5
|
-
*/
|
|
6
|
-
export declare const AGENT_BOOK_FILE_PATH = "agent.book";
|
|
1
|
+
import { AGENT_BOOK_FILE_PATH, AGENT_FAILED_MESSAGES_DIRECTORY_PATH, AGENT_FINISHED_MESSAGES_DIRECTORY_PATH, AGENT_MESSAGES_DIRECTORY_PATH, AGENT_QUEUED_MESSAGES_DIRECTORY_PATH } from '../../../book-3.0/agentFolderPaths';
|
|
2
|
+
export { AGENT_BOOK_FILE_PATH, AGENT_FAILED_MESSAGES_DIRECTORY_PATH, AGENT_FINISHED_MESSAGES_DIRECTORY_PATH, AGENT_MESSAGES_DIRECTORY_PATH, AGENT_QUEUED_MESSAGES_DIRECTORY_PATH, };
|
|
7
3
|
/**
|
|
8
4
|
* Relative path to local knowledge files initialized by `ptbk agent-folder init`.
|
|
9
5
|
*
|
|
10
6
|
* @private internal utility of `ptbk agent-folder`
|
|
11
7
|
*/
|
|
12
8
|
export declare const AGENT_KNOWLEDGE_DIRECTORY_PATH = "knowledge";
|
|
13
|
-
/**
|
|
14
|
-
* Relative path to the message queue root initialized by `ptbk agent-folder init`.
|
|
15
|
-
*
|
|
16
|
-
* @private internal utility of `ptbk agent-folder`
|
|
17
|
-
*/
|
|
18
|
-
export declare const AGENT_MESSAGES_DIRECTORY_PATH = "messages";
|
|
19
|
-
/**
|
|
20
|
-
* Relative path to queued user messages consumed by `ptbk agent-folder run-once`.
|
|
21
|
-
*
|
|
22
|
-
* @private internal utility of `ptbk agent-folder`
|
|
23
|
-
*/
|
|
24
|
-
export declare const AGENT_QUEUED_MESSAGES_DIRECTORY_PATH: string;
|
|
25
|
-
/**
|
|
26
|
-
* Relative path to answered messages written by `ptbk agent-folder run-once`.
|
|
27
|
-
*
|
|
28
|
-
* @private internal utility of `ptbk agent-folder`
|
|
29
|
-
*/
|
|
30
|
-
export declare const AGENT_FINISHED_MESSAGES_DIRECTORY_PATH: string;
|
|
31
|
-
/**
|
|
32
|
-
* Relative path to messages that the agent runner stopped retrying.
|
|
33
|
-
*
|
|
34
|
-
* @private internal utility of `ptbk agent-folder`
|
|
35
|
-
*/
|
|
36
|
-
export declare const AGENT_FAILED_MESSAGES_DIRECTORY_PATH: string;
|
|
37
9
|
/**
|
|
38
10
|
* Relative path to generated local agent documentation initialized by `ptbk agent-folder init`.
|
|
39
11
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import showdown from 'showdown';
|
|
2
2
|
/**
|
|
3
3
|
* Create a new showdown converter instance
|
|
4
4
|
*
|
|
5
5
|
* @private utility of `WebsiteScraper`
|
|
6
6
|
*/
|
|
7
|
-
export declare function createShowdownConverter():
|
|
7
|
+
export declare function createShowdownConverter(): showdown.Converter;
|
package/esm/src/version.d.ts
CHANGED
|
@@ -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.112.0-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.112.0-116`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
|
@@ -17,6 +17,7 @@ import type { BookEditorUploadProgressCallback } from '../book-components/BookEd
|
|
|
17
17
|
import type { BookEditorUploadOptions } from '../book-components/BookEditor/BookEditor';
|
|
18
18
|
import type { BookEditorProps } from '../book-components/BookEditor/BookEditor';
|
|
19
19
|
import { BookEditor } from '../book-components/BookEditor/BookEditor';
|
|
20
|
+
import { BookEditorForClient } from '../book-components/BookEditor/BookEditorForClient';
|
|
20
21
|
import { AgentChat } from '../book-components/Chat/AgentChat/AgentChat';
|
|
21
22
|
import type { AgentChatProps } from '../book-components/Chat/AgentChat/AgentChatProps';
|
|
22
23
|
import { Chat } from '../book-components/Chat/Chat/Chat';
|
|
@@ -106,6 +107,7 @@ export type { BookEditorUploadProgressCallback };
|
|
|
106
107
|
export type { BookEditorUploadOptions };
|
|
107
108
|
export type { BookEditorProps };
|
|
108
109
|
export { BookEditor };
|
|
110
|
+
export { BookEditorForClient };
|
|
109
111
|
export { AgentChat };
|
|
110
112
|
export type { AgentChatProps };
|
|
111
113
|
export { Chat };
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
// `@promptbook/node`
|
|
3
3
|
|
|
4
4
|
import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';
|
|
5
|
+
import { AGENT_BOOK_FILE_PATH } from '../book-3.0/agentFolderPaths';
|
|
6
|
+
import { AGENT_MESSAGES_DIRECTORY_PATH } from '../book-3.0/agentFolderPaths';
|
|
7
|
+
import { AGENT_QUEUED_MESSAGES_DIRECTORY_PATH } from '../book-3.0/agentFolderPaths';
|
|
8
|
+
import { AGENT_FINISHED_MESSAGES_DIRECTORY_PATH } from '../book-3.0/agentFolderPaths';
|
|
9
|
+
import { AGENT_FAILED_MESSAGES_DIRECTORY_PATH } from '../book-3.0/agentFolderPaths';
|
|
5
10
|
import type { BookNodeAgentSource } from '../book-3.0/BookNodeAgentSource';
|
|
6
11
|
import type { BookNodeAgentSourceOptions } from '../book-3.0/BookNodeAgentSource';
|
|
7
12
|
import type { CliAgentHarness } from '../book-3.0/CliAgent';
|
|
@@ -31,6 +36,11 @@ export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
|
|
|
31
36
|
|
|
32
37
|
|
|
33
38
|
// Note: Entities of the `@promptbook/node`
|
|
39
|
+
export { AGENT_BOOK_FILE_PATH };
|
|
40
|
+
export { AGENT_MESSAGES_DIRECTORY_PATH };
|
|
41
|
+
export { AGENT_QUEUED_MESSAGES_DIRECTORY_PATH };
|
|
42
|
+
export { AGENT_FINISHED_MESSAGES_DIRECTORY_PATH };
|
|
43
|
+
export { AGENT_FAILED_MESSAGES_DIRECTORY_PATH };
|
|
34
44
|
export type { BookNodeAgentSource };
|
|
35
45
|
export type { BookNodeAgentSourceOptions };
|
|
36
46
|
export type { CliAgentHarness };
|
package/src/book-3.0/CliAgent.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { mkdir, writeFile } from 'fs/promises';
|
|
2
2
|
import { dirname } from 'path';
|
|
3
|
+
import { executeAgentChatTurn } from '../../scripts/run-agent-chat/executeAgentChatTurn';
|
|
3
4
|
import { NotAllowed } from '../errors/NotAllowed';
|
|
4
5
|
import { resolvePromptbookTemporaryPath } from '../utils/filesystem/promptbookTemporaryPath';
|
|
5
|
-
import { $execCommand } from '../utils/execCommand/$execCommand';
|
|
6
6
|
import type { BookNodeAgentSourceOptions, ResolvedBookNodeAgentSource } from './BookNodeAgentSource';
|
|
7
7
|
import { resolveBookNodeAgentSource } from './BookNodeAgentSource';
|
|
8
8
|
|
|
@@ -41,22 +41,7 @@ export type CliAgentRunOptions = {
|
|
|
41
41
|
*
|
|
42
42
|
* @public exported from `@promptbook/node`
|
|
43
43
|
*/
|
|
44
|
-
export type CliAgentOptions = BookNodeAgentSourceOptions &
|
|
45
|
-
CliAgentRunOptions & {
|
|
46
|
-
/**
|
|
47
|
-
* Executable used for the wrapper command.
|
|
48
|
-
*
|
|
49
|
-
* @default ptbk
|
|
50
|
-
*/
|
|
51
|
-
readonly command?: string;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Default executable used by `CliAgent`.
|
|
56
|
-
*
|
|
57
|
-
* @private internal constant of `CliAgent`
|
|
58
|
-
*/
|
|
59
|
-
const DEFAULT_CLI_AGENT_COMMAND = 'ptbk';
|
|
44
|
+
export type CliAgentOptions = BookNodeAgentSourceOptions & CliAgentRunOptions;
|
|
60
45
|
|
|
61
46
|
/**
|
|
62
47
|
* Default non-interactive mode used by `CliAgent`.
|
|
@@ -66,10 +51,10 @@ const DEFAULT_CLI_AGENT_COMMAND = 'ptbk';
|
|
|
66
51
|
const DEFAULT_CLI_AGENT_IS_NO_UI = true;
|
|
67
52
|
|
|
68
53
|
/**
|
|
69
|
-
* Lightweight JavaScript wrapper around
|
|
54
|
+
* Lightweight JavaScript wrapper around the Promptbook agent execution pipeline.
|
|
70
55
|
*
|
|
71
|
-
* It uses the same
|
|
72
|
-
*
|
|
56
|
+
* It uses the same harnesses and execution path as `ptbk agent exec`, running the runner
|
|
57
|
+
* in-process instead of spawning a separate CLI process.
|
|
73
58
|
*
|
|
74
59
|
* @public exported from `@promptbook/node`
|
|
75
60
|
*/
|
|
@@ -79,11 +64,11 @@ export class CliAgent {
|
|
|
79
64
|
public constructor(private readonly options: CliAgentOptions) {}
|
|
80
65
|
|
|
81
66
|
/**
|
|
82
|
-
* Runs one non-interactive agent turn through
|
|
67
|
+
* Runs one non-interactive agent turn through the selected harness.
|
|
83
68
|
*
|
|
84
69
|
* @param message - User message sent to the agent.
|
|
85
|
-
* @param options - Optional per-run
|
|
86
|
-
* @returns
|
|
70
|
+
* @param options - Optional per-run overrides.
|
|
71
|
+
* @returns Final agent answer.
|
|
87
72
|
*/
|
|
88
73
|
public async run(message: string, options: CliAgentRunOptions = {}): Promise<string> {
|
|
89
74
|
const normalizedMessage = message.trim();
|
|
@@ -96,27 +81,24 @@ export class CliAgent {
|
|
|
96
81
|
const agentPath = await this.resolveExecutableAgentPath(resolvedSource);
|
|
97
82
|
const mergedOptions = mergeCliAgentRunOptions(this.options, options);
|
|
98
83
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
model: mergedOptions.model,
|
|
108
|
-
noUi: mergedOptions.noUi ?? DEFAULT_CLI_AGENT_IS_NO_UI,
|
|
109
|
-
thinkingLevel: mergedOptions.thinkingLevel,
|
|
110
|
-
}),
|
|
111
|
-
cwd: resolvedSource.currentWorkingDirectory,
|
|
112
|
-
crashOnError: true,
|
|
113
|
-
timeout: Infinity,
|
|
84
|
+
const result = await executeAgentChatTurn({
|
|
85
|
+
agentPath,
|
|
86
|
+
messages: [{ sender: 'USER', content: normalizedMessage }],
|
|
87
|
+
agentName: mergedOptions.harness,
|
|
88
|
+
model: mergedOptions.model,
|
|
89
|
+
noUi: mergedOptions.noUi ?? DEFAULT_CLI_AGENT_IS_NO_UI,
|
|
90
|
+
thinkingLevel: mergedOptions.thinkingLevel,
|
|
91
|
+
allowCredits: mergedOptions.allowCredits ?? false,
|
|
114
92
|
isVerbose: false,
|
|
93
|
+
context: mergedOptions.context,
|
|
94
|
+
currentWorkingDirectory: resolvedSource.currentWorkingDirectory,
|
|
115
95
|
});
|
|
96
|
+
|
|
97
|
+
return result.answer;
|
|
116
98
|
}
|
|
117
99
|
|
|
118
100
|
/**
|
|
119
|
-
* Resolves the agent path passed to the
|
|
101
|
+
* Resolves the agent path passed to the runner, materializing one temporary `.book` file when needed.
|
|
120
102
|
*
|
|
121
103
|
* @private internal utility of `CliAgent`
|
|
122
104
|
*/
|
|
@@ -137,7 +119,7 @@ export class CliAgent {
|
|
|
137
119
|
}
|
|
138
120
|
|
|
139
121
|
/**
|
|
140
|
-
* Merges constructor defaults with per-run
|
|
122
|
+
* Merges constructor defaults with per-run overrides.
|
|
141
123
|
*
|
|
142
124
|
* @private internal utility of `CliAgent`
|
|
143
125
|
*/
|
|
@@ -152,50 +134,6 @@ function mergeCliAgentRunOptions(defaults: CliAgentRunOptions, overrides: CliAge
|
|
|
152
134
|
};
|
|
153
135
|
}
|
|
154
136
|
|
|
155
|
-
/**
|
|
156
|
-
* Builds CLI arguments for `ptbk agent exec`.
|
|
157
|
-
*
|
|
158
|
-
* @private internal utility of `CliAgent`
|
|
159
|
-
*/
|
|
160
|
-
function createCliAgentExecArguments(options: {
|
|
161
|
-
readonly agentPath: string;
|
|
162
|
-
readonly allowCredits: boolean;
|
|
163
|
-
readonly context?: string;
|
|
164
|
-
readonly harness?: CliAgentHarness;
|
|
165
|
-
readonly message: string;
|
|
166
|
-
readonly model?: string;
|
|
167
|
-
readonly noUi: boolean;
|
|
168
|
-
readonly thinkingLevel?: CliAgentThinkingLevel;
|
|
169
|
-
}): Array<string> {
|
|
170
|
-
const argumentsList = ['agent', 'exec', '--agent', options.agentPath, '--message', options.message];
|
|
171
|
-
|
|
172
|
-
if (options.harness) {
|
|
173
|
-
argumentsList.push('--harness', options.harness);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if (options.model) {
|
|
177
|
-
argumentsList.push('--model', options.model);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (options.noUi) {
|
|
181
|
-
argumentsList.push('--no-ui');
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (options.thinkingLevel) {
|
|
185
|
-
argumentsList.push('--thinking-level', options.thinkingLevel);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if (options.allowCredits) {
|
|
189
|
-
argumentsList.push('--allow-credits');
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if (options.context?.trim()) {
|
|
193
|
-
argumentsList.push('--context', options.context.trim());
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
return argumentsList;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
137
|
/**
|
|
200
138
|
* Creates the stable temporary path used when `CliAgent` is initialized from in-memory Book source.
|
|
201
139
|
*
|
|
@@ -214,7 +152,7 @@ function createCliAgentTemporaryBookPath(resolvedSource: ResolvedBookNodeAgentSo
|
|
|
214
152
|
}
|
|
215
153
|
|
|
216
154
|
/**
|
|
217
|
-
* Keeps in-memory Book source readable when persisted for the
|
|
155
|
+
* Keeps in-memory Book source readable when persisted for the runner.
|
|
218
156
|
*
|
|
219
157
|
* @private internal utility of `CliAgent`
|
|
220
158
|
*/
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
|
|
3
|
+
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Relative path to the local agent source used by the agent folder convention.
|
|
7
|
+
*
|
|
8
|
+
* @public exported from `@promptbook/node`
|
|
9
|
+
*/
|
|
10
|
+
export const AGENT_BOOK_FILE_PATH = 'agent.book';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Relative path to the message queue root used by the agent folder convention.
|
|
14
|
+
*
|
|
15
|
+
* @public exported from `@promptbook/node`
|
|
16
|
+
*/
|
|
17
|
+
export const AGENT_MESSAGES_DIRECTORY_PATH = 'messages';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Relative path to queued user messages consumed by the agent runner.
|
|
21
|
+
*
|
|
22
|
+
* @public exported from `@promptbook/node`
|
|
23
|
+
*/
|
|
24
|
+
export const AGENT_QUEUED_MESSAGES_DIRECTORY_PATH = join(AGENT_MESSAGES_DIRECTORY_PATH, 'queued');
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Relative path to answered messages written by the agent runner.
|
|
28
|
+
*
|
|
29
|
+
* @public exported from `@promptbook/node`
|
|
30
|
+
*/
|
|
31
|
+
export const AGENT_FINISHED_MESSAGES_DIRECTORY_PATH = join(AGENT_MESSAGES_DIRECTORY_PATH, 'finished');
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Relative path to messages that the agent runner stopped retrying.
|
|
35
|
+
*
|
|
36
|
+
* @public exported from `@promptbook/node`
|
|
37
|
+
*/
|
|
38
|
+
export const AGENT_FAILED_MESSAGES_DIRECTORY_PATH = join(AGENT_MESSAGES_DIRECTORY_PATH, 'failed');
|
|
@@ -7,7 +7,6 @@ import { createPortal } from 'react-dom';
|
|
|
7
7
|
import type { Promisable } from 'type-fest';
|
|
8
8
|
import type { string_book } from '../../book-2.0/agent-source/string_book';
|
|
9
9
|
import { DEFAULT_BOOK } from '../../book-2.0/agent-source/string_book';
|
|
10
|
-
import { DEFAULT_IS_VERBOSE } from '../../config';
|
|
11
10
|
import type { number_percent } from '../../types/number_percent';
|
|
12
11
|
import type { number_positive } from '../../types/number_positive';
|
|
13
12
|
import type { string_knowledge_source_content } from '../../types/string_knowledge_source_content';
|
|
@@ -15,6 +14,7 @@ import type { string_css_value } from '../../types/string_markdown';
|
|
|
15
14
|
import { countLines } from '../../utils/expectation-counters/countLines';
|
|
16
15
|
import type { HoistedMenuItem } from '../_common/MenuHoisting/MenuHoistingContext';
|
|
17
16
|
import { classNames } from '../_common/react-utils/classNames';
|
|
17
|
+
import { DEFAULT_IS_VERBOSE } from './BookEditorBrowserConfig';
|
|
18
18
|
import styles from './BookEditor.module.css';
|
|
19
19
|
import { BookEditorMonaco } from './BookEditorMonaco';
|
|
20
20
|
import type { BookEditorTheme } from './BookEditorTheme';
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { PUBLIC_AGENTS_SERVERS } from '../../../servers';
|
|
2
|
-
import { CLAIM, IS_COST_PREVENTED, NAME } from '../../config';
|
|
3
1
|
import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../../version';
|
|
4
2
|
import { $detectRuntimeEnvironment } from '../../utils/environment/$detectRuntimeEnvironment';
|
|
5
3
|
import type { AboutPromptbookInformationOptions } from '../../utils/misc/aboutPromptbookInformation';
|
|
6
|
-
import {
|
|
4
|
+
import { CLAIM, IS_COST_PREVENTED, NAME, PUBLIC_AGENTS_SERVERS } from './BookEditorBrowserConfig';
|
|
7
5
|
import styles from './BookEditor.module.css';
|
|
8
6
|
|
|
9
7
|
/**
|
|
@@ -63,7 +61,7 @@ export function BookEditorAboutPromptbookInformation(props: AboutPromptbookInfor
|
|
|
63
61
|
<ul>
|
|
64
62
|
{Object.entries(runtimeEnvironmentInfo).map(([key, value]) => (
|
|
65
63
|
<li key={key}>
|
|
66
|
-
<strong>{key}:</strong> {
|
|
64
|
+
<strong>{key}:</strong> {String(value)}
|
|
67
65
|
</li>
|
|
68
66
|
))}
|
|
69
67
|
</ul>
|
|
@@ -6,7 +6,6 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
|
6
6
|
// Note: Do not import from `../../package.json` because it would be included in the bundle
|
|
7
7
|
// TODO: [🧠] Is there a better way to get the version?
|
|
8
8
|
import { DEFAULT_BOOK, validateBook } from '../../book-2.0/agent-source/string_book';
|
|
9
|
-
import { $induceBookDownload } from '../../utils/files/$induceBookDownload';
|
|
10
9
|
import { AboutIcon } from '../icons/AboutIcon';
|
|
11
10
|
import { AttachmentIcon } from '../icons/AttachmentIcon';
|
|
12
11
|
import { CameraIcon } from '../icons/CameraIcon';
|
|
@@ -37,6 +36,37 @@ type BookEditorActionbarProps = {
|
|
|
37
36
|
hoistedMenuItems?: ReadonlyArray<HoistedMenuItem>;
|
|
38
37
|
};
|
|
39
38
|
|
|
39
|
+
function induceBookDownloadInBrowser(book: string): void {
|
|
40
|
+
const filename = `${normalizeBookDownloadName(extractBookTitle(book) || 'AI Avatar')}.book`;
|
|
41
|
+
const objectUrl = URL.createObjectURL(new Blob([book], { type: 'application/json' }));
|
|
42
|
+
const link = window.document.createElement('a');
|
|
43
|
+
|
|
44
|
+
link.href = objectUrl;
|
|
45
|
+
link.download = filename;
|
|
46
|
+
link.click();
|
|
47
|
+
URL.revokeObjectURL(objectUrl);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function extractBookTitle(book: string): string | null {
|
|
51
|
+
return (
|
|
52
|
+
book
|
|
53
|
+
.split(/\r?\n/)
|
|
54
|
+
.map((line) => line.trim())
|
|
55
|
+
.find(Boolean) || null
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function normalizeBookDownloadName(value: string): string {
|
|
60
|
+
return (
|
|
61
|
+
value
|
|
62
|
+
.normalize('NFD')
|
|
63
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
64
|
+
.replace(/[^\dA-Za-z]+/g, '-')
|
|
65
|
+
.replace(/^-+|-+$/g, '')
|
|
66
|
+
.toLowerCase() || 'ai-avatar'
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
40
70
|
/**
|
|
41
71
|
* Handles book editor actionbar.
|
|
42
72
|
*
|
|
@@ -67,7 +97,7 @@ export function BookEditorActionbar(props: BookEditorActionbarProps) {
|
|
|
67
97
|
|
|
68
98
|
const handleDownload = useCallback(() => {
|
|
69
99
|
const book = validateBook(valueRef.current || DEFAULT_BOOK);
|
|
70
|
-
|
|
100
|
+
induceBookDownloadInBrowser(book);
|
|
71
101
|
}, []);
|
|
72
102
|
|
|
73
103
|
const actions = useMemo(() => {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Re-export browser-compatible constants from canonical sources to avoid duplicate entity names
|
|
2
|
+
export {
|
|
3
|
+
NAME,
|
|
4
|
+
CLAIM,
|
|
5
|
+
PROMPTBOOK_LEGAL_ENTITY,
|
|
6
|
+
IS_COST_PREVENTED,
|
|
7
|
+
DEFAULT_IS_VERBOSE,
|
|
8
|
+
DEFAULT_MAX_CONCURRENT_UPLOADS,
|
|
9
|
+
PROMPTBOOK_SYNTAX_COLORS,
|
|
10
|
+
} from '../../config';
|
|
11
|
+
export { PUBLIC_AGENTS_SERVERS } from '../../../servers';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { BookEditorProps } from './BookEditor';
|
|
3
|
+
|
|
4
|
+
type BookEditorComponent = typeof import('./BookEditor').BookEditor;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Renders a book editor
|
|
8
|
+
*
|
|
9
|
+
* @public exported from `@promptbook/components`
|
|
10
|
+
*/
|
|
11
|
+
export function BookEditorForClient(props: BookEditorProps) {
|
|
12
|
+
const [BookEditorComponent, setBookEditorComponent] = useState<BookEditorComponent | null>(null);
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
let isCancelled = false;
|
|
16
|
+
|
|
17
|
+
void import('./BookEditor').then(({ BookEditor }) => {
|
|
18
|
+
if (!isCancelled) {
|
|
19
|
+
setBookEditorComponent(() => BookEditor);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return () => {
|
|
24
|
+
isCancelled = true;
|
|
25
|
+
};
|
|
26
|
+
}, []);
|
|
27
|
+
|
|
28
|
+
if (!BookEditorComponent) {
|
|
29
|
+
return <div style={{ minHeight: 260 }} />;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return <BookEditorComponent {...props} />;
|
|
33
|
+
}
|
|
@@ -13,7 +13,7 @@ import styles from './BookEditor.module.css';
|
|
|
13
13
|
import { BookEditorActionbar } from './BookEditorActionbar';
|
|
14
14
|
import { BookEditorMonacoConstants } from './BookEditorMonacoConstants';
|
|
15
15
|
import { BOOK_EDITOR_RENDER_THEME, resolveBookEditorRenderTheme } from './BookEditorTheme';
|
|
16
|
-
import { createDeprecatedCommitmentDiagnostics } from './createDeprecatedCommitmentDiagnostics';
|
|
16
|
+
import { createDeprecatedCommitmentDiagnostics } from './createDeprecatedCommitmentDiagnostics.browser';
|
|
17
17
|
import { useBookEditorMonacoDecorations } from './useBookEditorMonacoDecorations';
|
|
18
18
|
import { useBookEditorMonacoDiagnostics } from './useBookEditorMonacoDiagnostics';
|
|
19
19
|
import { useBookEditorMonacoInteractions } from './useBookEditorMonacoInteractions';
|