@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.
Files changed (174) hide show
  1. package/apps/agents-server/src/app/admin/image-generator-test/ImageAttachmentsEditor.tsx +19 -3
  2. package/apps/agents-server/src/app/admin/limits/LimitsClient.tsx +11 -12
  3. package/apps/agents-server/src/app/admin/metadata/MetadataClient.tsx +34 -2
  4. package/apps/agents-server/src/app/admin/servers/CreateServerDialog.tsx +6 -1
  5. package/apps/agents-server/src/app/admin/servers/useCreateServerWizard.ts +13 -1
  6. package/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +11 -2
  7. package/apps/agents-server/src/app/agents/[agentName]/AgentProfileChat.tsx +11 -1
  8. package/apps/agents-server/src/app/agents/[agentName]/book/BookEditorWrapper.tsx +7 -1
  9. package/apps/agents-server/src/app/agents/[agentName]/chat/CanonicalAgentChatSurface.tsx +11 -1
  10. package/apps/agents-server/src/app/agents/[agentName]/images/default-avatar.png/route.ts +6 -2
  11. package/apps/agents-server/src/app/api/images/[filename]/route.ts +6 -2
  12. package/apps/agents-server/src/app/api/internal/agent-runner-limits/route.ts +51 -0
  13. package/apps/agents-server/src/app/api/upload/route.ts +48 -12
  14. package/apps/agents-server/src/app/layout.tsx +13 -0
  15. package/apps/agents-server/src/components/FileUploadAvailability/FileUploadAvailabilityContext.tsx +50 -0
  16. package/apps/agents-server/src/components/FileUploadAvailability/FileUploadUnavailableNotice.tsx +45 -0
  17. package/apps/agents-server/src/components/LayoutWrapper/LayoutWrapper.tsx +85 -76
  18. package/apps/agents-server/src/components/NewAgentDialog/NewAgentDialog.tsx +7 -3
  19. package/apps/agents-server/src/components/NewAgentDialog/NewAgentWizardKnowledgeStep.tsx +6 -0
  20. package/apps/agents-server/src/components/NewAgentDialog/useNewAgentWizardKnowledgeState.ts +8 -1
  21. package/apps/agents-server/src/constants/serverLimits.ts +22 -2
  22. package/apps/agents-server/src/database/seedDefaultAgents.ts +218 -0
  23. package/apps/agents-server/src/tools/$provideCdnForServer.ts +72 -8
  24. package/apps/agents-server/src/utils/defaultAgents/loadDefaultAgentBooks.ts +103 -0
  25. package/apps/agents-server/src/utils/knowledge/createInlineKnowledgeSourceUploader.ts +24 -5
  26. package/apps/agents-server/src/utils/serverLimits.ts +26 -1
  27. package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerDefaultAgents.ts +1 -85
  28. package/apps/agents-server/src/utils/shareTargetPayloads.ts +20 -2
  29. package/apps/agents-server/src/utils/upload/fileUploadAvailability.ts +91 -0
  30. package/apps/agents-server/src/utils/upload/uploadFileToServer.ts +46 -2
  31. package/esm/apps/agents-server/src/constants/federatedAgentImport.d.ts +42 -0
  32. package/esm/apps/agents-server/src/constants/serverLimits.d.ts +207 -0
  33. package/esm/apps/agents-server/src/constants/toolUsageLimits.d.ts +55 -0
  34. package/esm/index.es.js +602 -39
  35. package/esm/index.es.js.map +1 -1
  36. package/esm/scripts/run-agent-messages/main/AgentMessageFailureTracker.d.ts +27 -0
  37. package/esm/scripts/run-agent-messages/main/handleAgentWatchError.d.ts +4 -0
  38. package/esm/scripts/run-agent-messages/main/runAgentMessages.d.ts +1 -0
  39. package/esm/scripts/run-agent-messages/messages/moveAgentMessageToFailed.d.ts +17 -0
  40. package/esm/src/book-components/BookEditor/BookEditor.d.ts +5 -4
  41. package/esm/src/book-components/BookEditor/BookEditorTheme.d.ts +24 -0
  42. package/esm/src/book-components/BookEditor/useBookEditorMonacoLanguage.d.ts +1 -6
  43. package/esm/src/book-components/BookEditor/useBookEditorMonacoLifecycle.d.ts +1 -4
  44. package/esm/src/book-components/BookEditor/useBookEditorMonacoStyles.d.ts +2 -1
  45. package/esm/src/cli/cli-commands/agent-folder/agentProjectPaths.d.ts +6 -0
  46. package/esm/src/version.d.ts +1 -1
  47. package/package.json +1 -1
  48. package/src/avatars/visuals/octopus3d3AvatarVisual.ts +28 -29
  49. package/src/book-components/BookEditor/BookEditor.tsx +10 -7
  50. package/src/book-components/BookEditor/BookEditorMonaco.tsx +3 -1
  51. package/src/book-components/BookEditor/BookEditorTheme.ts +32 -0
  52. package/src/book-components/BookEditor/useBookEditorMonacoLanguage.ts +12 -15
  53. package/src/book-components/BookEditor/useBookEditorMonacoLifecycle.ts +1 -5
  54. package/src/book-components/BookEditor/useBookEditorMonacoStyles.ts +2 -1
  55. package/src/cli/cli-commands/agent-folder/agentProjectPaths.ts +7 -0
  56. package/src/cli/cli-commands/agents-server/buildAgentsServer.ts +109 -9
  57. package/src/cli/cli-commands/agents-server/startAgentsServer.ts +132 -4
  58. package/src/other/templates/getTemplatesPipelineCollection.ts +729 -854
  59. package/src/version.ts +2 -2
  60. package/src/versions.txt +1 -0
  61. package/umd/apps/agents-server/src/constants/federatedAgentImport.d.ts +42 -0
  62. package/umd/apps/agents-server/src/constants/serverLimits.d.ts +207 -0
  63. package/umd/apps/agents-server/src/constants/toolUsageLimits.d.ts +55 -0
  64. package/umd/index.umd.js +602 -39
  65. package/umd/index.umd.js.map +1 -1
  66. package/umd/scripts/run-agent-messages/main/AgentMessageFailureTracker.d.ts +27 -0
  67. package/umd/scripts/run-agent-messages/main/handleAgentWatchError.d.ts +4 -0
  68. package/umd/scripts/run-agent-messages/main/runAgentMessages.d.ts +1 -0
  69. package/umd/scripts/run-agent-messages/messages/moveAgentMessageToFailed.d.ts +17 -0
  70. package/umd/src/book-components/BookEditor/BookEditor.d.ts +5 -4
  71. package/umd/src/book-components/BookEditor/BookEditorTheme.d.ts +24 -0
  72. package/umd/src/book-components/BookEditor/useBookEditorMonacoLanguage.d.ts +1 -6
  73. package/umd/src/book-components/BookEditor/useBookEditorMonacoLifecycle.d.ts +1 -4
  74. package/umd/src/book-components/BookEditor/useBookEditorMonacoStyles.d.ts +2 -1
  75. package/umd/src/cli/cli-commands/agent-folder/agentProjectPaths.d.ts +6 -0
  76. package/umd/src/version.d.ts +1 -1
  77. package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddress.test.ts.todo +0 -108
  78. package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddresses.test.ts.todo +0 -117
  79. package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddress.test.ts.todo +0 -119
  80. package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddresses.test.ts.todo +0 -74
  81. package/apps/agents-server/src/utils/defaultAgents/defaultAgents.ts +0 -168
  82. package/apps/agents-server/src/utils/defaultAgents/installDefaultAgents.ts +0 -139
  83. package/apps/agents-server/tests/e2e/authentication-and-navigation.spec.ts.todo +0 -178
  84. package/src/_packages/browser.index.ts +0 -31
  85. package/src/_packages/browser.readme.md +0 -43
  86. package/src/book-2.0/agent-source/parseAgentSourceWithCommitments.test.ts.todo +0 -265
  87. package/src/book-components/BookEditor/BookEditorMonaco.test.tsx.todo +0 -115
  88. package/src/book-components/Chat/utils/renderMarkdown.test.ts.tmp +0 -199
  89. package/src/collection/agent-collection/constructors/agent-collection-in-directory/AgentCollectionInDirectory.test.ts.todo +0 -131
  90. package/src/commands/_common/parseCommand.test.ts.todo +0 -48
  91. package/src/commitments/META_LINK/META_LINK.test.ts.todo +0 -75
  92. package/src/conversion/validation/pipelineStringToJson-errors.test.ts.todo +0 -33
  93. package/src/dialogs/simple-prompt/SimplePromptInterfaceTools.ts +0 -51
  94. package/src/executables/browsers/locateSafari.test.ts.tmp +0 -15
  95. package/src/execution/PromptbookFetch.test-type.ts +0 -14
  96. package/src/execution/createPipelineExecutor/00-createPipelineExecutor.test.ts.todo +0 -0
  97. package/src/execution/execution-report/executionReportJsonToString.test.ts.todo +0 -83
  98. package/src/execution/utils/usageToHuman.test.ts.todo +0 -80
  99. package/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.ts +0 -76
  100. package/src/llm-providers/_common/utils/assertUniqueModels.ts +0 -27
  101. package/src/llm-providers/_multiple/playground/playground.ts +0 -141
  102. package/src/llm-providers/_multiple/playground/tsconfig.json +0 -19
  103. package/src/llm-providers/agent/playground/playground.ts +0 -190
  104. package/src/llm-providers/agent/playground/tsconfig.json +0 -19
  105. package/src/llm-providers/anthropic-claude/playground/playground.ts +0 -99
  106. package/src/llm-providers/anthropic-claude/playground/tsconfig.json +0 -19
  107. package/src/llm-providers/azure-openai/playground/playground.ts +0 -101
  108. package/src/llm-providers/azure-openai/playground/tsconfig.json +0 -19
  109. package/src/llm-providers/ollama/playground/playground.ts +0 -120
  110. package/src/llm-providers/ollama/playground/tsconfig.json +0 -19
  111. package/src/llm-providers/openai/playground/playground.ts +0 -406
  112. package/src/llm-providers/openai/playground/tsconfig.json +0 -19
  113. package/src/llm-providers/remote/playground/playground.ts +0 -144
  114. package/src/llm-providers/remote/playground/tsconfig.json +0 -19
  115. package/src/llm-providers/vercel/playground/playground.ts +0 -133
  116. package/src/llm-providers/vercel/playground/tsconfig.json +0 -19
  117. package/src/personas/preparePersona.test.ts.todo +0 -126
  118. package/src/playground/backup/_playground-boilerplate.ts.txt +0 -37
  119. package/src/playground/backup/playground-agent-os.txt +0 -62
  120. package/src/playground/backup/playground-brj-app.ts.txt +0 -302
  121. package/src/playground/backup/playground-browser-playwright.txt +0 -110
  122. package/src/playground/backup/playground-claude-mcp.txt +0 -43
  123. package/src/playground/backup/playground-document-conversion.txt +0 -84
  124. package/src/playground/backup/playground-glob.ts.txt +0 -42
  125. package/src/playground/backup/playground-mcp-server.txt +0 -1
  126. package/src/playground/backup/playground-openai-agent-kit.txt +0 -73
  127. package/src/playground/backup/playground-openai-function-calling.txt +0 -131
  128. package/src/playground/backup/playground-openai-streaming.ts.txt +0 -68
  129. package/src/playground/backup/playground-scrape-knowledge.txt +0 -65
  130. package/src/playground/backup/playground-scraperFetch.ts.txt +0 -44
  131. package/src/playground/backup/playground-using-openai-compatible-route-on-agents-server.ts.txt +0 -49
  132. package/src/playground/backup/playground-write-pavolhejny-bio.txt +0 -120
  133. package/src/playground/permanent/_boilerplate.ts +0 -54
  134. package/src/playground/permanent/agent-with-browser-playground.ts +0 -92
  135. package/src/playground/permanent/error-handling-playground.ts +0 -103
  136. package/src/playground/playground.ts +0 -36
  137. package/src/playground/tsconfig.json +0 -19
  138. package/src/scrapers/_boilerplate/BoilerplateScraper.test.ts.todo +0 -73
  139. package/src/scrapers/_boilerplate/playground/boilerplate-scraper-playground.ts +0 -79
  140. package/src/scrapers/_boilerplate/playground/tsconfig.json +0 -19
  141. package/src/scrapers/_common/utils/files/blobToDataurl.test.ts.todo +0 -17
  142. package/src/scrapers/_common/utils/files/dataurlToBlob.test.ts.todo +0 -52
  143. package/src/scrapers/_common/utils/files/isValidDataurl.test.ts.todo +0 -42
  144. package/src/scrapers/_common/utils/files/shorten.test.ts.todo +0 -13
  145. package/src/scrapers/document/playground/document-scraper-playground.ts +0 -80
  146. package/src/scrapers/document/playground/tsconfig.json +0 -19
  147. package/src/scrapers/document-legacy/playground/legacy-document-scraper-playground.ts +0 -80
  148. package/src/scrapers/document-legacy/playground/tsconfig.json +0 -19
  149. package/src/scrapers/markdown/playground/markdown-scraper-playground.ts +0 -74
  150. package/src/scrapers/markdown/playground/tsconfig.json +0 -19
  151. package/src/scrapers/markitdown/MarkitdownScraper.test.ts.todo +0 -132
  152. package/src/scrapers/markitdown/playground/markitdown-scraper-playground.ts +0 -91
  153. package/src/scrapers/markitdown/playground/tsconfig.json +0 -19
  154. package/src/scrapers/pdf/PdfScraper.test.ts.todo +0 -52
  155. package/src/scrapers/pdf/playground/pdf-scraper-playground.ts +0 -75
  156. package/src/scrapers/pdf/playground/tsconfig.json +0 -19
  157. package/src/scrapers/website/playground/tsconfig.json +0 -19
  158. package/src/scrapers/website/playground/website-scraper-playground.ts +0 -82
  159. package/src/storage/_common/PromptbookStorage.test-type.ts +0 -14
  160. package/src/storage/local-storage/getIndexedDbStorage.ts +0 -36
  161. package/src/storage/local-storage/getLocalStorage.ts +0 -33
  162. package/src/storage/local-storage/getSessionStorage.ts +0 -33
  163. package/src/storage/local-storage/utils/IndexedDbStorageOptions.ts +0 -16
  164. package/src/storage/local-storage/utils/makePromptbookStorageFromIndexedDb.ts +0 -58
  165. package/src/storage/local-storage/utils/makePromptbookStorageFromWebStorage.ts +0 -45
  166. package/src/transpilers/formatted-book-in-markdown/FormattedBookInMarkdownTranspiler.test.ts.todo +0 -35
  167. package/src/transpilers/openai-sdk/playground/playground.ts +0 -85
  168. package/src/transpilers/openai-sdk/playground/tmp/chatbot-openaisdk-1.js +0 -194
  169. package/src/transpilers/openai-sdk/playground/tmp/package.json +0 -3
  170. package/src/transpilers/openai-sdk/playground/tsconfig.json +0 -18
  171. package/src/utils/editable/utils/findUsableParameters.test.ts.todo +0 -43
  172. package/src/utils/editable/utils/stringifyPipelineJson.test.ts.todo +0 -38
  173. package/src/utils/markdown/prettifyMarkdown.test.ts.tmp +0 -42
  174. package/src/utils/serialization/serializeToPromptbookJavascript.test.ts.todo +0 -116
