@promptbook/cli 0.112.0-115 → 0.112.0-118

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 (82) hide show
  1. package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatSidebarDefault.tsx +5 -6
  2. package/apps/agents-server/src/utils/externalChatRunner/processExternalUserChatJob.ts +17 -7
  3. package/apps/agents-server/src/utils/localChatRunner/processLocalUserChatJob.ts +17 -7
  4. package/apps/agents-server/src/utils/userChat/createImmediateUserChatAnswerModelRequirements.ts +11 -0
  5. package/apps/agents-server/src/utils/userChat/listUserChats.ts +5 -7
  6. package/esm/index.es.js +451 -95
  7. package/esm/index.es.js.map +1 -1
  8. package/esm/scripts/run-codex-prompts/common/parseDuration.d.ts +19 -0
  9. package/esm/src/_packages/components.index.d.ts +2 -0
  10. package/esm/src/_packages/node.index.d.ts +20 -0
  11. package/esm/src/book-3.0/BookNodeAgentSource.d.ts +1 -1
  12. package/esm/src/book-3.0/CliAgent.d.ts +15 -17
  13. package/esm/src/book-3.0/agentFolderPaths.d.ts +30 -0
  14. package/esm/src/book-3.0/cliAgentEnv.d.ts +33 -0
  15. package/esm/src/book-components/BookEditor/BookEditorBrowserConfig.d.ts +2 -0
  16. package/esm/src/book-components/BookEditor/BookEditorForClient.d.ts +7 -0
  17. package/esm/src/book-components/BookEditor/createDeprecatedCommitmentDiagnostics.browser.d.ts +9 -0
  18. package/esm/src/cli/cli-commands/agent-folder/agentProjectPaths.d.ts +2 -30
  19. package/esm/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +2 -18
  20. package/esm/src/scrapers/website/utils/createShowdownConverter.d.ts +2 -2
  21. package/esm/src/version.d.ts +1 -1
  22. package/package.json +1 -1
  23. package/src/_packages/components.index.ts +2 -0
  24. package/src/_packages/node.index.ts +20 -0
  25. package/src/avatars/avatarAnimationScheduler.ts +33 -2
  26. package/src/avatars/visuals/fractalAvatarVisual.ts +5 -4
  27. package/src/avatars/visuals/minecraft2AvatarVisual.ts +16 -11
  28. package/src/avatars/visuals/minecraftAvatarVisual.ts +21 -7
  29. package/src/avatars/visuals/octopus3d2AvatarVisual.ts +69 -17
  30. package/src/avatars/visuals/octopus3d3AvatarVisual.ts +81 -18
  31. package/src/avatars/visuals/octopus3dAvatarVisual.ts +69 -17
  32. package/src/book-3.0/Book.ts +3 -1
  33. package/src/book-3.0/BookNodeAgentSource.ts +2 -2
  34. package/src/book-3.0/CliAgent.ts +87 -71
  35. package/src/book-3.0/agentFolderPaths.ts +38 -0
  36. package/src/book-3.0/cliAgentEnv.ts +46 -0
  37. package/src/book-components/BookEditor/BookEditor.tsx +1 -1
  38. package/src/book-components/BookEditor/BookEditorAboutPromptbookInformation.tsx +2 -4
  39. package/src/book-components/BookEditor/BookEditorActionbar.tsx +32 -2
  40. package/src/book-components/BookEditor/BookEditorBrowserConfig.ts +11 -0
  41. package/src/book-components/BookEditor/BookEditorForClient.tsx +33 -0
  42. package/src/book-components/BookEditor/BookEditorMonaco.tsx +1 -1
  43. package/src/book-components/BookEditor/BookEditorMonacoTokenization.ts +83 -15
  44. package/src/book-components/BookEditor/createDeprecatedCommitmentDiagnostics.browser.ts +11 -0
  45. package/src/book-components/BookEditor/useBookEditorMonacoLanguage.ts +32 -46
  46. package/src/book-components/BookEditor/useBookEditorMonacoStyles.ts +1 -1
  47. package/src/book-components/BookEditor/useBookEditorMonacoUploads.ts +1 -1
  48. package/src/book-components/Chat/utils/renderMarkdown.ts +3 -2
  49. package/src/cli/cli-commands/agent-folder/agentProjectPaths.ts +15 -35
  50. package/src/cli/cli-commands/coder/run.ts +28 -3
  51. package/src/cli/cli-commands/common/promptRunnerCliOptions.ts +9 -29
  52. package/src/commands/KNOWLEDGE/utils/knowledgeSourceContentToName.ts +2 -2
  53. package/src/commitments/_common/teamInternalAgentAccess.ts +2 -2
  54. package/src/formats/csv/CsvFormatParser.ts +4 -4
  55. package/src/formats/csv/utils/csvParse.ts +2 -2
  56. package/src/llm-providers/agent/AgentLlmExecutionTools.ts +2 -2
  57. package/src/llm-providers/agent/AgentLlmExecutionToolsAgentKitRunner.ts +2 -2
  58. package/src/llm-providers/agent/AgentLlmExecutionToolsOpenAiAssistantRunner.ts +2 -2
  59. package/src/other/templates/getTemplatesPipelineCollection.ts +712 -807
  60. package/src/scrapers/_common/utils/getScraperIntermediateSource.ts +2 -2
  61. package/src/scrapers/website/WebsiteScraper.ts +1 -1
  62. package/src/scrapers/website/utils/createShowdownConverter.ts +2 -2
  63. package/src/utils/misc/computeHash.ts +2 -2
  64. package/src/utils/random/$randomToken.ts +2 -2
  65. package/src/version.ts +2 -2
  66. package/src/versions.txt +3 -0
  67. package/umd/index.umd.js +453 -94
  68. package/umd/index.umd.js.map +1 -1
  69. package/umd/scripts/run-codex-prompts/common/parseDuration.d.ts +19 -0
  70. package/umd/src/_packages/components.index.d.ts +2 -0
  71. package/umd/src/_packages/node.index.d.ts +20 -0
  72. package/umd/src/book-3.0/BookNodeAgentSource.d.ts +1 -1
  73. package/umd/src/book-3.0/CliAgent.d.ts +15 -17
  74. package/umd/src/book-3.0/agentFolderPaths.d.ts +30 -0
  75. package/umd/src/book-3.0/cliAgentEnv.d.ts +33 -0
  76. package/umd/src/book-components/BookEditor/BookEditorBrowserConfig.d.ts +2 -0
  77. package/umd/src/book-components/BookEditor/BookEditorForClient.d.ts +7 -0
  78. package/umd/src/book-components/BookEditor/createDeprecatedCommitmentDiagnostics.browser.d.ts +9 -0
  79. package/umd/src/cli/cli-commands/agent-folder/agentProjectPaths.d.ts +2 -30
  80. package/umd/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +2 -18
  81. package/umd/src/scrapers/website/utils/createShowdownConverter.d.ts +2 -2
  82. package/umd/src/version.d.ts +1 -1
