@promptbook/cli 0.112.0-126 → 0.112.0-127

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 (190) hide show
  1. package/README.md +5 -5
  2. package/apps/agents-server/README.md +3 -0
  3. package/apps/agents-server/playwright.config.ts +1 -0
  4. package/apps/agents-server/public/promptbook-logo-blue.png +0 -0
  5. package/apps/agents-server/public/promptbook-logo-white.png +0 -0
  6. package/apps/agents-server/src/app/[agentName]/layout.tsx +1 -0
  7. package/apps/agents-server/src/app/actions.ts +2 -2
  8. package/apps/agents-server/src/app/admin/update/UpdateClient.tsx +68 -36
  9. package/apps/agents-server/src/app/agents/[agentName]/ActiveAgentBreadcrumbBinder.tsx +30 -0
  10. package/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +2 -0
  11. package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatHistoryPayloadState.ts +38 -4
  12. package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatHistorySyncOperations.ts +4 -1
  13. package/apps/agents-server/src/app/agents/[agentName]/chat/CanonicalAgentChatSurface.tsx +19 -15
  14. package/apps/agents-server/src/app/agents/[agentName]/chat/useCanonicalAgentChatPanelState.ts +58 -7
  15. package/apps/agents-server/src/app/agents/[agentName]/layout.tsx +47 -1
  16. package/apps/agents-server/src/app/api/chat/citation-label/route.ts +133 -0
  17. package/apps/agents-server/src/app/globals.css +78 -0
  18. package/apps/agents-server/src/components/Header/ActiveAgentBreadcrumbContext.tsx +82 -0
  19. package/apps/agents-server/src/components/Header/useHeaderActiveAgent.ts +26 -7
  20. package/apps/agents-server/src/components/LayoutWrapper/LayoutWrapper.tsx +35 -32
  21. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/ManGoNewAgentWizard.tsx +151 -0
  22. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/ManGoOnboardingNavigation.tsx +50 -0
  23. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/BookLanguagePanel.tsx +125 -0
  24. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/DropZone.tsx +83 -0
  25. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/EmailTestRun.tsx +216 -0
  26. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/KnowledgeList.tsx +79 -0
  27. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/Logo.tsx +20 -0
  28. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/MarkdownBookEditor.tsx +154 -0
  29. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/MarkdownPreview.tsx +188 -0
  30. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/RailStepper.tsx +115 -0
  31. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/StepFrame.tsx +47 -0
  32. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/TestChat.tsx +159 -0
  33. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/WizardShell.tsx +114 -0
  34. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/brand/RailArtwork.tsx +60 -0
  35. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/steps/BookStep.tsx +135 -0
  36. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/steps/DoneStep.tsx +215 -0
  37. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/steps/KnowledgeStep.tsx +152 -0
  38. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/steps/TestStep.tsx +262 -0
  39. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/steps/ZadaniStep.tsx +64 -0
  40. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/ui/Badge.tsx +41 -0
  41. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/ui/Banner.tsx +69 -0
  42. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/ui/Button.tsx +77 -0
  43. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/ui/Card.tsx +33 -0
  44. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/ui/Field.tsx +103 -0
  45. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/ui/IconButton.tsx +40 -0
  46. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/ui/Spinner.tsx +14 -0
  47. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/ui/tokens.ts +37 -0
  48. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/config/bookSections.ts +62 -0
  49. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/config/emailScenarios.ts +22 -0
  50. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/config/steps.ts +46 -0
  51. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/index.ts +11 -0
  52. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/lib/cn.ts +4 -0
  53. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/lib/format.ts +9 -0
  54. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/lib/id.ts +11 -0
  55. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/agentEvalService.ts +30 -0
  56. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/agentTestService.ts +69 -0
  57. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/bookService.ts +21 -0
  58. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/createManGoAgentSource.ts +107 -0
  59. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/draftService.ts +45 -0
  60. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/uploadService.ts +27 -0
  61. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/state/OnboardingProvider.tsx +121 -0
  62. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/types.ts +52 -0
  63. package/apps/agents-server/src/components/NewAgentDialog/createNewAgentWizardSource.ts +1 -1
  64. package/apps/agents-server/src/components/NewAgentDialog/trackNewAgentCreationEvent.ts +1 -1
  65. package/apps/agents-server/src/components/NewAgentDialog/useNewAgentDialog.tsx +76 -0
  66. package/apps/agents-server/src/constants/newAgentWizard.ts +17 -8
  67. package/apps/agents-server/src/database/getMetadata.ts +37 -1
  68. package/apps/agents-server/src/database/metadataDefaults.ts +18 -7
  69. package/apps/agents-server/src/database/migrations/2026-06-2200-new-agent-wizard-metadata-key.sql +27 -0
  70. package/apps/agents-server/src/database/migrations/2026-06-2201-new-agent-wizard-mango-default.sql +11 -0
  71. package/apps/agents-server/src/generated/reservedPaths.ts +2 -0
  72. package/apps/agents-server/src/languages/translations/english.yaml +1 -1
  73. package/apps/agents-server/src/tools/createChatAttachmentToolFunctions.ts +8 -4
  74. package/apps/agents-server/src/utils/chat/resolveAgentsServerCitationLabel.ts +130 -0
  75. package/apps/agents-server/src/utils/chat/resolveCitationSourceLabel.ts +436 -0
  76. package/apps/agents-server/src/utils/knowledge/resolveWebsiteKnowledgeSourcesForServer.ts +10 -1
  77. package/apps/agents-server/src/utils/session.ts +62 -5
  78. package/apps/agents-server/src/utils/transpilers/resolveTranspiledTeamExport.ts +10 -10
  79. package/apps/agents-server/src/utils/userChat/userChatProgressCard.ts +198 -63
  80. package/apps/agents-server/src/utils/vpsConfiguration.ts +1 -0
  81. package/apps/agents-server/src/utils/vpsSelfUpdate.ts +81 -8
  82. package/esm/index.es.js +1052 -455
  83. package/esm/index.es.js.map +1 -1
  84. package/esm/scripts/run-codex-prompts/git/commitChanges.d.ts +3 -1
  85. package/esm/scripts/run-codex-prompts/main/runPromptRound.d.ts +2 -2
  86. package/esm/scripts/run-codex-prompts/server/buildCoderServerPromptResponse.d.ts +50 -0
  87. package/esm/scripts/run-codex-prompts/server/buildCoderServerRunState.d.ts +23 -0
  88. package/esm/scripts/run-codex-prompts/server/coderServerHtml.d.ts +1 -1
  89. package/esm/scripts/run-codex-prompts/server/runCoderHttpServer.d.ts +13 -1
  90. package/esm/scripts/run-codex-prompts/server/updatePromptSection.d.ts +1 -1
  91. package/esm/scripts/run-codex-prompts/ui/CoderRunUiState.d.ts +1 -0
  92. package/esm/scripts/run-codex-prompts/ui/buildRunUiFrameShared.d.ts +4 -0
  93. package/esm/scripts/run-codex-prompts/ui/renderCoderRunUi.d.ts +1 -0
  94. package/esm/src/_packages/components.index.d.ts +2 -0
  95. package/esm/src/_packages/types.index.d.ts +2 -0
  96. package/esm/src/avatars/avatarAnimationScheduler.d.ts +4 -0
  97. package/esm/src/book-components/Chat/Chat/ChatCitationModal.d.ts +2 -0
  98. package/esm/src/book-components/Chat/Chat/ChatMessageItem.d.ts +4 -0
  99. package/esm/src/book-components/Chat/Chat/ChatMessageList.d.ts +4 -0
  100. package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +5 -0
  101. package/esm/src/book-components/Chat/Chat/ChatToolCallModal.d.ts +2 -0
  102. package/esm/src/book-components/Chat/Chat/ChatToolCallModalContent.d.ts +3 -1
  103. package/esm/src/book-components/Chat/Chat/TeamToolCallModalContent.d.ts +2 -0
  104. package/esm/src/book-components/Chat/SourceChip/SourceChip.d.ts +6 -1
  105. package/esm/src/book-components/Chat/hooks/useResolvedCitationLabel.d.ts +12 -0
  106. package/esm/src/book-components/Chat/types/ChatMessage.d.ts +4 -0
  107. package/esm/src/book-components/Chat/types/ChatParticipant.d.ts +1 -1
  108. package/esm/src/book-components/Chat/types/CitationLabelResolver.d.ts +8 -0
  109. package/esm/src/book-components/Chat/utils/citationHelpers.d.ts +9 -0
  110. package/esm/src/book-components/Chat/utils/decodeJsonUnicodeEscapesInMarkdownText.d.ts +14 -0
  111. package/esm/src/book-components/Chat/utils/decodeJsonUnicodeEscapesInMarkdownText.test.d.ts +1 -0
  112. package/esm/src/book-components/Chat/utils/parseCitationsFromContent.d.ts +4 -0
  113. package/esm/src/version.d.ts +1 -1
  114. package/package.json +1 -1
  115. package/src/_packages/components.index.ts +2 -0
  116. package/src/_packages/types.index.ts +2 -0
  117. package/src/avatars/avatarAnimationScheduler.ts +61 -20
  118. package/src/avatars/visuals/octopus3d2AvatarVisual.ts +106 -21
  119. package/src/avatars/visuals/octopus3d3AvatarVisual.ts +131 -28
  120. package/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments/augmentAgentModelRequirementsFromSource.ts +18 -2
  121. package/src/book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.ts +7 -1
  122. package/src/book-components/Chat/Chat/Chat.tsx +4 -0
  123. package/src/book-components/Chat/Chat/ChatCitationModal.tsx +17 -3
  124. package/src/book-components/Chat/Chat/ChatMessageItem.tsx +22 -2
  125. package/src/book-components/Chat/Chat/ChatMessageList.tsx +6 -0
  126. package/src/book-components/Chat/Chat/ChatProps.tsx +6 -0
  127. package/src/book-components/Chat/Chat/ChatToolCallModal.tsx +4 -0
  128. package/src/book-components/Chat/Chat/ChatToolCallModalContent.tsx +4 -0
  129. package/src/book-components/Chat/Chat/TeamToolCallModalContent.tsx +16 -3
  130. package/src/book-components/Chat/Chat/useChatPostprocessedMessages.ts +13 -2
  131. package/src/book-components/Chat/SourceChip/SourceChip.module.css +8 -0
  132. package/src/book-components/Chat/SourceChip/SourceChip.tsx +19 -5
  133. package/src/book-components/Chat/hooks/useResolvedCitationLabel.ts +65 -0
  134. package/src/book-components/Chat/save/html/htmlSaveFormatDefinition.ts +315 -88
  135. package/src/book-components/Chat/save/react/reactSaveFormatDefinition.ts +7 -1
  136. package/src/book-components/Chat/types/ChatMessage.ts +5 -0
  137. package/src/book-components/Chat/types/ChatParticipant.ts +1 -1
  138. package/src/book-components/Chat/types/CitationLabelResolver.ts +9 -0
  139. package/src/book-components/Chat/utils/citationHelpers.ts +90 -2
  140. package/src/book-components/Chat/utils/createCitationFootnoteRenderModel.ts +3 -0
  141. package/src/book-components/Chat/utils/decodeJsonUnicodeEscapesInMarkdownText.ts +178 -0
  142. package/src/book-components/Chat/utils/parseCitationsFromContent.ts +6 -0
  143. package/src/cli/cli-commands/agents-server/ensureAgentsServerEnvFile.ts +13 -2
  144. package/src/cli/cli-commands/coder/getDefaultCoderPackageJsonScripts.ts +1 -1
  145. package/src/cli/cli-commands/coder/run.ts +17 -20
  146. package/src/cli/cli-commands/coder/server.ts +13 -16
  147. package/src/cli/common/$deprecateCliCommand.ts +10 -1
  148. package/src/commitments/GOAL/GOAL.ts +7 -2
  149. package/src/commitments/LANGUAGE/LANGUAGE.ts +7 -2
  150. package/src/commitments/TEAM/TEAM.ts +12 -1
  151. package/src/commitments/USE_PROJECT/createUseProjectToolFunctions.ts +8 -1
  152. package/src/import-plugins/JsonFileImportPlugin.ts +15 -2
  153. package/src/import-plugins/TextFileImportPlugin.ts +8 -1
  154. package/src/llm-providers/_common/register/$registeredLlmToolsMessage.ts +6 -1
  155. package/src/other/templates/getTemplatesPipelineCollection.ts +681 -837
  156. package/src/utils/chat/chatAttachments/resolveChatAttachmentContent.ts +8 -1
  157. package/src/version.ts +2 -2
  158. package/src/versions.txt +1 -0
  159. package/umd/index.umd.js +1055 -458
  160. package/umd/index.umd.js.map +1 -1
  161. package/umd/scripts/run-codex-prompts/git/commitChanges.d.ts +3 -1
  162. package/umd/scripts/run-codex-prompts/main/runPromptRound.d.ts +2 -2
  163. package/umd/scripts/run-codex-prompts/server/buildCoderServerPromptResponse.d.ts +50 -0
  164. package/umd/scripts/run-codex-prompts/server/buildCoderServerRunState.d.ts +23 -0
  165. package/umd/scripts/run-codex-prompts/server/coderServerHtml.d.ts +1 -1
  166. package/umd/scripts/run-codex-prompts/server/runCoderHttpServer.d.ts +13 -1
  167. package/umd/scripts/run-codex-prompts/server/updatePromptSection.d.ts +1 -1
  168. package/umd/scripts/run-codex-prompts/ui/CoderRunUiState.d.ts +1 -0
  169. package/umd/scripts/run-codex-prompts/ui/buildRunUiFrameShared.d.ts +4 -0
  170. package/umd/scripts/run-codex-prompts/ui/renderCoderRunUi.d.ts +1 -0
  171. package/umd/src/_packages/components.index.d.ts +2 -0
  172. package/umd/src/_packages/types.index.d.ts +2 -0
  173. package/umd/src/avatars/avatarAnimationScheduler.d.ts +4 -0
  174. package/umd/src/book-components/Chat/Chat/ChatCitationModal.d.ts +2 -0
  175. package/umd/src/book-components/Chat/Chat/ChatMessageItem.d.ts +4 -0
  176. package/umd/src/book-components/Chat/Chat/ChatMessageList.d.ts +4 -0
  177. package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +5 -0
  178. package/umd/src/book-components/Chat/Chat/ChatToolCallModal.d.ts +2 -0
  179. package/umd/src/book-components/Chat/Chat/ChatToolCallModalContent.d.ts +3 -1
  180. package/umd/src/book-components/Chat/Chat/TeamToolCallModalContent.d.ts +2 -0
  181. package/umd/src/book-components/Chat/SourceChip/SourceChip.d.ts +6 -1
  182. package/umd/src/book-components/Chat/hooks/useResolvedCitationLabel.d.ts +12 -0
  183. package/umd/src/book-components/Chat/types/ChatMessage.d.ts +4 -0
  184. package/umd/src/book-components/Chat/types/ChatParticipant.d.ts +1 -1
  185. package/umd/src/book-components/Chat/types/CitationLabelResolver.d.ts +8 -0
  186. package/umd/src/book-components/Chat/utils/citationHelpers.d.ts +9 -0
  187. package/umd/src/book-components/Chat/utils/decodeJsonUnicodeEscapesInMarkdownText.d.ts +14 -0
  188. package/umd/src/book-components/Chat/utils/decodeJsonUnicodeEscapesInMarkdownText.test.d.ts +1 -0
  189. package/umd/src/book-components/Chat/utils/parseCitationsFromContent.d.ts +4 -0
  190. package/umd/src/version.d.ts +1 -1
