@promptbook/cli 0.112.0-104 → 0.112.0-105
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/apps/agents-server/src/app/admin/image-generator-test/ImageAttachmentsEditor.tsx +19 -3
- package/apps/agents-server/src/app/admin/limits/LimitsClient.tsx +11 -12
- package/apps/agents-server/src/app/admin/metadata/MetadataClient.tsx +34 -2
- package/apps/agents-server/src/app/admin/servers/CreateServerDialog.tsx +6 -1
- package/apps/agents-server/src/app/admin/servers/useCreateServerWizard.ts +13 -1
- package/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +11 -2
- package/apps/agents-server/src/app/agents/[agentName]/AgentProfileChat.tsx +11 -1
- package/apps/agents-server/src/app/agents/[agentName]/book/BookEditorWrapper.tsx +7 -1
- package/apps/agents-server/src/app/agents/[agentName]/chat/CanonicalAgentChatSurface.tsx +11 -1
- package/apps/agents-server/src/app/agents/[agentName]/images/default-avatar.png/route.ts +6 -2
- package/apps/agents-server/src/app/api/images/[filename]/route.ts +6 -2
- package/apps/agents-server/src/app/api/internal/agent-runner-limits/route.ts +51 -0
- package/apps/agents-server/src/app/api/upload/route.ts +48 -12
- package/apps/agents-server/src/app/layout.tsx +13 -0
- package/apps/agents-server/src/components/FileUploadAvailability/FileUploadAvailabilityContext.tsx +50 -0
- package/apps/agents-server/src/components/FileUploadAvailability/FileUploadUnavailableNotice.tsx +45 -0
- package/apps/agents-server/src/components/LayoutWrapper/LayoutWrapper.tsx +85 -76
- package/apps/agents-server/src/components/NewAgentDialog/NewAgentDialog.tsx +7 -3
- package/apps/agents-server/src/components/NewAgentDialog/NewAgentWizardKnowledgeStep.tsx +6 -0
- package/apps/agents-server/src/components/NewAgentDialog/useNewAgentWizardKnowledgeState.ts +8 -1
- package/apps/agents-server/src/constants/serverLimits.ts +22 -2
- package/apps/agents-server/src/database/seedDefaultAgents.ts +218 -0
- package/apps/agents-server/src/tools/$provideCdnForServer.ts +72 -8
- package/apps/agents-server/src/utils/defaultAgents/loadDefaultAgentBooks.ts +103 -0
- package/apps/agents-server/src/utils/knowledge/createInlineKnowledgeSourceUploader.ts +24 -5
- package/apps/agents-server/src/utils/serverLimits.ts +26 -1
- package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerDefaultAgents.ts +1 -85
- package/apps/agents-server/src/utils/shareTargetPayloads.ts +20 -2
- package/apps/agents-server/src/utils/upload/fileUploadAvailability.ts +91 -0
- package/apps/agents-server/src/utils/upload/uploadFileToServer.ts +46 -2
- package/esm/apps/agents-server/src/constants/federatedAgentImport.d.ts +42 -0
- package/esm/apps/agents-server/src/constants/serverLimits.d.ts +207 -0
- package/esm/apps/agents-server/src/constants/toolUsageLimits.d.ts +55 -0
- package/esm/index.es.js +602 -39
- package/esm/index.es.js.map +1 -1
- package/esm/scripts/run-agent-messages/main/AgentMessageFailureTracker.d.ts +27 -0
- package/esm/scripts/run-agent-messages/main/handleAgentWatchError.d.ts +4 -0
- package/esm/scripts/run-agent-messages/main/runAgentMessages.d.ts +1 -0
- package/esm/scripts/run-agent-messages/messages/moveAgentMessageToFailed.d.ts +17 -0
- package/esm/src/book-components/BookEditor/BookEditor.d.ts +5 -4
- package/esm/src/book-components/BookEditor/BookEditorTheme.d.ts +24 -0
- package/esm/src/book-components/BookEditor/useBookEditorMonacoLanguage.d.ts +1 -6
- package/esm/src/book-components/BookEditor/useBookEditorMonacoLifecycle.d.ts +1 -4
- package/esm/src/book-components/BookEditor/useBookEditorMonacoStyles.d.ts +2 -1
- package/esm/src/cli/cli-commands/agent-folder/agentProjectPaths.d.ts +6 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/avatars/visuals/octopus3d3AvatarVisual.ts +28 -29
- package/src/book-components/BookEditor/BookEditor.tsx +10 -7
- package/src/book-components/BookEditor/BookEditorMonaco.tsx +3 -1
- package/src/book-components/BookEditor/BookEditorTheme.ts +32 -0
- package/src/book-components/BookEditor/useBookEditorMonacoLanguage.ts +12 -15
- package/src/book-components/BookEditor/useBookEditorMonacoLifecycle.ts +1 -5
- package/src/book-components/BookEditor/useBookEditorMonacoStyles.ts +2 -1
- package/src/cli/cli-commands/agent-folder/agentProjectPaths.ts +7 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer.ts +109 -9
- package/src/cli/cli-commands/agents-server/startAgentsServer.ts +132 -4
- package/src/other/templates/getTemplatesPipelineCollection.ts +729 -854
- package/src/version.ts +2 -2
- package/src/versions.txt +1 -0
- package/umd/apps/agents-server/src/constants/federatedAgentImport.d.ts +42 -0
- package/umd/apps/agents-server/src/constants/serverLimits.d.ts +207 -0
- package/umd/apps/agents-server/src/constants/toolUsageLimits.d.ts +55 -0
- package/umd/index.umd.js +602 -39
- package/umd/index.umd.js.map +1 -1
- package/umd/scripts/run-agent-messages/main/AgentMessageFailureTracker.d.ts +27 -0
- package/umd/scripts/run-agent-messages/main/handleAgentWatchError.d.ts +4 -0
- package/umd/scripts/run-agent-messages/main/runAgentMessages.d.ts +1 -0
- package/umd/scripts/run-agent-messages/messages/moveAgentMessageToFailed.d.ts +17 -0
- package/umd/src/book-components/BookEditor/BookEditor.d.ts +5 -4
- package/umd/src/book-components/BookEditor/BookEditorTheme.d.ts +24 -0
- package/umd/src/book-components/BookEditor/useBookEditorMonacoLanguage.d.ts +1 -6
- package/umd/src/book-components/BookEditor/useBookEditorMonacoLifecycle.d.ts +1 -4
- package/umd/src/book-components/BookEditor/useBookEditorMonacoStyles.d.ts +2 -1
- package/umd/src/cli/cli-commands/agent-folder/agentProjectPaths.d.ts +6 -0
- package/umd/src/version.d.ts +1 -1
- package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddress.test.ts.todo +0 -108
- package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddresses.test.ts.todo +0 -117
- package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddress.test.ts.todo +0 -119
- package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddresses.test.ts.todo +0 -74
- package/apps/agents-server/src/utils/defaultAgents/defaultAgents.ts +0 -168
- package/apps/agents-server/src/utils/defaultAgents/installDefaultAgents.ts +0 -139
- package/apps/agents-server/tests/e2e/authentication-and-navigation.spec.ts.todo +0 -178
- package/src/_packages/browser.index.ts +0 -31
- package/src/_packages/browser.readme.md +0 -43
- package/src/book-2.0/agent-source/parseAgentSourceWithCommitments.test.ts.todo +0 -265
- package/src/book-components/BookEditor/BookEditorMonaco.test.tsx.todo +0 -115
- package/src/book-components/Chat/utils/renderMarkdown.test.ts.tmp +0 -199
- package/src/collection/agent-collection/constructors/agent-collection-in-directory/AgentCollectionInDirectory.test.ts.todo +0 -131
- package/src/commands/_common/parseCommand.test.ts.todo +0 -48
- package/src/commitments/META_LINK/META_LINK.test.ts.todo +0 -75
- package/src/conversion/validation/pipelineStringToJson-errors.test.ts.todo +0 -33
- package/src/dialogs/simple-prompt/SimplePromptInterfaceTools.ts +0 -51
- package/src/executables/browsers/locateSafari.test.ts.tmp +0 -15
- package/src/execution/PromptbookFetch.test-type.ts +0 -14
- package/src/execution/createPipelineExecutor/00-createPipelineExecutor.test.ts.todo +0 -0
- package/src/execution/execution-report/executionReportJsonToString.test.ts.todo +0 -83
- package/src/execution/utils/usageToHuman.test.ts.todo +0 -80
- package/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.ts +0 -76
- package/src/llm-providers/_common/utils/assertUniqueModels.ts +0 -27
- package/src/llm-providers/_multiple/playground/playground.ts +0 -141
- package/src/llm-providers/_multiple/playground/tsconfig.json +0 -19
- package/src/llm-providers/agent/playground/playground.ts +0 -190
- package/src/llm-providers/agent/playground/tsconfig.json +0 -19
- package/src/llm-providers/anthropic-claude/playground/playground.ts +0 -99
- package/src/llm-providers/anthropic-claude/playground/tsconfig.json +0 -19
- package/src/llm-providers/azure-openai/playground/playground.ts +0 -101
- package/src/llm-providers/azure-openai/playground/tsconfig.json +0 -19
- package/src/llm-providers/ollama/playground/playground.ts +0 -120
- package/src/llm-providers/ollama/playground/tsconfig.json +0 -19
- package/src/llm-providers/openai/playground/playground.ts +0 -406
- package/src/llm-providers/openai/playground/tsconfig.json +0 -19
- package/src/llm-providers/remote/playground/playground.ts +0 -144
- package/src/llm-providers/remote/playground/tsconfig.json +0 -19
- package/src/llm-providers/vercel/playground/playground.ts +0 -133
- package/src/llm-providers/vercel/playground/tsconfig.json +0 -19
- package/src/personas/preparePersona.test.ts.todo +0 -126
- package/src/playground/backup/_playground-boilerplate.ts.txt +0 -37
- package/src/playground/backup/playground-agent-os.txt +0 -62
- package/src/playground/backup/playground-brj-app.ts.txt +0 -302
- package/src/playground/backup/playground-browser-playwright.txt +0 -110
- package/src/playground/backup/playground-claude-mcp.txt +0 -43
- package/src/playground/backup/playground-document-conversion.txt +0 -84
- package/src/playground/backup/playground-glob.ts.txt +0 -42
- package/src/playground/backup/playground-mcp-server.txt +0 -1
- package/src/playground/backup/playground-openai-agent-kit.txt +0 -73
- package/src/playground/backup/playground-openai-function-calling.txt +0 -131
- package/src/playground/backup/playground-openai-streaming.ts.txt +0 -68
- package/src/playground/backup/playground-scrape-knowledge.txt +0 -65
- package/src/playground/backup/playground-scraperFetch.ts.txt +0 -44
- package/src/playground/backup/playground-using-openai-compatible-route-on-agents-server.ts.txt +0 -49
- package/src/playground/backup/playground-write-pavolhejny-bio.txt +0 -120
- package/src/playground/permanent/_boilerplate.ts +0 -54
- package/src/playground/permanent/agent-with-browser-playground.ts +0 -92
- package/src/playground/permanent/error-handling-playground.ts +0 -103
- package/src/playground/playground.ts +0 -36
- package/src/playground/tsconfig.json +0 -19
- package/src/scrapers/_boilerplate/BoilerplateScraper.test.ts.todo +0 -73
- package/src/scrapers/_boilerplate/playground/boilerplate-scraper-playground.ts +0 -79
- package/src/scrapers/_boilerplate/playground/tsconfig.json +0 -19
- package/src/scrapers/_common/utils/files/blobToDataurl.test.ts.todo +0 -17
- package/src/scrapers/_common/utils/files/dataurlToBlob.test.ts.todo +0 -52
- package/src/scrapers/_common/utils/files/isValidDataurl.test.ts.todo +0 -42
- package/src/scrapers/_common/utils/files/shorten.test.ts.todo +0 -13
- package/src/scrapers/document/playground/document-scraper-playground.ts +0 -80
- package/src/scrapers/document/playground/tsconfig.json +0 -19
- package/src/scrapers/document-legacy/playground/legacy-document-scraper-playground.ts +0 -80
- package/src/scrapers/document-legacy/playground/tsconfig.json +0 -19
- package/src/scrapers/markdown/playground/markdown-scraper-playground.ts +0 -74
- package/src/scrapers/markdown/playground/tsconfig.json +0 -19
- package/src/scrapers/markitdown/MarkitdownScraper.test.ts.todo +0 -132
- package/src/scrapers/markitdown/playground/markitdown-scraper-playground.ts +0 -91
- package/src/scrapers/markitdown/playground/tsconfig.json +0 -19
- package/src/scrapers/pdf/PdfScraper.test.ts.todo +0 -52
- package/src/scrapers/pdf/playground/pdf-scraper-playground.ts +0 -75
- package/src/scrapers/pdf/playground/tsconfig.json +0 -19
- package/src/scrapers/website/playground/tsconfig.json +0 -19
- package/src/scrapers/website/playground/website-scraper-playground.ts +0 -82
- package/src/storage/_common/PromptbookStorage.test-type.ts +0 -14
- package/src/storage/local-storage/getIndexedDbStorage.ts +0 -36
- package/src/storage/local-storage/getLocalStorage.ts +0 -33
- package/src/storage/local-storage/getSessionStorage.ts +0 -33
- package/src/storage/local-storage/utils/IndexedDbStorageOptions.ts +0 -16
- package/src/storage/local-storage/utils/makePromptbookStorageFromIndexedDb.ts +0 -58
- package/src/storage/local-storage/utils/makePromptbookStorageFromWebStorage.ts +0 -45
- package/src/transpilers/formatted-book-in-markdown/FormattedBookInMarkdownTranspiler.test.ts.todo +0 -35
- package/src/transpilers/openai-sdk/playground/playground.ts +0 -85
- package/src/transpilers/openai-sdk/playground/tmp/chatbot-openaisdk-1.js +0 -194
- package/src/transpilers/openai-sdk/playground/tmp/package.json +0 -3
- package/src/transpilers/openai-sdk/playground/tsconfig.json +0 -18
- package/src/utils/editable/utils/findUsableParameters.test.ts.todo +0 -43
- package/src/utils/editable/utils/stringifyPipelineJson.test.ts.todo +0 -38
- package/src/utils/markdown/prettifyMarkdown.test.ts.tmp +0 -42
- package/src/utils/serialization/serializeToPromptbookJavascript.test.ts.todo +0 -116
|
@@ -96,12 +96,41 @@ const AGENTS_SERVER_BUILD_INPUT_EXCLUDED_DIRECTORY_NAMES = new Set([
|
|
|
96
96
|
'test-results',
|
|
97
97
|
]);
|
|
98
98
|
|
|
99
|
+
/**
|
|
100
|
+
* Runtime source files excluded from the packaged Agents Server copy.
|
|
101
|
+
*
|
|
102
|
+
* @private internal constant of `ptbk agents-server`
|
|
103
|
+
*/
|
|
104
|
+
const AGENTS_SERVER_BUILD_INPUT_EXCLUDED_SOURCE_PATHS = new Set([
|
|
105
|
+
'src/_packages/browser.index.ts',
|
|
106
|
+
'src/_packages/browser.readme.md',
|
|
107
|
+
'src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.ts',
|
|
108
|
+
'src/llm-providers/_common/utils/assertUniqueModels.ts',
|
|
109
|
+
]);
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Runtime source folders excluded from the packaged Agents Server copy.
|
|
113
|
+
*
|
|
114
|
+
* @private internal constant of `ptbk agents-server`
|
|
115
|
+
*/
|
|
116
|
+
const AGENTS_SERVER_BUILD_INPUT_EXCLUDED_SOURCE_PATH_PREFIXES = [
|
|
117
|
+
'src/dialogs/simple-prompt',
|
|
118
|
+
'src/storage/local-storage',
|
|
119
|
+
] as const;
|
|
120
|
+
|
|
99
121
|
/**
|
|
100
122
|
* Test files copied out of packaged runtime input paths because Next does not build them.
|
|
101
123
|
*
|
|
102
124
|
* @private internal constant of `ptbk agents-server`
|
|
103
125
|
*/
|
|
104
|
-
const AGENTS_SERVER_BUILD_INPUT_TEST_FILE_PATTERN = /\.(?:spec|test)
|
|
126
|
+
const AGENTS_SERVER_BUILD_INPUT_TEST_FILE_PATTERN = /\.(?:spec|test)(?:\.|$)/iu;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Type-only compile check files copied out of packaged runtime input paths.
|
|
130
|
+
*
|
|
131
|
+
* @private internal constant of `ptbk agents-server`
|
|
132
|
+
*/
|
|
133
|
+
const AGENTS_SERVER_BUILD_INPUT_TEST_TYPE_FILE_PATTERN = /\.test-type\.[jt]sx?$/iu;
|
|
105
134
|
|
|
106
135
|
/**
|
|
107
136
|
* Metadata persisted after one successful Agents Server production build.
|
|
@@ -410,6 +439,7 @@ async function copyAgentsServerRuntimePath(options: {
|
|
|
410
439
|
*/
|
|
411
440
|
function shouldCopyAgentsServerRuntimePath(sourcePath: string, sourceRootPath: string): boolean {
|
|
412
441
|
const sourceRelativePath = relative(sourceRootPath, sourcePath).replace(/\\/gu, '/');
|
|
442
|
+
const sourceRuntimeRelativePath = normalizeRuntimeSourceRelativePath(sourcePath, sourceRootPath);
|
|
413
443
|
const sourcePathSegments = sourceRelativePath.split('/').filter(Boolean);
|
|
414
444
|
const sourceBasename = basename(sourcePath);
|
|
415
445
|
|
|
@@ -421,11 +451,58 @@ function shouldCopyAgentsServerRuntimePath(sourcePath: string, sourceRootPath: s
|
|
|
421
451
|
return false;
|
|
422
452
|
}
|
|
423
453
|
|
|
454
|
+
if (sourcePathSegments.includes('playground')) {
|
|
455
|
+
return false;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
if (isExcludedAgentsServerRuntimeSourcePath(sourceRuntimeRelativePath)) {
|
|
459
|
+
return false;
|
|
460
|
+
}
|
|
461
|
+
|
|
424
462
|
if (sourceBasename.startsWith('.env')) {
|
|
425
463
|
return false;
|
|
426
464
|
}
|
|
427
465
|
|
|
428
|
-
return
|
|
466
|
+
return (
|
|
467
|
+
!AGENTS_SERVER_BUILD_INPUT_TEST_FILE_PATTERN.test(sourceBasename) &&
|
|
468
|
+
!AGENTS_SERVER_BUILD_INPUT_TEST_TYPE_FILE_PATTERN.test(sourceBasename)
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Normalizes a copied runtime path to the shape used inside the packaged runtime root.
|
|
474
|
+
*/
|
|
475
|
+
function normalizeRuntimeSourceRelativePath(sourcePath: string, sourceRootPath: string): string {
|
|
476
|
+
const sourceRelativePath = relative(sourceRootPath, sourcePath).replace(/\\/gu, '/');
|
|
477
|
+
const sourceRootBasename = basename(sourceRootPath);
|
|
478
|
+
|
|
479
|
+
if (!sourceRelativePath) {
|
|
480
|
+
return sourceRootBasename;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
return `${sourceRootBasename}/${sourceRelativePath}`;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Checks whether one normalized runtime path is equal to or nested below another path.
|
|
488
|
+
*/
|
|
489
|
+
function isRuntimePathWithin(sourceRuntimeRelativePath: string, excludedSourcePathPrefix: string): boolean {
|
|
490
|
+
return (
|
|
491
|
+
sourceRuntimeRelativePath === excludedSourcePathPrefix ||
|
|
492
|
+
sourceRuntimeRelativePath.startsWith(`${excludedSourcePathPrefix}/`)
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Returns true for runtime source files and folders that are not needed by the Agents Server build.
|
|
498
|
+
*/
|
|
499
|
+
function isExcludedAgentsServerRuntimeSourcePath(sourceRuntimeRelativePath: string): boolean {
|
|
500
|
+
return (
|
|
501
|
+
AGENTS_SERVER_BUILD_INPUT_EXCLUDED_SOURCE_PATHS.has(sourceRuntimeRelativePath) ||
|
|
502
|
+
AGENTS_SERVER_BUILD_INPUT_EXCLUDED_SOURCE_PATH_PREFIXES.some((excludedSourcePathPrefix) =>
|
|
503
|
+
isRuntimePathWithin(sourceRuntimeRelativePath, excludedSourcePathPrefix),
|
|
504
|
+
)
|
|
505
|
+
);
|
|
429
506
|
}
|
|
430
507
|
|
|
431
508
|
/**
|
|
@@ -595,6 +672,10 @@ async function addAgentsServerBuildInputToFingerprint(
|
|
|
595
672
|
readonly runtimeRootPath: string;
|
|
596
673
|
},
|
|
597
674
|
): Promise<void> {
|
|
675
|
+
if (isExcludedAgentsServerBuildInputPath(options.inputPath, options.runtimeRootPath)) {
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
|
|
598
679
|
let inputStats;
|
|
599
680
|
|
|
600
681
|
try {
|
|
@@ -605,10 +686,6 @@ async function addAgentsServerBuildInputToFingerprint(
|
|
|
605
686
|
}
|
|
606
687
|
|
|
607
688
|
if (inputStats.isFile()) {
|
|
608
|
-
if (isExcludedAgentsServerBuildInputFile(options.inputPath)) {
|
|
609
|
-
return;
|
|
610
|
-
}
|
|
611
|
-
|
|
612
689
|
fingerprint.update(`file:${normalizeBuildInputPath(options.runtimeRootPath, options.inputPath)}\n`);
|
|
613
690
|
fingerprint.update(await readFile(options.inputPath));
|
|
614
691
|
fingerprint.update('\n');
|
|
@@ -636,10 +713,33 @@ async function addAgentsServerBuildInputToFingerprint(
|
|
|
636
713
|
}
|
|
637
714
|
|
|
638
715
|
/**
|
|
639
|
-
* Returns true for non-build
|
|
716
|
+
* Returns true for non-build files and folders inside shared runtime source paths.
|
|
640
717
|
*/
|
|
641
|
-
function
|
|
642
|
-
|
|
718
|
+
function isExcludedAgentsServerBuildInputPath(inputPath: string, runtimeRootPath: string): boolean {
|
|
719
|
+
const inputRelativePath = normalizeBuildInputPath(runtimeRootPath, inputPath);
|
|
720
|
+
const inputPathSegments = inputRelativePath.split('/').filter(Boolean);
|
|
721
|
+
const inputBasename = basename(inputPath);
|
|
722
|
+
|
|
723
|
+
if (
|
|
724
|
+
inputPathSegments.some((inputPathSegment) =>
|
|
725
|
+
AGENTS_SERVER_BUILD_INPUT_EXCLUDED_DIRECTORY_NAMES.has(inputPathSegment),
|
|
726
|
+
)
|
|
727
|
+
) {
|
|
728
|
+
return true;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
if (inputPathSegments.includes('playground')) {
|
|
732
|
+
return true;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
if (isExcludedAgentsServerRuntimeSourcePath(inputRelativePath)) {
|
|
736
|
+
return true;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
return (
|
|
740
|
+
AGENTS_SERVER_BUILD_INPUT_TEST_FILE_PATTERN.test(inputBasename) ||
|
|
741
|
+
AGENTS_SERVER_BUILD_INPUT_TEST_TYPE_FILE_PATTERN.test(inputBasename)
|
|
742
|
+
);
|
|
643
743
|
}
|
|
644
744
|
|
|
645
745
|
/**
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
ensureAgentsServerBuild,
|
|
20
20
|
resolveAgentsServerAppPath,
|
|
21
21
|
} from './buildAgentsServer';
|
|
22
|
+
import { DEFAULT_LOCAL_AGENT_RUNNER_MAX_FAILED_ATTEMPTS } from '../../../../apps/agents-server/src/constants/serverLimits';
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Local worker-pump delay while the Agents Server foreground process stays active.
|
|
@@ -41,6 +42,20 @@ const USER_CHAT_JOB_WORKER_REPEATED_ERROR_LOG_INTERVAL = 10;
|
|
|
41
42
|
*/
|
|
42
43
|
const USER_CHAT_JOB_WORKER_ERROR_BODY_MAX_LENGTH = 2_000;
|
|
43
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Delay between foreground CLI attempts to load internal Agents Server limits during startup.
|
|
47
|
+
*
|
|
48
|
+
* @private internal constant of `ptbk agents-server`
|
|
49
|
+
*/
|
|
50
|
+
const INTERNAL_SERVER_LIMITS_RETRY_DELAY_MS = 1_000;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Maximum time spent waiting for the internal limits route before startup fails.
|
|
54
|
+
*
|
|
55
|
+
* @private internal constant of `ptbk agents-server`
|
|
56
|
+
*/
|
|
57
|
+
const INTERNAL_SERVER_LIMITS_STARTUP_TIMEOUT_MS = 60_000;
|
|
58
|
+
|
|
44
59
|
/**
|
|
45
60
|
* HTTP status used by an idle internal worker tick with no job to process.
|
|
46
61
|
*
|
|
@@ -163,6 +178,15 @@ type AgentsServerSupervisorState = {
|
|
|
163
178
|
};
|
|
164
179
|
};
|
|
165
180
|
|
|
181
|
+
/**
|
|
182
|
+
* Local runner limits loaded from the running Agents Server app.
|
|
183
|
+
*
|
|
184
|
+
* @private internal type of `ptbk agents-server`
|
|
185
|
+
*/
|
|
186
|
+
type LocalAgentRunnerLimits = {
|
|
187
|
+
readonly maxFailedAttempts: number;
|
|
188
|
+
};
|
|
189
|
+
|
|
166
190
|
/**
|
|
167
191
|
* Starts the Agents Server web app and local coding-agent queue workers in the foreground.
|
|
168
192
|
*
|
|
@@ -229,6 +253,12 @@ export async function startAgentsServer(options: StartAgentsServerOptions): Prom
|
|
|
229
253
|
logStreams,
|
|
230
254
|
state,
|
|
231
255
|
});
|
|
256
|
+
const localAgentRunnerLimits = await waitForLocalAgentRunnerLimits({
|
|
257
|
+
port: options.port,
|
|
258
|
+
environment: runtimeChildEnvironment,
|
|
259
|
+
logStreams,
|
|
260
|
+
state,
|
|
261
|
+
});
|
|
232
262
|
stopUserChatJobWorkerPump = startUserChatJobWorkerPump({
|
|
233
263
|
port: options.port,
|
|
234
264
|
environment: runtimeChildEnvironment,
|
|
@@ -237,7 +267,7 @@ export async function startAgentsServer(options: StartAgentsServerOptions): Prom
|
|
|
237
267
|
});
|
|
238
268
|
|
|
239
269
|
await withCurrentWorkingDirectory(runtimePaths.agentRootPath, async () => {
|
|
240
|
-
await runMultipleAgentMessages(createLocalAgentRunOptions(options), {
|
|
270
|
+
await runMultipleAgentMessages(createLocalAgentRunOptions(options, localAgentRunnerLimits), {
|
|
241
271
|
shouldContinue: () => state.isContinuing,
|
|
242
272
|
watchErrorLogDirectoryPath: runtimePaths.logDirectoryPath,
|
|
243
273
|
onUiInitialized: (uiHandle) => {
|
|
@@ -409,7 +439,10 @@ function createAgentsServerChildEnvironment(port: number_port, agentRootPath: st
|
|
|
409
439
|
/**
|
|
410
440
|
* Creates local no-git agent runner options for folders managed by the Agents Server database.
|
|
411
441
|
*/
|
|
412
|
-
function createLocalAgentRunOptions(
|
|
442
|
+
function createLocalAgentRunOptions(
|
|
443
|
+
options: StartAgentsServerOptions,
|
|
444
|
+
localAgentRunnerLimits: LocalAgentRunnerLimits,
|
|
445
|
+
): AgentRunOptions {
|
|
413
446
|
return {
|
|
414
447
|
agentName: options.agentName,
|
|
415
448
|
model: options.model,
|
|
@@ -422,9 +455,90 @@ function createLocalAgentRunOptions(options: StartAgentsServerOptions): AgentRun
|
|
|
422
455
|
autoPush: false,
|
|
423
456
|
autoPull: false,
|
|
424
457
|
autoClone: false,
|
|
458
|
+
maxMessageProcessingFailures: localAgentRunnerLimits.maxFailedAttempts,
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Waits until the internal Next route can return current local runner limits.
|
|
464
|
+
*/
|
|
465
|
+
async function waitForLocalAgentRunnerLimits(options: {
|
|
466
|
+
readonly port: number_port;
|
|
467
|
+
readonly environment: AgentsServerChildEnvironment;
|
|
468
|
+
readonly logStreams: AgentsServerLogStreams;
|
|
469
|
+
readonly state: AgentsServerSupervisorState;
|
|
470
|
+
}): Promise<LocalAgentRunnerLimits> {
|
|
471
|
+
const startedAt = Date.now();
|
|
472
|
+
let lastError: unknown;
|
|
473
|
+
|
|
474
|
+
while (options.state.isContinuing && Date.now() - startedAt < INTERNAL_SERVER_LIMITS_STARTUP_TIMEOUT_MS) {
|
|
475
|
+
try {
|
|
476
|
+
const limits = await fetchLocalAgentRunnerLimits(options);
|
|
477
|
+
logRunnerEvent(
|
|
478
|
+
options.logStreams.runner,
|
|
479
|
+
`Local agent runner max failed attempts: ${limits.maxFailedAttempts}.`,
|
|
480
|
+
);
|
|
481
|
+
return limits;
|
|
482
|
+
} catch (error) {
|
|
483
|
+
lastError = error;
|
|
484
|
+
await wait(INTERNAL_SERVER_LIMITS_RETRY_DELAY_MS);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
if (!options.state.isContinuing) {
|
|
489
|
+
return {
|
|
490
|
+
maxFailedAttempts: DEFAULT_LOCAL_AGENT_RUNNER_MAX_FAILED_ATTEMPTS,
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
throw new NotAllowed(
|
|
495
|
+
spaceTrim(`
|
|
496
|
+
Failed to load local agent runner limits from the Agents Server.
|
|
497
|
+
|
|
498
|
+
${lastError instanceof Error ? lastError.message : String(lastError)}
|
|
499
|
+
`),
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Loads local runner limits through the token-protected internal Agents Server route.
|
|
505
|
+
*/
|
|
506
|
+
async function fetchLocalAgentRunnerLimits(options: {
|
|
507
|
+
readonly port: number_port;
|
|
508
|
+
readonly environment: AgentsServerChildEnvironment;
|
|
509
|
+
}): Promise<LocalAgentRunnerLimits> {
|
|
510
|
+
const response = await fetch(`http://localhost:${options.port}/api/internal/agent-runner-limits`, {
|
|
511
|
+
method: 'GET',
|
|
512
|
+
cache: 'no-store',
|
|
513
|
+
headers: {
|
|
514
|
+
'x-user-chat-worker-token': options.environment.PTBK_AGENTS_SERVER_USER_CHAT_WORKER_TOKEN,
|
|
515
|
+
},
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
if (!response.ok) {
|
|
519
|
+
const details = await readUserChatJobWorkerErrorDetails(response);
|
|
520
|
+
throw new Error(createInternalRouteErrorMessage('agent runner limits', response, details));
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
const payload = (await response.json()) as Partial<LocalAgentRunnerLimits>;
|
|
524
|
+
return {
|
|
525
|
+
maxFailedAttempts: normalizeLocalAgentRunnerMaxFailedAttempts(payload.maxFailedAttempts),
|
|
425
526
|
};
|
|
426
527
|
}
|
|
427
528
|
|
|
529
|
+
/**
|
|
530
|
+
* Normalizes the local runner retry cap returned by the internal server route.
|
|
531
|
+
*/
|
|
532
|
+
function normalizeLocalAgentRunnerMaxFailedAttempts(rawValue: unknown): number {
|
|
533
|
+
const parsedValue = Number(rawValue);
|
|
534
|
+
|
|
535
|
+
if (!Number.isFinite(parsedValue) || parsedValue <= 0) {
|
|
536
|
+
return DEFAULT_LOCAL_AGENT_RUNNER_MAX_FAILED_ATTEMPTS;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
return Math.floor(parsedValue);
|
|
540
|
+
}
|
|
541
|
+
|
|
428
542
|
/**
|
|
429
543
|
* Starts periodic internal worker calls that queue and reconcile local message-folder jobs.
|
|
430
544
|
*/
|
|
@@ -563,14 +677,21 @@ function parseUserChatJobWorkerErrorMessage(body: string): string | null {
|
|
|
563
677
|
* Builds the foreground worker failure message from HTTP status and route details.
|
|
564
678
|
*/
|
|
565
679
|
function createUserChatJobWorkerErrorMessage(response: Response, details: string | null): string {
|
|
680
|
+
return createInternalRouteErrorMessage('user chat worker', response, details);
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* Builds a foreground failure message for one internal Agents Server route.
|
|
685
|
+
*/
|
|
686
|
+
function createInternalRouteErrorMessage(routeLabel: string, response: Response, details: string | null): string {
|
|
566
687
|
const statusText = response.statusText ? ` ${response.statusText}` : '';
|
|
567
688
|
const statusMessage = `${response.status}${statusText}`;
|
|
568
689
|
|
|
569
690
|
if (!details) {
|
|
570
|
-
return `Internal
|
|
691
|
+
return `Internal ${routeLabel} route returned ${statusMessage}.`;
|
|
571
692
|
}
|
|
572
693
|
|
|
573
|
-
return `Internal
|
|
694
|
+
return `Internal ${routeLabel} route returned ${statusMessage}: ${details}`;
|
|
574
695
|
}
|
|
575
696
|
|
|
576
697
|
/**
|
|
@@ -652,4 +773,11 @@ function stopChildProcess(commandProcess: ChildProcess | undefined): void {
|
|
|
652
773
|
commandProcess.kill();
|
|
653
774
|
}
|
|
654
775
|
|
|
776
|
+
/**
|
|
777
|
+
* Waits for the given delay.
|
|
778
|
+
*/
|
|
779
|
+
async function wait(delayMs: number): Promise<void> {
|
|
780
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
781
|
+
}
|
|
782
|
+
|
|
655
783
|
// Note: [🟡] Code for CLI runtime [startAgentsServer](src/cli/cli-commands/agents-server/startAgentsServer.ts) should never be published outside of `@promptbook/cli`
|