@@ -1,168 +0,0 @@
1
- import { readdir, readFile } from 'fs/promises';
2
- import { join } from 'path';
3
- import type { AgentBasicInformation, AgentCollection, string_book } from '@promptbook-local/types';
4
- import { parseAgentSource } from '../../../../../src/book-2.0/agent-source/parseAgentSource';
5
- import { DEFAULT_AGENT_VISIBILITY } from '../agentVisibility';
6
-
7
- /**
8
- * Installation status for one default agent book.
9
- *
10
- * @private shared utility for Agents Server default-agent installation
11
- */
12
- export type DefaultAgentInstallStatus = 'installed' | 'skipped';
13
-
14
- /**
15
- * Result for one processed default agent book.
16
- *
17
- * @private shared utility for Agents Server default-agent installation
18
- */
19
- export type DefaultAgentInstallRecord = {
20
- /**
21
- * Source book filename.
22
- */
23
- readonly fileName: string;
24
-
25
- /**
26
- * Parsed canonical agent name.
27
- */
28
- readonly agentName: string;
29
-
30
- /**
31
- * Whether the agent was created or skipped because an active agent with the same name already exists.
32
- */
33
- readonly status: DefaultAgentInstallStatus;
34
-
35
- /**
36
- * Permanent id of the newly created agent, if created.
37
- */
38
- readonly permanentId?: string;
39
- };
40
-
41
- /**
42
- * Aggregate default-agent installation result.
43
- *
44
- * @private shared utility for Agents Server default-agent installation
45
- */
46
- export type DefaultAgentInstallResult = {
47
- /**
48
- * Number of newly created agents.
49
- */
50
- readonly installedCount: number;
51
-
52
- /**
53
- * Number of already-present agents skipped by name.
54
- */
55
- readonly skippedCount: number;
56
-
57
- /**
58
- * Per-book processing records.
59
- */
60
- readonly records: ReadonlyArray<DefaultAgentInstallRecord>;
61
- };
62
-
63
- /**
64
- * Options for installing default agents from a directory.
65
- *
66
- * @private shared utility for Agents Server default-agent installation
67
- */
68
- export type InstallDefaultAgentsFromDirectoryOptions = {
69
- /**
70
- * Agent collection used for persistence.
71
- */
72
- readonly collection: AgentCollection;
73
-
74
- /**
75
- * Directory containing the repository default `*.book` files.
76
- */
77
- readonly defaultAgentsDirectoryPath: string;
78
-
79
- /**
80
- * Optional logger for install-time progress.
81
- */
82
- readonly logger?: Pick<Console, 'info'>;
83
- };
84
-
85
- /**
86
- * Lists repository default book filenames in stable install order.
87
- *
88
- * @param defaultAgentsDirectoryPath - Directory containing default `*.book` files.
89
- * @returns Sorted book filenames.
90
- *
91
- * @private shared utility for Agents Server default-agent installation
92
- */
93
- export async function listDefaultAgentBookFileNames(defaultAgentsDirectoryPath: string): Promise<ReadonlyArray<string>> {
94
- const directoryEntries = await readdir(defaultAgentsDirectoryPath, { withFileTypes: true });
95
-
96
- return directoryEntries
97
- .filter((entry) => entry.isFile() && entry.name.endsWith('.book'))
98
- .map((entry) => entry.name)
99
- .sort((left, right) => left.localeCompare(right));
100
- }
101
-
102
- /**
103
- * Creates default agents from repository `*.book` files, skipping already-active agents with matching names.
104
- *
105
- * @param options - Installation options.
106
- * @returns Aggregate installation result.
107
- *
108
- * @private shared utility for Agents Server default-agent installation
109
- */
110
- export async function installDefaultAgentsFromDirectory(
111
- options: InstallDefaultAgentsFromDirectoryOptions,
112
- ): Promise<DefaultAgentInstallResult> {
113
- const fileNames = await listDefaultAgentBookFileNames(options.defaultAgentsDirectoryPath);
114
- const existingAgentNames = new Set((await options.collection.listAgents()).map((agent) => agent.agentName));
115
- const records: Array<DefaultAgentInstallRecord> = [];
116
-
117
- for (const [index, fileName] of fileNames.entries()) {
118
- const agentSource = (await readFile(join(options.defaultAgentsDirectoryPath, fileName), 'utf-8')) as string_book;
119
- const parsedAgentProfile = parseAgentSource(agentSource);
120
- const agentName = parsedAgentProfile.agentName;
121
-
122
- if (existingAgentNames.has(agentName)) {
123
- options.logger?.info(`[default-agents] Skipping existing agent "${agentName}" from ${fileName}.`);
124
- records.push({
125
- fileName,
126
- agentName,
127
- status: 'skipped',
128
- });
129
- continue;
130
- }
131
-
132
- const createdAgent = await options.collection.createAgent(agentSource, {
133
- sortOrder: index + 1,
134
- visibility: DEFAULT_AGENT_VISIBILITY,
135
- });
136
-
137
- existingAgentNames.add(createdAgent.agentName);
138
- options.logger?.info(`[default-agents] Installed "${createdAgent.agentName}" from ${fileName}.`);
139
- records.push(createInstalledDefaultAgentRecord(fileName, createdAgent));
140
- }
141
-
142
- return {
143
- installedCount: records.filter((record) => record.status === 'installed').length,
144
- skippedCount: records.filter((record) => record.status === 'skipped').length,
145
- records,
146
- };
147
- }
148
-
149
- /**
150
- * Creates a typed result record for a newly installed default agent.
151
- *
152
- * @param fileName - Source book filename.
153
- * @param createdAgent - Created agent profile returned by the collection.
154
- * @returns Installation record.
155
- *
156
- * @private utility of `installDefaultAgentsFromDirectory`
157
- */
158
- function createInstalledDefaultAgentRecord(
159
- fileName: string,
160
- createdAgent: AgentBasicInformation & Required<Pick<AgentBasicInformation, 'permanentId'>>,
161
- ): DefaultAgentInstallRecord {
162
- return {
163
- fileName,
164
- agentName: createdAgent.agentName,
165
- status: 'installed',
166
- permanentId: createdAgent.permanentId,
167
- };
168
- }
@@ -1,139 +0,0 @@
1
- import * as dotenv from 'dotenv';
2
- import { createClient, type SupabaseClient } from '@supabase/supabase-js';
3
- import { AgentCollectionInSupabase } from '../../../../../src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase';
4
- import type { AgentCollection } from '../../../../../src/collection/agent-collection/AgentCollection';
5
- import { isAgentsServerSqliteMode } from '../../database/agentsServerDatabaseMode';
6
- import { $provideLocalSqliteSupabase } from '../../database/sqlite/$provideLocalSqliteSupabase';
7
- import { installDefaultAgentsFromDirectory } from './defaultAgents';
8
-
9
- /**
10
- * Environment variable pointing to the installed Agents Server `.env` file.
11
- *
12
- * @private install-time default-agent utility
13
- */
14
- const AGENTS_SERVER_ENV_FILE_ENV_NAME = 'PTBK_AGENTS_SERVER_ENV_FILE';
15
-
16
- /**
17
- * Environment variable pointing to the repository `agents/default` directory.
18
- *
19
- * @private install-time default-agent utility
20
- */
21
- const DEFAULT_AGENTS_DIRECTORY_ENV_NAME = 'PTBK_DEFAULT_AGENTS_DIR';
22
-
23
- /**
24
- * Environment variable containing the current server table prefix.
25
- *
26
- * @private install-time default-agent utility
27
- */
28
- const SUPABASE_TABLE_PREFIX_ENV_NAME = 'SUPABASE_TABLE_PREFIX';
29
-
30
- /**
31
- * Public Supabase URL environment variable.
32
- *
33
- * @private install-time default-agent utility
34
- */
35
- const NEXT_PUBLIC_SUPABASE_URL_ENV_NAME = 'NEXT_PUBLIC_SUPABASE_URL';
36
-
37
- /**
38
- * Supabase service role key environment variable.
39
- *
40
- * @private install-time default-agent utility
41
- */
42
- const SUPABASE_SERVICE_ROLE_KEY_ENV_NAME = 'SUPABASE_SERVICE_ROLE_KEY';
43
-
44
- /**
45
- * Public Supabase anon key environment variable used as a fallback when service role is unavailable.
46
- *
47
- * @private install-time default-agent utility
48
- */
49
- const NEXT_PUBLIC_SUPABASE_ANON_KEY_ENV_NAME = 'NEXT_PUBLIC_SUPABASE_ANON_KEY';
50
-
51
- /**
52
- * Loads the installed Agents Server environment for the detached installer script.
53
- *
54
- * @private install-time default-agent utility
55
- */
56
- function loadDefaultAgentInstallEnvironment(): void {
57
- const explicitEnvFilePath = process.env[AGENTS_SERVER_ENV_FILE_ENV_NAME]?.trim();
58
- if (explicitEnvFilePath) {
59
- const explicitLoadResult = dotenv.config({ path: explicitEnvFilePath });
60
- if (!explicitLoadResult.error) {
61
- return;
62
- }
63
- }
64
-
65
- dotenv.config();
66
- }
67
-
68
- /**
69
- * Creates the install-time agent collection using the same database backend as the server.
70
- *
71
- * @returns Agent collection bound to the configured table prefix.
72
- *
73
- * @private install-time default-agent utility
74
- */
75
- function createDefaultAgentInstallCollection(): AgentCollection {
76
- return new AgentCollectionInSupabase(createDefaultAgentInstallSupabaseClient(), {
77
- tablePrefix: process.env[SUPABASE_TABLE_PREFIX_ENV_NAME] || '',
78
- });
79
- }
80
-
81
- /**
82
- * Creates the Supabase-shaped client used by the install-time agent collection.
83
- *
84
- * @returns Supabase or local SQLite client.
85
- *
86
- * @private install-time default-agent utility
87
- */
88
- function createDefaultAgentInstallSupabaseClient(): SupabaseClient {
89
- if (isAgentsServerSqliteMode()) {
90
- return $provideLocalSqliteSupabase();
91
- }
92
-
93
- const supabaseUrl = process.env[NEXT_PUBLIC_SUPABASE_URL_ENV_NAME];
94
- const supabaseKey =
95
- process.env[SUPABASE_SERVICE_ROLE_KEY_ENV_NAME] || process.env[NEXT_PUBLIC_SUPABASE_ANON_KEY_ENV_NAME];
96
-
97
- if (!supabaseUrl || !supabaseKey) {
98
- throw new Error(
99
- `Missing \`${NEXT_PUBLIC_SUPABASE_URL_ENV_NAME}\` and \`${SUPABASE_SERVICE_ROLE_KEY_ENV_NAME}\` for Supabase default-agent installation.`,
100
- );
101
- }
102
-
103
- return createClient(supabaseUrl, supabaseKey, {
104
- auth: {
105
- autoRefreshToken: false,
106
- persistSession: false,
107
- },
108
- });
109
- }
110
-
111
- /**
112
- * Runs the default-agent install command.
113
- *
114
- * @private install-time default-agent utility
115
- */
116
- async function installDefaultAgents(): Promise<void> {
117
- loadDefaultAgentInstallEnvironment();
118
-
119
- const defaultAgentsDirectoryPath = process.env[DEFAULT_AGENTS_DIRECTORY_ENV_NAME]?.trim();
120
- if (!defaultAgentsDirectoryPath) {
121
- throw new Error(`Missing \`${DEFAULT_AGENTS_DIRECTORY_ENV_NAME}\` environment variable.`);
122
- }
123
-
124
- const result = await installDefaultAgentsFromDirectory({
125
- collection: createDefaultAgentInstallCollection(),
126
- defaultAgentsDirectoryPath,
127
- logger: console,
128
- });
129
-
130
- console.info(
131
- `[default-agents] Finished. Installed ${result.installedCount}, skipped ${result.skippedCount}.`,
132
- );
133
- }
134
-
135
- installDefaultAgents().catch((error) => {
136
- console.error('[default-agents] Failed to install default agents.');
137
- console.error(error instanceof Error ? error.message : error);
138
- process.exitCode = 1;
139
- });
@@ -1,178 +0,0 @@
1
- import { expect, test, type Page } from 'playwright/test';
2
- import { loginAsAdmin, logoutFromHeader } from './support/auth';
3
- import { openHeaderMenu } from './support/navigation';
4
-
5
- /**
6
- * Emulates a coarse-pointer touch environment while keeping desktop viewport width.
7
- *
8
- * @param page - Current Playwright page.
9
- */
10
- async function emulateTouchInput(page: Page) {
11
- await page.addInitScript(() => {
12
- const originalMatchMedia = window.matchMedia.bind(window);
13
-
14
- Object.defineProperty(navigator, 'maxTouchPoints', {
15
- configurable: true,
16
- get: () => 5,
17
- });
18
-
19
- Object.defineProperty(window, 'ontouchstart', {
20
- configurable: true,
21
- value: null,
22
- });
23
-
24
- window.matchMedia = (query: string): MediaQueryList => {
25
- if (query === '(hover: none) and (pointer: coarse)') {
26
- return {
27
- matches: true,
28
- media: query,
29
- onchange: null,
30
- addListener: () => void 0,
31
- removeListener: () => void 0,
32
- addEventListener: () => void 0,
33
- removeEventListener: () => void 0,
34
- dispatchEvent: () => false,
35
- } as MediaQueryList;
36
- }
37
-
38
- return originalMatchMedia(query);
39
- };
40
- });
41
- }
42
-
43
- /**
44
- * Creates a new agent through the homepage dialog and waits for its profile page.
45
- *
46
- * @param page - Current Playwright page.
47
- */
48
- async function createAgentViaHomepageDialog(page: Page): Promise<void> {
49
- const addAgentCard = page.getByText('Add New Agent');
50
- await expect(addAgentCard).toBeVisible();
51
- await addAgentCard.click();
52
-
53
- await expect(page.getByRole('heading', { name: 'Create New Agent' })).toBeVisible();
54
- await page.getByRole('button', { name: 'Create Agent' }).click();
55
- await expect(page).toHaveURL(/\/agents\/[^/?#]+$/);
56
- }
57
-
58
- /**
59
- * Opens the `System` menu and expands the `My Account` category.
60
- *
61
- * @param page - Current Playwright page.
62
- */
63
- async function openSystemMyAccountMenu(page: Page): Promise<void> {
64
- await openHeaderMenu(page, 'System');
65
- const myAccountButton = page.getByRole('button', { name: 'My Account' });
66
- await expect(myAccountButton).toBeVisible();
67
- await myAccountButton.hover();
68
- }
69
-
70
- /**
71
- * Clicks one link inside the `System > My Account` nested submenu.
72
- *
73
- * @param page - Current Playwright page.
74
- * @param linkName - Visible text of the destination link.
75
- */
76
- async function clickSystemMyAccountLink(page: Page, linkName: string): Promise<void> {
77
- await openSystemMyAccountMenu(page);
78
-
79
- const nestedMenuPortal = page.locator('[data-header-dropdown-portal="true"]');
80
- await expect(nestedMenuPortal).toBeAttached();
81
-
82
- const nestedLink = nestedMenuPortal.getByRole('link', { name: linkName });
83
- await expect(nestedLink).toBeVisible();
84
- await nestedLink.click();
85
- }
86
-
87
- /**
88
- * Core authentication and navigation integration flows for Agents Server.
89
- */
90
- test.describe('Agents Server authentication and navigation', () => {
91
- test('shows forbidden state for protected System page when anonymous', async ({ page }) => {
92
- await page.goto('/system/profile');
93
- await expect(page.getByRole('heading', { name: '403 Forbidden' })).toBeVisible();
94
- await expect(page.getByLabel('Username')).toBeVisible();
95
- });
96
-
97
- test('allows admin to sign in, navigate major menus, and sign out', async ({ page }) => {
98
- await page.goto('/');
99
- await expect(page.getByRole('link', { name: 'Promptbook Agents Server' })).toBeVisible();
100
-
101
- await loginAsAdmin(page);
102
- await expect(page.getByRole('button', { name: 'System' })).toBeVisible();
103
-
104
- await openHeaderMenu(page, 'Documentation');
105
- await page.getByRole('link', { name: 'Overview' }).click();
106
- await expect(page).toHaveURL(/\/docs$/);
107
- await expect(page.getByRole('heading', { name: 'Documentation' })).toBeVisible();
108
-
109
- await page.goto('/docs/PERSONA');
110
- await expect(page.getByRole('heading', { name: 'PERSONA', exact: true })).toBeVisible();
111
-
112
- await clickSystemMyAccountLink(page, 'Profile');
113
- await expect(page).toHaveURL(/\/system\/profile$/);
114
- await expect(page.getByRole('heading', { name: 'Profile' })).toBeVisible();
115
-
116
- await clickSystemMyAccountLink(page, 'User Memory');
117
- await expect(page).toHaveURL(/\/system\/user-memory$/);
118
- await expect(page.getByRole('heading', { name: 'User Memory' })).toBeVisible();
119
-
120
- await logoutFromHeader(page);
121
- });
122
-
123
- test('keeps nested header submenu items tappable on touch devices', async ({ page }) => {
124
- await emulateTouchInput(page);
125
- await page.goto('/');
126
-
127
- await loginAsAdmin(page);
128
- await openHeaderMenu(page, 'Documentation');
129
-
130
- const allSubmenuButton = page.getByRole('button', { name: /^All$/ });
131
- await expect(allSubmenuButton).toBeVisible();
132
- await allSubmenuButton.click();
133
-
134
- const personaLink = page.getByRole('link', { name: /^PERSONA\b/ });
135
- await expect(personaLink).toBeVisible();
136
- await personaLink.click();
137
-
138
- await expect(page).toHaveURL(/\/docs\/PERSONA$/);
139
- await expect(page.getByRole('heading', { name: 'PERSONA', exact: true })).toBeVisible();
140
- });
141
-
142
- test('protects clone prompt against accidental close when the input is dirty', async ({ page }) => {
143
- await page.goto('/');
144
- await loginAsAdmin(page);
145
- await createAgentViaHomepageDialog(page);
146
-
147
- await page.getByRole('button', { name: 'More options' }).click();
148
- await page.getByRole('button', { name: 'Clone agent' }).click();
149
- const cloneHeading = page.getByRole('heading', { name: 'Clone agent' });
150
- const cloneInput = page.getByLabel('Agent name');
151
-
152
- await expect(cloneHeading).toBeVisible();
153
- await cloneInput.fill('Clone name draft');
154
-
155
- let dismissedDiscardDialog = false;
156
- page.once('dialog', async (dialog) => {
157
- dismissedDiscardDialog = true;
158
- expect(dialog.type()).toBe('confirm');
159
- await dialog.dismiss();
160
- });
161
-
162
- await page.mouse.click(8, 8);
163
- await expect.poll(() => dismissedDiscardDialog).toBe(true);
164
- await expect(cloneHeading).toBeVisible();
165
- await expect(cloneInput).toHaveValue('Clone name draft');
166
-
167
- let acceptedDiscardDialog = false;
168
- page.once('dialog', async (dialog) => {
169
- acceptedDiscardDialog = true;
170
- expect(dialog.type()).toBe('confirm');
171
- await dialog.accept();
172
- });
173
-
174
- await page.keyboard.press('Escape');
175
- await expect.poll(() => acceptedDiscardDialog).toBe(true);
176
- await expect(cloneHeading).toBeHidden();
177
- });
178
- });
@@ -1,31 +0,0 @@
1
- // ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
2
- // `@promptbook/browser`
3
-
4
- import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';
5
- import { getAllCommitmentsToolFunctionsForBrowser } from '../commitments/_common/getAllCommitmentsToolFunctionsForBrowser';
6
- import { SimplePromptInterfaceTools } from '../dialogs/simple-prompt/SimplePromptInterfaceTools';
7
- import { $provideScrapersForBrowser } from '../scrapers/_common/register/$provideScrapersForBrowser';
8
- import { BrowserSpeechRecognition } from '../speech-recognition/BrowserSpeechRecognition';
9
- import { getIndexedDbStorage } from '../storage/local-storage/getIndexedDbStorage';
10
- import { getLocalStorage } from '../storage/local-storage/getLocalStorage';
11
- import { getSessionStorage } from '../storage/local-storage/getSessionStorage';
12
- import { $induceBookDownload } from '../utils/files/$induceBookDownload';
13
- import { $induceFileDownload } from '../utils/files/$induceFileDownload';
14
- import { ObjectUrl } from '../utils/files/ObjectUrl';
15
-
16
-
17
- // Note: Exporting version from each package
18
- export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
19
-
20
-
21
- // Note: Entities of the `@promptbook/browser`
22
- export { getAllCommitmentsToolFunctionsForBrowser };
23
- export { SimplePromptInterfaceTools };
24
- export { $provideScrapersForBrowser };
25
- export { BrowserSpeechRecognition };
26
- export { getIndexedDbStorage };
27
- export { getLocalStorage };
28
- export { getSessionStorage };
29
- export { $induceBookDownload };
30
- export { $induceFileDownload };
31
- export { ObjectUrl };
@@ -1,43 +0,0 @@
1
- The browser package provides browser-specific functionality for Promptbook, including localStorage integration, IndexedDB storage, and browser-compatible scrapers. It enables Promptbook to run efficiently in web browser environments.
2
-
3
- ## 🎯 Purpose and Motivation
4
-
5
- This package extends Promptbook's core functionality with browser-specific features that are essential for web applications. It provides browser storage APIs, user interface tools, and browser-compatible scrapers that enable full-featured Promptbook applications in web environments.
6
-
7
- ## 🔧 High-Level Functionality
8
-
9
- The package provides browser-specific integrations and utilities:
10
- - **Browser Storage**: Integration with localStorage, sessionStorage, and IndexedDB
11
- - **User Interface Tools**: Simple prompt interface for browser interactions
12
- - **Browser Scrapers**: Browser-compatible content scrapers
13
- - **Web Compatibility**: Ensures Promptbook works seamlessly in browser environments
14
- - **Client-side Caching**: Efficient caching using browser storage APIs
15
-
16
- ## ✨ Key Features
17
-
18
- - 💾 **Multiple Storage Options** - Support for localStorage, sessionStorage, and IndexedDB
19
- - 🌐 **Browser-native APIs** - Leverage browser-specific capabilities and storage
20
- - 🎨 **Simple UI Tools** - Basic interface tools for browser-based interactions
21
- - 📱 **Cross-browser Compatibility** - Works across modern web browsers
22
- - 🔒 **Client-side Security** - Secure storage and execution in browser sandbox
23
- - ⚡ **Performance Optimized** - Efficient storage and caching for web applications
24
- - 🛠️ **Web Scrapers** - Browser-compatible content scraping capabilities
25
-
26
- ## 📦 Exported Entities
27
-
28
- ### Version Information
29
- - `BOOK_LANGUAGE_VERSION` - Current book language version
30
- - `PROMPTBOOK_ENGINE_VERSION` - Current engine version
31
-
32
- ### User Interface Tools
33
- - `SimplePromptInterfaceTools` - Simple prompt interface for browser interactions
34
-
35
- ### Browser Scrapers
36
- - `$provideScrapersForBrowser` - Provide browser-compatible knowledge scrapers
37
-
38
- ### Storage APIs
39
- - `getIndexedDbStorage` - Get IndexedDB storage implementation
40
- - `getLocalStorage` - Get localStorage storage implementation
41
- - `getSessionStorage` - Get sessionStorage storage implementation
42
-
43
- > 💡 This package does not make sense on its own, look at [all promptbook packages](#-packages) or just install all by `npm i ptbk`