@promptbook/cli 0.113.0-4 → 0.113.0-8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/agents-server/src/app/admin/update/AdvancedOriginRepositoryPanel.tsx +76 -0
- package/apps/agents-server/src/app/admin/update/CurrentDeploymentCard.tsx +160 -0
- package/apps/agents-server/src/app/admin/update/PendingCommitsCard.tsx +86 -0
- package/apps/agents-server/src/app/admin/update/TargetEnvironmentCard.tsx +331 -0
- package/apps/agents-server/src/app/admin/update/UpdateClient.tsx +20 -873
- package/apps/agents-server/src/app/admin/update/UpdateJobCard.tsx +329 -0
- package/apps/agents-server/src/app/admin/update/UpdateOverview.ts +74 -0
- package/apps/agents-server/src/app/admin/update/buildDeploymentTimeBehindLabel.ts +29 -0
- package/apps/agents-server/src/app/admin/update/formatHumanReadableTimestamp.ts +18 -0
- package/apps/agents-server/src/app/admin/update/getUpdateJobFailureMessage.ts +13 -0
- package/apps/agents-server/src/app/admin/update/getUpdateJobSuccessMessage.ts +13 -0
- package/apps/agents-server/src/app/admin/update/useUpdateClientState.ts +441 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/book/route.ts +13 -1
- package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/AgentCodePageClient.tsx +14 -559
- package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/AgentCodePageHeader.tsx +84 -0
- package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/AgentCodePageSection.tsx +52 -0
- package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/GeneratedCodePreview.tsx +138 -0
- package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/GeneratedHarnessSection.tsx +98 -0
- package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/SourceBookSection.tsx +66 -0
- package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/TranspiledCodeErrorBanner.tsx +30 -0
- package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/TranspiledCodeExportWarningBanner.tsx +62 -0
- package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/Transpiler.ts +9 -0
- package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/useAgentCodeExportState.ts +478 -0
- package/apps/agents-server/src/app/system/utilities/mocked-chats/cloneMockedChatPreset.ts +17 -0
- package/apps/agents-server/src/app/system/utilities/mocked-chats/confirmDeleteMockedChat.ts +16 -0
- package/apps/agents-server/src/app/system/utilities/mocked-chats/createDraftWithUpdatedMessage.ts +81 -0
- package/apps/agents-server/src/app/system/utilities/mocked-chats/createDraftWithUpdatedParticipant.ts +146 -0
- package/apps/agents-server/src/app/system/utilities/mocked-chats/createDraftWithUpdatedSettings.ts +19 -0
- package/apps/agents-server/src/app/system/utilities/mocked-chats/createDuplicatedDraft.ts +66 -0
- package/apps/agents-server/src/app/system/utilities/mocked-chats/findMockedChatById.ts +51 -0
- package/apps/agents-server/src/app/system/utilities/mocked-chats/persistMockedChats.ts +51 -0
- package/apps/agents-server/src/app/system/utilities/mocked-chats/useMockedChatsEditorState.ts +16 -426
- package/apps/agents-server/src/components/Homepage/buildFreeGraphBoxLayout.ts +446 -0
- package/apps/agents-server/src/components/Homepage/buildGraphLayoutNodes.ts +415 -157
- package/apps/agents-server/src/components/Homepage/useAgentsGraphCanvasState.ts +2 -1
- package/apps/agents-server/src/database/sqlite/$provideLocalSqliteSupabase.ts +3 -1541
- package/apps/agents-server/src/database/sqlite/localSqliteSupabase/LocalSqliteQueryBuilder.ts +623 -0
- package/apps/agents-server/src/database/sqlite/localSqliteSupabase/LocalSqliteSupabaseClient.ts +64 -0
- package/apps/agents-server/src/database/sqlite/localSqliteSupabase/ensureTable.ts +93 -0
- package/apps/agents-server/src/database/sqlite/localSqliteSupabase/localSqliteFilters.ts +202 -0
- package/apps/agents-server/src/database/sqlite/localSqliteSupabase/localSqliteMutationPayload.ts +131 -0
- package/apps/agents-server/src/database/sqlite/localSqliteSupabase/localSqliteRowOperations.ts +102 -0
- package/apps/agents-server/src/database/sqlite/localSqliteSupabase/localSqliteSql.ts +59 -0
- package/apps/agents-server/src/database/sqlite/localSqliteSupabase/localSqliteTableSchema.ts +329 -0
- package/apps/agents-server/src/database/sqlite/localSqliteSupabase/localSqliteTypes.ts +84 -0
- package/apps/agents-server/src/database/sqlite/localSqliteSupabase/localSqliteValueCodec.ts +63 -0
- package/apps/agents-server/src/database/sqlite/localSqliteSupabase/normalizeSqliteError.ts +22 -0
- package/apps/agents-server/src/search/createDefaultServerSearchProviders/loadLocalOrganizationSearchDataset.ts +12 -1
- package/apps/agents-server/src/tools/send_email.ts +1 -2
- package/apps/agents-server/src/utils/agentOrganization/loadAgentOrganizationState.ts +13 -1
- package/apps/agents-server/src/utils/backup/createServerBackupZipStream.ts +7 -1382
- package/apps/agents-server/src/utils/backup/serverBackup/appendAgentBackupEntriesToZip.ts +27 -0
- package/apps/agents-server/src/utils/backup/serverBackup/appendConversationBackupEntriesToZip.ts +140 -0
- package/apps/agents-server/src/utils/backup/serverBackup/appendFileBackupEntriesToZip.ts +147 -0
- package/apps/agents-server/src/utils/backup/serverBackup/appendMessageBackupEntriesToZip.ts +65 -0
- package/apps/agents-server/src/utils/backup/serverBackup/appendMetadataBackupEntriesToZip.ts +39 -0
- package/apps/agents-server/src/utils/backup/serverBackup/appendSectionEntriesToZip.ts +92 -0
- package/apps/agents-server/src/utils/backup/serverBackup/appendUserBackupEntriesToZip.ts +80 -0
- package/apps/agents-server/src/utils/backup/serverBackup/createRedactedWalletBackupRecord.ts +34 -0
- package/apps/agents-server/src/utils/backup/serverBackup/createServerBackupManifest.ts +82 -0
- package/apps/agents-server/src/utils/backup/serverBackup/downloadBackupBinaryContent.ts +39 -0
- package/apps/agents-server/src/utils/backup/serverBackup/resolveFeedbackThreadMessages.ts +53 -0
- package/apps/agents-server/src/utils/backup/serverBackup/serverBackupAttachments.ts +151 -0
- package/apps/agents-server/src/utils/backup/serverBackup/serverBackupContext.ts +167 -0
- package/apps/agents-server/src/utils/backup/serverBackup/serverBackupFilenames.ts +161 -0
- package/apps/agents-server/src/utils/backup/serverBackup/serverBackupPreviews.ts +97 -0
- package/apps/agents-server/src/utils/backup/serverBackup/serverBackupRowUtilities.ts +158 -0
- package/apps/agents-server/src/utils/backup/serverBackup/serverBackupTypes.ts +59 -0
- package/apps/agents-server/src/utils/createLocalAgentSourceImporter.ts +159 -0
- package/apps/agents-server/src/utils/createMissingImportedAgentFallback.ts +60 -0
- package/apps/agents-server/src/utils/customDomainRouting.ts +157 -12
- package/apps/agents-server/src/utils/externalChatRunner/processExternalUserChatJob.ts +1 -1
- package/apps/agents-server/src/utils/importAgentWithFallback.ts +1 -58
- package/apps/agents-server/src/utils/localAgentRouteReferences.ts +167 -0
- package/apps/agents-server/src/utils/localChatRunner/processLocalUserChatJob.ts +1 -1
- package/apps/agents-server/src/utils/managementApi/managementApiAgents.ts +17 -3
- package/apps/agents-server/src/utils/messages/sendMessage.ts +5 -3
- package/apps/agents-server/src/utils/resolveAgentStateFromSource.ts +7 -1
- package/apps/agents-server/src/utils/resolveInheritedAgentSource.ts +54 -5
- package/apps/agents-server/src/utils/resolveServerAgentContext.ts +12 -1
- package/apps/agents-server/src/utils/resolveStoredAgentState.ts +2 -1
- package/apps/agents-server/src/utils/speech-to-text/SpeechToTextFailoverRecognition/SpeechToTextFailoverRecognitionProviderRuntime.ts +0 -1
- package/apps/agents-server/src/utils/speech-to-text/SpeechToTextFailoverRecognition.ts +34 -2
- package/apps/agents-server/src/utils/userChat/userChatMessageLifecycle.ts +39 -9
- package/apps/agents-server/tests/e2e/support/ChatHistoryNavigationSupport.ts +5 -0
- package/esm/index.es.js +875 -60
- package/esm/index.es.js.map +1 -1
- package/esm/scripts/find-refactor-candidates/find-refactor-candidates.d.ts +7 -0
- package/esm/scripts/find-refactor-candidates/selectMostImportantRefactorCandidates.d.ts +12 -0
- package/esm/scripts/run-codex-prompts/common/resolveCoderAgent.d.ts +20 -0
- package/esm/scripts/run-codex-prompts/ui/CoderRunUiState.d.ts +5 -0
- package/esm/scripts/run-codex-prompts/ui/buildCoderRunAgentVisual.d.ts +29 -0
- package/esm/scripts/run-codex-prompts/ui/buildCoderRunUiFrame.d.ts +4 -0
- package/esm/src/avatars/renderAvatarVisualAsciiArt.d.ts +75 -0
- package/esm/src/book-components/Chat/Chat/insertDictationChunk.d.ts +1 -1
- package/esm/src/book-components/Chat/Chat/insertDictationChunk.test.d.ts +1 -0
- package/esm/src/book-components/Chat/Chat/learnDictationDictionary.test.d.ts +1 -0
- package/esm/src/book-components/Chat/Chat/refineFinalDictationChunk.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/common/createPositiveIntegerOptionParser.d.ts +10 -0
- package/esm/src/utils/ascii-art/$detectTerminalAnsiColorDepth.d.ts +15 -0
- package/esm/src/utils/ascii-art/convertImageDataToAsciiArt.d.ts +80 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/avatars/avatarAnimationScheduler.ts +2 -1
- package/src/avatars/renderAvatarVisualAsciiArt.ts +138 -0
- package/src/avatars/visuals/octopus3d3AvatarVisual.ts +6 -2
- package/src/avatars/visuals/octopus3d4AvatarVisual.ts +14 -18
- package/src/book-components/Chat/Chat/insertDictationChunk.ts +3 -3
- package/src/book-components/Chat/Chat/learnDictationDictionary.ts +1 -1
- package/src/book-components/Chat/Chat/useChatInputAreaDictation.ts +133 -26
- package/src/cli/cli-commands/agents-server/buildAgentsServer.ts +3 -1
- package/src/cli/cli-commands/coder/boilerplateTemplates.ts +14 -21
- package/src/cli/cli-commands/coder/find-refactor-candidates.ts +9 -2
- package/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.ts +1 -4
- package/src/cli/cli-commands/coder/run.ts +3 -27
- package/src/cli/cli-commands/common/createPositiveIntegerOptionParser.ts +31 -0
- package/src/commitments/TEAM/TEAM.ts +5 -5
- package/src/other/templates/getTemplatesPipelineCollection.ts +770 -1169
- package/src/utils/ascii-art/$detectTerminalAnsiColorDepth.ts +45 -0
- package/src/utils/ascii-art/convertImageDataToAsciiArt.ts +396 -0
- package/src/version.ts +2 -2
- package/src/versions.txt +2 -0
- package/umd/index.umd.js +875 -60
- package/umd/index.umd.js.map +1 -1
- package/umd/scripts/find-refactor-candidates/find-refactor-candidates.d.ts +7 -0
- package/umd/scripts/find-refactor-candidates/selectMostImportantRefactorCandidates.d.ts +12 -0
- package/umd/scripts/run-codex-prompts/common/resolveCoderAgent.d.ts +20 -0
- package/umd/scripts/run-codex-prompts/ui/CoderRunUiState.d.ts +5 -0
- package/umd/scripts/run-codex-prompts/ui/buildCoderRunAgentVisual.d.ts +29 -0
- package/umd/scripts/run-codex-prompts/ui/buildCoderRunUiFrame.d.ts +4 -0
- package/umd/src/avatars/renderAvatarVisualAsciiArt.d.ts +75 -0
- package/umd/src/book-components/Chat/Chat/insertDictationChunk.d.ts +1 -1
- package/umd/src/book-components/Chat/Chat/insertDictationChunk.test.d.ts +1 -0
- package/umd/src/book-components/Chat/Chat/learnDictationDictionary.test.d.ts +1 -0
- package/umd/src/book-components/Chat/Chat/refineFinalDictationChunk.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/createPositiveIntegerOptionParser.d.ts +10 -0
- package/umd/src/utils/ascii-art/$detectTerminalAnsiColorDepth.d.ts +15 -0
- package/umd/src/utils/ascii-art/convertImageDataToAsciiArt.d.ts +80 -0
- package/umd/src/version.d.ts +1 -1
- package/esm/scripts/run-codex-prompts/common/resolveAgentSystemMessage.d.ts +0 -6
- package/umd/scripts/run-codex-prompts/common/resolveAgentSystemMessage.d.ts +0 -6
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { ReactNode } from 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Props for one page section card.
|
|
7
|
+
*
|
|
8
|
+
* @private type of `<AgentCodePageSection/>`
|
|
9
|
+
*/
|
|
10
|
+
type AgentCodePageSectionProps = {
|
|
11
|
+
/**
|
|
12
|
+
* Section heading shown above the content.
|
|
13
|
+
*/
|
|
14
|
+
readonly title: string;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Supporting copy shown under the title.
|
|
18
|
+
*/
|
|
19
|
+
readonly description: string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Optional header actions rendered beside the title.
|
|
23
|
+
*/
|
|
24
|
+
readonly actions?: ReactNode;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Main section content.
|
|
28
|
+
*/
|
|
29
|
+
readonly children: ReactNode;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Shared card section used on the export-as-transpiled-code page.
|
|
34
|
+
*
|
|
35
|
+
* @private internal component of `<AgentCodePageClient/>`
|
|
36
|
+
*/
|
|
37
|
+
export function AgentCodePageSection({ title, description, actions, children }: AgentCodePageSectionProps) {
|
|
38
|
+
return (
|
|
39
|
+
<section className="overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm dark:border-slate-800 dark:bg-slate-900">
|
|
40
|
+
<div className="flex flex-col gap-4 border-b border-slate-200 px-5 py-4 sm:flex-row sm:items-start sm:justify-between dark:border-slate-800">
|
|
41
|
+
<div className="min-w-0">
|
|
42
|
+
<h2 className="text-lg font-semibold text-slate-900 dark:text-slate-100">{title}</h2>
|
|
43
|
+
<p className="mt-1 text-sm text-slate-600 dark:text-slate-400">{description}</p>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
{actions ? <div className="flex shrink-0 flex-wrap items-center gap-3">{actions}</div> : null}
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
<div className="p-5">{children}</div>
|
|
50
|
+
</section>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { MonacoEditorWithShadowDom } from '../../../../components/_utils/MonacoEditorWithShadowDom';
|
|
4
|
+
import { getTranspiledCodeFileMetadata } from '../../../../utils/transpilers/getTranspiledCodeFileMetadata';
|
|
5
|
+
import type { Transpiler } from './Transpiler';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Props for the generated code preview.
|
|
9
|
+
*
|
|
10
|
+
* @private type of `<GeneratedCodePreview/>`
|
|
11
|
+
*/
|
|
12
|
+
type GeneratedCodePreviewProps = {
|
|
13
|
+
/**
|
|
14
|
+
* Currently selected transpiler, used for the preview heading.
|
|
15
|
+
*/
|
|
16
|
+
readonly selectedTranspiler: Transpiler | null;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Currently selected transpiler name, used to resolve the editor language.
|
|
20
|
+
*/
|
|
21
|
+
readonly selectedTranspilerName: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Generated harness code, or an empty string when there is nothing to show yet.
|
|
25
|
+
*/
|
|
26
|
+
readonly transpiledCode: string;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Whether code generation is currently in progress.
|
|
30
|
+
*/
|
|
31
|
+
readonly isTranspiling: boolean;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Whether a ZIP download is currently in progress.
|
|
35
|
+
*/
|
|
36
|
+
readonly isDownloading: boolean;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Shows the generated harness code in a read-only Monaco editor, plus generation/download status.
|
|
41
|
+
*
|
|
42
|
+
* @private internal component of `<AgentCodePageClient/>`
|
|
43
|
+
*/
|
|
44
|
+
export function GeneratedCodePreview({
|
|
45
|
+
selectedTranspiler,
|
|
46
|
+
selectedTranspilerName,
|
|
47
|
+
transpiledCode,
|
|
48
|
+
isTranspiling,
|
|
49
|
+
isDownloading,
|
|
50
|
+
}: GeneratedCodePreviewProps) {
|
|
51
|
+
const statusLabel = getGeneratedCodeStatusLabel(isTranspiling, isDownloading);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div className="overflow-hidden rounded-xl border border-slate-200 bg-slate-50 dark:border-slate-700 dark:bg-slate-950">
|
|
55
|
+
<div className="flex flex-wrap items-center justify-between gap-3 border-b border-slate-200 px-4 py-3 dark:border-slate-700">
|
|
56
|
+
<h3 className="text-base font-semibold text-slate-900 dark:text-slate-100">
|
|
57
|
+
{selectedTranspiler?.title || 'Generated code'}
|
|
58
|
+
</h3>
|
|
59
|
+
{statusLabel ? (
|
|
60
|
+
<div className="text-sm text-slate-500 dark:text-slate-400" role="status" aria-live="polite">
|
|
61
|
+
{statusLabel}
|
|
62
|
+
</div>
|
|
63
|
+
) : null}
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
<div className="p-4">
|
|
67
|
+
{transpiledCode ? (
|
|
68
|
+
<div className="h-[32rem] overflow-hidden rounded-lg border border-slate-200 dark:border-slate-700">
|
|
69
|
+
<MonacoEditorWithShadowDom
|
|
70
|
+
value={transpiledCode}
|
|
71
|
+
language={getTranspiledCodeFileMetadata(selectedTranspilerName).language}
|
|
72
|
+
options={{
|
|
73
|
+
readOnly: true,
|
|
74
|
+
minimap: { enabled: false },
|
|
75
|
+
fontSize: 14,
|
|
76
|
+
lineNumbers: 'on',
|
|
77
|
+
scrollBeyondLastLine: false,
|
|
78
|
+
automaticLayout: true,
|
|
79
|
+
wordWrap: 'on',
|
|
80
|
+
}}
|
|
81
|
+
loading={
|
|
82
|
+
<div className="flex h-full items-center justify-center text-slate-500 dark:text-slate-400">
|
|
83
|
+
Loading editor...
|
|
84
|
+
</div>
|
|
85
|
+
}
|
|
86
|
+
/>
|
|
87
|
+
</div>
|
|
88
|
+
) : (
|
|
89
|
+
<div className="py-12 text-center text-sm text-slate-500 dark:text-slate-400">
|
|
90
|
+
{getGeneratedCodePlaceholderText(isTranspiling, selectedTranspilerName)}
|
|
91
|
+
</div>
|
|
92
|
+
)}
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Resolves the status label shown in the preview header while generating or downloading.
|
|
100
|
+
*
|
|
101
|
+
* @param isTranspiling - Whether code generation is in progress.
|
|
102
|
+
* @param isDownloading - Whether a ZIP download is in progress.
|
|
103
|
+
* @returns Status label, or `null` when neither action is running.
|
|
104
|
+
*
|
|
105
|
+
* @private function of `<GeneratedCodePreview/>`
|
|
106
|
+
*/
|
|
107
|
+
function getGeneratedCodeStatusLabel(isTranspiling: boolean, isDownloading: boolean): string | null {
|
|
108
|
+
if (isDownloading) {
|
|
109
|
+
return 'Preparing ZIP archive...';
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (isTranspiling) {
|
|
113
|
+
return 'Generating code...';
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Resolves the placeholder text shown when there is no generated code yet.
|
|
121
|
+
*
|
|
122
|
+
* @param isTranspiling - Whether code generation is in progress.
|
|
123
|
+
* @param selectedTranspilerName - Currently selected transpiler name.
|
|
124
|
+
* @returns Placeholder text describing the current empty state.
|
|
125
|
+
*
|
|
126
|
+
* @private function of `<GeneratedCodePreview/>`
|
|
127
|
+
*/
|
|
128
|
+
function getGeneratedCodePlaceholderText(isTranspiling: boolean, selectedTranspilerName: string): string {
|
|
129
|
+
if (isTranspiling) {
|
|
130
|
+
return 'Generating code...';
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (selectedTranspilerName) {
|
|
134
|
+
return 'Generated code will appear here.';
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return 'Select a transpiler to generate code.';
|
|
138
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { ChevronDownIcon, DownloadIcon } from 'lucide-react';
|
|
4
|
+
import type { TranspiledAgentExportWarning } from '../../../../utils/transpilers/getTranspiledAgentExportWarnings';
|
|
5
|
+
import { AgentCodePageSection } from './AgentCodePageSection';
|
|
6
|
+
import { GeneratedCodePreview } from './GeneratedCodePreview';
|
|
7
|
+
import { TranspiledCodeErrorBanner } from './TranspiledCodeErrorBanner';
|
|
8
|
+
import { TranspiledCodeExportWarningBanner } from './TranspiledCodeExportWarningBanner';
|
|
9
|
+
import type { AgentCodeExportState } from './useAgentCodeExportState';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Props for the generated harness section.
|
|
13
|
+
*
|
|
14
|
+
* @private type of `<GeneratedHarnessSection/>`
|
|
15
|
+
*/
|
|
16
|
+
type GeneratedHarnessSectionProps = {
|
|
17
|
+
/**
|
|
18
|
+
* Export page state and actions.
|
|
19
|
+
*/
|
|
20
|
+
readonly state: AgentCodeExportState;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Warnings about commitments that cannot be transpiled 1:1.
|
|
24
|
+
*/
|
|
25
|
+
readonly exportWarnings: ReadonlyArray<TranspiledAgentExportWarning>;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Renders the transpiler picker, export warnings/errors, download action, and generated code preview.
|
|
30
|
+
*
|
|
31
|
+
* @private internal component of `<AgentCodePageClient/>`
|
|
32
|
+
*/
|
|
33
|
+
export function GeneratedHarnessSection({ state, exportWarnings }: GeneratedHarnessSectionProps) {
|
|
34
|
+
return (
|
|
35
|
+
<AgentCodePageSection
|
|
36
|
+
title="Generated Harness"
|
|
37
|
+
description="Generate runnable output from the current agent and download the source book plus transpiled harness as one ZIP archive."
|
|
38
|
+
actions={
|
|
39
|
+
<button
|
|
40
|
+
type="button"
|
|
41
|
+
onClick={() => void state.downloadTranspiledCode()}
|
|
42
|
+
disabled={state.isDownloadButtonDisabled}
|
|
43
|
+
className="inline-flex items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-60"
|
|
44
|
+
>
|
|
45
|
+
<DownloadIcon className="h-4 w-4" />
|
|
46
|
+
{state.downloadButtonLabel}
|
|
47
|
+
</button>
|
|
48
|
+
}
|
|
49
|
+
>
|
|
50
|
+
<div className="space-y-4">
|
|
51
|
+
<TranspiledCodeExportWarningBanner warnings={exportWarnings} />
|
|
52
|
+
|
|
53
|
+
<div>
|
|
54
|
+
<label
|
|
55
|
+
htmlFor="agent-code-transpiler"
|
|
56
|
+
className="mb-2 block text-sm font-medium text-slate-700 dark:text-slate-300"
|
|
57
|
+
>
|
|
58
|
+
Select transpiler
|
|
59
|
+
</label>
|
|
60
|
+
<div className="relative">
|
|
61
|
+
<select
|
|
62
|
+
id="agent-code-transpiler"
|
|
63
|
+
value={state.selectedTranspilerName}
|
|
64
|
+
onChange={(event) => state.selectTranspiler(event.target.value)}
|
|
65
|
+
disabled={state.isPageLoading || state.transpilers.length === 0}
|
|
66
|
+
className="w-full appearance-none rounded-md border border-slate-300 bg-white px-3 py-2 pr-9 text-sm text-slate-900 shadow-sm outline-none transition focus:border-blue-500 focus:ring-2 focus:ring-blue-500/20 disabled:cursor-not-allowed disabled:opacity-60 dark:border-slate-700 dark:bg-slate-950 dark:text-slate-100"
|
|
67
|
+
>
|
|
68
|
+
{state.transpilers.length === 0 ? (
|
|
69
|
+
<option value="">
|
|
70
|
+
{state.isPageLoading ? 'Loading transpilers...' : 'No transpilers available'}
|
|
71
|
+
</option>
|
|
72
|
+
) : (
|
|
73
|
+
state.transpilers.map((transpiler) => (
|
|
74
|
+
<option key={transpiler.name} value={transpiler.name}>
|
|
75
|
+
{transpiler.title}
|
|
76
|
+
</option>
|
|
77
|
+
))
|
|
78
|
+
)}
|
|
79
|
+
</select>
|
|
80
|
+
<ChevronDownIcon className="pointer-events-none absolute right-3 top-2.5 h-4 w-4 text-slate-400" />
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
<TranspiledCodeErrorBanner message={state.pageErrorMessage} />
|
|
85
|
+
<TranspiledCodeErrorBanner message={state.transpileErrorMessage} />
|
|
86
|
+
<TranspiledCodeErrorBanner message={state.downloadErrorMessage} />
|
|
87
|
+
|
|
88
|
+
<GeneratedCodePreview
|
|
89
|
+
selectedTranspiler={state.selectedTranspiler}
|
|
90
|
+
selectedTranspilerName={state.selectedTranspilerName}
|
|
91
|
+
transpiledCode={state.transpiledCode}
|
|
92
|
+
isTranspiling={state.isTranspiling}
|
|
93
|
+
isDownloading={state.isDownloading}
|
|
94
|
+
/>
|
|
95
|
+
</div>
|
|
96
|
+
</AgentCodePageSection>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { BookEditor } from '@promptbook-local/components';
|
|
4
|
+
import type { string_book } from '@promptbook-local/types';
|
|
5
|
+
import { PencilIcon } from 'lucide-react';
|
|
6
|
+
import Link from 'next/link';
|
|
7
|
+
import { usePromptbookTheme } from '../../../../components/ThemeMode/usePromptbookTheme';
|
|
8
|
+
import { AgentCodePageSection } from './AgentCodePageSection';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Props for the source-book section.
|
|
12
|
+
*
|
|
13
|
+
* @private type of `<SourceBookSection/>`
|
|
14
|
+
*/
|
|
15
|
+
type SourceBookSectionProps = {
|
|
16
|
+
/**
|
|
17
|
+
* Routed agent name.
|
|
18
|
+
*/
|
|
19
|
+
readonly agentName: string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Stored source book shown in the read-only Book viewer.
|
|
23
|
+
*/
|
|
24
|
+
readonly agentSource: string_book;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Renders the read-only Book source viewer and the link to the dedicated Book editor.
|
|
29
|
+
*
|
|
30
|
+
* @private internal component of `<AgentCodePageClient/>`
|
|
31
|
+
*/
|
|
32
|
+
export function SourceBookSection({ agentName, agentSource }: SourceBookSectionProps) {
|
|
33
|
+
const { promptbookTheme } = usePromptbookTheme();
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<AgentCodePageSection
|
|
37
|
+
title="Source Book"
|
|
38
|
+
description="Review the stored Book source used to create this agent. Editing stays in the dedicated Book editor."
|
|
39
|
+
actions={
|
|
40
|
+
<Link
|
|
41
|
+
href={`/agents/${encodeURIComponent(agentName)}/book`}
|
|
42
|
+
className="inline-flex items-center justify-center gap-2 rounded-md border border-slate-300 bg-white px-4 py-2 text-sm font-medium text-slate-700 transition-colors hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-200 dark:hover:bg-slate-800"
|
|
43
|
+
>
|
|
44
|
+
<PencilIcon className="h-4 w-4" />
|
|
45
|
+
Edit Book
|
|
46
|
+
</Link>
|
|
47
|
+
}
|
|
48
|
+
>
|
|
49
|
+
<div className="h-[28rem] overflow-hidden rounded-xl border border-slate-200 dark:border-slate-700">
|
|
50
|
+
<BookEditor
|
|
51
|
+
className="h-full w-full"
|
|
52
|
+
height={null}
|
|
53
|
+
value={agentSource}
|
|
54
|
+
isReadonly
|
|
55
|
+
isUploadButtonShown={false}
|
|
56
|
+
isCameraButtonShown={false}
|
|
57
|
+
isDownloadButtonShown={false}
|
|
58
|
+
isAboutButtonShown={false}
|
|
59
|
+
isFullscreenButtonShown={false}
|
|
60
|
+
translations={{ readonlyMessage: 'Use Edit Book to change the source.' }}
|
|
61
|
+
theme={promptbookTheme}
|
|
62
|
+
/>
|
|
63
|
+
</div>
|
|
64
|
+
</AgentCodePageSection>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Props for a single export error banner.
|
|
5
|
+
*
|
|
6
|
+
* @private type of `<TranspiledCodeErrorBanner/>`
|
|
7
|
+
*/
|
|
8
|
+
type TranspiledCodeErrorBannerProps = {
|
|
9
|
+
/**
|
|
10
|
+
* Error message to show, or `null`/empty to render nothing.
|
|
11
|
+
*/
|
|
12
|
+
readonly message: string | null;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Renders a single red error banner, or nothing when there is no message.
|
|
17
|
+
*
|
|
18
|
+
* @private internal component of `<AgentCodePageClient/>`
|
|
19
|
+
*/
|
|
20
|
+
export function TranspiledCodeErrorBanner({ message }: TranspiledCodeErrorBannerProps) {
|
|
21
|
+
if (!message) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div className="rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/40 dark:text-red-300">
|
|
27
|
+
{message}
|
|
28
|
+
</div>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { AlertTriangleIcon } from 'lucide-react';
|
|
4
|
+
import type { TranspiledAgentExportWarning } from '../../../../utils/transpilers/getTranspiledAgentExportWarnings';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Props for the export warning banner.
|
|
8
|
+
*
|
|
9
|
+
* @private type of `<TranspiledCodeExportWarningBanner/>`
|
|
10
|
+
*/
|
|
11
|
+
type TranspiledCodeExportWarningBannerProps = {
|
|
12
|
+
/**
|
|
13
|
+
* Non-transpilable commitment warnings computed for the current agent.
|
|
14
|
+
*/
|
|
15
|
+
readonly warnings: ReadonlyArray<TranspiledAgentExportWarning>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Renders a warning banner when the current agent uses commitments that cannot be exported 1:1.
|
|
20
|
+
*
|
|
21
|
+
* @private internal component of `<AgentCodePageClient/>`
|
|
22
|
+
*/
|
|
23
|
+
export function TranspiledCodeExportWarningBanner({ warnings }: TranspiledCodeExportWarningBannerProps) {
|
|
24
|
+
if (warnings.length === 0) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div
|
|
30
|
+
className="rounded-xl border border-amber-200 bg-amber-50 p-4 text-amber-950 shadow-sm dark:border-amber-900/60 dark:bg-amber-950/40 dark:text-amber-100"
|
|
31
|
+
role="alert"
|
|
32
|
+
>
|
|
33
|
+
<div className="flex items-start gap-3">
|
|
34
|
+
<AlertTriangleIcon className="mt-0.5 h-5 w-5 shrink-0 text-amber-600 dark:text-amber-300" />
|
|
35
|
+
<div className="min-w-0">
|
|
36
|
+
<p className="text-sm font-semibold">Some agent functionality cannot be transpiled exactly.</p>
|
|
37
|
+
<p className="mt-1 text-sm text-amber-900/90 dark:text-amber-100/80">
|
|
38
|
+
The exported code may not behave 1:1 with the live agent in Agents Server.
|
|
39
|
+
</p>
|
|
40
|
+
|
|
41
|
+
<ul className="mt-3 space-y-3">
|
|
42
|
+
{warnings.map((warning) => (
|
|
43
|
+
<li key={warning.commitmentName} className="flex gap-2">
|
|
44
|
+
<span className="mt-2 h-1.5 w-1.5 shrink-0 rounded-full bg-amber-500" />
|
|
45
|
+
<div className="min-w-0">
|
|
46
|
+
<p className="text-sm font-medium">
|
|
47
|
+
<code className="rounded bg-amber-100 px-1 py-0.5 font-mono text-[0.85em] text-amber-950 dark:bg-amber-900/60 dark:text-amber-100">
|
|
48
|
+
{warning.commitmentName}
|
|
49
|
+
</code>
|
|
50
|
+
</p>
|
|
51
|
+
<p className="mt-1 text-sm text-amber-900/90 dark:text-amber-100/80">
|
|
52
|
+
{warning.description}
|
|
53
|
+
</p>
|
|
54
|
+
</div>
|
|
55
|
+
</li>
|
|
56
|
+
))}
|
|
57
|
+
</ul>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
}
|