@promptbook/node 0.113.0-9 → 0.114.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 -3
- package/esm/index.es.js +463 -117
- package/esm/index.es.js.map +1 -1
- package/esm/scripts/run-agent-messages/messages/buildAgentMessagePrompt.d.ts +6 -1
- package/esm/scripts/run-agent-messages/messages/buildAgentProjectsPromptSection.d.ts +39 -0
- package/esm/scripts/run-codex-prompts/common/waitUntilWorldTimeDeadline.d.ts +27 -0
- package/esm/scripts/run-codex-prompts/runners/openai-codex/parseCodexLoginMethodFromOutput.d.ts +10 -0
- package/esm/src/_packages/components.index.d.ts +8 -0
- package/esm/src/_packages/core.index.d.ts +4 -0
- package/esm/src/_packages/types.index.d.ts +12 -0
- package/esm/src/book-2.0/agent-source/AgentBasicInformation.d.ts +7 -0
- package/esm/src/book-2.0/agent-source/parseAgentSource/ParsedAgentProfile.d.ts +1 -1
- package/esm/src/book-2.0/book-language-documentation/BookLanguageDocumentationExample.d.ts +5 -13
- package/esm/src/book-2.0/book-language-documentation/BookLanguageManualDictionary.d.ts +195 -0
- package/esm/src/book-2.0/book-language-documentation/bookLanguageDocumentationExamples.d.ts +2 -1
- package/esm/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.d.ts +43 -1
- package/esm/src/book-2.0/book-language-documentation/czechBookLanguageManualDictionary.d.ts +10 -0
- package/esm/src/book-2.0/book-language-documentation/englishBookLanguageManualDictionary.d.ts +10 -0
- package/esm/src/book-2.0/book-language-documentation/getBookLanguageManualCommitmentGroups.d.ts +33 -0
- package/esm/src/book-2.0/book-language-documentation/getBookLanguageManualDictionary.d.ts +15 -0
- package/esm/src/book-2.0/book-language-documentation/getSafeCodeBlock.d.ts +10 -0
- package/esm/src/book-2.0/book-language-documentation/renderCommitmentCatalogSection.d.ts +30 -0
- package/esm/src/book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.d.ts +2 -1
- package/esm/src/book-2.0/book-language-documentation/toStableAnchorId.d.ts +12 -0
- package/esm/src/book-3.0/AgentMessageRunReport.d.ts +78 -0
- package/esm/src/book-3.0/agentFolderPaths.d.ts +9 -0
- package/esm/src/book-3.0/codexLoginMethod.d.ts +38 -0
- package/esm/src/book-components/BookEditor/BookEditorSyntaxTokenStyles.d.ts +39 -0
- package/esm/src/book-components/BookEditor/createBookSourceHighlightStyles.d.ts +12 -0
- package/esm/src/book-components/BookEditor/highlightBookSourceToHtml.d.ts +20 -0
- package/esm/src/book-components/Chat/Chat/ChatCitationModal.d.ts +5 -0
- package/esm/src/book-components/Chat/Chat/ChatCitationModal.test.d.ts +2 -0
- package/esm/src/book-components/Chat/Chat/ChatFeedbackStar.d.ts +37 -0
- package/esm/src/book-components/Chat/Chat/ChatMessageItem.d.ts +4 -0
- package/esm/src/book-components/Chat/Chat/ChatMessageList.d.ts +4 -0
- package/esm/src/book-components/Chat/Chat/ChatMessageRichContent.d.ts +5 -0
- package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +13 -0
- package/esm/src/book-components/Chat/Chat/ChatRatingModal.test.d.ts +2 -0
- package/esm/src/book-components/Chat/Chat/CitationIframePreview.d.ts +25 -2
- package/esm/src/book-components/Chat/Chat/pagePreview/LiveBrowserPreview.d.ts +39 -0
- package/esm/src/book-components/Chat/Chat/pagePreview/LiveBrowserPreview.test.d.ts +2 -0
- package/esm/src/book-components/Chat/Chat/pagePreview/LiveBrowserPreviewToolbar.d.ts +71 -0
- package/esm/src/book-components/Chat/Chat/pagePreview/PagePreviewInputEvent.d.ts +72 -0
- package/esm/src/book-components/Chat/Chat/pagePreview/PagePreviewInputQueue.d.ts +64 -0
- package/esm/src/book-components/Chat/Chat/pagePreview/PagePreviewInputQueue.test.d.ts +1 -0
- package/esm/src/book-components/Chat/Chat/pagePreview/PagePreviewSessionState.d.ts +14 -0
- package/esm/src/book-components/Chat/Chat/pagePreview/PagePreviewViewport.d.ts +37 -0
- package/esm/src/book-components/Chat/Chat/pagePreview/createPagePreviewSessionId.d.ts +20 -0
- package/esm/src/book-components/Chat/Chat/pagePreview/normalizePagePreviewInputEvent.d.ts +13 -0
- package/esm/src/book-components/Chat/Chat/pagePreview/normalizePagePreviewInputEvent.test.d.ts +1 -0
- package/esm/src/book-components/Chat/Chat/resolveChatRatingMessageKey.d.ts +8 -0
- package/esm/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +2 -0
- package/esm/src/book-components/Chat/SourceChip/SourceChip.test.d.ts +2 -0
- package/esm/src/book-components/Chat/hooks/useResolvedCitationLabel.test.d.ts +2 -0
- package/esm/src/book-components/Chat/utils/renderMarkdown.d.ts +78 -0
- package/esm/src/book-components/Chat/utils/resolveCitationSourceDisplay.d.ts +149 -0
- package/esm/src/book-components/Chat/utils/thinkingMessageVariants.d.ts +9 -0
- package/esm/src/cli/cli-commands/agent-folder/agentProjectPaths.d.ts +2 -2
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerChildEnvironment.d.ts +1 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerChildEnvironment.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/PreparedAgentsServerLaunch.d.ts +1 -1
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/forwardChildOutput.d.ts +1 -1
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/startNextServer.d.ts +1 -1
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/startUserChatJobWorkerPump.d.ts +1 -1
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +1 -1
- package/esm/src/cli/cli-commands/coder/add.d.ts +36 -0
- package/esm/src/cli/cli-commands/coder/add.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/coder/boilerplateTemplates.d.ts +24 -0
- package/esm/src/cli/cli-commands/coder.d.ts +1 -0
- package/esm/src/cli/cli-commands/common/createNonNegativeIntegerOptionParser.d.ts +10 -0
- package/esm/src/cli/cli-commands/common/harness/$applyHarnessInstallationStatus.d.ts +9 -0
- package/esm/src/cli/cli-commands/common/harness/$askForHarnessInstallationApproval.d.ts +9 -0
- package/esm/src/cli/cli-commands/common/harness/$checkHarnessInstallation.d.ts +10 -0
- package/esm/src/cli/cli-commands/common/harness/$ensureHarnessInstallations.d.ts +13 -0
- package/esm/src/cli/cli-commands/common/harness/$installHarness.d.ts +13 -0
- package/esm/src/cli/cli-commands/common/harness/$resolveInstalledHarnessVersion.d.ts +10 -0
- package/esm/src/cli/cli-commands/common/harness/$resolveLatestHarnessVersion.d.ts +10 -0
- package/esm/src/cli/cli-commands/common/harness/HarnessDefinition.d.ts +40 -0
- package/esm/src/cli/cli-commands/common/harness/HarnessDefinition.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/common/harness/HarnessInstallationStatus.d.ts +35 -0
- package/esm/src/cli/cli-commands/common/harness/buildHarnessInstallCommand.d.ts +10 -0
- package/esm/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.d.ts +11 -0
- package/esm/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/common/harness/formatHarnessInstallationWarning.d.ts +7 -0
- package/esm/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.d.ts +9 -0
- package/esm/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.test.d.ts +1 -0
- package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/buildAgentNameOrPermanentIdFilter.d.ts +18 -0
- package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/buildAgentNameOrPermanentIdFilter.test.d.ts +1 -0
- package/esm/src/commitments/META/META.d.ts +2 -0
- package/esm/src/commitments/META_THINKING_MESSAGE/META_THINKING_MESSAGE.d.ts +26 -0
- package/esm/src/commitments/index.d.ts +2 -1
- package/esm/src/execution/utils/formatUsagePrice.d.ts +12 -0
- package/esm/src/execution/utils/formatUsagePrice.test.d.ts +1 -0
- package/esm/src/utils/agent-message-runtime/agentMessageRuntimePaths.d.ts +24 -0
- package/esm/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.d.ts +16 -0
- package/esm/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.test.d.ts +1 -0
- package/esm/src/utils/agents/terminalAgentAvatarVisual.d.ts +104 -0
- package/esm/src/utils/agents/terminalAgentAvatarVisual.test.d.ts +1 -0
- package/esm/src/utils/html/escapeHtml.d.ts +9 -0
- package/esm/src/utils/markdown/shiftMarkdownHeadingLevels.d.ts +15 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +463 -117
- package/umd/index.umd.js.map +1 -1
- package/umd/scripts/run-agent-messages/messages/buildAgentMessagePrompt.d.ts +6 -1
- package/umd/scripts/run-agent-messages/messages/buildAgentProjectsPromptSection.d.ts +39 -0
- package/umd/scripts/run-codex-prompts/common/waitUntilWorldTimeDeadline.d.ts +27 -0
- package/umd/scripts/run-codex-prompts/runners/openai-codex/parseCodexLoginMethodFromOutput.d.ts +10 -0
- package/umd/src/_packages/components.index.d.ts +8 -0
- package/umd/src/_packages/core.index.d.ts +4 -0
- package/umd/src/_packages/types.index.d.ts +12 -0
- package/umd/src/book-2.0/agent-source/AgentBasicInformation.d.ts +7 -0
- package/umd/src/book-2.0/agent-source/parseAgentSource/ParsedAgentProfile.d.ts +1 -1
- package/umd/src/book-2.0/book-language-documentation/BookLanguageDocumentationExample.d.ts +5 -13
- package/umd/src/book-2.0/book-language-documentation/BookLanguageManualDictionary.d.ts +195 -0
- package/umd/src/book-2.0/book-language-documentation/bookLanguageDocumentationExamples.d.ts +2 -1
- package/umd/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.d.ts +43 -1
- package/umd/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.test.d.ts +1 -0
- package/umd/src/book-2.0/book-language-documentation/czechBookLanguageManualDictionary.d.ts +10 -0
- package/umd/src/book-2.0/book-language-documentation/englishBookLanguageManualDictionary.d.ts +10 -0
- package/umd/src/book-2.0/book-language-documentation/getBookLanguageManualCommitmentGroups.d.ts +33 -0
- package/umd/src/book-2.0/book-language-documentation/getBookLanguageManualDictionary.d.ts +15 -0
- package/umd/src/book-2.0/book-language-documentation/getSafeCodeBlock.d.ts +10 -0
- package/umd/src/book-2.0/book-language-documentation/renderCommitmentCatalogSection.d.ts +30 -0
- package/umd/src/book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.d.ts +2 -1
- package/umd/src/book-2.0/book-language-documentation/toStableAnchorId.d.ts +12 -0
- package/umd/src/book-3.0/AgentMessageRunReport.d.ts +78 -0
- package/umd/src/book-3.0/AgentMessageRunReport.test.d.ts +1 -0
- package/umd/src/book-3.0/agentFolderPaths.d.ts +9 -0
- package/umd/src/book-3.0/codexLoginMethod.d.ts +38 -0
- package/umd/src/book-components/BookEditor/BookEditorSyntaxTokenStyles.d.ts +39 -0
- package/umd/src/book-components/BookEditor/createBookSourceHighlightStyles.d.ts +12 -0
- package/umd/src/book-components/BookEditor/highlightBookSourceToHtml.d.ts +20 -0
- package/umd/src/book-components/Chat/Chat/ChatCitationModal.d.ts +5 -0
- package/umd/src/book-components/Chat/Chat/ChatCitationModal.test.d.ts +2 -0
- package/umd/src/book-components/Chat/Chat/ChatFeedbackStar.d.ts +37 -0
- package/umd/src/book-components/Chat/Chat/ChatMessageItem.d.ts +4 -0
- package/umd/src/book-components/Chat/Chat/ChatMessageList.d.ts +4 -0
- package/umd/src/book-components/Chat/Chat/ChatMessageRichContent.d.ts +5 -0
- package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +13 -0
- package/umd/src/book-components/Chat/Chat/ChatRatingModal.test.d.ts +2 -0
- package/umd/src/book-components/Chat/Chat/CitationIframePreview.d.ts +25 -2
- package/umd/src/book-components/Chat/Chat/pagePreview/LiveBrowserPreview.d.ts +39 -0
- package/umd/src/book-components/Chat/Chat/pagePreview/LiveBrowserPreview.test.d.ts +2 -0
- package/umd/src/book-components/Chat/Chat/pagePreview/LiveBrowserPreviewToolbar.d.ts +71 -0
- package/umd/src/book-components/Chat/Chat/pagePreview/PagePreviewInputEvent.d.ts +72 -0
- package/umd/src/book-components/Chat/Chat/pagePreview/PagePreviewInputQueue.d.ts +64 -0
- package/umd/src/book-components/Chat/Chat/pagePreview/PagePreviewInputQueue.test.d.ts +1 -0
- package/umd/src/book-components/Chat/Chat/pagePreview/PagePreviewSessionState.d.ts +14 -0
- package/umd/src/book-components/Chat/Chat/pagePreview/PagePreviewViewport.d.ts +37 -0
- package/umd/src/book-components/Chat/Chat/pagePreview/createPagePreviewSessionId.d.ts +20 -0
- package/umd/src/book-components/Chat/Chat/pagePreview/normalizePagePreviewInputEvent.d.ts +13 -0
- package/umd/src/book-components/Chat/Chat/pagePreview/normalizePagePreviewInputEvent.test.d.ts +1 -0
- package/umd/src/book-components/Chat/Chat/resolveChatRatingMessageKey.d.ts +8 -0
- package/umd/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +2 -0
- package/umd/src/book-components/Chat/SourceChip/SourceChip.test.d.ts +2 -0
- package/umd/src/book-components/Chat/hooks/useResolvedCitationLabel.test.d.ts +2 -0
- package/umd/src/book-components/Chat/utils/renderMarkdown.d.ts +78 -0
- package/umd/src/book-components/Chat/utils/resolveCitationSourceDisplay.d.ts +149 -0
- package/umd/src/book-components/Chat/utils/thinkingMessageVariants.d.ts +9 -0
- package/umd/src/cli/cli-commands/agent-folder/agentProjectPaths.d.ts +2 -2
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerChildEnvironment.d.ts +1 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerChildEnvironment.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/PreparedAgentsServerLaunch.d.ts +1 -1
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/forwardChildOutput.d.ts +1 -1
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/startNextServer.d.ts +1 -1
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/startUserChatJobWorkerPump.d.ts +1 -1
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +1 -1
- package/umd/src/cli/cli-commands/coder/add.d.ts +36 -0
- package/umd/src/cli/cli-commands/coder/add.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/coder/boilerplateTemplates.d.ts +24 -0
- package/umd/src/cli/cli-commands/coder.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/createNonNegativeIntegerOptionParser.d.ts +10 -0
- package/umd/src/cli/cli-commands/common/harness/$applyHarnessInstallationStatus.d.ts +9 -0
- package/umd/src/cli/cli-commands/common/harness/$askForHarnessInstallationApproval.d.ts +9 -0
- package/umd/src/cli/cli-commands/common/harness/$checkHarnessInstallation.d.ts +10 -0
- package/umd/src/cli/cli-commands/common/harness/$ensureHarnessInstallations.d.ts +13 -0
- package/umd/src/cli/cli-commands/common/harness/$installHarness.d.ts +13 -0
- package/umd/src/cli/cli-commands/common/harness/$resolveInstalledHarnessVersion.d.ts +10 -0
- package/umd/src/cli/cli-commands/common/harness/$resolveLatestHarnessVersion.d.ts +10 -0
- package/umd/src/cli/cli-commands/common/harness/HarnessDefinition.d.ts +40 -0
- package/umd/src/cli/cli-commands/common/harness/HarnessDefinition.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/harness/HarnessInstallationStatus.d.ts +35 -0
- package/umd/src/cli/cli-commands/common/harness/buildHarnessInstallCommand.d.ts +10 -0
- package/umd/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.d.ts +11 -0
- package/umd/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/harness/formatHarnessInstallationWarning.d.ts +7 -0
- package/umd/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.d.ts +9 -0
- package/umd/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.test.d.ts +1 -0
- package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/buildAgentNameOrPermanentIdFilter.d.ts +18 -0
- package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/buildAgentNameOrPermanentIdFilter.test.d.ts +1 -0
- package/umd/src/commitments/META/META.d.ts +2 -0
- package/umd/src/commitments/META_THINKING_MESSAGE/META_THINKING_MESSAGE.d.ts +26 -0
- package/umd/src/commitments/index.d.ts +2 -1
- package/umd/src/execution/utils/formatUsagePrice.d.ts +12 -0
- package/umd/src/execution/utils/formatUsagePrice.test.d.ts +1 -0
- package/umd/src/utils/agent-message-runtime/agentMessageRuntimePaths.d.ts +24 -0
- package/umd/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.d.ts +16 -0
- package/umd/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.test.d.ts +1 -0
- package/umd/src/utils/agents/terminalAgentAvatarVisual.d.ts +104 -0
- package/umd/src/utils/agents/terminalAgentAvatarVisual.test.d.ts +1 -0
- package/umd/src/utils/html/escapeHtml.d.ts +9 -0
- package/umd/src/utils/markdown/shiftMarkdownHeadingLevels.d.ts +15 -0
- package/umd/src/version.d.ts +1 -1
- package/esm/scripts/run-codex-prompts/common/runGoScript/buildTemporaryPromptScriptPath.d.ts +0 -14
- package/esm/src/book-2.0/book-language-documentation/bookLanguageCommonPitfalls.d.ts +0 -25
- package/esm/src/book-components/_common/react-utils/escapeHtml.d.ts +0 -6
- package/umd/scripts/run-codex-prompts/common/runGoScript/buildTemporaryPromptScriptPath.d.ts +0 -14
- package/umd/src/book-2.0/book-language-documentation/bookLanguageCommonPitfalls.d.ts +0 -25
- package/umd/src/book-components/_common/react-utils/escapeHtml.d.ts +0 -6
- /package/esm/src/{executables/browsers/locateInternetExplorer.test.d.ts → book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.test.d.ts} +0 -0
- /package/{umd/src/executables/browsers/locateInternetExplorer.test.d.ts → esm/src/book-3.0/AgentMessageRunReport.test.d.ts} +0 -0
package/esm/index.es.js
CHANGED
|
@@ -36,7 +36,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
36
36
|
* @generated
|
|
37
37
|
* @see https://github.com/webgptorg/promptbook
|
|
38
38
|
*/
|
|
39
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.
|
|
39
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.114.0-0';
|
|
40
40
|
/**
|
|
41
41
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
42
42
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -73,6 +73,15 @@ const AGENT_FINISHED_MESSAGES_DIRECTORY_PATH = join(AGENT_MESSAGES_DIRECTORY_PAT
|
|
|
73
73
|
* @public exported from `@promptbook/node`
|
|
74
74
|
*/
|
|
75
75
|
const AGENT_FAILED_MESSAGES_DIRECTORY_PATH = join(AGENT_MESSAGES_DIRECTORY_PATH, 'failed');
|
|
76
|
+
/**
|
|
77
|
+
* Relative path to the agent-owned projects root used by the agent folder convention.
|
|
78
|
+
*
|
|
79
|
+
* Each direct child directory is one project — an isolated folder the agent fully controls
|
|
80
|
+
* (files, scripts, optionally its own git repository).
|
|
81
|
+
*
|
|
82
|
+
* @private internal constant of the agent folder convention, used by agent runners and the Agents Server
|
|
83
|
+
*/
|
|
84
|
+
const AGENT_PROJECTS_DIRECTORY_PATH = 'projects';
|
|
76
85
|
|
|
77
86
|
/**
|
|
78
87
|
* Parser for the agent source for Promptbook agents in book language
|
|
@@ -469,48 +478,6 @@ async function withPromptRuntimeLog(scriptPath, handler, options) {
|
|
|
469
478
|
}
|
|
470
479
|
}
|
|
471
480
|
|
|
472
|
-
/**
|
|
473
|
-
* Orders JSON object by keys
|
|
474
|
-
*
|
|
475
|
-
* @returns The same type of object as the input re-ordered
|
|
476
|
-
*
|
|
477
|
-
* @public exported from `@promptbook/utils`
|
|
478
|
-
*/
|
|
479
|
-
function orderJson(options) {
|
|
480
|
-
const { value, order } = options;
|
|
481
|
-
const orderedValue = {
|
|
482
|
-
...(order === undefined ? {} : Object.fromEntries(order.map((key) => [key, undefined]))),
|
|
483
|
-
...value,
|
|
484
|
-
};
|
|
485
|
-
return orderedValue;
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
/**
|
|
489
|
-
* Freezes the given object and all its nested objects recursively
|
|
490
|
-
*
|
|
491
|
-
* Note: `$` is used to indicate that this function is not a pure function - it mutates given object
|
|
492
|
-
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
493
|
-
*
|
|
494
|
-
* @returns The same object as the input, but deeply frozen
|
|
495
|
-
*
|
|
496
|
-
* @public exported from `@promptbook/utils`
|
|
497
|
-
*/
|
|
498
|
-
function $deepFreeze(objectValue) {
|
|
499
|
-
if (Array.isArray(objectValue)) {
|
|
500
|
-
return Object.freeze(objectValue.map((item) => $deepFreeze(item)));
|
|
501
|
-
}
|
|
502
|
-
const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
503
|
-
for (const propertyName of propertyNames) {
|
|
504
|
-
const value = objectValue[propertyName];
|
|
505
|
-
if (value && typeof value === 'object') {
|
|
506
|
-
$deepFreeze(value);
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
Object.freeze(objectValue);
|
|
510
|
-
return objectValue;
|
|
511
|
-
}
|
|
512
|
-
// TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
513
|
-
|
|
514
481
|
/**
|
|
515
482
|
* Class implementing take chain.
|
|
516
483
|
*
|
|
@@ -1815,6 +1782,110 @@ class UnexpectedError extends Error {
|
|
|
1815
1782
|
}
|
|
1816
1783
|
}
|
|
1817
1784
|
|
|
1785
|
+
/**
|
|
1786
|
+
* Single source of truth about how each supported CLI coding harness is installed and detected.
|
|
1787
|
+
*
|
|
1788
|
+
* @private internal utility of `promptbookCli`
|
|
1789
|
+
*/
|
|
1790
|
+
const HARNESS_DEFINITIONS = {
|
|
1791
|
+
'openai-codex': {
|
|
1792
|
+
harnessName: 'openai-codex',
|
|
1793
|
+
label: 'OpenAI Codex',
|
|
1794
|
+
commandName: 'codex',
|
|
1795
|
+
npmPackageName: '@openai/codex',
|
|
1796
|
+
},
|
|
1797
|
+
'github-copilot': {
|
|
1798
|
+
harnessName: 'github-copilot',
|
|
1799
|
+
label: 'GitHub Copilot',
|
|
1800
|
+
commandName: 'copilot',
|
|
1801
|
+
npmPackageName: '@github/copilot',
|
|
1802
|
+
// Note: The GitHub Copilot CLI downloads its native binary in a postinstall script
|
|
1803
|
+
npmInstallEnvironment: { npm_config_ignore_scripts: 'false' },
|
|
1804
|
+
},
|
|
1805
|
+
cline: {
|
|
1806
|
+
harnessName: 'cline',
|
|
1807
|
+
label: 'Cline',
|
|
1808
|
+
commandName: 'cline',
|
|
1809
|
+
npmPackageName: 'cline',
|
|
1810
|
+
},
|
|
1811
|
+
'claude-code': {
|
|
1812
|
+
harnessName: 'claude-code',
|
|
1813
|
+
label: 'Claude Code',
|
|
1814
|
+
commandName: 'claude',
|
|
1815
|
+
npmPackageName: '@anthropic-ai/claude-code',
|
|
1816
|
+
},
|
|
1817
|
+
opencode: {
|
|
1818
|
+
harnessName: 'opencode',
|
|
1819
|
+
label: 'Opencode',
|
|
1820
|
+
commandName: 'opencode',
|
|
1821
|
+
npmPackageName: 'opencode-ai',
|
|
1822
|
+
},
|
|
1823
|
+
gemini: {
|
|
1824
|
+
harnessName: 'gemini',
|
|
1825
|
+
label: 'Gemini CLI',
|
|
1826
|
+
commandName: 'gemini',
|
|
1827
|
+
npmPackageName: '@google/gemini-cli',
|
|
1828
|
+
},
|
|
1829
|
+
};
|
|
1830
|
+
/**
|
|
1831
|
+
* Looks up the definition of one supported CLI coding harness.
|
|
1832
|
+
*
|
|
1833
|
+
* @private internal utility of `promptbookCli`
|
|
1834
|
+
*/
|
|
1835
|
+
function getHarnessDefinition(harnessName) {
|
|
1836
|
+
const definition = HARNESS_DEFINITIONS[harnessName];
|
|
1837
|
+
if (definition === undefined) {
|
|
1838
|
+
throw new UnexpectedError(spaceTrim$1(`
|
|
1839
|
+
Missing harness definition for \`${harnessName}\`.
|
|
1840
|
+
|
|
1841
|
+
Every harness must be described in \`HARNESS_DEFINITIONS\`.
|
|
1842
|
+
`));
|
|
1843
|
+
}
|
|
1844
|
+
return definition;
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
/**
|
|
1848
|
+
* Orders JSON object by keys
|
|
1849
|
+
*
|
|
1850
|
+
* @returns The same type of object as the input re-ordered
|
|
1851
|
+
*
|
|
1852
|
+
* @public exported from `@promptbook/utils`
|
|
1853
|
+
*/
|
|
1854
|
+
function orderJson(options) {
|
|
1855
|
+
const { value, order } = options;
|
|
1856
|
+
const orderedValue = {
|
|
1857
|
+
...(order === undefined ? {} : Object.fromEntries(order.map((key) => [key, undefined]))),
|
|
1858
|
+
...value,
|
|
1859
|
+
};
|
|
1860
|
+
return orderedValue;
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
/**
|
|
1864
|
+
* Freezes the given object and all its nested objects recursively
|
|
1865
|
+
*
|
|
1866
|
+
* Note: `$` is used to indicate that this function is not a pure function - it mutates given object
|
|
1867
|
+
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
1868
|
+
*
|
|
1869
|
+
* @returns The same object as the input, but deeply frozen
|
|
1870
|
+
*
|
|
1871
|
+
* @public exported from `@promptbook/utils`
|
|
1872
|
+
*/
|
|
1873
|
+
function $deepFreeze(objectValue) {
|
|
1874
|
+
if (Array.isArray(objectValue)) {
|
|
1875
|
+
return Object.freeze(objectValue.map((item) => $deepFreeze(item)));
|
|
1876
|
+
}
|
|
1877
|
+
const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
1878
|
+
for (const propertyName of propertyNames) {
|
|
1879
|
+
const value = objectValue[propertyName];
|
|
1880
|
+
if (value && typeof value === 'object') {
|
|
1881
|
+
$deepFreeze(value);
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
Object.freeze(objectValue);
|
|
1885
|
+
return objectValue;
|
|
1886
|
+
}
|
|
1887
|
+
// TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
1888
|
+
|
|
1818
1889
|
/**
|
|
1819
1890
|
* This error type indicates that somewhere in the code non-Error object was thrown and it was wrapped into the `WrappedError`
|
|
1820
1891
|
*
|
|
@@ -3061,6 +3132,55 @@ async function $runGoScriptWithOutput(options) {
|
|
|
3061
3132
|
});
|
|
3062
3133
|
}
|
|
3063
3134
|
|
|
3135
|
+
/**
|
|
3136
|
+
* Minimum timer duration used to avoid a zero-millisecond polling loop.
|
|
3137
|
+
*/
|
|
3138
|
+
const MINIMUM_WORLD_TIME_WAIT_POLL_INTERVAL_MS = 1;
|
|
3139
|
+
/**
|
|
3140
|
+
* Waits until one wall-clock deadline has passed.
|
|
3141
|
+
*
|
|
3142
|
+
* The remaining time is recalculated from `Date.now()` after every poll and after every tick callback.
|
|
3143
|
+
* This makes waits elapse while the process is paused at a checkpoint or the computer is asleep.
|
|
3144
|
+
*
|
|
3145
|
+
* @private internal utility of `ptbk coder` wait handling
|
|
3146
|
+
*/
|
|
3147
|
+
async function waitUntilWorldTimeDeadline(options) {
|
|
3148
|
+
var _a;
|
|
3149
|
+
const { deadlineTimeMs, pollIntervalMs, onTick, shouldStopWaiting } = options;
|
|
3150
|
+
const normalizedPollIntervalMs = Math.max(MINIMUM_WORLD_TIME_WAIT_POLL_INTERVAL_MS, pollIntervalMs);
|
|
3151
|
+
const waitForMilliseconds = (_a = options.waitForMilliseconds) !== null && _a !== void 0 ? _a : waitForRegularMilliseconds;
|
|
3152
|
+
while (true) {
|
|
3153
|
+
if (shouldStopWaiting === null || shouldStopWaiting === void 0 ? void 0 : shouldStopWaiting()) {
|
|
3154
|
+
return;
|
|
3155
|
+
}
|
|
3156
|
+
const remainingDurationMs = getRemainingDurationMs(deadlineTimeMs);
|
|
3157
|
+
if (remainingDurationMs <= 0) {
|
|
3158
|
+
return;
|
|
3159
|
+
}
|
|
3160
|
+
await (onTick === null || onTick === void 0 ? void 0 : onTick(remainingDurationMs));
|
|
3161
|
+
if (shouldStopWaiting === null || shouldStopWaiting === void 0 ? void 0 : shouldStopWaiting()) {
|
|
3162
|
+
return;
|
|
3163
|
+
}
|
|
3164
|
+
const remainingDurationAfterTickMs = getRemainingDurationMs(deadlineTimeMs);
|
|
3165
|
+
if (remainingDurationAfterTickMs <= 0) {
|
|
3166
|
+
return;
|
|
3167
|
+
}
|
|
3168
|
+
await waitForMilliseconds(Math.min(normalizedPollIntervalMs, remainingDurationAfterTickMs));
|
|
3169
|
+
}
|
|
3170
|
+
}
|
|
3171
|
+
/**
|
|
3172
|
+
* Returns the remaining wall-clock duration until a timestamp.
|
|
3173
|
+
*/
|
|
3174
|
+
function getRemainingDurationMs(deadlineTimeMs) {
|
|
3175
|
+
return Math.max(0, deadlineTimeMs - Date.now());
|
|
3176
|
+
}
|
|
3177
|
+
/**
|
|
3178
|
+
* Waits for one short polling interval.
|
|
3179
|
+
*/
|
|
3180
|
+
async function waitForRegularMilliseconds(durationMs) {
|
|
3181
|
+
await new Promise((resolve) => setTimeout(resolve, durationMs));
|
|
3182
|
+
}
|
|
3183
|
+
|
|
3064
3184
|
/**
|
|
3065
3185
|
* Base delimiter used for passing large prompts through stdin.
|
|
3066
3186
|
*/
|
|
@@ -3470,36 +3590,32 @@ class ClaudeCodeRunner {
|
|
|
3470
3590
|
* Waits until the Claude Code session can be resumed, keeping terminal status clear.
|
|
3471
3591
|
*/
|
|
3472
3592
|
async function waitForClaudeCodeSessionLimitReset(sessionLimit, resurrectionCount, options) {
|
|
3473
|
-
var _a, _b
|
|
3593
|
+
var _a, _b;
|
|
3474
3594
|
const delayMs = getClaudeCodeSessionLimitDelayMs(sessionLimit);
|
|
3595
|
+
const resetDeadlineTimeMs = Date.now() + delayMs;
|
|
3475
3596
|
const sessionLabel = formatClaudeCodeSessionIdForDisplay(sessionLimit.sessionId);
|
|
3476
3597
|
const resetSummary = formatClaudeCodeSessionLimitForDisplay(sessionLimit);
|
|
3477
3598
|
if ((_a = options.shouldPrintLiveOutput) !== null && _a !== void 0 ? _a : true) {
|
|
3478
3599
|
console.warn(colors.yellow(`[claude-code] Session limit detected for ${sessionLimit.sessionId}. Resurrection #${resurrectionCount} will resume with --resume after ${formatDurationMs(delayMs)}. ${resetSummary}`));
|
|
3479
3600
|
}
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3601
|
+
await waitUntilWorldTimeDeadline({
|
|
3602
|
+
deadlineTimeMs: resetDeadlineTimeMs,
|
|
3603
|
+
pollIntervalMs: CLAUDE_CODE_SESSION_RESURRECTION_POLL_MS,
|
|
3604
|
+
onTick: async (remainingDelayMs) => {
|
|
3605
|
+
var _a;
|
|
3606
|
+
await ((_a = options.waitForPauseCheckpoint) === null || _a === void 0 ? void 0 : _a.call(options, {
|
|
3607
|
+
checkpointLabel: 'the Claude Code session limit reset',
|
|
3608
|
+
phase: 'waiting',
|
|
3609
|
+
statusMessage: `Claude Code session ${sessionLabel} hit its limit; resurrection #${resurrectionCount} resumes in ${formatDurationMs(Math.min(remainingDelayMs, delayMs))}`,
|
|
3610
|
+
}));
|
|
3611
|
+
},
|
|
3612
|
+
});
|
|
3613
|
+
await ((_b = options.waitForPauseCheckpoint) === null || _b === void 0 ? void 0 : _b.call(options, {
|
|
3492
3614
|
checkpointLabel: 'resurrecting the Claude Code session with --resume',
|
|
3493
3615
|
phase: 'running',
|
|
3494
3616
|
statusMessage: `Resurrecting Claude Code session ${sessionLabel} with --resume`,
|
|
3495
3617
|
}));
|
|
3496
3618
|
}
|
|
3497
|
-
/**
|
|
3498
|
-
* Waits for a fixed amount of milliseconds.
|
|
3499
|
-
*/
|
|
3500
|
-
async function waitFor$1(delayMs) {
|
|
3501
|
-
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
3502
|
-
}
|
|
3503
3619
|
/**
|
|
3504
3620
|
* Formats a Claude Code session id for compact terminal status lines.
|
|
3505
3621
|
*/
|
|
@@ -4107,6 +4223,27 @@ class ProgressiveBackoff {
|
|
|
4107
4223
|
}
|
|
4108
4224
|
}
|
|
4109
4225
|
|
|
4226
|
+
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
4227
|
+
/**
|
|
4228
|
+
* Stable stdout marker printed by the generated Codex runner script to report which login method it used.
|
|
4229
|
+
*
|
|
4230
|
+
* The marker is followed by the resolved method keyword, for example `ptbk-codex-login-method: chatgpt`,
|
|
4231
|
+
* so `parseCodexLoginMethodFromOutput` can recover it from the captured runner output.
|
|
4232
|
+
*
|
|
4233
|
+
* @private internal constant of the OpenAI Codex runner
|
|
4234
|
+
*/
|
|
4235
|
+
const CODEX_LOGIN_METHOD_MARKER = 'ptbk-codex-login-method:';
|
|
4236
|
+
/**
|
|
4237
|
+
* Substring that the `codex login status` command prints when the Codex CLI is signed in with a
|
|
4238
|
+
* ChatGPT subscription account instead of an `OPENAI_API_KEY`.
|
|
4239
|
+
*
|
|
4240
|
+
* This is the single source of truth for detecting an active ChatGPT login, reused by the Codex runner
|
|
4241
|
+
* script and by the Agents Server harness authentication status resolver.
|
|
4242
|
+
*
|
|
4243
|
+
* @private internal constant of the OpenAI Codex runner and the Agents Server Harness Auth
|
|
4244
|
+
*/
|
|
4245
|
+
const CODEX_CHATGPT_LOGIN_STATUS_NEEDLE = 'Logged in using ChatGPT';
|
|
4246
|
+
|
|
4110
4247
|
/**
|
|
4111
4248
|
* Default Codex reasoning effort preserved for backwards compatibility when no CLI override is provided.
|
|
4112
4249
|
*/
|
|
@@ -4123,10 +4260,28 @@ function buildCodexScript(options) {
|
|
|
4123
4260
|
const delimiter = resolveShellHereDocumentDelimiter(CODEX_PROMPT_DELIMITER, options.prompt);
|
|
4124
4261
|
const projectPath = toPosixPath(options.projectPath);
|
|
4125
4262
|
const loginMethodConfig = spaceTrim(`
|
|
4263
|
+
CODEX_LOGIN_STATUS="$(
|
|
4264
|
+
unset OPENAI_API_KEY OPENAI_BASE_URL CODEX_API_KEY
|
|
4265
|
+
# 'codex login status' prints the "Logged in using ChatGPT" line to stderr, so merge stderr into stdout (2>&1) to capture it
|
|
4266
|
+
${options.codexCommand} login status 2>&1 || true
|
|
4267
|
+
)"
|
|
4268
|
+
case "$CODEX_LOGIN_STATUS" in
|
|
4269
|
+
*"${CODEX_CHATGPT_LOGIN_STATUS_NEEDLE}"*)
|
|
4270
|
+
IS_CODEX_CHATGPT_LOGIN_ACTIVE=1
|
|
4271
|
+
;;
|
|
4272
|
+
*)
|
|
4273
|
+
IS_CODEX_CHATGPT_LOGIN_ACTIVE=0
|
|
4274
|
+
;;
|
|
4275
|
+
esac
|
|
4276
|
+
|
|
4277
|
+
CODEX_LOGIN_METHOD=chatgpt
|
|
4126
4278
|
${options.allowCredits ? 'CODEX_LOGIN_METHOD_ARGUMENTS=()' : 'CODEX_LOGIN_METHOD_ARGUMENTS=(-c forced_login_method=chatgpt)'}
|
|
4127
4279
|
unset CODEX_API_KEY
|
|
4128
|
-
if [ "
|
|
4280
|
+
if [ "$IS_CODEX_CHATGPT_LOGIN_ACTIVE" != "1" ] &&
|
|
4281
|
+
[ "\${PTBK_OPENAI_CODEX_USE_API_KEY:-0}" = "1" ] &&
|
|
4282
|
+
[ -n "\${OPENAI_API_KEY:-}" ]; then
|
|
4129
4283
|
CODEX_LOGIN_METHOD_ARGUMENTS=(-c forced_login_method=api)
|
|
4284
|
+
CODEX_LOGIN_METHOD=api
|
|
4130
4285
|
CODEX_API_KEY="\${OPENAI_API_KEY}"
|
|
4131
4286
|
export CODEX_API_KEY
|
|
4132
4287
|
fi
|
|
@@ -4145,11 +4300,15 @@ function buildCodexScript(options) {
|
|
|
4145
4300
|
'',
|
|
4146
4301
|
loginMethodConfig,
|
|
4147
4302
|
'',
|
|
4148
|
-
'if [ "$
|
|
4303
|
+
'if [ "$IS_CODEX_CHATGPT_LOGIN_ACTIVE" = "1" ] ||',
|
|
4304
|
+
' [ "${PTBK_OPENAI_CODEX_USE_API_KEY:-0}" != "1" ] ||',
|
|
4305
|
+
' [ -z "${OPENAI_API_KEY:-}" ]; then',
|
|
4149
4306
|
'unset OPENAI_API_KEY',
|
|
4150
4307
|
'unset OPENAI_BASE_URL',
|
|
4151
4308
|
'fi',
|
|
4152
4309
|
'',
|
|
4310
|
+
`printf '%s %s\\n' '${CODEX_LOGIN_METHOD_MARKER}' "\${CODEX_LOGIN_METHOD}"`,
|
|
4311
|
+
'',
|
|
4153
4312
|
`${options.codexCommand} \\`,
|
|
4154
4313
|
' "${CODEX_LOGIN_METHOD_ARGUMENTS[@]}" \\',
|
|
4155
4314
|
` -c model_reasoning_effort="${thinkingLevel}" \\`,
|
|
@@ -4351,6 +4510,37 @@ function resolveCodexPricing(modelName) {
|
|
|
4351
4510
|
return (_c = OPENAI_MODELS.find((model) => model.modelName === CODEX_FALLBACK_PRICING_MODEL)) === null || _c === void 0 ? void 0 : _c.pricing;
|
|
4352
4511
|
}
|
|
4353
4512
|
|
|
4513
|
+
/**
|
|
4514
|
+
* Detects which login method Codex used from the captured CLI output.
|
|
4515
|
+
*
|
|
4516
|
+
* The generated Codex runner script prints one `CODEX_LOGIN_METHOD_MARKER` line before invoking Codex.
|
|
4517
|
+
* The most recent marker wins so retries within one captured output resolve to the final decision.
|
|
4518
|
+
*
|
|
4519
|
+
* @returns The resolved login method, or `unknown` when no marker is present.
|
|
4520
|
+
*/
|
|
4521
|
+
function parseCodexLoginMethodFromOutput(output) {
|
|
4522
|
+
const lines = output.split(/\r?\n/);
|
|
4523
|
+
for (let index = lines.length - 1; index >= 0; index--) {
|
|
4524
|
+
const line = lines[index];
|
|
4525
|
+
if (line === undefined) {
|
|
4526
|
+
continue;
|
|
4527
|
+
}
|
|
4528
|
+
const markerIndex = line.indexOf(CODEX_LOGIN_METHOD_MARKER);
|
|
4529
|
+
if (markerIndex === -1) {
|
|
4530
|
+
continue;
|
|
4531
|
+
}
|
|
4532
|
+
const reportedMethod = line.slice(markerIndex + CODEX_LOGIN_METHOD_MARKER.length).trim().toLowerCase();
|
|
4533
|
+
if (reportedMethod === 'chatgpt') {
|
|
4534
|
+
return 'chatgpt';
|
|
4535
|
+
}
|
|
4536
|
+
if (reportedMethod === 'api') {
|
|
4537
|
+
return 'api';
|
|
4538
|
+
}
|
|
4539
|
+
return 'unknown';
|
|
4540
|
+
}
|
|
4541
|
+
return 'unknown';
|
|
4542
|
+
}
|
|
4543
|
+
|
|
4354
4544
|
/**
|
|
4355
4545
|
* Error signatures that mean Codex requires credit spending to continue.
|
|
4356
4546
|
*/
|
|
@@ -4460,12 +4650,6 @@ const RATE_LIMIT_BACKOFF_MAX_MS = 30 * 60 * 1000;
|
|
|
4460
4650
|
* Randomized delay proportion added/subtracted for retry jitter.
|
|
4461
4651
|
*/
|
|
4462
4652
|
const RATE_LIMIT_BACKOFF_JITTER_RATIO = 0.15;
|
|
4463
|
-
/**
|
|
4464
|
-
* Waits for one given amount of milliseconds.
|
|
4465
|
-
*/
|
|
4466
|
-
async function waitFor(delayMs) {
|
|
4467
|
-
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
4468
|
-
}
|
|
4469
4653
|
/**
|
|
4470
4654
|
* Formats a delay value into a concise `xh ym zs` style label.
|
|
4471
4655
|
*/
|
|
@@ -4543,7 +4727,10 @@ class OpenAiCodexRunner {
|
|
|
4543
4727
|
preserveArtifactsOnSuccess: options.preserveArtifactsOnSuccess,
|
|
4544
4728
|
});
|
|
4545
4729
|
this.rateLimitBackoff.reset();
|
|
4546
|
-
return {
|
|
4730
|
+
return {
|
|
4731
|
+
usage: buildCodexUsageFromOutput(output, this.options.model),
|
|
4732
|
+
loginMethod: parseCodexLoginMethodFromOutput(output),
|
|
4733
|
+
};
|
|
4547
4734
|
}
|
|
4548
4735
|
catch (error) {
|
|
4549
4736
|
const details = extractCodexFailureDetails(error);
|
|
@@ -4555,13 +4742,18 @@ class OpenAiCodexRunner {
|
|
|
4555
4742
|
throw error;
|
|
4556
4743
|
}
|
|
4557
4744
|
const delayMs = this.rateLimitBackoff.nextDelayMs();
|
|
4558
|
-
const
|
|
4745
|
+
const retryDeadlineTimeMs = Date.now() + delayMs;
|
|
4746
|
+
const retryAt = new Date(retryDeadlineTimeMs).toISOString();
|
|
4559
4747
|
const retryIndex = this.rateLimitBackoff.retryCount;
|
|
4560
4748
|
const summary = extractFailureSummary(details);
|
|
4561
4749
|
if ((_b = options.shouldPrintLiveOutput) !== null && _b !== void 0 ? _b : true) {
|
|
4562
4750
|
console.warn(colors.yellow(`[codex] Rate limit/quota detected (${summary}). Retry #${retryIndex} in ${formatDelay(delayMs)} at ${retryAt}.`));
|
|
4563
4751
|
}
|
|
4564
|
-
await waitForRetryDelay(
|
|
4752
|
+
await waitForRetryDelay({
|
|
4753
|
+
delayMs,
|
|
4754
|
+
retryDeadlineTimeMs,
|
|
4755
|
+
promptRunOptions: options,
|
|
4756
|
+
});
|
|
4565
4757
|
}
|
|
4566
4758
|
}
|
|
4567
4759
|
}
|
|
@@ -4569,20 +4761,21 @@ class OpenAiCodexRunner {
|
|
|
4569
4761
|
/**
|
|
4570
4762
|
* Waits for the next Codex retry while polling for requested pause checkpoints.
|
|
4571
4763
|
*/
|
|
4572
|
-
async function waitForRetryDelay(
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4764
|
+
async function waitForRetryDelay(options) {
|
|
4765
|
+
const { delayMs, retryDeadlineTimeMs, promptRunOptions } = options;
|
|
4766
|
+
await waitUntilWorldTimeDeadline({
|
|
4767
|
+
deadlineTimeMs: retryDeadlineTimeMs,
|
|
4768
|
+
pollIntervalMs: RATE_LIMIT_BACKOFF_POLL_MS,
|
|
4769
|
+
onTick: async (remainingDelayMs) => {
|
|
4770
|
+
var _a;
|
|
4771
|
+
const remainingDelayLabel = formatDelay(Math.min(remainingDelayMs, delayMs));
|
|
4772
|
+
await ((_a = promptRunOptions.waitForPauseCheckpoint) === null || _a === void 0 ? void 0 : _a.call(promptRunOptions, {
|
|
4773
|
+
checkpointLabel: 'the next OpenAI Codex retry after rate limit',
|
|
4774
|
+
phase: 'running',
|
|
4775
|
+
statusMessage: `Waiting ${remainingDelayLabel} before retrying OpenAI Codex`,
|
|
4776
|
+
}));
|
|
4777
|
+
},
|
|
4778
|
+
});
|
|
4586
4779
|
}
|
|
4587
4780
|
|
|
4588
4781
|
/**
|
|
@@ -4720,17 +4913,6 @@ const DEFAULT_CODEX_MODEL = 'gpt-5.2-codex';
|
|
|
4720
4913
|
* Constant for cline model.
|
|
4721
4914
|
*/
|
|
4722
4915
|
const CLINE_MODEL = 'gemini:gemini-3-flash-preview';
|
|
4723
|
-
/**
|
|
4724
|
-
* Map of runner labels.
|
|
4725
|
-
*/
|
|
4726
|
-
const RUNNER_LABELS = {
|
|
4727
|
-
'openai-codex': 'OpenAI Codex',
|
|
4728
|
-
'github-copilot': 'GitHub Copilot',
|
|
4729
|
-
cline: 'Cline',
|
|
4730
|
-
'claude-code': 'Claude Code',
|
|
4731
|
-
opencode: 'Opencode',
|
|
4732
|
-
gemini: 'Gemini CLI',
|
|
4733
|
-
};
|
|
4734
4916
|
/**
|
|
4735
4917
|
* Resolves the configured prompt runner together with status-line metadata.
|
|
4736
4918
|
*
|
|
@@ -4822,8 +5004,7 @@ function createRunnerResolution(options, runner, actualRunnerModel) {
|
|
|
4822
5004
|
* Resolves runner metadata for prompt status lines.
|
|
4823
5005
|
*/
|
|
4824
5006
|
function getRunnerMetadata(options, actualRunnerModel) {
|
|
4825
|
-
|
|
4826
|
-
const runnerName = options.agentName ? (_a = RUNNER_LABELS[options.agentName]) !== null && _a !== void 0 ? _a : 'unknown' : 'unknown';
|
|
5007
|
+
const runnerName = options.agentName ? getHarnessDefinition(options.agentName).label : 'unknown';
|
|
4827
5008
|
if (options.agentName === 'openai-codex' ||
|
|
4828
5009
|
options.agentName === 'github-copilot' ||
|
|
4829
5010
|
options.agentName === 'gemini') {
|
|
@@ -4869,16 +5050,87 @@ function exitForMissingModel(agentName, availableModels, exampleUsages) {
|
|
|
4869
5050
|
process.exit(1);
|
|
4870
5051
|
}
|
|
4871
5052
|
|
|
5053
|
+
/**
|
|
5054
|
+
* Builds the `## Projects` prompt section explaining the agent-owned projects convention.
|
|
5055
|
+
*
|
|
5056
|
+
* The section is part of the prompt of every harness, so each coding agent knows it has its
|
|
5057
|
+
* own isolated project folders it fully controls and how to reference them in the chat.
|
|
5058
|
+
*/
|
|
5059
|
+
function buildAgentProjectsPromptSection(options = {}) {
|
|
5060
|
+
const { projectsUrlPath } = options;
|
|
5061
|
+
return spaceTrim$1((block) => `
|
|
5062
|
+
## Projects
|
|
5063
|
+
|
|
5064
|
+
You have your own projects folder \`${AGENT_PROJECTS_DIRECTORY_PATH}/\` in the current working directory. Each direct subfolder of it is one project — your own isolated environment for persistent work.
|
|
5065
|
+
|
|
5066
|
+
- You have 100% control over every project folder: create, read, modify, and delete files there, run scripts and commands inside it, and keep any persistent data you need between conversations.
|
|
5067
|
+
- When the user asks you to build something (for example a website) or to do longer-term work, create a new project folder \`${AGENT_PROJECTS_DIRECTORY_PATH}/<project-name>/\` (use a short kebab-case name) and do the work inside it. Modify an existing project when the user refers to work you already did.
|
|
5068
|
+
- A project can be a git repository — you can run \`git init\` inside a project folder and commit your work there.
|
|
5069
|
+
- Do not touch anything outside the \`${AGENT_PROJECTS_DIRECTORY_PATH}/\` directory except the queued message file you are answering.
|
|
5070
|
+
|
|
5071
|
+
${block(buildProjectReferenceInstructions(projectsUrlPath))}
|
|
5072
|
+
${block(buildProjectRuntimeInstructions(options.projectRuntimeApi))}
|
|
5073
|
+
`);
|
|
5074
|
+
}
|
|
5075
|
+
/**
|
|
5076
|
+
* Builds the part of the section explaining how to reference projects in chat answers.
|
|
5077
|
+
*/
|
|
5078
|
+
function buildProjectReferenceInstructions(projectsUrlPath) {
|
|
5079
|
+
if (!projectsUrlPath) {
|
|
5080
|
+
return spaceTrim$1(`
|
|
5081
|
+
When you mention a project or its files in your answer, reference them by the project name and the file path inside the project, for example \`${AGENT_PROJECTS_DIRECTORY_PATH}/my-website/index.html\`.
|
|
5082
|
+
`);
|
|
5083
|
+
}
|
|
5084
|
+
return spaceTrim$1(`
|
|
5085
|
+
You can link any project or any file of any project into the chat answer as a markdown link:
|
|
5086
|
+
|
|
5087
|
+
- Link one file: \`[index.html](${projectsUrlPath}/<project-name>/files/<file-path>)\` — for example \`[Homepage](${projectsUrlPath}/my-website/files/index.html)\`
|
|
5088
|
+
- Link the projects dashboard listing all your projects: \`[My projects](${projectsUrlPath})\`
|
|
5089
|
+
|
|
5090
|
+
Use these links whenever you want to show the user a file you created or changed in a project.
|
|
5091
|
+
`);
|
|
5092
|
+
}
|
|
5093
|
+
/**
|
|
5094
|
+
* Builds instructions for running projects through the Agents Server runtime API.
|
|
5095
|
+
*/
|
|
5096
|
+
function buildProjectRuntimeInstructions(projectRuntimeApi) {
|
|
5097
|
+
if (!projectRuntimeApi) {
|
|
5098
|
+
return '';
|
|
5099
|
+
}
|
|
5100
|
+
return spaceTrim$1(`
|
|
5101
|
+
You can make a project runnable in the user's browser by asking the Agents Server to start it:
|
|
5102
|
+
|
|
5103
|
+
- The server automatically runs \`npm run dev\` for a project whose \`package.json\` declares a non-empty \`dev\` script.
|
|
5104
|
+
- Otherwise, the server starts a static file server for the project.
|
|
5105
|
+
- If you need to run your own long-lived dev process, ask only for \`assign_port\`, then start your process on the returned \`runtime.port\`.
|
|
5106
|
+
- Always include the returned \`runtime.url\` in your answer when the user should open the running project.
|
|
5107
|
+
|
|
5108
|
+
Examples:
|
|
5109
|
+
|
|
5110
|
+
\`\`\`bash
|
|
5111
|
+
curl -sS -X POST "$${projectRuntimeApi.serverUrlEnvironmentVariableName}/api/internal/agent-project-runtimes" \\
|
|
5112
|
+
-H "Content-Type: application/json" \\
|
|
5113
|
+
-H "x-user-chat-worker-token: $${projectRuntimeApi.tokenEnvironmentVariableName}" \\
|
|
5114
|
+
-d '{"action":"start","agentPermanentId":"${projectRuntimeApi.agentPermanentId}","projectName":"<project-name>"}'
|
|
5115
|
+
|
|
5116
|
+
curl -sS -X POST "$${projectRuntimeApi.serverUrlEnvironmentVariableName}/api/internal/agent-project-runtimes" \\
|
|
5117
|
+
-H "Content-Type: application/json" \\
|
|
5118
|
+
-H "x-user-chat-worker-token: $${projectRuntimeApi.tokenEnvironmentVariableName}" \\
|
|
5119
|
+
-d '{"action":"assign_port","agentPermanentId":"${projectRuntimeApi.agentPermanentId}","projectName":"<project-name>"}'
|
|
5120
|
+
\`\`\`
|
|
5121
|
+
`);
|
|
5122
|
+
}
|
|
5123
|
+
|
|
4872
5124
|
/**
|
|
4873
5125
|
* Builds the prompt sent to the selected coding runner for one queued user-thread book.
|
|
4874
5126
|
*/
|
|
4875
|
-
function buildAgentMessagePrompt(messageRelativePath, agentSystemMessage) {
|
|
5127
|
+
function buildAgentMessagePrompt(messageRelativePath, agentSystemMessage, options = {}) {
|
|
4876
5128
|
return spaceTrim$1((block) => `
|
|
4877
5129
|
# Answer 1 user question
|
|
4878
5130
|
|
|
4879
5131
|
- Read \`${messageRelativePath}\` and answer the most recent \`MESSAGE @User\`
|
|
4880
5132
|
- Only change the queued message file by appending one new \`MESSAGE @Agent\` block
|
|
4881
|
-
- Do not modify any other file in the repository
|
|
5133
|
+
- Do not modify any other file in the repository, except files inside your own \`${AGENT_PROJECTS_DIRECTORY_PATH}/\` directory
|
|
4882
5134
|
|
|
4883
5135
|
## Rules for the answering
|
|
4884
5136
|
|
|
@@ -4914,34 +5166,46 @@ function buildAgentMessagePrompt(messageRelativePath, agentSystemMessage) {
|
|
|
4914
5166
|
|
|
4915
5167
|
- You can use \`message\` for message that will be sent immediately after clicking the button, or \`messageDraft\` for message that will be prefilled in the input field for editing before sending.
|
|
4916
5168
|
|
|
5169
|
+
${block(buildAgentProjectsPromptSection(options))}
|
|
5170
|
+
|
|
4917
5171
|
## This is how you should behave
|
|
4918
5172
|
|
|
4919
5173
|
${block(agentSystemMessage)}
|
|
4920
5174
|
`);
|
|
4921
5175
|
}
|
|
4922
5176
|
|
|
4923
|
-
/**
|
|
4924
|
-
* Builds a normalized temporary shell script path for prompt runners.
|
|
4925
|
-
*/
|
|
4926
|
-
function buildTemporaryPromptScriptPath(options) {
|
|
4927
|
-
const sourceFileName = basename(options.sourceFileName);
|
|
4928
|
-
const scriptFileName = `${sourceFileName.replace(/\.[^.]+$/u, '')}${options.suffix || ''}.sh`;
|
|
4929
|
-
return resolvePromptbookTemporaryPath(options.projectPath, options.scriptDirectoryName, scriptFileName);
|
|
4930
|
-
}
|
|
4931
|
-
|
|
4932
5177
|
/**
|
|
4933
5178
|
* Temporary subdirectory used for agent-message runner shell scripts.
|
|
5179
|
+
*
|
|
5180
|
+
* @private internal constant of agent-message runtime paths
|
|
4934
5181
|
*/
|
|
4935
5182
|
const AGENT_MESSAGE_SCRIPT_DIRECTORY_NAME = 'agent-messages';
|
|
5183
|
+
/**
|
|
5184
|
+
* File extension used for temporary prompt-runner shell scripts.
|
|
5185
|
+
*
|
|
5186
|
+
* @private internal constant of agent-message runtime paths
|
|
5187
|
+
*/
|
|
5188
|
+
const AGENT_MESSAGE_SCRIPT_EXTENSION = '.sh';
|
|
5189
|
+
/**
|
|
5190
|
+
* Builds the temporary shell script path used by one queued agent-message harness run.
|
|
5191
|
+
*
|
|
5192
|
+
* @param projectPath - Local agent project path containing the message queue.
|
|
5193
|
+
* @param sourceFileName - Queued message filename used to name the temporary shell script.
|
|
5194
|
+
* @returns Temporary shell script path.
|
|
5195
|
+
* @private internal utility of agent-message runners
|
|
5196
|
+
*/
|
|
5197
|
+
function buildAgentMessageScriptPathFromFileName(projectPath, sourceFileName) {
|
|
5198
|
+
const sourceFileBasename = basename(sourceFileName);
|
|
5199
|
+
const scriptFileName = `${sourceFileBasename.replace(/\.[^.]+$/u, '')}${AGENT_MESSAGE_SCRIPT_EXTENSION}`;
|
|
5200
|
+
return resolvePromptbookTemporaryPath(projectPath, AGENT_MESSAGE_SCRIPT_DIRECTORY_NAME, scriptFileName);
|
|
5201
|
+
}
|
|
5202
|
+
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
5203
|
+
|
|
4936
5204
|
/**
|
|
4937
5205
|
* Builds a temporary script path for one agent message runner invocation.
|
|
4938
5206
|
*/
|
|
4939
5207
|
function buildAgentMessageScriptPath(projectPath, messageFile) {
|
|
4940
|
-
return
|
|
4941
|
-
projectPath,
|
|
4942
|
-
scriptDirectoryName: AGENT_MESSAGE_SCRIPT_DIRECTORY_NAME,
|
|
4943
|
-
sourceFileName: messageFile.fileName,
|
|
4944
|
-
});
|
|
5208
|
+
return buildAgentMessageScriptPathFromFileName(projectPath, messageFile.fileName);
|
|
4945
5209
|
}
|
|
4946
5210
|
|
|
4947
5211
|
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge from Markdown\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book`\n- INPUT PARAMETER `{knowledgeContent}` Markdown document content\n- OUTPUT PARAMETER `{knowledgePieces}` The knowledge JSON object\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}\n```\n\n`-> {knowledgePieces}`\n"}],sourceFile:"./books/prepare-knowledge-from-markdown.book"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Keywords\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-keywords.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{keywords}` Keywords separated by comma\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}\n```\n\n`-> {keywords}`\n"}],sourceFile:"./books/prepare-knowledge-keywords.book"},{title:"Prepare Knowledge-piece Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge-piece Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-title.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{title}` The title of the document\n\n## Knowledge\n\n- EXPECT MIN 1 WORD\n- EXPECT MAX 8 WORDS\n\n```markdown\nYou are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-knowledge-title.book"},{title:"Prepare Persona",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book",formfactorName:"GENERIC",parameters:[{name:"availableModels",description:"List of available model names together with their descriptions as JSON",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelsRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n```json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpful assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n```\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nHere are the available models:\n\n```json\n{availableModels}\n```\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelsRequirements",format:"JSON",dependentParameterNames:["availableModels","personaDescription"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Persona\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-persona.book`\n- INPUT PARAMETER `{availableModels}` List of available model names together with their descriptions as JSON\n- INPUT PARAMETER `{personaDescription}` Description of the persona\n- OUTPUT PARAMETER `{modelsRequirements}` Specific requirements for the model\n\n## Make modelRequirements\n\n- FORMAT JSON\n\n```markdown\nYou are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n\\`\\`\\`json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpful assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n\\`\\`\\`\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nHere are the available models:\n\n\\`\\`\\`json\n{availableModels}\n\\`\\`\\`\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}\n```\n\n`-> {modelsRequirements}`\n"}],sourceFile:"./books/prepare-persona.book"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-title.book",formfactorName:"GENERIC",parameters:[{name:"book",description:"The book to prepare the title for",isInput:true,isOutput:false},{name:"title",description:"Best title for the book",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-title",title:"Make title",content:"Make best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}",resultingParameterName:"title",expectations:{words:{min:1,max:8},lines:{min:1,max:1}},dependentParameterNames:["book"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-title.book`\n- INPUT PARAMETER `{book}` The book to prepare the title for\n- OUTPUT PARAMETER `{title}` Best title for the book\n\n## Make title\n\n- EXPECT MIN 1 Word\n- EXPECT MAX 8 Words\n- EXPECT EXACTLY 1 Line\n\n```markdown\nMake best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-title.book"}];
|
|
@@ -14492,6 +14756,7 @@ class MessageSuffixCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14492
14756
|
* - META TITLE: Sets the agent's display title
|
|
14493
14757
|
* - META DESCRIPTION: Sets the agent's description
|
|
14494
14758
|
* - META INPUT PLACEHOLDER: Sets chat input placeholder text
|
|
14759
|
+
* - META THINKING MESSAGE: Adds custom thinking placeholder variants
|
|
14495
14760
|
* - META [ANYTHING]: Any other meta information in uppercase format
|
|
14496
14761
|
*
|
|
14497
14762
|
* These commitments are special because they don't affect the system message,
|
|
@@ -14507,6 +14772,7 @@ class MessageSuffixCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14507
14772
|
* META TITLE Professional Assistant
|
|
14508
14773
|
* META DESCRIPTION An AI assistant specialized in business tasks
|
|
14509
14774
|
* META INPUT PLACEHOLDER Write a message...
|
|
14775
|
+
* META THINKING MESSAGE Thinking...
|
|
14510
14776
|
* META AUTHOR John Doe
|
|
14511
14777
|
* META VERSION 1.0
|
|
14512
14778
|
* ```
|
|
@@ -14547,6 +14813,7 @@ class MetaCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14547
14813
|
- **META TITLE** - Sets the agent's display title
|
|
14548
14814
|
- **META DESCRIPTION** - Sets the agent's description
|
|
14549
14815
|
- **META INPUT PLACEHOLDER** - Sets chat input placeholder text
|
|
14816
|
+
- **META THINKING MESSAGE** - Adds custom thinking placeholder variants
|
|
14550
14817
|
- **META [ANYTHING]** - Any other meta information in uppercase format
|
|
14551
14818
|
|
|
14552
14819
|
## Key aspects
|
|
@@ -14555,6 +14822,7 @@ class MetaCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14555
14822
|
- Used for visual representation and attribution in user interfaces
|
|
14556
14823
|
- Multiple META commitments of different types can be used
|
|
14557
14824
|
- Multiple META LINK commitments can be used for different social profiles
|
|
14825
|
+
- Multiple META THINKING MESSAGE commitments can be used for different thinking placeholder variants
|
|
14558
14826
|
- If multiple META commitments of the same type are specified, the last one takes precedence (except for LINK)
|
|
14559
14827
|
|
|
14560
14828
|
## Examples
|
|
@@ -21353,6 +21621,68 @@ class MetaLinkCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
21353
21621
|
}
|
|
21354
21622
|
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
21355
21623
|
|
|
21624
|
+
/**
|
|
21625
|
+
* META THINKING MESSAGE commitment definition.
|
|
21626
|
+
*
|
|
21627
|
+
* The `META THINKING MESSAGE` commitment adds one custom thinking placeholder
|
|
21628
|
+
* variant used by chat UIs while an agent is composing a reply.
|
|
21629
|
+
*
|
|
21630
|
+
* @private Metadata-only commitment used by Agents Server chat UIs.
|
|
21631
|
+
*/
|
|
21632
|
+
class MetaThinkingMessageCommitmentDefinition extends BaseCommitmentDefinition {
|
|
21633
|
+
constructor() {
|
|
21634
|
+
super('META THINKING MESSAGE');
|
|
21635
|
+
}
|
|
21636
|
+
/**
|
|
21637
|
+
* Short one-line description of META THINKING MESSAGE.
|
|
21638
|
+
*/
|
|
21639
|
+
get description() {
|
|
21640
|
+
return 'Add a custom thinking placeholder shown while the agent replies.';
|
|
21641
|
+
}
|
|
21642
|
+
/**
|
|
21643
|
+
* Icon for this commitment.
|
|
21644
|
+
*/
|
|
21645
|
+
get icon() {
|
|
21646
|
+
return '💭';
|
|
21647
|
+
}
|
|
21648
|
+
/**
|
|
21649
|
+
* Markdown documentation for META THINKING MESSAGE commitment.
|
|
21650
|
+
*/
|
|
21651
|
+
get documentation() {
|
|
21652
|
+
return spaceTrim$1(`
|
|
21653
|
+
# META THINKING MESSAGE
|
|
21654
|
+
|
|
21655
|
+
Adds one custom placeholder variant shown while the agent is composing a reply.
|
|
21656
|
+
|
|
21657
|
+
## Key aspects
|
|
21658
|
+
|
|
21659
|
+
- Does not modify model behavior, system message, or tools.
|
|
21660
|
+
- Multiple \`META THINKING MESSAGE\` commitments define multiple variants.
|
|
21661
|
+
- Chat UIs randomly rotate between the configured variants while the reply is running.
|
|
21662
|
+
- When no non-empty variants are configured, the server-level \`THINKING_MESSAGES\` metadata is used.
|
|
21663
|
+
- Supports multiline markdown content.
|
|
21664
|
+
|
|
21665
|
+
## Example
|
|
21666
|
+
|
|
21667
|
+
\`\`\`book
|
|
21668
|
+
Helpful Assistant
|
|
21669
|
+
|
|
21670
|
+
META THINKING MESSAGE Thinking...
|
|
21671
|
+
META THINKING MESSAGE Processing...
|
|
21672
|
+
META THINKING MESSAGE
|
|
21673
|
+
|
|
21674
|
+
Doing
|
|
21675
|
+
extra **hard** work
|
|
21676
|
+
\`\`\`
|
|
21677
|
+
`);
|
|
21678
|
+
}
|
|
21679
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
21680
|
+
// META THINKING MESSAGE is metadata only and does not alter model requirements.
|
|
21681
|
+
return requirements;
|
|
21682
|
+
}
|
|
21683
|
+
}
|
|
21684
|
+
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
21685
|
+
|
|
21356
21686
|
/**
|
|
21357
21687
|
* META VISIBILITY commitment definition.
|
|
21358
21688
|
*
|
|
@@ -23431,6 +23761,7 @@ class UseBrowserCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
23431
23761
|
1. **One-shot URL fetching**: Simple function to fetch and scrape URL content (active)
|
|
23432
23762
|
2. **Running browser**: For complex tasks like scrolling, clicking, form filling, etc. (runtime-dependent)
|
|
23433
23763
|
- The actual browser tool usage is handled by the agent runtime
|
|
23764
|
+
- On the Agents Server, every agent browses in its own persistent isolated browser profile, so cookies and logged-in sessions survive across chats (the profile is linked from the agent wallet)
|
|
23434
23765
|
- Allows the agent to fetch current information from websites and documents
|
|
23435
23766
|
- Useful for research tasks, fact-checking, and accessing dynamic content
|
|
23436
23767
|
- Supports various content types including HTML pages and PDF documents
|
|
@@ -29975,6 +30306,7 @@ const COMMITMENT_REGISTRY = [
|
|
|
29975
30306
|
new MetaDomainCommitmentDefinition(),
|
|
29976
30307
|
new MetaDisclaimerCommitmentDefinition(),
|
|
29977
30308
|
new MetaInputPlaceholderCommitmentDefinition(),
|
|
30309
|
+
new MetaThinkingMessageCommitmentDefinition(),
|
|
29978
30310
|
new MetaVisibilityCommitmentDefinition(),
|
|
29979
30311
|
new MetaCommitmentDefinition(),
|
|
29980
30312
|
new MetaVoiceCommitmentDefinition(),
|
|
@@ -31326,6 +31658,7 @@ const META_COMMITMENT_APPLIERS = {
|
|
|
31326
31658
|
'META DESCRIPTION': applyMetaDescriptionContent,
|
|
31327
31659
|
'META DISCLAIMER': applyMetaDisclaimerContent,
|
|
31328
31660
|
'META INPUT PLACEHOLDER': applyMetaInputPlaceholderContent,
|
|
31661
|
+
'META THINKING MESSAGE': applyMetaThinkingMessageContent,
|
|
31329
31662
|
'MESSAGE SUFFIX': applyMessageSuffixContent,
|
|
31330
31663
|
'META COLOR': applyMetaColorContent,
|
|
31331
31664
|
'META FONT': applyMetaFontContent,
|
|
@@ -31416,6 +31749,16 @@ function applyMetaDisclaimerContent(state, content) {
|
|
|
31416
31749
|
function applyMetaInputPlaceholderContent(state, content) {
|
|
31417
31750
|
state.meta.inputPlaceholder = spaceTrim$1(content);
|
|
31418
31751
|
}
|
|
31752
|
+
/**
|
|
31753
|
+
* Applies one META THINKING MESSAGE content block into the custom thinking-message variants.
|
|
31754
|
+
*/
|
|
31755
|
+
function applyMetaThinkingMessageContent(state, content) {
|
|
31756
|
+
const thinkingMessage = spaceTrim$1(content);
|
|
31757
|
+
if (!thinkingMessage) {
|
|
31758
|
+
return;
|
|
31759
|
+
}
|
|
31760
|
+
state.thinkingMessages = [...(state.thinkingMessages || []), thinkingMessage];
|
|
31761
|
+
}
|
|
31419
31762
|
/**
|
|
31420
31763
|
* Applies MESSAGE SUFFIX content into the canonical `meta.messageSuffix` field.
|
|
31421
31764
|
*/
|
|
@@ -31784,6 +32127,7 @@ function extractParsedAgentProfile(commitments) {
|
|
|
31784
32127
|
capabilities: [],
|
|
31785
32128
|
samples: [],
|
|
31786
32129
|
knowledgeSources: [],
|
|
32130
|
+
thinkingMessages: [],
|
|
31787
32131
|
pendingUserMessage: null,
|
|
31788
32132
|
knownKnowledgeSourceUrls: new Set(),
|
|
31789
32133
|
};
|
|
@@ -31796,6 +32140,7 @@ function extractParsedAgentProfile(commitments) {
|
|
|
31796
32140
|
capabilities: state.capabilities,
|
|
31797
32141
|
samples: state.samples,
|
|
31798
32142
|
knowledgeSources: state.knowledgeSources,
|
|
32143
|
+
thinkingMessages: state.thinkingMessages,
|
|
31799
32144
|
};
|
|
31800
32145
|
}
|
|
31801
32146
|
/**
|
|
@@ -31835,6 +32180,7 @@ function parseAgentSource(agentSource) {
|
|
|
31835
32180
|
permanentId: parsedProfile.meta.id,
|
|
31836
32181
|
personaDescription,
|
|
31837
32182
|
initialMessage,
|
|
32183
|
+
thinkingMessages: parsedProfile.thinkingMessages,
|
|
31838
32184
|
meta: parsedProfile.meta,
|
|
31839
32185
|
links: parsedProfile.links,
|
|
31840
32186
|
parameters: parseParameters(agentSource),
|
|
@@ -43271,7 +43617,7 @@ async function locateAppOnWindows({ appName, windowsSuffix, }) {
|
|
|
43271
43617
|
*
|
|
43272
43618
|
* @private within the repository
|
|
43273
43619
|
*/
|
|
43274
|
-
function locateApp(options) {
|
|
43620
|
+
async function locateApp(options) {
|
|
43275
43621
|
if (!$isRunningInNode()) {
|
|
43276
43622
|
throw new EnvironmentMismatchError('Locating apps works only in Node.js environment');
|
|
43277
43623
|
}
|