@promptbook/cli 0.112.0-125 → 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 +696 -941
  156. package/src/utils/chat/chatAttachments/resolveChatAttachmentContent.ts +8 -1
  157. package/src/version.ts +2 -2
  158. package/src/versions.txt +2 -1
  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
@@ -1,4 +1,5 @@
1
1
  import { createAgentModelRequirements, parseAgentSource } from '@promptbook-local/core';
2
+ import { spaceTrim } from 'spacetrim';
2
3
  import type { AgentReferenceResolver } from '../../../../../src/book-2.0/agent-source/AgentReferenceResolver';
3
4
  import { resolvePseudoAgentKindFromUrl } from '../../../../../src/book-2.0/agent-source/pseudoAgentReferences';
4
5
  import type { string_book } from '../../../../../src/book-2.0/agent-source/string_book';
@@ -140,15 +141,9 @@ async function createTranspiledTeamAgentFromSource(options: {
140
141
  readonly agentReferenceResolver: AgentReferenceResolver;
141
142
  readonly isRootAgent: boolean;
142
143
  }): Promise<TranspiledTeamAgent> {
143
- const modelRequirements = await createAgentModelRequirements(
144
- options.agentSource,
145
- undefined,
146
- undefined,
147
- undefined,
148
- {
149
- agentReferenceResolver: options.agentReferenceResolver,
150
- },
151
- );
144
+ const modelRequirements = await createAgentModelRequirements(options.agentSource, undefined, undefined, undefined, {
145
+ agentReferenceResolver: options.agentReferenceResolver,
146
+ });
152
147
  const parsedAgentSource = parseAgentSource(options.agentSource);
153
148
  const agentName = parsedAgentSource.agentName || options.agentUrl;
154
149
 
@@ -174,7 +169,12 @@ function createPseudoTranspiledTeamAgent(teammate: TranspiledTeamTeammate): Tran
174
169
  pseudoAgentKind === 'USER'
175
170
  ? 'This pseudo-agent represents the human user. Ask for exactly one reply from the user.'
176
171
  : 'This pseudo-agent represents silence and intentionally does not answer.';
177
- const agentSource = `${teammate.label}\n\nNOTE Built-in ${pseudoAgentKind || 'pseudo'} TEAM pseudo-agent.\nCLOSED`;
172
+ const agentSource = spaceTrim(`
173
+ ${teammate.label}
174
+
175
+ NOTE Built-in ${pseudoAgentKind || 'pseudo'} TEAM pseudo-agent.
176
+ CLOSED
177
+ `);
178
178
 
179
179
  return {
180
180
  url: teammate.url,
@@ -2,7 +2,7 @@ import type { ChatMessage, ToolCall } from '@promptbook-local/types';
2
2
  import { ASSISTANT_PREPARATION_TOOL_CALL_NAME } from '../../../../../src/types/ToolCall';
3
3
 
4
4
  /**
5
- * Prefix used by automatic durable chat progress items.
5
+ * Prefix used by automatic durable chat progress items so we can recognize and refresh them later.
6
6
  *
7
7
  * @private internal helper for Agents Server durable chat progress
8
8
  */
@@ -16,14 +16,50 @@ const AUTOMATIC_PROGRESS_ITEM_ID_PREFIX = 'user-chat-job-progress-';
16
16
  const AUTOMATIC_PROGRESS_TITLE = 'Agent Progress';
17
17
 
18
18
  /**
19
- * Tool names that are already represented by the progress card itself.
19
+ * Tool names that are never surfaced in the automatic progress card.
20
+ *
21
+ * `agent_progress` is the model's own progress channel; we never want to advertise this
22
+ * internal tool to the user as if it were doing visible work.
20
23
  *
21
24
  * @private internal helper for Agents Server durable chat progress
22
25
  */
23
26
  const HIDDEN_PROGRESS_TOOL_NAMES = new Set(['agent_progress']);
24
27
 
25
28
  /**
26
- * Options for building an automatic running progress card.
29
+ * Maximum number of characters surfaced from a tool log message to keep progress copy compact.
30
+ *
31
+ * @private internal helper for Agents Server durable chat progress
32
+ */
33
+ const MAX_TOOL_LOG_PREVIEW_LENGTH = 140;
34
+
35
+ /**
36
+ * Known technical tool names mapped to a user-friendly action verb phrase.
37
+ *
38
+ * Used so users see "Searching the web" instead of "Web search" or "search_web" in
39
+ * the progress card. Unknown tools fall back to a sentence-cased version of their raw name.
40
+ *
41
+ * @private internal helper for Agents Server durable chat progress
42
+ */
43
+ const FRIENDLY_TOOL_NAME_OVERRIDES: ReadonlyMap<string, string> = new Map([
44
+ [ASSISTANT_PREPARATION_TOOL_CALL_NAME, 'Preparing the agent'],
45
+ ['web_search', 'Searching the web'],
46
+ ['search_web', 'Searching the web'],
47
+ ['search_engine_search', 'Searching the web'],
48
+ ['browser', 'Browsing the web'],
49
+ ['browser_open_url', 'Opening a web page'],
50
+ ['browser_read', 'Reading a web page'],
51
+ ['get_url_content', 'Reading a web page'],
52
+ ['read_url', 'Reading a web page'],
53
+ ['scrape', 'Reading a web page'],
54
+ ['file_read', 'Reading a file'],
55
+ ['project_read_file', 'Reading a project file'],
56
+ ['file_write', 'Writing a file'],
57
+ ['email_send', 'Sending an email'],
58
+ ['send_email', 'Sending an email'],
59
+ ]);
60
+
61
+ /**
62
+ * Options for building an automatic running progress card snapshot.
27
63
  *
28
64
  * @private internal helper for Agents Server durable chat progress
29
65
  */
@@ -35,9 +71,9 @@ type CreateRunningUserChatProgressCardOptions = {
35
71
  };
36
72
 
37
73
  /**
38
- * Creates the initial real progress payload shown before an agent runner starts.
74
+ * Creates the initial real-progress payload shown before the agent starts working.
39
75
  *
40
- * @param updatedAt - Timestamp used for the progress-card update marker.
76
+ * @param updatedAt Timestamp used for the progress-card update marker.
41
77
  * @returns Structured progress card for a queued assistant placeholder.
42
78
  *
43
79
  * @private internal helper for Agents Server durable chat progress
@@ -47,17 +83,17 @@ export function createQueuedUserChatProgressCard(
47
83
  ): NonNullable<ChatMessage['progressCard']> {
48
84
  return {
49
85
  title: AUTOMATIC_PROGRESS_TITLE,
50
- now: 'Your message is queued for the agent runner.',
51
- next: 'The runner will prepare the agent context and start generating the response.',
86
+ now: 'Your message is in the queue.',
87
+ next: 'The agent will pick it up and start working on your reply.',
52
88
  items: [
53
89
  {
54
90
  id: `${AUTOMATIC_PROGRESS_ITEM_ID_PREFIX}queued`,
55
- text: 'Request added to the chat queue',
91
+ text: 'Message added to the chat queue',
56
92
  status: 'completed',
57
93
  },
58
94
  {
59
95
  id: `${AUTOMATIC_PROGRESS_ITEM_ID_PREFIX}waiting-for-runner`,
60
- text: 'Waiting for an available agent runner',
96
+ text: 'Waiting for the agent to start',
61
97
  status: 'pending',
62
98
  },
63
99
  ],
@@ -69,10 +105,10 @@ export function createQueuedUserChatProgressCard(
69
105
  /**
70
106
  * Creates or refreshes the automatic progress card for a running durable chat job.
71
107
  *
72
- * A model-authored `agent_progress` card is preserved once it takes over, so the
73
- * durable runner does not overwrite more specific progress supplied by the agent.
108
+ * A model-authored `agent_progress` card always wins: if one is already present,
109
+ * the durable runner returns it unchanged so the model can drive its own narrative.
74
110
  *
75
- * @param options - Current message state and streamed runtime details.
111
+ * @param options Current message state and the latest streamed runtime details.
76
112
  * @returns Progress card that should be stored on the assistant message.
77
113
  *
78
114
  * @private internal helper for Agents Server durable chat progress
@@ -84,8 +120,10 @@ export function createRunningUserChatProgressCard(
84
120
  return options.currentProgressCard;
85
121
  }
86
122
 
87
- const visibleToolCalls = (options.toolCalls || []).filter((toolCall) => !HIDDEN_PROGRESS_TOOL_NAMES.has(toolCall.name));
88
- const hasVisibleToolCalls = visibleToolCalls.length > 0;
123
+ const visibleToolCalls = (options.toolCalls || []).filter(
124
+ (toolCall) => !HIDDEN_PROGRESS_TOOL_NAMES.has(toolCall.name),
125
+ );
126
+ const activeToolCalls = visibleToolCalls.filter((toolCall) => !isToolCallComplete(toolCall));
89
127
  const hasStartedWriting = options.content.trim().length > 0;
90
128
 
91
129
  return {
@@ -93,24 +131,26 @@ export function createRunningUserChatProgressCard(
93
131
  now: resolveRunningProgressNowText({
94
132
  hasStartedWriting,
95
133
  visibleToolCalls,
134
+ activeToolCalls,
135
+ }),
136
+ next: resolveRunningProgressNextText({
137
+ hasStartedWriting,
138
+ activeToolCalls,
96
139
  }),
97
- next: hasVisibleToolCalls
98
- ? 'Tool results will be incorporated into the final response.'
99
- : 'The final answer will replace this progress view when generation finishes.',
100
140
  items: [
101
141
  {
102
142
  id: `${AUTOMATIC_PROGRESS_ITEM_ID_PREFIX}queued`,
103
- text: 'Request added to the chat queue',
143
+ text: 'Message added to the chat queue',
104
144
  status: 'completed',
105
145
  },
106
146
  {
107
147
  id: `${AUTOMATIC_PROGRESS_ITEM_ID_PREFIX}runtime-prepared`,
108
- text: 'Agent context and runtime tools prepared',
148
+ text: 'Agent is ready',
109
149
  status: 'completed',
110
150
  },
111
151
  {
112
152
  id: `${AUTOMATIC_PROGRESS_ITEM_ID_PREFIX}generating-response`,
113
- text: hasStartedWriting ? 'Response text has started streaming' : 'Generating the assistant response',
153
+ text: hasStartedWriting ? 'Writing the answer for you' : 'Thinking through your request',
114
154
  status: hasStartedWriting ? 'completed' : 'pending',
115
155
  },
116
156
  ...visibleToolCalls.map(createToolCallProgressItem),
@@ -121,9 +161,9 @@ export function createRunningUserChatProgressCard(
121
161
  }
122
162
 
123
163
  /**
124
- * Returns true when the existing progress card should be treated as model-authored.
164
+ * Returns true when an existing progress card was authored by the model and should not be overwritten.
125
165
  *
126
- * @param progressCard - Existing progress-card payload on the assistant message.
166
+ * @param progressCard Existing progress-card payload on the assistant message.
127
167
  * @returns Whether automatic runner progress should leave the card untouched.
128
168
  *
129
169
  * @private internal helper for Agents Server durable chat progress
@@ -145,36 +185,75 @@ function shouldPreserveModelProgressCard(
145
185
  /**
146
186
  * Resolves the current-work copy for a running progress card.
147
187
  *
148
- * @param options - Running output and tool-call state.
149
- * @returns Concise progress-card text.
188
+ * Prefers a friendly preview of the latest tool log so the user can see what is
189
+ * actually happening, then falls back to higher-level phase descriptions.
190
+ *
191
+ * @param options Running output and tool-call snapshot summary.
192
+ * @returns Concise user-facing progress-card "now" text.
150
193
  *
151
194
  * @private internal helper for Agents Server durable chat progress
152
195
  */
153
196
  function resolveRunningProgressNowText(options: {
154
197
  readonly hasStartedWriting: boolean;
155
198
  readonly visibleToolCalls: ReadonlyArray<ToolCall>;
199
+ readonly activeToolCalls: ReadonlyArray<ToolCall>;
156
200
  }): string {
201
+ const latestActiveLogText = resolveLatestToolLogPhrase(options.activeToolCalls);
202
+ if (latestActiveLogText) {
203
+ return latestActiveLogText;
204
+ }
205
+
206
+ if (options.activeToolCalls.length > 0) {
207
+ return `${formatToolCallActionList(options.activeToolCalls)}.`;
208
+ }
209
+
210
+ if (options.hasStartedWriting) {
211
+ return 'Writing the answer for you.';
212
+ }
213
+
157
214
  if (options.visibleToolCalls.length > 0) {
158
- return `Using ${formatToolCallList(options.visibleToolCalls)}.`;
215
+ return 'Reviewing what the tools returned.';
159
216
  }
160
217
 
218
+ return 'Thinking through your request.';
219
+ }
220
+
221
+ /**
222
+ * Resolves the upcoming-work copy for a running progress card.
223
+ *
224
+ * @param options Running output and tool-call snapshot summary.
225
+ * @returns Concise user-facing progress-card "next" text.
226
+ *
227
+ * @private internal helper for Agents Server durable chat progress
228
+ */
229
+ function resolveRunningProgressNextText(options: {
230
+ readonly hasStartedWriting: boolean;
231
+ readonly activeToolCalls: ReadonlyArray<ToolCall>;
232
+ }): string {
161
233
  if (options.hasStartedWriting) {
162
- return 'The agent has started writing the response.';
234
+ return 'Finishing up the answer.';
163
235
  }
164
236
 
165
- return 'The agent runtime is prepared and the model is generating the response.';
237
+ if (options.activeToolCalls.length > 0) {
238
+ return 'The results will be turned into your answer.';
239
+ }
240
+
241
+ return 'The answer will appear here once it is ready.';
166
242
  }
167
243
 
168
244
  /**
169
245
  * Creates one checklist item from an observed tool-call snapshot.
170
246
  *
171
- * @param toolCall - Tool call observed while the model is running.
172
- * @param index - Position of the tool call in the current snapshot.
173
- * @returns Progress item for the tool action.
247
+ * @param toolCall Tool call observed while the model is running.
248
+ * @param index Position of the tool call in the current snapshot.
249
+ * @returns Progress item describing the tool action.
174
250
  *
175
251
  * @private internal helper for Agents Server durable chat progress
176
252
  */
177
- function createToolCallProgressItem(toolCall: ToolCall, index: number): NonNullable<ChatMessage['progressCard']>['items'][number] {
253
+ function createToolCallProgressItem(
254
+ toolCall: ToolCall,
255
+ index: number,
256
+ ): NonNullable<ChatMessage['progressCard']>['items'][number] {
178
257
  return {
179
258
  id: `${AUTOMATIC_PROGRESS_ITEM_ID_PREFIX}tool-${resolveToolCallProgressId(toolCall, index)}`,
180
259
  text: resolveToolCallProgressText(toolCall),
@@ -183,10 +262,10 @@ function createToolCallProgressItem(toolCall: ToolCall, index: number): NonNulla
183
262
  }
184
263
 
185
264
  /**
186
- * Creates a stable progress item id from one tool-call snapshot.
265
+ * Creates a stable progress item id from one tool-call snapshot so partial updates re-use the same row.
187
266
  *
188
- * @param toolCall - Tool call observed while the model is running.
189
- * @param index - Position of the tool call in the current snapshot.
267
+ * @param toolCall Tool call observed while the model is running.
268
+ * @param index Position of the tool call in the current snapshot.
190
269
  * @returns Stable id suffix for the rendered progress item.
191
270
  *
192
271
  * @private internal helper for Agents Server durable chat progress
@@ -203,75 +282,131 @@ function resolveToolCallProgressId(toolCall: ToolCall, index: number): string {
203
282
  /**
204
283
  * Resolves user-facing progress text for one tool-call snapshot.
205
284
  *
206
- * @param toolCall - Tool call observed while the model is running.
207
- * @returns Concise description of the action or result.
285
+ * @param toolCall Tool call observed while the model is running.
286
+ * @returns Concise description of the tool action or its result.
208
287
  *
209
288
  * @private internal helper for Agents Server durable chat progress
210
289
  */
211
290
  function resolveToolCallProgressText(toolCall: ToolCall): string {
212
- const toolTitle = formatToolName(toolCall.name);
213
- const latestLog = [...(toolCall.logs || [])].reverse().find((log) => log.title || log.message);
214
-
215
- if (toolCall.name === ASSISTANT_PREPARATION_TOOL_CALL_NAME) {
216
- return 'Preparing assistant runtime';
217
- }
291
+ const toolAction = resolveFriendlyToolAction(toolCall.name);
218
292
 
219
293
  if (Array.isArray(toolCall.errors) && toolCall.errors.length > 0) {
220
- return `${toolTitle} reported an error`;
294
+ return `${toolAction} ran into a problem`;
221
295
  }
222
296
 
297
+ const latestLogText = resolveToolCallLatestLogText(toolCall);
223
298
  if (isToolCallComplete(toolCall)) {
224
- return `${toolTitle} completed`;
299
+ return latestLogText ? `${toolAction} – ${latestLogText}` : `${toolAction} done`;
225
300
  }
226
301
 
227
- if (latestLog) {
228
- const logText = latestLog.title || latestLog.message;
229
- return `${toolTitle}: ${logText}`;
302
+ if (latestLogText) {
303
+ return `${toolAction}: ${latestLogText}`;
230
304
  }
231
305
 
232
- return `${toolTitle} is running`;
306
+ return `${toolAction}…`;
233
307
  }
234
308
 
235
309
  /**
236
- * Formats a short comma-separated list of active tools.
310
+ * Returns a friendly phrase for the latest log line observed across the given tool calls.
237
311
  *
238
- * @param toolCalls - Visible tool calls in the current stream snapshot.
239
- * @returns Human-readable tool list.
312
+ * @param toolCalls Tool calls to inspect.
313
+ * @returns Compact phrase suitable for the progress-card "now" field, or null when no log is informative.
240
314
  *
241
315
  * @private internal helper for Agents Server durable chat progress
242
316
  */
243
- function formatToolCallList(toolCalls: ReadonlyArray<ToolCall>): string {
244
- const uniqueToolNames = [...new Set(toolCalls.map((toolCall) => formatToolName(toolCall.name)))];
317
+ function resolveLatestToolLogPhrase(toolCalls: ReadonlyArray<ToolCall>): string | null {
318
+ for (let index = toolCalls.length - 1; index >= 0; index--) {
319
+ const toolCall = toolCalls[index]!;
320
+ const latestLogText = resolveToolCallLatestLogText(toolCall);
321
+ if (!latestLogText) {
322
+ continue;
323
+ }
245
324
 
246
- if (uniqueToolNames.length === 1) {
247
- return uniqueToolNames[0]!;
325
+ return `${resolveFriendlyToolAction(toolCall.name)}: ${latestLogText}`;
248
326
  }
249
327
 
250
- const finalToolName = uniqueToolNames[uniqueToolNames.length - 1]!;
251
- return `${uniqueToolNames.slice(0, -1).join(', ')} and ${finalToolName}`;
328
+ return null;
329
+ }
330
+
331
+ /**
332
+ * Returns the most recent informative log line for one tool call, truncated for compact display.
333
+ *
334
+ * @param toolCall Tool call to inspect.
335
+ * @returns Compact log preview or null when no informative log was observed.
336
+ *
337
+ * @private internal helper for Agents Server durable chat progress
338
+ */
339
+ function resolveToolCallLatestLogText(toolCall: ToolCall): string | null {
340
+ if (!toolCall.logs || toolCall.logs.length === 0) {
341
+ return null;
342
+ }
343
+
344
+ for (let index = toolCall.logs.length - 1; index >= 0; index--) {
345
+ const logEntry = toolCall.logs[index];
346
+ const logText = logEntry?.title?.trim() || logEntry?.message?.trim();
347
+ if (!logText) {
348
+ continue;
349
+ }
350
+
351
+ if (logText.length <= MAX_TOOL_LOG_PREVIEW_LENGTH) {
352
+ return logText;
353
+ }
354
+
355
+ return `${logText.slice(0, MAX_TOOL_LOG_PREVIEW_LENGTH - 1).trimEnd()}…`;
356
+ }
357
+
358
+ return null;
359
+ }
360
+
361
+ /**
362
+ * Formats a short comma-separated description of active tool actions.
363
+ *
364
+ * @param toolCalls Visible tool calls that are still in progress.
365
+ * @returns Human-readable tool action list.
366
+ *
367
+ * @private internal helper for Agents Server durable chat progress
368
+ */
369
+ function formatToolCallActionList(toolCalls: ReadonlyArray<ToolCall>): string {
370
+ const uniqueToolActions = [...new Set(toolCalls.map((toolCall) => resolveFriendlyToolAction(toolCall.name)))];
371
+
372
+ if (uniqueToolActions.length === 1) {
373
+ return uniqueToolActions[0]!;
374
+ }
375
+
376
+ const finalToolAction = uniqueToolActions[uniqueToolActions.length - 1]!;
377
+ return `${uniqueToolActions.slice(0, -1).join(', ')} and ${finalToolAction.toLowerCase()}`;
252
378
  }
253
379
 
254
380
  /**
255
381
  * Converts one technical tool name into compact user-facing copy.
256
382
  *
257
- * @param toolName - Tool function name.
258
- * @returns Human-readable tool name.
383
+ * Falls back to a sentence-cased version of the raw name when no friendly mapping is known.
384
+ *
385
+ * @param toolName Tool function name reported by the model.
386
+ * @returns Human-readable action phrase such as "Searching the web".
259
387
  *
260
388
  * @private internal helper for Agents Server durable chat progress
261
389
  */
262
- function formatToolName(toolName: string): string {
263
- return toolName
390
+ function resolveFriendlyToolAction(toolName: string): string {
391
+ const overriddenAction = FRIENDLY_TOOL_NAME_OVERRIDES.get(toolName);
392
+ if (overriddenAction) {
393
+ return overriddenAction;
394
+ }
395
+
396
+ const sentenceCasedName = toolName
264
397
  .replace(/[_-]+/g, ' ')
265
398
  .replace(/\s+/g, ' ')
266
399
  .trim()
267
400
  .replace(/^\w/, (character) => character.toUpperCase());
401
+
402
+ return sentenceCasedName.length > 0 ? sentenceCasedName : 'Running a tool';
268
403
  }
269
404
 
270
405
  /**
271
406
  * Infers whether a tool-call snapshot has reached a terminal successful state.
272
407
  *
273
- * @param toolCall - Tool call observed while the model is running.
274
- * @returns Whether the tool call has a completed result.
408
+ * @param toolCall Tool call observed while the model is running.
409
+ * @returns Whether the tool call has a completed result and should be rendered as such.
275
410
  *
276
411
  * @private internal helper for Agents Server durable chat progress
277
412
  */
@@ -22,6 +22,7 @@ export const VPS_ENVIRONMENT_VARIABLE_KEYS = [
22
22
  'SERVERS',
23
23
  'NEXT_PUBLIC_SITE_URL',
24
24
  'ADMIN_PASSWORD',
25
+ 'SESSION_SECRET',
25
26
  'OPENAI_API_KEY',
26
27
  'PTBK_HARNESS',
27
28
  'PTBK_MODEL',
@@ -5,10 +5,26 @@ import { dirname, resolve } from 'path';
5
5
  import { promisify } from 'util';
6
6
  import { NotAllowed } from '../../../../src/errors/NotAllowed';
7
7
  import { spaceTrim } from 'spacetrim';
8
- import { createVpsInstallerCommandEnvironment, resolveVpsEnvironmentFilePath, resolveVpsInstallerScriptPath } from './vpsConfiguration';
8
+ import {
9
+ createVpsInstallerCommandEnvironment,
10
+ resolveVpsEnvironmentFilePath,
11
+ resolveVpsInstallerScriptPath,
12
+ } from './vpsConfiguration';
9
13
 
10
14
  const execFileAsync = promisify(execFile);
11
15
 
16
+ /**
17
+ * Fallback error used when a running self-update process disappears without writing a terminal status.
18
+ */
19
+ const VPS_SELF_UPDATE_STALE_ERROR_MESSAGE =
20
+ 'The previous background update process stopped unexpectedly before writing its final status.';
21
+
22
+ /**
23
+ * Success step shown when the server proves a stale-looking job completed across a process restart.
24
+ */
25
+ const VPS_SELF_UPDATE_RESTART_SUCCESS_STEP =
26
+ 'Standalone VPS self-update finished successfully after restarting the server.';
27
+
12
28
  /**
13
29
  * Supported standalone VPS update environments.
14
30
  */
@@ -166,6 +182,20 @@ export type VpsSelfUpdateOverview = {
166
182
  readonly job: VpsSelfUpdateJobSnapshot;
167
183
  };
168
184
 
185
+ /**
186
+ * Repository state used to resolve a persisted self-update job for the browser overview.
187
+ */
188
+ export type VpsSelfUpdateJobOverviewContext = {
189
+ /**
190
+ * Environment currently configured in the running Agents Server.
191
+ */
192
+ readonly currentEnvironment: VpsSelfUpdateEnvironmentOption;
193
+ /**
194
+ * Current local repository commit observed by the running server.
195
+ */
196
+ readonly currentCommitSha: string | null;
197
+ };
198
+
169
199
  /**
170
200
  * Starts one detached VPS self-update run for the selected environment.
171
201
  *
@@ -306,6 +336,10 @@ export async function readVpsSelfUpdateOverview(): Promise<VpsSelfUpdateOverview
306
336
  runGitInRepository(repositoryDirectory, ['log', '-1', '--format=%s']),
307
337
  readRemoteCommitSha(repositoryDirectory, currentEnvironment.branch),
308
338
  ]);
339
+ const resolvedJob = resolveVpsSelfUpdateJobForOverview(job, {
340
+ currentEnvironment,
341
+ currentCommitSha,
342
+ });
309
343
 
310
344
  return {
311
345
  isAvailable: Boolean(currentCommitSha),
@@ -318,8 +352,48 @@ export async function readVpsSelfUpdateOverview(): Promise<VpsSelfUpdateOverview
318
352
  currentCommitMessage,
319
353
  latestRemoteCommitSha,
320
354
  latestRemoteCommitShortSha: abbreviateCommitSha(latestRemoteCommitSha),
321
- isUpdateAvailable: Boolean(currentCommitSha && latestRemoteCommitSha && currentCommitSha !== latestRemoteCommitSha),
322
- job,
355
+ isUpdateAvailable: Boolean(
356
+ currentCommitSha && latestRemoteCommitSha && currentCommitSha !== latestRemoteCommitSha,
357
+ ),
358
+ job: resolvedJob,
359
+ };
360
+ }
361
+
362
+ /**
363
+ * Converts the persisted shell status into the status that should be shown in the admin overview.
364
+ *
365
+ * A successful self-update may restart the old Agents Server process before the browser sees the final
366
+ * `STATUS=succeeded` write. In that case the stale PID alone is not enough to call the update failed:
367
+ * if the running server is already on the recorded target branch and target commit, the update succeeded.
368
+ *
369
+ * @param job - Persisted self-update job snapshot.
370
+ * @param context - Current repository state observed by the running server.
371
+ * @returns Job snapshot resolved for browser display.
372
+ */
373
+ export function resolveVpsSelfUpdateJobForOverview(
374
+ job: VpsSelfUpdateJobSnapshot,
375
+ context: VpsSelfUpdateJobOverviewContext,
376
+ ): VpsSelfUpdateJobSnapshot {
377
+ const isRestartedSuccessfulUpdate =
378
+ job.status === 'failed' &&
379
+ job.isStale &&
380
+ (!job.errorMessage || job.errorMessage === VPS_SELF_UPDATE_STALE_ERROR_MESSAGE) &&
381
+ job.targetBranch === context.currentEnvironment.branch &&
382
+ job.targetCommitSha !== null &&
383
+ context.currentCommitSha !== null &&
384
+ job.targetCommitSha === context.currentCommitSha;
385
+
386
+ if (!isRestartedSuccessfulUpdate) {
387
+ return job;
388
+ }
389
+
390
+ return {
391
+ ...job,
392
+ status: 'succeeded',
393
+ currentStep: VPS_SELF_UPDATE_RESTART_SUCCESS_STEP,
394
+ currentCommitSha: context.currentCommitSha,
395
+ errorMessage: null,
396
+ isStale: false,
323
397
  };
324
398
  }
325
399
 
@@ -410,10 +484,7 @@ async function readPersistedVpsSelfUpdateJob(): Promise<VpsSelfUpdateJobSnapshot
410
484
  currentStep,
411
485
  currentCommitSha: statusEntries.get('CURRENT_COMMIT') || null,
412
486
  targetCommitSha: statusEntries.get('TARGET_COMMIT') || null,
413
- errorMessage:
414
- isStale && !errorMessage
415
- ? 'The previous background update process stopped unexpectedly before writing its final status.'
416
- : errorMessage,
487
+ errorMessage: isStale && !errorMessage ? VPS_SELF_UPDATE_STALE_ERROR_MESSAGE : errorMessage,
417
488
  startedAt: statusEntries.get('STARTED_AT') || null,
418
489
  finishedAt: statusEntries.get('FINISHED_AT') || null,
419
490
  isStale,
@@ -513,7 +584,9 @@ async function readConfiguredVpsEnvironmentValue(key: string): Promise<string |
513
584
  */
514
585
  async function resolveManagedPromptbookRepositoryDirectory(): Promise<string | null> {
515
586
  const configuredDirectory =
516
- (await readConfiguredVpsEnvironmentValue('PTBK_REPOSITORY_DIR')) || process.env.PTBK_REPOSITORY_DIR?.trim() || '';
587
+ (await readConfiguredVpsEnvironmentValue('PTBK_REPOSITORY_DIR')) ||
588
+ process.env.PTBK_REPOSITORY_DIR?.trim() ||
589
+ '';
517
590
 
518
591
  if (configuredDirectory) {
519
592
  return resolve(configuredDirectory);