@@ -168,10 +168,7 @@ function resolveAgentChatSidebarExpandedStatusClassName(activityKind: AgentChatS
168
168
  *
169
169
  * @private function of AgentChatSidebar
170
170
  */
171
- function AgentChatSidebarDefaultCollapsedRow({
172
- item,
173
- onChatSelect,
174
- }: AgentChatSidebarDefaultCollapsedRowProps) {
171
+ function AgentChatSidebarDefaultCollapsedRow({ item, onChatSelect }: AgentChatSidebarDefaultCollapsedRowProps) {
175
172
  const statusClassName = resolveAgentChatSidebarCollapsedStatusClassName(
176
173
  item.content.activityIndicator.kind,
177
174
  item.isActive,
@@ -444,7 +441,9 @@ function AgentChatSidebarDefaultCollapsedSection({
444
441
  ) : (
445
442
  <div className="flex min-h-0 w-full flex-1 flex-col gap-2 overflow-y-auto scrollbar-hidden">
446
443
  {sidebarItems.length === 0 ? (
447
- <p className="px-1 text-center text-[11px] text-slate-500 dark:text-slate-400">{emptyStateText}</p>
444
+ <p className="px-1 text-center text-[11px] text-slate-500 dark:text-slate-400">
445
+ {emptyStateText}
446
+ </p>
448
447
  ) : (
449
448
  sidebarItems.map((item) => (
450
449
  <AgentChatSidebarDefaultCollapsedRow
@@ -600,7 +599,7 @@ export function AgentChatSidebarDefault({
600
599
  </div>
601
600
  </div>
602
601
 
603
- <div className="agent-chat-sidebar-toggle-slot pointer-events-none absolute inset-y-0 right-0 z-10 hidden translate-x-1/2 items-center justify-center md:flex">
602
+ <div className="agent-chat-sidebar-toggle-slot pointer-events-none absolute inset-y-0 right-0 z-10 hidden translate-x-1 items-center justify-center md:flex">
604
603
  <SolidArrowButton
605
604
  direction={isCollapsed ? 'right' : 'left'}
606
605
  onClick={onToggleCollapse}
@@ -1,4 +1,5 @@
1
1
  import type { Json } from '@/src/database/schema';
2
+ import { parseAgentSource } from '../../../../../src/book-2.0/agent-source/parseAgentSource';
2
3
  import { createUserChatJobFailureDetails } from '../userChat/createUserChatJobFailureDetails';
3
4
  import { claimNextQueuedUserChatJob } from '../userChat/claimNextQueuedUserChatJob';
4
5
  import { finalizeUserChatJob } from '../userChat/finalizeUserChatJob';
@@ -148,13 +149,22 @@ async function enqueueExternalUserChatJob(job: UserChatJobRecord): Promise<Proce
148
149
  return { didMutate: false, outcome: 'waiting' };
149
150
  }
150
151
 
151
- const threadMessages = [...previousThreadMessages, userMessage]
152
- .filter((message) => message.isComplete !== false)
153
- .filter((message) => message.sender === 'USER' || message.sender === 'AGENT')
154
- .map((message) => ({
155
- sender: String(message.sender),
156
- content: message.content,
157
- }));
152
+ const agentInitialMessage = previousThreadMessages.length === 0
153
+ ? parseAgentSource(agentSourceSnapshot.agentSource).initialMessage
154
+ : null;
155
+ const initialAgentThreadMessages = agentInitialMessage
156
+ ? [{ sender: 'AGENT' as const, content: agentInitialMessage }]
157
+ : [];
158
+
159
+ const threadMessages = [
160
+ ...initialAgentThreadMessages,
161
+ ...[...previousThreadMessages, userMessage]
162
+ .filter((message) => message.isComplete !== false)
163
+ .filter((message) => message.sender === 'USER' || message.sender === 'AGENT'),
164
+ ].map((message) => ({
165
+ sender: String(message.sender),
166
+ content: message.content,
167
+ }));
158
168
 
159
169
  const repository = await ensureExternalAgentRepository(agentSourceSnapshot);
160
170
  const queuedAt = new Date().toISOString();
@@ -1,6 +1,7 @@
1
1
  import type { Json } from '@/src/database/schema';
2
2
  import { mkdir, readFile, rm, writeFile } from 'fs/promises';
3
3
  import { join } from 'path';
4
+ import { parseAgentSource } from '../../../../../src/book-2.0/agent-source/parseAgentSource';
4
5
  import { createUserChatJobFailureDetails } from '../userChat/createUserChatJobFailureDetails';
5
6
  import { claimNextQueuedUserChatJob } from '../userChat/claimNextQueuedUserChatJob';
6
7
  import { finalizeUserChatJob } from '../userChat/finalizeUserChatJob';
@@ -145,13 +146,22 @@ async function enqueueLocalUserChatJob(job: UserChatJobRecord): Promise<ProcessL
145
146
  return { didMutate: false, outcome: 'waiting' };
146
147
  }
147
148
 
148
- const threadMessages = [...previousThreadMessages, userMessage]
149
- .filter((message) => message.isComplete !== false)
150
- .filter((message) => message.sender === 'USER' || message.sender === 'AGENT')
151
- .map((message) => ({
152
- sender: String(message.sender),
153
- content: message.content,
154
- }));
149
+ const agentInitialMessage = previousThreadMessages.length === 0
150
+ ? parseAgentSource(agentSourceSnapshot.agentSource).initialMessage
151
+ : null;
152
+ const initialAgentThreadMessages = agentInitialMessage
153
+ ? [{ sender: 'AGENT' as const, content: agentInitialMessage }]
154
+ : [];
155
+
156
+ const threadMessages = [
157
+ ...initialAgentThreadMessages,
158
+ ...[...previousThreadMessages, userMessage]
159
+ .filter((message) => message.isComplete !== false)
160
+ .filter((message) => message.sender === 'USER' || message.sender === 'AGENT'),
161
+ ].map((message) => ({
162
+ sender: String(message.sender),
163
+ content: message.content,
164
+ }));
155
165
 
156
166
  const agentFolder = await ensureLocalAgentFolder(agentSourceSnapshot);
157
167
  const queuedAt = new Date().toISOString();
@@ -29,7 +29,9 @@ const IMMEDIATE_USER_CHAT_ANSWER_INSTRUCTION_COMMITMENTS = new Set<string>([
29
29
  * Prefix added to the immediate pre-answer system message.
30
30
  */
31
31
  const IMMEDIATE_USER_CHAT_ANSWER_SYSTEM_PREAMBLE = spaceTrim(`
32
+
32
33
  You are preparing a short in-progress confirmation for the user while a slower full agent run continues separately.
34
+
33
35
  This response is not the final answer. It is only a confirmation that the task is being handled.
34
36
  These immediate-answer rules override any agent instruction below that would make the answer sound final or complete.
35
37
 
@@ -37,6 +39,7 @@ const IMMEDIATE_USER_CHAT_ANSWER_SYSTEM_PREAMBLE = spaceTrim(`
37
39
  - You understood what the user wants.
38
40
  - You are working on it now or the job has already started.
39
41
  - The final answer will arrive after the background processing finishes.
42
+ - You can use Markdown formatting in the messages like **bold** or *italic*
40
43
 
41
44
  Keep the whole response short, preferably one or two sentences.
42
45
  Do not provide any part of the final answer yet.
@@ -46,6 +49,14 @@ const IMMEDIATE_USER_CHAT_ANSWER_SYSTEM_PREAMBLE = spaceTrim(`
46
49
  Do not use or claim to have used external tools, memory, knowledge bases, web browsing, search, calendar, email, projects, or teammate agents.
47
50
  Never present this message as complete, definitive, or ready to use.
48
51
  If the user asks for something that clearly requires unavailable capabilities, simply say the checked final answer is still being prepared.
52
+
53
+
54
+ Example of a good immediate pre-answer response:
55
+
56
+ \`\`\`markdown
57
+ xxx
58
+ \`\`\`
59
+
49
60
  `);
50
61
 
51
62
  /**
@@ -40,7 +40,7 @@ const CLIENT_SQL_MISSING_CONNECTION_MESSAGE_FRAGMENT =
40
40
  const SQLITE_CHAT_MESSAGES_JSON_EXPRESSION = `CASE WHEN json_valid(chat."messages") THEN chat."messages" ELSE '[]' END`;
41
41
 
42
42
  /**
43
- * Lists all user chats for one agent ordered by last activity.
43
+ * Lists all user chats for one agent ordered by creation time (newest first).
44
44
  */
45
45
  export async function listUserChats(options: ListUserChatsOptions): Promise<Array<UserChatRecord>> {
46
46
  const { userId, viewerIsAdmin, agentPermanentId, includeExternalChats = false } = options;
@@ -53,9 +53,7 @@ export async function listUserChats(options: ListUserChatsOptions): Promise<Arra
53
53
  .eq('userId', userId)
54
54
  .eq('agentPermanentId', agentPermanentId)
55
55
  .eq('source', USER_CHAT_SOURCES.WEB_UI);
56
- const { data, error } = await query
57
- .order('lastMessageAt', { ascending: false, nullsFirst: false })
58
- .order('updatedAt', { ascending: false });
56
+ const { data, error } = await query.order('createdAt', { ascending: false });
59
57
 
60
58
  if (error) {
61
59
  throw new Error(`Failed to list user chats: ${error.message}`);
@@ -73,7 +71,7 @@ export async function listUserChats(options: ListUserChatsOptions): Promise<Arra
73
71
  }
74
72
 
75
73
  /**
76
- * Lists lightweight chat-summary seeds without loading full `messages` JSON payloads.
74
+ * Lists lightweight chat-summary seeds without loading full `messages` JSON payloads, ordered by creation time (newest first).
77
75
  *
78
76
  * @private function of `userChat`
79
77
  */
@@ -149,7 +147,7 @@ export async function listUserChatSummarySeeds(options: ListUserChatsOptions): P
149
147
  ) AS "pendingAssistantMessageCount"
150
148
  FROM ${userChatTableName}
151
149
  WHERE ${whereClause}
152
- ORDER BY "lastMessageAt" DESC NULLS LAST, "updatedAt" DESC
150
+ ORDER BY "createdAt" DESC
153
151
  `,
154
152
  queryValues,
155
153
  );
@@ -235,7 +233,7 @@ async function listUserChatSummarySeedsViaSqlite(options: ListUserChatsOptions):
235
233
  ) AS "pendingAssistantMessageCount"
236
234
  FROM ${userChatTableName} AS chat
237
235
  WHERE ${whereClause}
238
- ORDER BY chat."lastMessageAt" IS NULL ASC, chat."lastMessageAt" DESC, chat."updatedAt" DESC
236
+ ORDER BY chat."createdAt" DESC
239
237
  `,
240
238
  )
241
239
  .all(...queryValues) as Array<UserChatSummarySeedSqlRow>;