@@ -0,0 +1,121 @@
1
+ 'use client';
2
+
3
+ import { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
4
+ import { NotAllowed } from '../../../../../../../src/errors/NotAllowed';
5
+
6
+ import type { OnboardingState } from '../types';
7
+
8
+ /** sessionStorage key for the wizard session — exported so callers (e.g. the dashboard's
9
+ * "Nový onboarding") can clear a stale draft before starting fresh. */
10
+ export const ONBOARDING_STORAGE_KEY = 'onboarding:v1';
11
+ const STORAGE_KEY = ONBOARDING_STORAGE_KEY;
12
+
13
+ const INITIAL_STATE: OnboardingState = {
14
+ agentName: '',
15
+ agentBrief: '',
16
+ bookSource: '',
17
+ knowledge: [],
18
+ testMessages: [],
19
+ savedAgentId: null,
20
+ savedAgentTargetPath: null,
21
+ };
22
+
23
+ type OnboardingPatch = Partial<OnboardingState> | ((previous: OnboardingState) => Partial<OnboardingState>);
24
+
25
+ type OnboardingContextValue = {
26
+ readonly state: OnboardingState;
27
+ /** True once the initial `sessionStorage` hydration has run (client-only). */
28
+ readonly isHydrated: boolean;
29
+ /**
30
+ * Shallow-merges a patch into the state and writes it through to `sessionStorage`.
31
+ * Accepts a function form for updates that depend on the latest state (e.g. mutating
32
+ * the knowledge list from several concurrent uploads).
33
+ */
34
+ readonly update: (patch: OnboardingPatch) => void;
35
+ /** Clears the session (state + storage). */
36
+ readonly reset: () => void;
37
+ };
38
+
39
+ const OnboardingContext = createContext<OnboardingContextValue | null>(null);
40
+
41
+ function readPersistedState(): OnboardingState | null {
42
+ if (typeof window === 'undefined') {
43
+ return null;
44
+ }
45
+
46
+ try {
47
+ const raw = window.sessionStorage.getItem(STORAGE_KEY);
48
+ return raw ? { ...INITIAL_STATE, ...(JSON.parse(raw) as Partial<OnboardingState>) } : null;
49
+ } catch {
50
+ return null;
51
+ }
52
+ }
53
+
54
+ function writePersistedState(state: OnboardingState): void {
55
+ if (typeof window === 'undefined') {
56
+ return;
57
+ }
58
+
59
+ try {
60
+ window.sessionStorage.setItem(STORAGE_KEY, JSON.stringify(state));
61
+ } catch {
62
+ // Ignore storage failures (private mode, quota) — state still lives in memory.
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Holds the whole wizard state for one onboarding session.
68
+ *
69
+ * Mounted by the `/onboarding` layout route so the state survives navigation between
70
+ * steps. Hydration from `sessionStorage` happens after the first client render to avoid
71
+ * an SSR/CSR mismatch; subsequent writes are write-through.
72
+ */
73
+ export function OnboardingProvider({ children }: { readonly children: React.ReactNode }) {
74
+ const [state, setState] = useState<OnboardingState>(INITIAL_STATE);
75
+ const [isHydrated, setIsHydrated] = useState(false);
76
+
77
+ useEffect(() => {
78
+ const persisted = readPersistedState();
79
+ if (persisted) {
80
+ setState(persisted);
81
+ }
82
+ setIsHydrated(true);
83
+ }, []);
84
+
85
+ const update = useCallback((patch: OnboardingPatch) => {
86
+ setState((previous) => {
87
+ const resolved = typeof patch === 'function' ? patch(previous) : patch;
88
+ const next = { ...previous, ...resolved };
89
+ writePersistedState(next);
90
+ return next;
91
+ });
92
+ }, []);
93
+
94
+ const reset = useCallback(() => {
95
+ setState(INITIAL_STATE);
96
+ if (typeof window !== 'undefined') {
97
+ try {
98
+ window.sessionStorage.removeItem(STORAGE_KEY);
99
+ } catch {
100
+ // Ignore.
101
+ }
102
+ }
103
+ }, []);
104
+
105
+ const value = useMemo<OnboardingContextValue>(
106
+ () => ({ state, isHydrated, update, reset }),
107
+ [state, isHydrated, update, reset],
108
+ );
109
+
110
+ return <OnboardingContext.Provider value={value}>{children}</OnboardingContext.Provider>;
111
+ }
112
+
113
+ export function useOnboarding(): OnboardingContextValue {
114
+ const context = useContext(OnboardingContext);
115
+
116
+ if (!context) {
117
+ throw new NotAllowed('useOnboarding must be used within an <OnboardingProvider>.');
118
+ }
119
+
120
+ return context;
121
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Domain types for the onboarding wizard (Phase 1).
3
+ *
4
+ * These are the module's own types — anything coming from the outside (API responses,
5
+ * server functions) is mapped onto these in `services/` so the UI never depends on
6
+ * external shapes directly.
7
+ */
8
+
9
+ export type KnowledgeItemStatus = 'uploading' | 'ready' | 'error';
10
+
11
+ export type KnowledgeFileItem = {
12
+ readonly kind: 'file';
13
+ readonly id: string;
14
+ readonly name: string;
15
+ readonly size: number;
16
+ readonly publicUrl: string;
17
+ readonly objectKey: string;
18
+ readonly status: KnowledgeItemStatus;
19
+ };
20
+
21
+ export type KnowledgeUrlItem = {
22
+ readonly kind: 'url';
23
+ readonly id: string;
24
+ readonly url: string;
25
+ readonly status: KnowledgeItemStatus;
26
+ };
27
+
28
+ export type KnowledgeItem = KnowledgeFileItem | KnowledgeUrlItem;
29
+
30
+ export type ChatRole = 'user' | 'agent';
31
+
32
+ export type ChatMessage = {
33
+ readonly id: string;
34
+ readonly role: ChatRole;
35
+ readonly content: string;
36
+ };
37
+
38
+ /**
39
+ * The full in-memory state of one onboarding session. Persisted to `sessionStorage`
40
+ * so a refresh does not throw away work-in-progress. No server-side persistence in v1.
41
+ */
42
+ export type OnboardingState = {
43
+ readonly agentName: string;
44
+ readonly agentBrief: string;
45
+ readonly bookSource: string;
46
+ readonly knowledge: readonly KnowledgeItem[];
47
+ readonly testMessages: readonly ChatMessage[];
48
+ /** Permanent id of the created agent once this session reached "Hotovo" (so we save it exactly once). */
49
+ readonly savedAgentId: string | null;
50
+ /** Route opened by the final CTA after the agent is created. */
51
+ readonly savedAgentTargetPath: string | null;
52
+ };
@@ -213,7 +213,7 @@ export function createNewAgentWizardSource(options: CreateNewAgentWizardSourceOp
213
213
  }))
214
214
  .filter((item) => item.label !== '' && item.source !== '');
215
215
  const noteLines = [
216
- 'NOTE This agent was created via the NEW_AGENT_WIZZARD flow',
216
+ 'NOTE This agent was created via the NEW_AGENT_WIZARD flow',
217
217
  `- Goal: ${summarizedGoal || 'Guided default goal'}`,
218
218
  `- Personality: ${formatSummaryList(personaTraits, 'Default guided persona')}`,
219
219
  `- Learning: ${options.isOpenToLearning ? 'Open to learning' : 'Fixed after creation'}`,
@@ -21,7 +21,7 @@ export type TrackNewAgentCreationEventOptions = {
21
21
  /**
22
22
  * Concrete surface the user interacted with.
23
23
  */
24
- readonly surface?: 'editor' | 'wizard';
24
+ readonly surface?: 'editor' | 'wizard' | 'mango-wizard';
25
25
  /**
26
26
  * Folder scope where the flow started.
27
27
  */
@@ -3,6 +3,7 @@
3
3
  import type { string_book } from '@promptbook-local/types';
4
4
  import type { ReactElement } from 'react';
5
5
  import { useCallback, useState } from 'react';
6
+ import { NotAllowed } from '../../../../../src/errors/NotAllowed';
6
7
  import { appendHeadlessParam, useIsHeadless } from '../_utils/headlessParam';
7
8
  import type { AgentVisibility } from '../../utils/agentVisibility';
8
9
  import { buildFreshAgentChatHref } from '../../utils/agentRouting/agentRouteHrefs';
@@ -18,6 +19,10 @@ import type {
18
19
  NewAgentWizardOpenEditorRequest,
19
20
  } from './NewAgentWizard';
20
21
  import { NewAgentWizard } from './NewAgentWizard';
22
+ import {
23
+ ManGoNewAgentWizard,
24
+ type ManGoNewAgentWizardCreateRequest,
25
+ } from './ManGoNewAgentWizard/ManGoNewAgentWizard';
21
26
  import { trackNewAgentCreationEvent } from './trackNewAgentCreationEvent';
22
27
 
23
28
  /**
@@ -105,6 +110,12 @@ type NewAgentDialogState =
105
110
  readonly defaultVisibility: AgentVisibility;
106
111
  readonly initialAgentName?: string;
107
112
  readonly targetFolderId: number | null | undefined;
113
+ }
114
+ | {
115
+ readonly surface: 'mango-wizard';
116
+ readonly mode: NewAgentWizardMode;
117
+ readonly defaultVisibility: AgentVisibility;
118
+ readonly targetFolderId: number | null | undefined;
108
119
  };
109
120
 
110
121
  /**
@@ -176,6 +187,21 @@ export function useNewAgentDialog(options: UseNewAgentDialogOptions): UseNewAgen
176
187
  folderId: openOptions?.folderId,
177
188
  });
178
189
 
190
+ if (settings.mode === 'MANGO_WIZARD') {
191
+ setDialogState({
192
+ surface: 'mango-wizard',
193
+ mode: settings.mode,
194
+ defaultVisibility: settings.defaultVisibility,
195
+ targetFolderId: openOptions?.folderId,
196
+ });
197
+ trackNewAgentCreationEvent('new_agent_wizard_shown', {
198
+ mode: settings.mode,
199
+ surface: 'mango-wizard',
200
+ folderId: openOptions?.folderId,
201
+ });
202
+ return;
203
+ }
204
+
179
205
  if (settings.mode === 'WIZARD') {
180
206
  let initialAgentName = '';
181
207
  try {
@@ -268,6 +294,47 @@ export function useNewAgentDialog(options: UseNewAgentDialogOptions): UseNewAgen
268
294
  [dialogState, handleCreatedAgent, onCreateFailed],
269
295
  );
270
296
 
297
+ const handleCreateFromManGoWizard = useCallback(
298
+ async (request: ManGoNewAgentWizardCreateRequest) => {
299
+ if (!dialogState || dialogState.surface !== 'mango-wizard') {
300
+ throw new NotAllowed('The manGo wizard is not currently open.');
301
+ }
302
+
303
+ try {
304
+ const { agentName, permanentId } = await $createAgentFromBookAction(
305
+ request.agentSource,
306
+ dialogState.targetFolderId,
307
+ request.visibility,
308
+ );
309
+ const createdAgent = createCreatedAgentPayload(agentName, permanentId);
310
+ trackNewAgentCreationEvent('new_agent_created', {
311
+ mode: dialogState.mode,
312
+ surface: 'mango-wizard',
313
+ folderId: dialogState.targetFolderId,
314
+ knowledgeCount: request.knowledgeCount,
315
+ });
316
+ await onCreated?.(createdAgent);
317
+
318
+ return {
319
+ permanentId,
320
+ targetPath: createdAgent.targetPath,
321
+ };
322
+ } catch (error) {
323
+ await onCreateFailed?.(error);
324
+ throw error;
325
+ }
326
+ },
327
+ [dialogState, onCreateFailed, onCreated],
328
+ );
329
+
330
+ const handleOpenCreatedManGoAgent = useCallback(
331
+ (targetPath: string) => {
332
+ setDialogState(null);
333
+ window.location.assign(appendHeadlessParam(targetPath, isHeadless));
334
+ },
335
+ [isHeadless],
336
+ );
337
+
271
338
  const handleOpenEditorFromWizard = useCallback((request: NewAgentWizardOpenEditorRequest) => {
272
339
  setDialogState((currentDialogState) => {
273
340
  if (!currentDialogState || currentDialogState.surface !== 'wizard') {
@@ -305,6 +372,15 @@ export function useNewAgentDialog(options: UseNewAgentDialogOptions): UseNewAgen
305
372
  onCreate={handleCreateFromWizard}
306
373
  onOpenEditor={handleOpenEditorFromWizard}
307
374
  />
375
+ ) : dialogState?.surface === 'mango-wizard' ? (
376
+ <ManGoNewAgentWizard
377
+ mode={dialogState.mode}
378
+ defaultVisibility={dialogState.defaultVisibility}
379
+ folderId={dialogState.targetFolderId}
380
+ onClose={closeNewAgentDialog}
381
+ onCreate={handleCreateFromManGoWizard}
382
+ onOpenCreatedAgent={handleOpenCreatedManGoAgent}
383
+ />
308
384
  ) : null,
309
385
  };
310
386
  }
@@ -1,22 +1,27 @@
1
1
  /**
2
2
  * Metadata key that controls which "new agent" creation experience is shown.
3
3
  */
4
- export const NEW_AGENT_WIZZARD_METADATA_KEY = 'NEW_AGENT_WIZZARD' as const;
4
+ export const NEW_AGENT_WIZARD_METADATA_KEY = 'NEW_AGENT_WIZARD' as const;
5
+
6
+ /**
7
+ * Previous metadata key retained only for reading already persisted settings.
8
+ */
9
+ export const LEGACY_NEW_AGENT_WIZARD_METADATA_KEY = ['NEW_AGENT_', 'WIZ', 'ZARD'].join('');
5
10
 
6
11
  /**
7
12
  * Supported new-agent creation experiences.
8
13
  */
9
- export const NEW_AGENT_WIZZARD_VALUES = ['BOILERPLATE', 'WIZARD'] as const;
14
+ export const NEW_AGENT_WIZARD_VALUES = ['BOILERPLATE', 'WIZARD', 'MANGO_WIZARD'] as const;
10
15
 
11
16
  /**
12
17
  * Canonical union of supported new-agent creation experiences.
13
18
  */
14
- export type NewAgentWizardMode = (typeof NEW_AGENT_WIZZARD_VALUES)[number];
19
+ export type NewAgentWizardMode = (typeof NEW_AGENT_WIZARD_VALUES)[number];
15
20
 
16
21
  /**
17
22
  * Shared select options for the new-agent experience metadata.
18
23
  */
19
- export const NEW_AGENT_WIZZARD_OPTIONS: ReadonlyArray<{
24
+ export const NEW_AGENT_WIZARD_OPTIONS: ReadonlyArray<{
20
25
  readonly value: NewAgentWizardMode;
21
26
  readonly label: string;
22
27
  }> = [
@@ -28,12 +33,16 @@ export const NEW_AGENT_WIZZARD_OPTIONS: ReadonlyArray<{
28
33
  value: 'WIZARD',
29
34
  label: 'Wizard',
30
35
  },
36
+ {
37
+ value: 'MANGO_WIZARD',
38
+ label: 'manGo wizard',
39
+ },
31
40
  ] as const;
32
41
 
33
42
  /**
34
43
  * Default creation experience used when metadata is missing or invalid.
35
44
  */
36
- export const DEFAULT_NEW_AGENT_WIZZARD_MODE: NewAgentWizardMode = 'BOILERPLATE';
45
+ export const DEFAULT_NEW_AGENT_WIZARD_MODE: NewAgentWizardMode = 'MANGO_WIZARD';
37
46
 
38
47
  /**
39
48
  * Returns whether the provided value is a supported new-agent creation experience.
@@ -42,7 +51,7 @@ export const DEFAULT_NEW_AGENT_WIZZARD_MODE: NewAgentWizardMode = 'BOILERPLATE';
42
51
  * @returns `true` when the value matches a supported mode.
43
52
  */
44
53
  export function isNewAgentWizardMode(value: unknown): value is NewAgentWizardMode {
45
- return typeof value === 'string' && NEW_AGENT_WIZZARD_VALUES.includes(value as NewAgentWizardMode);
54
+ return typeof value === 'string' && NEW_AGENT_WIZARD_VALUES.includes(value as NewAgentWizardMode);
46
55
  }
47
56
 
48
57
  /**
@@ -54,12 +63,12 @@ export function isNewAgentWizardMode(value: unknown): value is NewAgentWizardMod
54
63
  */
55
64
  export function parseNewAgentWizardMode(
56
65
  value: unknown,
57
- fallback: NewAgentWizardMode = DEFAULT_NEW_AGENT_WIZZARD_MODE,
66
+ fallback: NewAgentWizardMode = DEFAULT_NEW_AGENT_WIZARD_MODE,
58
67
  ): NewAgentWizardMode {
59
68
  if (typeof value !== 'string') {
60
69
  return fallback;
61
70
  }
62
71
 
63
- const normalized = value.trim().toUpperCase();
72
+ const normalized = value.trim().toUpperCase().replace(/[\s-]+/g, '_');
64
73
  return isNewAgentWizardMode(normalized) ? normalized : fallback;
65
74
  }
@@ -10,6 +10,17 @@ import { cache } from 'react';
10
10
  */
11
11
  const metadataDefaultsMap = new Map<string, string>(metadataDefaults.map((metadata) => [metadata.key, metadata.value]));
12
12
 
13
+ /**
14
+ * Precomputed map of legacy metadata keys keyed by canonical metadata key.
15
+ *
16
+ * @private Internal helper for metadata lookups in `apps/agents-server`.
17
+ */
18
+ const metadataLegacyKeysMap = new Map<string, ReadonlyArray<string>>(
19
+ metadataDefaults
20
+ .filter((metadata) => metadata.legacyKeys && metadata.legacyKeys.length > 0)
21
+ .map((metadata): [string, ReadonlyArray<string>] => [metadata.key, metadata.legacyKeys ?? []]),
22
+ );
23
+
13
24
  /**
14
25
  * Process-level cache lifetime for metadata reads.
15
26
  *
@@ -146,8 +157,33 @@ export async function getMetadataMap(keys: readonly string[]): Promise<Record<st
146
157
 
147
158
  const metadataRecord: Record<string, string | null> = {};
148
159
  for (const key of uniqueKeys) {
149
- metadataRecord[key] = loadedMap.get(key) ?? metadataDefaultsMap.get(key) ?? null;
160
+ metadataRecord[key] = resolveMetadataValue(key, loadedMap);
150
161
  }
151
162
 
152
163
  return metadataRecord;
153
164
  }
165
+
166
+ /**
167
+ * Resolves one metadata value from canonical rows, legacy rows, or default definitions.
168
+ *
169
+ * @param key - Canonical metadata key requested by the caller.
170
+ * @param loadedMap - Persisted metadata values keyed by database row key.
171
+ * @returns Stored, legacy, default, or `null` metadata value.
172
+ *
173
+ * @private Internal helper for metadata lookups in `apps/agents-server`.
174
+ */
175
+ function resolveMetadataValue(key: string, loadedMap: ReadonlyMap<string, string | null>): string | null {
176
+ const storedValue = loadedMap.get(key);
177
+ if (storedValue !== undefined && storedValue !== null) {
178
+ return storedValue;
179
+ }
180
+
181
+ for (const legacyKey of metadataLegacyKeysMap.get(key) ?? []) {
182
+ const legacyValue = loadedMap.get(legacyKey);
183
+ if (legacyValue !== undefined && legacyValue !== null) {
184
+ return legacyValue;
185
+ }
186
+ }
187
+
188
+ return metadataDefaultsMap.get(key) ?? null;
189
+ }
@@ -19,7 +19,12 @@ import {
19
19
  } from '../constants/defaultAgentAvatarVisual';
20
20
  import { DEFAULT_THEME_METADATA_KEY, DEFAULT_THEME_MODE, THEME_MODE_OPTIONS } from '../constants/themeMode';
21
21
  import { DEFAULT_NAME_POOL, NAME_POOL_METADATA_KEY, NAME_POOL_OPTIONS } from '../constants/namePool';
22
- import { NEW_AGENT_WIZZARD_METADATA_KEY, NEW_AGENT_WIZZARD_OPTIONS } from '../constants/newAgentWizard';
22
+ import {
23
+ DEFAULT_NEW_AGENT_WIZARD_MODE,
24
+ LEGACY_NEW_AGENT_WIZARD_METADATA_KEY,
25
+ NEW_AGENT_WIZARD_METADATA_KEY,
26
+ NEW_AGENT_WIZARD_OPTIONS,
27
+ } from '../constants/newAgentWizard';
23
28
  import {
24
29
  DEFAULT_SHIBBOLETH_DISPLAY_NAME_ATTRIBUTE_NAMES,
25
30
  DEFAULT_SHIBBOLETH_EMAIL_ATTRIBUTE_NAMES,
@@ -90,6 +95,11 @@ export type MetadataDefinition = {
90
95
  * Optional predefined values rendered as a select instead of a free-form input.
91
96
  */
92
97
  readonly options?: ReadonlyArray<MetadataDefinitionOption>;
98
+
99
+ /**
100
+ * Optional previous keys that should be read when the canonical key is absent.
101
+ */
102
+ readonly legacyKeys?: ReadonlyArray<string>;
93
103
  };
94
104
 
95
105
  /**
@@ -120,7 +130,7 @@ const analyticsMetadataDefaults = ANALYTICS_METADATA_KEYS.map((key) => {
120
130
  /**
121
131
  * Constant for metadata defaults.
122
132
  */
123
- export const metadataDefaults = [
133
+ export const metadataDefaults: ReadonlyArray<MetadataDefinition> = [
124
134
  {
125
135
  key: 'SERVER_NAME',
126
136
  value: 'Promptbook Agents Server',
@@ -473,13 +483,14 @@ export const metadataDefaults = [
473
483
  options: AGENT_VISIBILITY_OPTIONS,
474
484
  },
475
485
  {
476
- key: NEW_AGENT_WIZZARD_METADATA_KEY,
477
- value: 'BOILERPLATE',
486
+ key: NEW_AGENT_WIZARD_METADATA_KEY,
487
+ value: DEFAULT_NEW_AGENT_WIZARD_MODE,
478
488
  note: `Controls the "new agent" flow. Allowed values: ${formatMetadataOptionValues(
479
- NEW_AGENT_WIZZARD_OPTIONS,
489
+ NEW_AGENT_WIZARD_OPTIONS,
480
490
  )}.`,
481
491
  type: 'TEXT_SINGLE_LINE',
482
- options: NEW_AGENT_WIZZARD_OPTIONS,
492
+ options: NEW_AGENT_WIZARD_OPTIONS,
493
+ legacyKeys: [LEGACY_NEW_AGENT_WIZARD_METADATA_KEY],
483
494
  },
484
495
  {
485
496
  key: 'MANAGEMENT_API_CORS_ORIGINS',
@@ -536,7 +547,7 @@ export const metadataDefaults = [
536
547
  type: 'TEXT_SINGLE_LINE',
537
548
  },
538
549
  ...analyticsMetadataDefaults,
539
- ] as const satisfies ReadonlyArray<MetadataDefinition>;
550
+ ];
540
551
 
541
552
  /**
542
553
  * Lookup map for metadata definitions by key.
@@ -0,0 +1,27 @@
1
+ UPDATE "prefix_Metadata"
2
+ SET "key" = 'NEW_AGENT_WIZARD',
3
+ "note" = 'Controls the "new agent" flow. Allowed values: BOILERPLATE, WIZARD, MANGO_WIZARD.',
4
+ "updatedAt" = NOW()
5
+ WHERE "key" = 'NEW_AGENT_' || 'WIZ' || 'ZARD'
6
+ AND NOT EXISTS (SELECT 1 FROM "prefix_Metadata" WHERE "key" = 'NEW_AGENT_WIZARD');
7
+
8
+ DELETE FROM "prefix_Metadata"
9
+ WHERE "key" = 'NEW_AGENT_' || 'WIZ' || 'ZARD';
10
+
11
+ INSERT INTO "prefix_Metadata" ("key", "value", "note", "createdAt", "updatedAt")
12
+ SELECT 'NEW_AGENT_WIZARD',
13
+ 'MANGO_WIZARD',
14
+ 'Controls the "new agent" flow. Allowed values: BOILERPLATE, WIZARD, MANGO_WIZARD.',
15
+ NOW(),
16
+ NOW()
17
+ WHERE NOT EXISTS (SELECT 1 FROM "prefix_Metadata" WHERE "key" = 'NEW_AGENT_WIZARD');
18
+
19
+ UPDATE "prefix_Metadata"
20
+ SET "value" = CASE
21
+ WHEN REPLACE(REPLACE(UPPER(TRIM(COALESCE("value", ''))), ' ', '_'), '-', '_') IN ('BOILERPLATE', 'WIZARD', 'MANGO_WIZARD')
22
+ THEN REPLACE(REPLACE(UPPER(TRIM("value")), ' ', '_'), '-', '_')
23
+ ELSE 'MANGO_WIZARD'
24
+ END,
25
+ "note" = 'Controls the "new agent" flow. Allowed values: BOILERPLATE, WIZARD, MANGO_WIZARD.',
26
+ "updatedAt" = NOW()
27
+ WHERE "key" = 'NEW_AGENT_WIZARD';
@@ -0,0 +1,11 @@
1
+ UPDATE "prefix_Metadata"
2
+ SET "value" = CASE
3
+ WHEN REPLACE(REPLACE(UPPER(TRIM(COALESCE("value", ''))), ' ', '_'), '-', '_') = 'BOILERPLATE'
4
+ THEN 'MANGO_WIZARD'
5
+ WHEN REPLACE(REPLACE(UPPER(TRIM(COALESCE("value", ''))), ' ', '_'), '-', '_') IN ('WIZARD', 'MANGO_WIZARD')
6
+ THEN REPLACE(REPLACE(UPPER(TRIM("value")), ' ', '_'), '-', '_')
7
+ ELSE 'MANGO_WIZARD'
8
+ END,
9
+ "note" = 'Controls the "new agent" flow. Allowed values: BOILERPLATE, WIZARD, MANGO_WIZARD.',
10
+ "updatedAt" = NOW()
11
+ WHERE "key" = 'NEW_AGENT_WIZARD';
@@ -25,6 +25,8 @@ export const RESERVED_PATHS: readonly string[] = [
25
25
  "manifest.webmanifest",
26
26
  "openapi.json",
27
27
  "pixel-agents-assets",
28
+ "promptbook-logo-blue.png",
29
+ "promptbook-logo-white.png",
28
30
  "recycle-bin",
29
31
  "restricted",
30
32
  "robots.txt",
@@ -384,7 +384,7 @@ footer.logosAndBranding: Logos & Branding
384
384
  footer.connectSectionTitle: Connect
385
385
  footer.linksSectionTitle: Links
386
386
  footer.allRightsReserved: All rights reserved.
387
- footer.madeInCzechRepublic: Made with ❤️ in the Czech Republic
387
+ footer.madeInCzechRepublic: Made with ❤️ in Europe
388
388
  footer.engineVersion: Promptbook engine version
389
389
  forbidden.title: 403 Forbidden
390
390
  forbidden.message: You do not have permission to access this page.
@@ -460,7 +460,13 @@ function truncateAttachmentToolContent(content: string, warnings: string[]): str
460
460
  }
461
461
 
462
462
  warnings.push(`Returned content was truncated to ${MAX_ATTACHED_FILE_OUTPUT_CHARACTERS} characters.`);
463
- return `${content.slice(0, MAX_ATTACHED_FILE_OUTPUT_CHARACTERS)}\n\n[...truncated...]`;
463
+ return spaceTrim(
464
+ (block) => `
465
+ ${block(content.slice(0, MAX_ATTACHED_FILE_OUTPUT_CHARACTERS))}
466
+
467
+ [...truncated...]
468
+ `,
469
+ );
464
470
  }
465
471
 
466
472
  /**
@@ -583,9 +589,7 @@ function normalizeBoundedInteger(
583
589
  }
584
590
 
585
591
  if (parsed < min || parsed > max) {
586
- throw new LimitReachedError(
587
- `Tool argument \`${fieldName}\` must be between \`${min}\` and \`${max}\`.`,
588
- );
592
+ throw new LimitReachedError(`Tool argument \`${fieldName}\` must be between \`${min}\` and \`${max}\`.`);
589
593
  }
590
594
 
591
595
  return parsed;