@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
|
@@ -2,9 +2,14 @@ import { $getTableName } from '@/src/database/$getTableName';
|
|
|
2
2
|
import { $provideSupabaseForServer } from '@/src/database/$provideSupabaseForServer';
|
|
3
3
|
import type { Json } from '@/src/database/schema';
|
|
4
4
|
import { FILE_SECURITY_CHECKERS } from '@/src/file-security-checkers';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
$provideCdnForServer,
|
|
7
|
+
isSelfContainedS3StorageSelected,
|
|
8
|
+
resolveCdnPublicUrlForServer,
|
|
9
|
+
} from '@/src/tools/$provideCdnForServer';
|
|
6
10
|
import { $provideServer } from '@/src/tools/$provideServer';
|
|
7
11
|
import { getUserFileCdnKey } from '@/src/utils/cdn/utils/getUserFileCdnKey';
|
|
12
|
+
import { resolveFileUploadAvailability } from '@/src/utils/upload/fileUploadAvailability';
|
|
8
13
|
import { validateMimeType } from '@/src/utils/validators/validateMimeType';
|
|
9
14
|
import { normalizeChatAttachments } from '@promptbook-local/core';
|
|
10
15
|
import type { TODO_any } from '@promptbook-local/types';
|
|
@@ -231,7 +236,20 @@ async function createShareTargetAttachment(file: File, maxFileUploadBytes: numbe
|
|
|
231
236
|
|
|
232
237
|
const mimeType = resolveShareTargetMimeType(file.type);
|
|
233
238
|
const blobPath = getUserFileCdnKey(buffer, normalizedFilename);
|
|
234
|
-
const
|
|
239
|
+
const providedServer = await $provideServer();
|
|
240
|
+
const fileUploadAvailability = resolveFileUploadAvailability({
|
|
241
|
+
serverId: providedServer.id,
|
|
242
|
+
serverPublicUrl: providedServer.publicUrl,
|
|
243
|
+
isSelfContainedS3StorageSelected: isSelfContainedS3StorageSelected(),
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
if (!fileUploadAvailability.isUploadAvailable) {
|
|
247
|
+
throw new NotAllowed(fileUploadAvailability.message || 'File uploads are not available for this server.');
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const cdn = $provideCdnForServer({
|
|
251
|
+
cdnPublicUrl: resolveCdnPublicUrlForServer(providedServer.publicUrl),
|
|
252
|
+
});
|
|
235
253
|
const storageUrl = cdn.getItemUrl(blobPath).href;
|
|
236
254
|
|
|
237
255
|
await cdn.setItem(blobPath, {
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message shown when self-contained file uploads cannot safely choose a serving domain.
|
|
3
|
+
*/
|
|
4
|
+
export const FILE_UPLOAD_REQUIRES_SERVER_DOMAIN_MESSAGE =
|
|
5
|
+
'Create the first server/domain before uploading files. Uploaded files are served from the current server domain, and raw-IP bootstrap access does not have one yet.';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Browser-safe upload availability state.
|
|
9
|
+
*/
|
|
10
|
+
export type FileUploadAvailability = {
|
|
11
|
+
/**
|
|
12
|
+
* Whether file uploads may be accepted for the current request.
|
|
13
|
+
*/
|
|
14
|
+
readonly isUploadAvailable: boolean;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* User-facing reason shown when uploads are unavailable.
|
|
18
|
+
*/
|
|
19
|
+
readonly message: string | null;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Inputs used to resolve whether uploads are allowed for the current server.
|
|
24
|
+
*/
|
|
25
|
+
export type ResolveFileUploadAvailabilityOptions = {
|
|
26
|
+
/**
|
|
27
|
+
* Current server id, or `null` before a request is matched to a server/domain.
|
|
28
|
+
*/
|
|
29
|
+
readonly serverId: number | null;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Public URL resolved for the current request.
|
|
33
|
+
*/
|
|
34
|
+
readonly serverPublicUrl: URL;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Whether the deployment is using the bundled self-contained S3 storage.
|
|
38
|
+
*/
|
|
39
|
+
readonly isSelfContainedS3StorageSelected: boolean;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Default upload availability used when no server-side context is available.
|
|
44
|
+
*/
|
|
45
|
+
export const AVAILABLE_FILE_UPLOAD: FileUploadAvailability = {
|
|
46
|
+
isUploadAvailable: true,
|
|
47
|
+
message: null,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Resolves whether file uploads can be accepted for the current request.
|
|
52
|
+
*
|
|
53
|
+
* Self-contained S3 publishes files through the current server domain. While the
|
|
54
|
+
* standalone VPS is still being accessed as a bootstrap/default server, there is
|
|
55
|
+
* no server-specific domain to publish under, so uploads must be disabled.
|
|
56
|
+
*
|
|
57
|
+
* @param options - Current server and storage mode.
|
|
58
|
+
* @returns Browser-safe upload availability state.
|
|
59
|
+
*/
|
|
60
|
+
export function resolveFileUploadAvailability(
|
|
61
|
+
options: ResolveFileUploadAvailabilityOptions,
|
|
62
|
+
): FileUploadAvailability {
|
|
63
|
+
if (!options.isSelfContainedS3StorageSelected) {
|
|
64
|
+
return AVAILABLE_FILE_UPLOAD;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (options.serverId !== null) {
|
|
68
|
+
return AVAILABLE_FILE_UPLOAD;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (isLocalDevelopmentUrl(options.serverPublicUrl)) {
|
|
72
|
+
return AVAILABLE_FILE_UPLOAD;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
isUploadAvailable: false,
|
|
77
|
+
message: FILE_UPLOAD_REQUIRES_SERVER_DOMAIN_MESSAGE,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Checks whether a server URL points to local development.
|
|
83
|
+
*
|
|
84
|
+
* @param serverPublicUrl - Public URL resolved for the current request.
|
|
85
|
+
* @returns `true` for localhost and loopback hosts.
|
|
86
|
+
*/
|
|
87
|
+
function isLocalDevelopmentUrl(serverPublicUrl: URL): boolean {
|
|
88
|
+
const hostname = serverPublicUrl.hostname.toLowerCase();
|
|
89
|
+
|
|
90
|
+
return hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '::1';
|
|
91
|
+
}
|
|
@@ -41,6 +41,16 @@ export type ServerFileUploadResult = {
|
|
|
41
41
|
size: number;
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Error response shape accepted from the upload endpoint.
|
|
46
|
+
*
|
|
47
|
+
* @private used by `uploadFileToServer`
|
|
48
|
+
*/
|
|
49
|
+
type ServerFileUploadErrorResponse = {
|
|
50
|
+
error?: string | { message?: string };
|
|
51
|
+
message?: string;
|
|
52
|
+
};
|
|
53
|
+
|
|
44
54
|
/**
|
|
45
55
|
* Builds the default CDN key used for user-uploaded files.
|
|
46
56
|
*
|
|
@@ -50,6 +60,38 @@ export function buildDefaultUserFileUploadPath(normalizedFilename: string): stri
|
|
|
50
60
|
return `user/files/${normalizedFilename}`;
|
|
51
61
|
}
|
|
52
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Resolves the most useful error message from an upload response body.
|
|
65
|
+
*
|
|
66
|
+
* @param responseBody - Parsed JSON response body.
|
|
67
|
+
* @param status - HTTP status code.
|
|
68
|
+
* @returns Error message for the rejected upload promise.
|
|
69
|
+
* @private helper of `uploadFileToServer`
|
|
70
|
+
*/
|
|
71
|
+
function resolveUploadErrorMessage(
|
|
72
|
+
responseBody: (Partial<ServerFileUploadResult> & ServerFileUploadErrorResponse) | null,
|
|
73
|
+
status: number,
|
|
74
|
+
): string {
|
|
75
|
+
if (typeof responseBody?.error === 'string' && responseBody.error) {
|
|
76
|
+
return responseBody.error;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (
|
|
80
|
+
typeof responseBody?.error === 'object' &&
|
|
81
|
+
responseBody.error !== null &&
|
|
82
|
+
typeof responseBody.error.message === 'string' &&
|
|
83
|
+
responseBody.error.message
|
|
84
|
+
) {
|
|
85
|
+
return responseBody.error.message;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (typeof responseBody?.message === 'string' && responseBody.message) {
|
|
89
|
+
return responseBody.message;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return `File upload failed with HTTP ${status}.`;
|
|
93
|
+
}
|
|
94
|
+
|
|
53
95
|
/**
|
|
54
96
|
* Uploads one browser file to `/api/upload` using normal multipart form data.
|
|
55
97
|
*
|
|
@@ -82,7 +124,9 @@ export function uploadFileToServer(options: ServerFileUploadOptions): Promise<Se
|
|
|
82
124
|
};
|
|
83
125
|
|
|
84
126
|
request.onload = () => {
|
|
85
|
-
const responseBody = request.response as
|
|
127
|
+
const responseBody = request.response as
|
|
128
|
+
| (Partial<ServerFileUploadResult> & ServerFileUploadErrorResponse)
|
|
129
|
+
| null;
|
|
86
130
|
|
|
87
131
|
if (request.status >= 200 && request.status < 300 && responseBody?.url) {
|
|
88
132
|
options.onProgress?.(1 as number_percent, {
|
|
@@ -94,7 +138,7 @@ export function uploadFileToServer(options: ServerFileUploadOptions): Promise<Se
|
|
|
94
138
|
return;
|
|
95
139
|
}
|
|
96
140
|
|
|
97
|
-
reject(new Error(responseBody
|
|
141
|
+
reject(new Error(resolveUploadErrorMessage(responseBody, request.status)));
|
|
98
142
|
};
|
|
99
143
|
|
|
100
144
|
request.onerror = () => reject(new Error('File upload failed.'));
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metadata key storing the delay between retry attempts when importing federated agent books.
|
|
3
|
+
*
|
|
4
|
+
* @private internal Agents Server constant
|
|
5
|
+
*/
|
|
6
|
+
export declare const FEDERATED_AGENT_IMPORT_RETRY_DELAY_MS_METADATA_KEY: "FEDERATED_AGENT_IMPORT_RETRY_DELAY_MS";
|
|
7
|
+
/**
|
|
8
|
+
* Total number of attempts used when loading a federated imported agent before falling back.
|
|
9
|
+
*
|
|
10
|
+
* @private internal Agents Server constant
|
|
11
|
+
*/
|
|
12
|
+
export declare const FEDERATED_AGENT_IMPORT_MAX_ATTEMPTS: 3;
|
|
13
|
+
/**
|
|
14
|
+
* Default delay in milliseconds between federated imported-agent retry attempts.
|
|
15
|
+
*
|
|
16
|
+
* @private internal Agents Server constant
|
|
17
|
+
*/
|
|
18
|
+
export declare const DEFAULT_FEDERATED_AGENT_IMPORT_RETRY_DELAY_MS = 500;
|
|
19
|
+
/**
|
|
20
|
+
* Runtime configuration applied to federated imported-agent retries.
|
|
21
|
+
*
|
|
22
|
+
* @private internal Agents Server type
|
|
23
|
+
*/
|
|
24
|
+
export type FederatedAgentImportConfiguration = {
|
|
25
|
+
/**
|
|
26
|
+
* Total number of attempts used before returning the fallback book.
|
|
27
|
+
*/
|
|
28
|
+
readonly maxAttempts: number;
|
|
29
|
+
/**
|
|
30
|
+
* Delay in milliseconds between retry attempts.
|
|
31
|
+
*/
|
|
32
|
+
readonly retryDelayMs: number;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Default retry configuration for federated imported-agent loading.
|
|
36
|
+
*
|
|
37
|
+
* @private internal Agents Server constant
|
|
38
|
+
*/
|
|
39
|
+
export declare const DEFAULT_FEDERATED_AGENT_IMPORT_CONFIGURATION: Readonly<{
|
|
40
|
+
maxAttempts: 3;
|
|
41
|
+
retryDelayMs: 500;
|
|
42
|
+
}>;
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Legacy metadata key storing the maximum accepted file upload size in megabytes.
|
|
3
|
+
*
|
|
4
|
+
* @private shared Agents Server constant
|
|
5
|
+
*/
|
|
6
|
+
export declare const MAX_FILE_UPLOAD_SIZE_MB_METADATA_KEY: "MAX_FILE_UPLOAD_SIZE_MB";
|
|
7
|
+
/**
|
|
8
|
+
* Default maximum accepted spawn depth in one tool-runtime context.
|
|
9
|
+
*
|
|
10
|
+
* @private shared Agents Server constant
|
|
11
|
+
*/
|
|
12
|
+
export declare const DEFAULT_SPAWN_AGENT_MAX_DEPTH = 2;
|
|
13
|
+
/**
|
|
14
|
+
* Default maximum number of spawned agents allowed per actor in one time window.
|
|
15
|
+
*
|
|
16
|
+
* @private shared Agents Server constant
|
|
17
|
+
*/
|
|
18
|
+
export declare const DEFAULT_SPAWN_AGENT_RATE_LIMIT_MAX = 5;
|
|
19
|
+
/**
|
|
20
|
+
* Default spawn rate-limit window size in milliseconds.
|
|
21
|
+
*
|
|
22
|
+
* @private shared Agents Server constant
|
|
23
|
+
*/
|
|
24
|
+
export declare const DEFAULT_SPAWN_AGENT_RATE_LIMIT_WINDOW_MS: number;
|
|
25
|
+
/**
|
|
26
|
+
* Default maximum number of failed local runner attempts before a queued message is moved to `messages/failed`.
|
|
27
|
+
*
|
|
28
|
+
* @private shared Agents Server constant
|
|
29
|
+
*/
|
|
30
|
+
export declare const DEFAULT_LOCAL_AGENT_RUNNER_MAX_FAILED_ATTEMPTS = 3;
|
|
31
|
+
/**
|
|
32
|
+
* Stable keys used by the dedicated server-limits table.
|
|
33
|
+
*
|
|
34
|
+
* @private shared Agents Server constant
|
|
35
|
+
*/
|
|
36
|
+
export declare const SERVER_LIMIT_KEYS: {
|
|
37
|
+
readonly TIMEOUT_MAX_ACTIVE_PER_CHAT: "TIMEOUT_MAX_ACTIVE_PER_CHAT";
|
|
38
|
+
readonly TIMEOUT_MAX_FIRED_PER_DAY_PER_CHAT: "TIMEOUT_MAX_FIRED_PER_DAY_PER_CHAT";
|
|
39
|
+
readonly MAX_FILE_UPLOAD_SIZE_MB: "MAX_FILE_UPLOAD_SIZE_MB";
|
|
40
|
+
readonly FEDERATED_AGENT_IMPORT_RETRY_DELAY_MS: "FEDERATED_AGENT_IMPORT_RETRY_DELAY_MS";
|
|
41
|
+
readonly SPAWN_AGENT_MAX_DEPTH: "SPAWN_AGENT_MAX_DEPTH";
|
|
42
|
+
readonly SPAWN_AGENT_RATE_LIMIT_MAX: "SPAWN_AGENT_RATE_LIMIT_MAX";
|
|
43
|
+
readonly SPAWN_AGENT_RATE_LIMIT_WINDOW_MS: "SPAWN_AGENT_RATE_LIMIT_WINDOW_MS";
|
|
44
|
+
readonly LOCAL_AGENT_RUNNER_MAX_FAILED_ATTEMPTS: "LOCAL_AGENT_RUNNER_MAX_FAILED_ATTEMPTS";
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* One supported dedicated server-limit key.
|
|
48
|
+
*
|
|
49
|
+
* @private shared Agents Server type
|
|
50
|
+
*/
|
|
51
|
+
export type ServerLimitKey = (typeof SERVER_LIMIT_KEYS)[keyof typeof SERVER_LIMIT_KEYS];
|
|
52
|
+
/**
|
|
53
|
+
* Supported units rendered in the admin limits page.
|
|
54
|
+
*
|
|
55
|
+
* @private shared Agents Server type
|
|
56
|
+
*/
|
|
57
|
+
export type ServerLimitUnit = 'count' | 'MB' | 'ms';
|
|
58
|
+
/**
|
|
59
|
+
* Shared definition describing one supported configurable limit.
|
|
60
|
+
*
|
|
61
|
+
* @private shared Agents Server type
|
|
62
|
+
*/
|
|
63
|
+
export type ServerLimitDefinition = {
|
|
64
|
+
readonly key: ServerLimitKey;
|
|
65
|
+
readonly category: 'Timeout tools' | 'Files' | 'Federation' | 'Agent spawning' | 'Local agent runner';
|
|
66
|
+
readonly title: string;
|
|
67
|
+
readonly description: string;
|
|
68
|
+
readonly unit: ServerLimitUnit;
|
|
69
|
+
readonly defaultValue: number;
|
|
70
|
+
readonly minimumValue: number;
|
|
71
|
+
readonly step: number;
|
|
72
|
+
readonly legacyMetadataKeys: ReadonlyArray<string>;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Shared metadata for all server limits exposed in the admin UI and runtime loaders.
|
|
76
|
+
*
|
|
77
|
+
* @private shared Agents Server constant
|
|
78
|
+
*/
|
|
79
|
+
export declare const SERVER_LIMIT_DEFINITIONS: ({
|
|
80
|
+
key: "TIMEOUT_MAX_ACTIVE_PER_CHAT";
|
|
81
|
+
category: "Timeout tools";
|
|
82
|
+
title: string;
|
|
83
|
+
description: string;
|
|
84
|
+
unit: "count";
|
|
85
|
+
defaultValue: number;
|
|
86
|
+
minimumValue: number;
|
|
87
|
+
step: number;
|
|
88
|
+
legacyMetadataKeys: string[];
|
|
89
|
+
} | {
|
|
90
|
+
key: "TIMEOUT_MAX_FIRED_PER_DAY_PER_CHAT";
|
|
91
|
+
category: "Timeout tools";
|
|
92
|
+
title: string;
|
|
93
|
+
description: string;
|
|
94
|
+
unit: "count";
|
|
95
|
+
defaultValue: number;
|
|
96
|
+
minimumValue: number;
|
|
97
|
+
step: number;
|
|
98
|
+
legacyMetadataKeys: string[];
|
|
99
|
+
} | {
|
|
100
|
+
key: "MAX_FILE_UPLOAD_SIZE_MB";
|
|
101
|
+
category: "Files";
|
|
102
|
+
title: string;
|
|
103
|
+
description: string;
|
|
104
|
+
unit: "MB";
|
|
105
|
+
defaultValue: number;
|
|
106
|
+
minimumValue: number;
|
|
107
|
+
step: number;
|
|
108
|
+
legacyMetadataKeys: "MAX_FILE_UPLOAD_SIZE_MB"[];
|
|
109
|
+
} | {
|
|
110
|
+
key: "FEDERATED_AGENT_IMPORT_RETRY_DELAY_MS";
|
|
111
|
+
category: "Federation";
|
|
112
|
+
title: string;
|
|
113
|
+
description: string;
|
|
114
|
+
unit: "ms";
|
|
115
|
+
defaultValue: number;
|
|
116
|
+
minimumValue: number;
|
|
117
|
+
step: number;
|
|
118
|
+
legacyMetadataKeys: "FEDERATED_AGENT_IMPORT_RETRY_DELAY_MS"[];
|
|
119
|
+
} | {
|
|
120
|
+
key: "SPAWN_AGENT_MAX_DEPTH";
|
|
121
|
+
category: "Agent spawning";
|
|
122
|
+
title: string;
|
|
123
|
+
description: string;
|
|
124
|
+
unit: "count";
|
|
125
|
+
defaultValue: number;
|
|
126
|
+
minimumValue: number;
|
|
127
|
+
step: number;
|
|
128
|
+
legacyMetadataKeys: never[];
|
|
129
|
+
} | {
|
|
130
|
+
key: "SPAWN_AGENT_RATE_LIMIT_MAX";
|
|
131
|
+
category: "Agent spawning";
|
|
132
|
+
title: string;
|
|
133
|
+
description: string;
|
|
134
|
+
unit: "count";
|
|
135
|
+
defaultValue: number;
|
|
136
|
+
minimumValue: number;
|
|
137
|
+
step: number;
|
|
138
|
+
legacyMetadataKeys: never[];
|
|
139
|
+
} | {
|
|
140
|
+
key: "SPAWN_AGENT_RATE_LIMIT_WINDOW_MS";
|
|
141
|
+
category: "Agent spawning";
|
|
142
|
+
title: string;
|
|
143
|
+
description: string;
|
|
144
|
+
unit: "ms";
|
|
145
|
+
defaultValue: number;
|
|
146
|
+
minimumValue: number;
|
|
147
|
+
step: number;
|
|
148
|
+
legacyMetadataKeys: never[];
|
|
149
|
+
} | {
|
|
150
|
+
key: "LOCAL_AGENT_RUNNER_MAX_FAILED_ATTEMPTS";
|
|
151
|
+
category: "Local agent runner";
|
|
152
|
+
title: string;
|
|
153
|
+
description: string;
|
|
154
|
+
unit: "count";
|
|
155
|
+
defaultValue: number;
|
|
156
|
+
minimumValue: number;
|
|
157
|
+
step: number;
|
|
158
|
+
legacyMetadataKeys: never[];
|
|
159
|
+
})[];
|
|
160
|
+
/**
|
|
161
|
+
* Fast lookup map used by server-limit validators and UI helpers.
|
|
162
|
+
*
|
|
163
|
+
* @private shared Agents Server constant
|
|
164
|
+
*/
|
|
165
|
+
export declare const SERVER_LIMIT_DEFINITION_BY_KEY: Map<ServerLimitKey, ServerLimitDefinition>;
|
|
166
|
+
/**
|
|
167
|
+
* Default values used whenever a server-limit row has not been persisted yet.
|
|
168
|
+
*
|
|
169
|
+
* @private shared Agents Server constant
|
|
170
|
+
*/
|
|
171
|
+
export declare const DEFAULT_SERVER_LIMIT_VALUES: Readonly<Record<ServerLimitKey, number>>;
|
|
172
|
+
/**
|
|
173
|
+
* Deprecated metadata keys that now mirror dedicated server-limit rows for backward compatibility.
|
|
174
|
+
*
|
|
175
|
+
* @private shared Agents Server constant
|
|
176
|
+
*/
|
|
177
|
+
export declare const DEPRECATED_LIMIT_METADATA_KEYS: string[];
|
|
178
|
+
/**
|
|
179
|
+
* Description of one deprecated metadata key that now points to the dedicated limits page.
|
|
180
|
+
*
|
|
181
|
+
* @private shared Agents Server type
|
|
182
|
+
*/
|
|
183
|
+
export type DeprecatedLimitMetadataDefinition = {
|
|
184
|
+
readonly key: string;
|
|
185
|
+
readonly href: '/admin/limits';
|
|
186
|
+
readonly limitKeys: ReadonlyArray<ServerLimitKey>;
|
|
187
|
+
readonly limitTitles: ReadonlyArray<string>;
|
|
188
|
+
readonly message: string;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* Returns the deprecated-metadata descriptor when one metadata key now belongs to the limits page.
|
|
192
|
+
*
|
|
193
|
+
* @param metadataKey - Metadata key being rendered in the admin metadata UI.
|
|
194
|
+
* @returns Deprecated metadata descriptor or `null`.
|
|
195
|
+
*
|
|
196
|
+
* @private shared Agents Server helper
|
|
197
|
+
*/
|
|
198
|
+
export declare function getDeprecatedLimitMetadataDefinition(metadataKey: string): DeprecatedLimitMetadataDefinition | null;
|
|
199
|
+
/**
|
|
200
|
+
* Resolves one shared server-limit definition by key.
|
|
201
|
+
*
|
|
202
|
+
* @param key - Dedicated server-limit key.
|
|
203
|
+
* @returns Matching definition or `null`.
|
|
204
|
+
*
|
|
205
|
+
* @private shared Agents Server helper
|
|
206
|
+
*/
|
|
207
|
+
export declare function getServerLimitDefinition(key: string): ServerLimitDefinition | null;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metadata key used to persist tool-usage limits.
|
|
3
|
+
*
|
|
4
|
+
* @private shared constant for Agents Server
|
|
5
|
+
*/
|
|
6
|
+
export declare const TOOL_USAGE_LIMITS_METADATA_KEY = "TOOL_USAGE_LIMITS";
|
|
7
|
+
/**
|
|
8
|
+
* Timeout-specific limits supported by the current admin UI.
|
|
9
|
+
*
|
|
10
|
+
* @private shared type for Agents Server
|
|
11
|
+
*/
|
|
12
|
+
export type TimeoutToolUsageLimits = {
|
|
13
|
+
maxActivePerChat: number;
|
|
14
|
+
maxFiredPerDayPerChat: number;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Full tool-limits payload stored in metadata.
|
|
18
|
+
*
|
|
19
|
+
* The shape is intentionally extensible so other tools can be added later.
|
|
20
|
+
*
|
|
21
|
+
* @private shared type for Agents Server
|
|
22
|
+
*/
|
|
23
|
+
export type ToolUsageLimits = Record<string, unknown> & {
|
|
24
|
+
timeout: TimeoutToolUsageLimits;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Default timeout limits applied when administrators do not override them.
|
|
28
|
+
*
|
|
29
|
+
* @private shared constant for Agents Server
|
|
30
|
+
*/
|
|
31
|
+
export declare const DEFAULT_TIMEOUT_TOOL_USAGE_LIMITS: TimeoutToolUsageLimits;
|
|
32
|
+
/**
|
|
33
|
+
* Default tool-limits payload used across metadata, admin UI, and runtime enforcement.
|
|
34
|
+
*
|
|
35
|
+
* @private shared constant for Agents Server
|
|
36
|
+
*/
|
|
37
|
+
export declare const DEFAULT_TOOL_USAGE_LIMITS: ToolUsageLimits;
|
|
38
|
+
/**
|
|
39
|
+
* Normalizes the complete tool-limits payload while preserving unknown future keys.
|
|
40
|
+
*
|
|
41
|
+
* @param rawValue - Unknown persisted payload.
|
|
42
|
+
* @returns Normalized tool-usage limits.
|
|
43
|
+
*
|
|
44
|
+
* @private shared Agents Server helper
|
|
45
|
+
*/
|
|
46
|
+
export declare function normalizeToolUsageLimits(rawValue: unknown): ToolUsageLimits;
|
|
47
|
+
/**
|
|
48
|
+
* Normalizes timeout-specific limits with defaults and integer guards.
|
|
49
|
+
*
|
|
50
|
+
* @param rawValue - Unknown timeout payload.
|
|
51
|
+
* @returns Normalized timeout tool limits.
|
|
52
|
+
*
|
|
53
|
+
* @private shared Agents Server helper
|
|
54
|
+
*/
|
|
55
|
+
export declare function normalizeTimeoutToolUsageLimits(rawValue: unknown): TimeoutToolUsageLimits;
|