mulmoclaude 0.1.0
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/README.md +44 -0
- package/bin/mulmoclaude.js +202 -0
- package/bin/prepare-dist.js +93 -0
- package/client/assets/chunk-vKJrgz-R-C_I3GbVV.js +1 -0
- package/client/assets/html2canvas-Cx501zZr-BF5dYYkY.js +5 -0
- package/client/assets/index-D8rhwXLq.js +4906 -0
- package/client/assets/index-KNLBjwuh.css +1 -0
- package/client/assets/index.es-D4YyL_Dg-BfRHLTZV.js +5 -0
- package/client/assets/material-icons-Dr0goTwe.woff +0 -0
- package/client/assets/material-icons-kAwBdRge.woff2 +0 -0
- package/client/assets/material-icons-outlined-BpWbwl2n.woff +0 -0
- package/client/assets/material-icons-outlined-DZhiGvEA.woff2 +0 -0
- package/client/assets/material-icons-round-BDlwx-sv.woff +0 -0
- package/client/assets/material-icons-round-DrirKXBx.woff2 +0 -0
- package/client/assets/material-icons-sharp-CH1KkVu7.woff +0 -0
- package/client/assets/material-icons-sharp-gidztirS.woff2 +0 -0
- package/client/assets/material-icons-two-tone-B7wz7mED.woff +0 -0
- package/client/assets/material-icons-two-tone-DuNIpaEj.woff2 +0 -0
- package/client/assets/mulmo_bw-ERmkSv0a.png +0 -0
- package/client/assets/purify.es-Fx1Nqyry-PeS5RUhs.js +2 -0
- package/client/assets/typeof-DBp4T-Ny-BC0P-2DM.js +1 -0
- package/client/index.html +28 -0
- package/package.json +66 -0
- package/server/agent/attachmentConverter.ts +270 -0
- package/server/agent/config.ts +414 -0
- package/server/agent/index.ts +260 -0
- package/server/agent/mcp-server.ts +412 -0
- package/server/agent/mcp-tools/index.ts +63 -0
- package/server/agent/mcp-tools/x.ts +188 -0
- package/server/agent/plugin-names.ts +75 -0
- package/server/agent/prompt.ts +349 -0
- package/server/agent/resumeFailover.ts +129 -0
- package/server/agent/sandboxMounts.ts +329 -0
- package/server/agent/stream.ts +194 -0
- package/server/api/auth/bearerAuth.ts +61 -0
- package/server/api/auth/token.ts +98 -0
- package/server/api/csrfGuard.ts +85 -0
- package/server/api/routes/agent.ts +478 -0
- package/server/api/routes/chart.ts +98 -0
- package/server/api/routes/chat-index.ts +46 -0
- package/server/api/routes/config.ts +258 -0
- package/server/api/routes/dispatchResponse.ts +79 -0
- package/server/api/routes/files.ts +812 -0
- package/server/api/routes/html.ts +101 -0
- package/server/api/routes/image.ts +169 -0
- package/server/api/routes/mulmo-script.ts +712 -0
- package/server/api/routes/mulmoScriptValidate.ts +101 -0
- package/server/api/routes/notifications.ts +69 -0
- package/server/api/routes/pdf.ts +163 -0
- package/server/api/routes/plugins.ts +276 -0
- package/server/api/routes/presentHtml.ts +48 -0
- package/server/api/routes/roles.ts +125 -0
- package/server/api/routes/scheduler.ts +153 -0
- package/server/api/routes/schedulerHandlers.ts +151 -0
- package/server/api/routes/schedulerTasks.ts +163 -0
- package/server/api/routes/sessions.ts +294 -0
- package/server/api/routes/sessionsCursor.ts +59 -0
- package/server/api/routes/skills.ts +195 -0
- package/server/api/routes/sources.ts +540 -0
- package/server/api/routes/todos.ts +263 -0
- package/server/api/routes/todosColumnsHandlers.ts +347 -0
- package/server/api/routes/todosHandlers.ts +274 -0
- package/server/api/routes/todosItemsHandlers.ts +386 -0
- package/server/api/routes/wiki/pageIndex.ts +53 -0
- package/server/api/routes/wiki.ts +363 -0
- package/server/api/sandboxStatus.ts +64 -0
- package/server/events/notifications.ts +160 -0
- package/server/events/pub-sub/index.ts +45 -0
- package/server/events/relay-client.ts +288 -0
- package/server/events/scheduler-adapter.ts +302 -0
- package/server/events/session-store/index.ts +492 -0
- package/server/events/task-manager/index.ts +181 -0
- package/server/index.ts +572 -0
- package/server/system/config.ts +243 -0
- package/server/system/credentials.ts +220 -0
- package/server/system/docker.ts +97 -0
- package/server/system/env.ts +109 -0
- package/server/system/logger/config.ts +112 -0
- package/server/system/logger/formatters.ts +40 -0
- package/server/system/logger/index.ts +53 -0
- package/server/system/logger/rotation.ts +37 -0
- package/server/system/logger/sinks.ts +101 -0
- package/server/system/logger/types.ts +29 -0
- package/server/utils/date.ts +57 -0
- package/server/utils/errors.ts +7 -0
- package/server/utils/fetch.ts +27 -0
- package/server/utils/files/atomic.ts +125 -0
- package/server/utils/files/html-io.ts +20 -0
- package/server/utils/files/image-store.ts +66 -0
- package/server/utils/files/index.ts +45 -0
- package/server/utils/files/journal-io.ts +213 -0
- package/server/utils/files/json.ts +69 -0
- package/server/utils/files/markdown-store.ts +33 -0
- package/server/utils/files/naming.ts +50 -0
- package/server/utils/files/reference-dirs-io.ts +45 -0
- package/server/utils/files/roles-io.ts +45 -0
- package/server/utils/files/safe.ts +106 -0
- package/server/utils/files/scheduler-io.ts +20 -0
- package/server/utils/files/scheduler-overrides-io.ts +64 -0
- package/server/utils/files/session-io.ts +136 -0
- package/server/utils/files/spreadsheet-store.ts +63 -0
- package/server/utils/files/todos-io.ts +29 -0
- package/server/utils/files/user-tasks-io.ts +25 -0
- package/server/utils/files/workspace-io.ts +221 -0
- package/server/utils/gemini.ts +59 -0
- package/server/utils/gitignore.ts +69 -0
- package/server/utils/http.ts +15 -0
- package/server/utils/httpError.ts +61 -0
- package/server/utils/id.ts +16 -0
- package/server/utils/json.ts +83 -0
- package/server/utils/logBackgroundError.ts +22 -0
- package/server/utils/markdown.ts +82 -0
- package/server/utils/request.ts +29 -0
- package/server/utils/slug.ts +50 -0
- package/server/utils/spawn.ts +62 -0
- package/server/utils/time.ts +34 -0
- package/server/utils/types.ts +47 -0
- package/server/workspace/chat-index/index.ts +153 -0
- package/server/workspace/chat-index/indexer.ts +209 -0
- package/server/workspace/chat-index/paths.ts +34 -0
- package/server/workspace/chat-index/summarizer.ts +247 -0
- package/server/workspace/chat-index/types.ts +38 -0
- package/server/workspace/custom-dirs.ts +220 -0
- package/server/workspace/helps/business.md +104 -0
- package/server/workspace/helps/github.md +23 -0
- package/server/workspace/helps/index.md +60 -0
- package/server/workspace/helps/mulmoscript.md +249 -0
- package/server/workspace/helps/sandbox.md +90 -0
- package/server/workspace/helps/spreadsheet.md +43 -0
- package/server/workspace/helps/telegram.md +135 -0
- package/server/workspace/helps/wiki.md +131 -0
- package/server/workspace/journal/archivist.ts +386 -0
- package/server/workspace/journal/dailyPass.ts +743 -0
- package/server/workspace/journal/diff.ts +71 -0
- package/server/workspace/journal/index.ts +185 -0
- package/server/workspace/journal/indexFile.ts +136 -0
- package/server/workspace/journal/linkRewrite.ts +4 -0
- package/server/workspace/journal/memoryExtractor.ts +130 -0
- package/server/workspace/journal/optimizationPass.ts +160 -0
- package/server/workspace/journal/paths.ts +76 -0
- package/server/workspace/journal/state.ts +125 -0
- package/server/workspace/paths.ts +158 -0
- package/server/workspace/reference-dirs.ts +252 -0
- package/server/workspace/roles.ts +37 -0
- package/server/workspace/skills/discovery.ts +125 -0
- package/server/workspace/skills/index.ts +10 -0
- package/server/workspace/skills/parser.ts +144 -0
- package/server/workspace/skills/paths.ts +41 -0
- package/server/workspace/skills/scheduler.ts +149 -0
- package/server/workspace/skills/types.ts +30 -0
- package/server/workspace/skills/user-tasks.ts +257 -0
- package/server/workspace/skills/writer.ts +189 -0
- package/server/workspace/sources/arxivDiscovery.ts +182 -0
- package/server/workspace/sources/classifier.ts +268 -0
- package/server/workspace/sources/fetchers/arxiv.ts +170 -0
- package/server/workspace/sources/fetchers/github.ts +106 -0
- package/server/workspace/sources/fetchers/githubIssues.ts +208 -0
- package/server/workspace/sources/fetchers/githubReleases.ts +186 -0
- package/server/workspace/sources/fetchers/index.ts +71 -0
- package/server/workspace/sources/fetchers/registerAll.ts +15 -0
- package/server/workspace/sources/fetchers/rss.ts +141 -0
- package/server/workspace/sources/fetchers/rssParser.ts +295 -0
- package/server/workspace/sources/httpFetcher.ts +230 -0
- package/server/workspace/sources/interests.ts +120 -0
- package/server/workspace/sources/paths.ts +110 -0
- package/server/workspace/sources/pipeline/dedup.ts +60 -0
- package/server/workspace/sources/pipeline/fetch.ts +136 -0
- package/server/workspace/sources/pipeline/index.ts +249 -0
- package/server/workspace/sources/pipeline/notify.ts +72 -0
- package/server/workspace/sources/pipeline/plan.ts +66 -0
- package/server/workspace/sources/pipeline/summarize.ts +189 -0
- package/server/workspace/sources/pipeline/write.ts +185 -0
- package/server/workspace/sources/rateLimiter.ts +148 -0
- package/server/workspace/sources/registry.ts +326 -0
- package/server/workspace/sources/robots.ts +271 -0
- package/server/workspace/sources/sourceState.ts +135 -0
- package/server/workspace/sources/taxonomy.ts +74 -0
- package/server/workspace/sources/types.ts +144 -0
- package/server/workspace/sources/urls.ts +112 -0
- package/server/workspace/tool-trace/classify.ts +114 -0
- package/server/workspace/tool-trace/index.ts +250 -0
- package/server/workspace/tool-trace/writeSearch.ts +98 -0
- package/server/workspace/wiki-backlinks/index.ts +107 -0
- package/server/workspace/wiki-backlinks/sessionBacklinks.ts +144 -0
- package/server/workspace/workspace.ts +66 -0
- package/src/App.vue +720 -0
- package/src/assets/mulmo_bw.png +0 -0
- package/src/components/CanvasViewToggle.vue +27 -0
- package/src/components/ChatAttachmentPreview.vue +45 -0
- package/src/components/ChatImagePreview.vue +17 -0
- package/src/components/ChatInput.vue +208 -0
- package/src/components/FileContentHeader.vue +49 -0
- package/src/components/FileContentRenderer.vue +162 -0
- package/src/components/FileTree.vue +115 -0
- package/src/components/FileTreePane.vue +85 -0
- package/src/components/FilesView.vue +206 -0
- package/src/components/LockStatusPopup.vue +111 -0
- package/src/components/NotificationBell.vue +131 -0
- package/src/components/NotificationToast.vue +72 -0
- package/src/components/PluginLauncher.vue +138 -0
- package/src/components/RightSidebar.vue +113 -0
- package/src/components/RoleSelector.vue +64 -0
- package/src/components/SessionHistoryPanel.vue +176 -0
- package/src/components/SessionTabBar.vue +81 -0
- package/src/components/SettingsMcpTab.vue +350 -0
- package/src/components/SettingsModal.vue +275 -0
- package/src/components/SettingsReferenceDirsTab.vue +173 -0
- package/src/components/SettingsWorkspaceDirsTab.vue +174 -0
- package/src/components/SidebarHeader.vue +69 -0
- package/src/components/StackView.vue +360 -0
- package/src/components/SuggestionsPanel.vue +65 -0
- package/src/components/TodoExplorer.vue +358 -0
- package/src/components/ToolResultsPanel.vue +77 -0
- package/src/components/todo/TodoAddDialog.vue +131 -0
- package/src/components/todo/TodoEditDialog.vue +47 -0
- package/src/components/todo/TodoEditPanel.vue +113 -0
- package/src/components/todo/TodoKanbanView.vue +249 -0
- package/src/components/todo/TodoListView.vue +79 -0
- package/src/components/todo/TodoTableView.vue +177 -0
- package/src/composables/useActiveSession.ts +40 -0
- package/src/composables/useAppApi.ts +45 -0
- package/src/composables/useCanvasViewMode.ts +121 -0
- package/src/composables/useChatScroll.ts +47 -0
- package/src/composables/useClickOutside.ts +26 -0
- package/src/composables/useClipboardCopy.ts +44 -0
- package/src/composables/useContentDisplay.ts +52 -0
- package/src/composables/useDebugBeat.ts +23 -0
- package/src/composables/useDynamicFavicon.ts +115 -0
- package/src/composables/useEventListeners.ts +42 -0
- package/src/composables/useExpandedDirs.ts +64 -0
- package/src/composables/useFaviconState.ts +30 -0
- package/src/composables/useFileSelection.ts +115 -0
- package/src/composables/useFileSortMode.ts +24 -0
- package/src/composables/useFileTree.ts +85 -0
- package/src/composables/useFreshPluginData.ts +89 -0
- package/src/composables/useHealth.ts +38 -0
- package/src/composables/useImeAwareEnter.ts +57 -0
- package/src/composables/useKeyNavigation.ts +60 -0
- package/src/composables/useMarkdownLinkHandler.ts +46 -0
- package/src/composables/useMarkdownMode.ts +17 -0
- package/src/composables/useMcpTools.ts +71 -0
- package/src/composables/useMergedSessions.ts +27 -0
- package/src/composables/useNotifications.ts +90 -0
- package/src/composables/usePdfDownload.ts +60 -0
- package/src/composables/usePendingCalls.ts +77 -0
- package/src/composables/usePubSub.ts +85 -0
- package/src/composables/useRightSidebar.ts +23 -0
- package/src/composables/useRoles.ts +34 -0
- package/src/composables/useSandboxStatus.ts +67 -0
- package/src/composables/useSelectedResult.ts +49 -0
- package/src/composables/useSessionDerived.ts +51 -0
- package/src/composables/useSessionHistory.ts +81 -0
- package/src/composables/useSessionSync.ts +57 -0
- package/src/composables/useViewLayout.ts +55 -0
- package/src/config/apiRoutes.ts +173 -0
- package/src/config/pubsubChannels.ts +45 -0
- package/src/config/roles.ts +335 -0
- package/src/config/schedulerActions.ts +25 -0
- package/src/config/toolNames.ts +71 -0
- package/src/config/workspacePaths.ts +24 -0
- package/src/index.css +107 -0
- package/src/main.ts +25 -0
- package/src/plugins/canvas/Preview.vue +13 -0
- package/src/plugins/canvas/View.vue +333 -0
- package/src/plugins/canvas/definition.ts +38 -0
- package/src/plugins/canvas/index.ts +36 -0
- package/src/plugins/chart/Preview.vue +49 -0
- package/src/plugins/chart/View.vue +143 -0
- package/src/plugins/chart/definition.ts +58 -0
- package/src/plugins/chart/index.ts +52 -0
- package/src/plugins/editImage/Preview.vue +13 -0
- package/src/plugins/editImage/View.vue +13 -0
- package/src/plugins/editImage/definition.ts +27 -0
- package/src/plugins/editImage/index.ts +36 -0
- package/src/plugins/generateImage/Preview.vue +13 -0
- package/src/plugins/generateImage/View.vue +33 -0
- package/src/plugins/generateImage/definition.ts +32 -0
- package/src/plugins/generateImage/index.ts +56 -0
- package/src/plugins/manageRoles/Preview.vue +49 -0
- package/src/plugins/manageRoles/View.vue +525 -0
- package/src/plugins/manageRoles/definition.ts +43 -0
- package/src/plugins/manageRoles/index.ts +47 -0
- package/src/plugins/manageSkills/Preview.vue +21 -0
- package/src/plugins/manageSkills/View.vue +321 -0
- package/src/plugins/manageSkills/definition.ts +49 -0
- package/src/plugins/manageSkills/index.ts +49 -0
- package/src/plugins/manageSource/Preview.vue +33 -0
- package/src/plugins/manageSource/View.vue +697 -0
- package/src/plugins/manageSource/definition.ts +63 -0
- package/src/plugins/manageSource/index.ts +66 -0
- package/src/plugins/markdown/Preview.vue +77 -0
- package/src/plugins/markdown/View.vue +476 -0
- package/src/plugins/markdown/definition.ts +50 -0
- package/src/plugins/markdown/index.ts +36 -0
- package/src/plugins/presentHtml/Preview.vue +25 -0
- package/src/plugins/presentHtml/View.vue +52 -0
- package/src/plugins/presentHtml/definition.ts +27 -0
- package/src/plugins/presentHtml/helpers.ts +72 -0
- package/src/plugins/presentHtml/index.ts +41 -0
- package/src/plugins/presentMulmoScript/Preview.vue +23 -0
- package/src/plugins/presentMulmoScript/View.vue +1166 -0
- package/src/plugins/presentMulmoScript/definition.ts +95 -0
- package/src/plugins/presentMulmoScript/helpers.ts +162 -0
- package/src/plugins/presentMulmoScript/index.ts +40 -0
- package/src/plugins/scheduler/Preview.vue +67 -0
- package/src/plugins/scheduler/TasksTab.vue +205 -0
- package/src/plugins/scheduler/View.vue +565 -0
- package/src/plugins/scheduler/definition.ts +57 -0
- package/src/plugins/scheduler/index.ts +45 -0
- package/src/plugins/scheduler/viewModes.ts +26 -0
- package/src/plugins/spreadsheet/Preview.vue +29 -0
- package/src/plugins/spreadsheet/View.vue +997 -0
- package/src/plugins/spreadsheet/cellHighlights.ts +79 -0
- package/src/plugins/spreadsheet/definition.ts +121 -0
- package/src/plugins/spreadsheet/engine/calculator.ts +459 -0
- package/src/plugins/spreadsheet/engine/cellBuilder.ts +81 -0
- package/src/plugins/spreadsheet/engine/date-parser.ts +220 -0
- package/src/plugins/spreadsheet/engine/date-utils.ts +56 -0
- package/src/plugins/spreadsheet/engine/engine.ts +176 -0
- package/src/plugins/spreadsheet/engine/evaluator.ts +390 -0
- package/src/plugins/spreadsheet/engine/formatter.ts +172 -0
- package/src/plugins/spreadsheet/engine/formulaRefs.ts +101 -0
- package/src/plugins/spreadsheet/engine/functions/date.ts +299 -0
- package/src/plugins/spreadsheet/engine/functions/financial.ts +387 -0
- package/src/plugins/spreadsheet/engine/functions/index.ts +16 -0
- package/src/plugins/spreadsheet/engine/functions/logical.ts +262 -0
- package/src/plugins/spreadsheet/engine/functions/lookup.ts +400 -0
- package/src/plugins/spreadsheet/engine/functions/mathematical.ts +297 -0
- package/src/plugins/spreadsheet/engine/functions/statistical.ts +338 -0
- package/src/plugins/spreadsheet/engine/functions/text.ts +389 -0
- package/src/plugins/spreadsheet/engine/index.ts +27 -0
- package/src/plugins/spreadsheet/engine/jsonCellLocator.ts +111 -0
- package/src/plugins/spreadsheet/engine/parser.ts +143 -0
- package/src/plugins/spreadsheet/engine/registry.ts +150 -0
- package/src/plugins/spreadsheet/engine/responseDecoder.ts +67 -0
- package/src/plugins/spreadsheet/engine/types.ts +64 -0
- package/src/plugins/spreadsheet/index.ts +36 -0
- package/src/plugins/textResponse/Preview.vue +94 -0
- package/src/plugins/textResponse/View.vue +503 -0
- package/src/plugins/textResponse/definition.ts +34 -0
- package/src/plugins/textResponse/index.ts +27 -0
- package/src/plugins/textResponse/plugin.ts +29 -0
- package/src/plugins/textResponse/samples.ts +97 -0
- package/src/plugins/textResponse/types.ts +11 -0
- package/src/plugins/todo/Preview.vue +63 -0
- package/src/plugins/todo/View.vue +364 -0
- package/src/plugins/todo/composables/useTodos.ts +177 -0
- package/src/plugins/todo/definition.ts +45 -0
- package/src/plugins/todo/index.ts +61 -0
- package/src/plugins/todo/labels.ts +163 -0
- package/src/plugins/todo/priority.ts +98 -0
- package/src/plugins/todo/viewModes.ts +19 -0
- package/src/plugins/ui-image/ImagePreview.vue +23 -0
- package/src/plugins/ui-image/ImageView.vue +34 -0
- package/src/plugins/ui-image/index.ts +3 -0
- package/src/plugins/ui-image/types.ts +4 -0
- package/src/plugins/wiki/Preview.vue +65 -0
- package/src/plugins/wiki/View.vue +342 -0
- package/src/plugins/wiki/definition.ts +25 -0
- package/src/plugins/wiki/helpers.ts +59 -0
- package/src/plugins/wiki/index.ts +52 -0
- package/src/router/guards.ts +61 -0
- package/src/router/index.ts +50 -0
- package/src/tools/index.ts +52 -0
- package/src/tools/types.ts +27 -0
- package/src/types/events.ts +16 -0
- package/src/types/fileTree.ts +13 -0
- package/src/types/notification.ts +67 -0
- package/src/types/session.ts +116 -0
- package/src/types/sse.ts +90 -0
- package/src/types/toolCallHistory.ts +13 -0
- package/src/utils/agent/eventDispatch.ts +74 -0
- package/src/utils/agent/request.ts +55 -0
- package/src/utils/agent/toolCalls.ts +62 -0
- package/src/utils/api.ts +218 -0
- package/src/utils/canvas/viewMode.ts +46 -0
- package/src/utils/dom/authTokenMeta.ts +20 -0
- package/src/utils/dom/clickOutside.ts +11 -0
- package/src/utils/dom/externalLink.ts +57 -0
- package/src/utils/dom/scrollable.ts +24 -0
- package/src/utils/errors.ts +11 -0
- package/src/utils/files/expandedDirs.ts +25 -0
- package/src/utils/files/filename.ts +12 -0
- package/src/utils/files/sortChildren.ts +20 -0
- package/src/utils/filesPreview/schedulerPreview.ts +38 -0
- package/src/utils/filesPreview/todoPreview.ts +40 -0
- package/src/utils/format/date.ts +85 -0
- package/src/utils/format/frontmatter.ts +80 -0
- package/src/utils/format/jsonSyntax.ts +109 -0
- package/src/utils/html/previewCsp.ts +65 -0
- package/src/utils/image/resolve.ts +8 -0
- package/src/utils/image/rewriteMarkdownImageRefs.ts +182 -0
- package/src/utils/markdown/extractFirstH1.ts +39 -0
- package/src/utils/notification/dispatch.ts +22 -0
- package/src/utils/path/relativeLink.ts +130 -0
- package/src/utils/role/icon.ts +20 -0
- package/src/utils/role/merge.ts +10 -0
- package/src/utils/role/plugins.ts +12 -0
- package/src/utils/session/mergeSessions.ts +103 -0
- package/src/utils/session/seedRoleDefault.ts +35 -0
- package/src/utils/session/sessionEntries.ts +121 -0
- package/src/utils/session/sessionFactory.ts +22 -0
- package/src/utils/session/sessionHelpers.ts +99 -0
- package/src/utils/tools/dedup.ts +17 -0
- package/src/utils/tools/mcp.ts +33 -0
- package/src/utils/tools/pendingCalls.ts +16 -0
- package/src/utils/tools/result.ts +40 -0
- package/src/utils/types.ts +44 -0
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="h-full flex flex-col">
|
|
3
|
+
<div v-if="isAssistant" class="flex justify-end px-4 py-2 border-b border-gray-100 shrink-0">
|
|
4
|
+
<div class="button-group">
|
|
5
|
+
<button class="download-btn download-btn-green" :disabled="pdfDownloading" @click="downloadPdf">
|
|
6
|
+
<span class="material-icons">{{ pdfDownloading ? "hourglass_empty" : "download" }}</span>
|
|
7
|
+
PDF
|
|
8
|
+
</button>
|
|
9
|
+
</div>
|
|
10
|
+
<span v-if="pdfError" class="text-xs text-red-500 self-center ml-2" :title="pdfError">⚠ PDF failed</span>
|
|
11
|
+
</div>
|
|
12
|
+
<div class="flex-1 overflow-hidden relative" @click.capture="openLinksInNewTab">
|
|
13
|
+
<div class="text-response-container">
|
|
14
|
+
<div class="text-response-content-wrapper">
|
|
15
|
+
<div class="p-6">
|
|
16
|
+
<div class="max-w-3xl mx-auto space-y-4">
|
|
17
|
+
<div class="rounded-lg border border-gray-300 bg-white shadow-sm p-5" :class="roleTheme">
|
|
18
|
+
<div class="flex justify-between items-start mb-2 text-sm text-gray-500">
|
|
19
|
+
<span class="font-medium text-gray-700">{{ speakerLabel }}</span>
|
|
20
|
+
<span v-if="transportKind" class="italic">{{ transportKind }}</span>
|
|
21
|
+
</div>
|
|
22
|
+
<div class="markdown-content prose prose-slate max-w-none leading-relaxed text-gray-900" v-html="renderedHtml"></div>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<!-- Collapsible Editor -->
|
|
29
|
+
<details v-if="editable" ref="detailsEl" class="text-response-source" data-testid="text-response-edit">
|
|
30
|
+
<summary data-testid="text-response-edit-summary">Edit Text Content</summary>
|
|
31
|
+
<textarea v-model="editedText" class="text-response-editor" spellcheck="false" data-testid="text-response-edit-textarea"></textarea>
|
|
32
|
+
<button class="apply-btn" :disabled="!hasChanges" data-testid="text-response-apply-btn" @click="applyChanges">Apply Changes</button>
|
|
33
|
+
</details>
|
|
34
|
+
</div>
|
|
35
|
+
<button v-show="!editing" class="copy-btn" :title="copied ? 'Copied!' : 'Copy'" @click="copyText">
|
|
36
|
+
<span class="material-icons">{{ copied ? "check" : "content_copy" }}</span>
|
|
37
|
+
</button>
|
|
38
|
+
<button v-show="editing" class="cancel-btn" @click="cancelEdit">Cancel</button>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
</template>
|
|
42
|
+
|
|
43
|
+
<script setup lang="ts">
|
|
44
|
+
import { ref, computed, watch, onMounted, onBeforeUnmount } from "vue";
|
|
45
|
+
import { marked } from "marked";
|
|
46
|
+
import type { ToolResult, ToolResultComplete } from "gui-chat-protocol/vue";
|
|
47
|
+
import type { TextResponseData } from "./types";
|
|
48
|
+
import { handleExternalLinkClick } from "../../utils/dom/externalLink";
|
|
49
|
+
import { usePdfDownload } from "../../composables/usePdfDownload";
|
|
50
|
+
import { useClipboardCopy } from "../../composables/useClipboardCopy";
|
|
51
|
+
|
|
52
|
+
const props = withDefaults(
|
|
53
|
+
defineProps<{
|
|
54
|
+
selectedResult: ToolResultComplete<TextResponseData>;
|
|
55
|
+
editable?: boolean;
|
|
56
|
+
// When set, the editor textarea edits this string instead of the
|
|
57
|
+
// displayed `data.text`. FilesView uses it to feed the editor the
|
|
58
|
+
// raw on-disk source (with frontmatter intact, no image-URL
|
|
59
|
+
// rewriting) while the rendered pane keeps showing the cleaned-up
|
|
60
|
+
// display text. Callers listen for `updateSource` to receive the
|
|
61
|
+
// edited source and handle persistence themselves.
|
|
62
|
+
editableSource?: string;
|
|
63
|
+
}>(),
|
|
64
|
+
{ editable: true, editableSource: undefined },
|
|
65
|
+
);
|
|
66
|
+
const emit = defineEmits<{
|
|
67
|
+
updateResult: [result: ToolResult];
|
|
68
|
+
updateSource: [source: string];
|
|
69
|
+
}>();
|
|
70
|
+
|
|
71
|
+
// --- Data & computed from upstream View ---
|
|
72
|
+
|
|
73
|
+
const messageText = computed(() => props.selectedResult.data?.text ?? "");
|
|
74
|
+
// Source fed into the editor. When the parent passes `editableSource`
|
|
75
|
+
// it wins; otherwise we edit the displayed text, matching the
|
|
76
|
+
// component's original (chat-message) behaviour.
|
|
77
|
+
const editorSource = computed(() => (props.editableSource !== undefined ? props.editableSource : messageText.value));
|
|
78
|
+
const editedText = ref(editorSource.value);
|
|
79
|
+
|
|
80
|
+
watch(editorSource, (next) => {
|
|
81
|
+
editedText.value = next;
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const messageRole = computed(() => props.selectedResult.data?.role ?? "assistant");
|
|
85
|
+
const transportKind = computed(() => props.selectedResult.data?.transportKind ?? "");
|
|
86
|
+
|
|
87
|
+
const renderedHtml = computed(() => {
|
|
88
|
+
if (!messageText.value) return "";
|
|
89
|
+
|
|
90
|
+
let processedText = messageText.value;
|
|
91
|
+
|
|
92
|
+
// Detect and wrap JSON content in code fences
|
|
93
|
+
const trimmedText = processedText.trim();
|
|
94
|
+
if ((trimmedText.startsWith("{") && trimmedText.endsWith("}")) || (trimmedText.startsWith("[") && trimmedText.endsWith("]"))) {
|
|
95
|
+
try {
|
|
96
|
+
JSON.parse(trimmedText);
|
|
97
|
+
processedText = "```json\n" + trimmedText + "\n```";
|
|
98
|
+
} catch {
|
|
99
|
+
// Not valid JSON, continue with original text
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Process <think> blocks to make them grey
|
|
104
|
+
processedText = processedText.replace(/<think>([\s\S]*?)<\/think>/g, (_, content) => {
|
|
105
|
+
const thinkContent = marked(content.trim());
|
|
106
|
+
return `<div class="think-block">${thinkContent}</div>`;
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
return marked(processedText, { breaks: true, gfm: true });
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const speakerLabel = computed(() => {
|
|
113
|
+
switch (messageRole.value) {
|
|
114
|
+
case "system":
|
|
115
|
+
return "System";
|
|
116
|
+
case "user":
|
|
117
|
+
return "You";
|
|
118
|
+
default:
|
|
119
|
+
return "Assistant";
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
const roleTheme = computed(() => {
|
|
124
|
+
switch (messageRole.value) {
|
|
125
|
+
case "system":
|
|
126
|
+
return "bg-blue-50 border-blue-200";
|
|
127
|
+
case "user":
|
|
128
|
+
return "bg-green-50 border-green-200";
|
|
129
|
+
default:
|
|
130
|
+
return "bg-purple-50 border-purple-200";
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const hasChanges = computed(() => editedText.value !== editorSource.value);
|
|
135
|
+
|
|
136
|
+
function applyChanges() {
|
|
137
|
+
if (!hasChanges.value) return;
|
|
138
|
+
|
|
139
|
+
if (props.editableSource !== undefined) {
|
|
140
|
+
// Source-editing mode: hand the edited string to the parent and
|
|
141
|
+
// let it decide how to persist. The component's own `data.text`
|
|
142
|
+
// isn't touched — the parent will re-supply `editableSource` after
|
|
143
|
+
// the save round-trip.
|
|
144
|
+
emit("updateSource", editedText.value);
|
|
145
|
+
} else {
|
|
146
|
+
const updatedResult: ToolResult = {
|
|
147
|
+
...props.selectedResult,
|
|
148
|
+
data: {
|
|
149
|
+
...props.selectedResult.data,
|
|
150
|
+
text: editedText.value,
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
emit("updateResult", updatedResult);
|
|
154
|
+
}
|
|
155
|
+
if (detailsEl.value) detailsEl.value.open = false;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// --- Local customizations: PDF, copy, edit toggle, external links ---
|
|
159
|
+
|
|
160
|
+
const isAssistant = computed(() => (props.selectedResult.data?.role ?? "assistant") === "assistant");
|
|
161
|
+
|
|
162
|
+
function openLinksInNewTab(event: MouseEvent): void {
|
|
163
|
+
handleExternalLinkClick(event);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const { pdfDownloading, pdfError, downloadPdf: rawDownloadPdf } = usePdfDownload();
|
|
167
|
+
|
|
168
|
+
const detailsEl = ref<HTMLDetailsElement>();
|
|
169
|
+
const editing = ref(false);
|
|
170
|
+
|
|
171
|
+
function onDetailsToggle(e: Event) {
|
|
172
|
+
editing.value = (e.target as HTMLDetailsElement).open;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
onMounted(() => {
|
|
176
|
+
detailsEl.value?.addEventListener("toggle", onDetailsToggle);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
onBeforeUnmount(() => {
|
|
180
|
+
detailsEl.value?.removeEventListener("toggle", onDetailsToggle);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
function cancelEdit() {
|
|
184
|
+
if (detailsEl.value) detailsEl.value.open = false;
|
|
185
|
+
// Reset edited text to whatever the editor started with — in
|
|
186
|
+
// source-editing mode that's the raw source, otherwise the display
|
|
187
|
+
// text. Using the computed `editorSource` keeps both paths correct.
|
|
188
|
+
editedText.value = editorSource.value;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const { copied, copy } = useClipboardCopy();
|
|
192
|
+
|
|
193
|
+
async function copyText() {
|
|
194
|
+
await copy(props.selectedResult.data?.text ?? "");
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
async function downloadPdf() {
|
|
198
|
+
const text = props.selectedResult.data?.text ?? "";
|
|
199
|
+
const filename = `${props.selectedResult.title ?? "response"}.pdf`;
|
|
200
|
+
await rawDownloadPdf(text, filename);
|
|
201
|
+
}
|
|
202
|
+
</script>
|
|
203
|
+
|
|
204
|
+
<style scoped>
|
|
205
|
+
.markdown-content :deep(h1) {
|
|
206
|
+
font-size: 2rem;
|
|
207
|
+
font-weight: bold;
|
|
208
|
+
margin-top: 1em;
|
|
209
|
+
margin-bottom: 0.5em;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.markdown-content :deep(h2) {
|
|
213
|
+
font-size: 1.75rem;
|
|
214
|
+
font-weight: bold;
|
|
215
|
+
margin-top: 1em;
|
|
216
|
+
margin-bottom: 0.5em;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.markdown-content :deep(h3) {
|
|
220
|
+
font-size: 1.5rem;
|
|
221
|
+
font-weight: bold;
|
|
222
|
+
margin-top: 1em;
|
|
223
|
+
margin-bottom: 0.5em;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.markdown-content :deep(h4) {
|
|
227
|
+
font-size: 1.25rem;
|
|
228
|
+
font-weight: bold;
|
|
229
|
+
margin-top: 1em;
|
|
230
|
+
margin-bottom: 0.5em;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.markdown-content :deep(h5) {
|
|
234
|
+
font-size: 1.125rem;
|
|
235
|
+
font-weight: bold;
|
|
236
|
+
margin-top: 1em;
|
|
237
|
+
margin-bottom: 0.5em;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.markdown-content :deep(h6) {
|
|
241
|
+
font-size: 1rem;
|
|
242
|
+
font-weight: bold;
|
|
243
|
+
margin-top: 1em;
|
|
244
|
+
margin-bottom: 0.5em;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.markdown-content :deep(p) {
|
|
248
|
+
margin-bottom: 1em;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.markdown-content :deep(ul),
|
|
252
|
+
.markdown-content :deep(ol) {
|
|
253
|
+
margin-left: 1.5em;
|
|
254
|
+
margin-bottom: 1em;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.markdown-content :deep(li) {
|
|
258
|
+
margin-bottom: 0.5em;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.markdown-content :deep(code) {
|
|
262
|
+
background-color: #f5f5f5;
|
|
263
|
+
padding: 0.2em 0.4em;
|
|
264
|
+
border-radius: 3px;
|
|
265
|
+
font-family: monospace;
|
|
266
|
+
font-size: 0.9em;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.markdown-content :deep(pre) {
|
|
270
|
+
background-color: #f5f5f5;
|
|
271
|
+
padding: 1em;
|
|
272
|
+
border-radius: 4px;
|
|
273
|
+
overflow-x: auto;
|
|
274
|
+
margin-bottom: 1em;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.markdown-content :deep(pre code) {
|
|
278
|
+
background-color: transparent;
|
|
279
|
+
padding: 0;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.markdown-content :deep(blockquote) {
|
|
283
|
+
border-left: 4px solid #ddd;
|
|
284
|
+
padding-left: 1em;
|
|
285
|
+
color: #666;
|
|
286
|
+
margin: 1em 0;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.markdown-content :deep(a) {
|
|
290
|
+
color: #2563eb;
|
|
291
|
+
text-decoration: underline;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.markdown-content :deep(a:hover) {
|
|
295
|
+
color: #1d4ed8;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.markdown-content :deep(table) {
|
|
299
|
+
border-collapse: collapse;
|
|
300
|
+
width: 100%;
|
|
301
|
+
margin-bottom: 1em;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.markdown-content :deep(th),
|
|
305
|
+
.markdown-content :deep(td) {
|
|
306
|
+
border: 1px solid #ddd;
|
|
307
|
+
padding: 0.5em;
|
|
308
|
+
text-align: left;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.markdown-content :deep(th) {
|
|
312
|
+
background-color: #f5f5f5;
|
|
313
|
+
font-weight: bold;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.markdown-content :deep(hr) {
|
|
317
|
+
border: none;
|
|
318
|
+
border-top: 1px solid #ddd;
|
|
319
|
+
margin: 1.5em 0;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.markdown-content :deep(.think-block) {
|
|
323
|
+
color: #6b7280;
|
|
324
|
+
background-color: #f9fafb;
|
|
325
|
+
border-left: 3px solid #d1d5db;
|
|
326
|
+
padding: 0.75em 1em;
|
|
327
|
+
margin: 1em 0;
|
|
328
|
+
border-radius: 4px;
|
|
329
|
+
font-style: italic;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
.markdown-content :deep(.think-block p) {
|
|
333
|
+
color: #6b7280;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
.markdown-content :deep(.think-block code) {
|
|
337
|
+
background-color: #e5e7eb;
|
|
338
|
+
color: #4b5563;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/* Container styles */
|
|
342
|
+
.text-response-container {
|
|
343
|
+
display: flex;
|
|
344
|
+
flex-direction: column;
|
|
345
|
+
height: 100%;
|
|
346
|
+
overflow: hidden;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.text-response-content-wrapper {
|
|
350
|
+
flex: 1;
|
|
351
|
+
overflow-y: auto;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/* Editor panel styles */
|
|
355
|
+
.text-response-source {
|
|
356
|
+
padding: 0.5rem;
|
|
357
|
+
background: #f5f5f5;
|
|
358
|
+
border-top: 1px solid #e0e0e0;
|
|
359
|
+
font-family: monospace;
|
|
360
|
+
font-size: 0.85rem;
|
|
361
|
+
flex-shrink: 0;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
.text-response-source summary {
|
|
365
|
+
cursor: pointer;
|
|
366
|
+
user-select: none;
|
|
367
|
+
padding: 0.5rem;
|
|
368
|
+
background: #e8e8e8;
|
|
369
|
+
border-radius: 4px;
|
|
370
|
+
font-weight: 500;
|
|
371
|
+
color: #333;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
.text-response-source[open] summary {
|
|
375
|
+
margin-bottom: 0.5rem;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
.text-response-source summary:hover {
|
|
379
|
+
background: #d8d8d8;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
.text-response-editor {
|
|
383
|
+
width: 100%;
|
|
384
|
+
height: 40vh;
|
|
385
|
+
padding: 1rem;
|
|
386
|
+
background: #ffffff;
|
|
387
|
+
border: 1px solid #ccc;
|
|
388
|
+
border-radius: 4px;
|
|
389
|
+
color: #333;
|
|
390
|
+
font-family: "Courier New", monospace;
|
|
391
|
+
font-size: 0.9rem;
|
|
392
|
+
resize: vertical;
|
|
393
|
+
margin-bottom: 0.5rem;
|
|
394
|
+
line-height: 1.5;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
.text-response-editor:focus {
|
|
398
|
+
outline: none;
|
|
399
|
+
border-color: #4caf50;
|
|
400
|
+
box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
.apply-btn {
|
|
404
|
+
padding: 0.5rem 1rem;
|
|
405
|
+
background: #4caf50;
|
|
406
|
+
color: white;
|
|
407
|
+
border: none;
|
|
408
|
+
border-radius: 4px;
|
|
409
|
+
cursor: pointer;
|
|
410
|
+
font-size: 0.9rem;
|
|
411
|
+
transition: background 0.2s;
|
|
412
|
+
font-weight: 500;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
.apply-btn:hover {
|
|
416
|
+
background: #45a049;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
.apply-btn:active {
|
|
420
|
+
background: #3d8b40;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
.apply-btn:disabled {
|
|
424
|
+
background: #cccccc;
|
|
425
|
+
color: #666666;
|
|
426
|
+
cursor: not-allowed;
|
|
427
|
+
opacity: 0.6;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
.apply-btn:disabled:hover {
|
|
431
|
+
background: #cccccc;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/* Toolbar button styles */
|
|
435
|
+
.button-group {
|
|
436
|
+
display: flex;
|
|
437
|
+
gap: 0.5em;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
.download-btn {
|
|
441
|
+
padding: 0.5em 1em;
|
|
442
|
+
color: white;
|
|
443
|
+
border: none;
|
|
444
|
+
border-radius: 4px;
|
|
445
|
+
cursor: pointer;
|
|
446
|
+
font-size: 0.9em;
|
|
447
|
+
display: flex;
|
|
448
|
+
align-items: center;
|
|
449
|
+
gap: 0.5em;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
.download-btn-green {
|
|
453
|
+
background-color: #4caf50;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
.download-btn .material-icons {
|
|
457
|
+
font-size: 1.2em;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
.download-btn:disabled {
|
|
461
|
+
opacity: 0.6;
|
|
462
|
+
cursor: not-allowed;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
.copy-btn {
|
|
466
|
+
position: absolute;
|
|
467
|
+
bottom: 0.3rem;
|
|
468
|
+
right: 0.65rem;
|
|
469
|
+
padding: 0.4rem;
|
|
470
|
+
background: none;
|
|
471
|
+
border: none;
|
|
472
|
+
color: #333;
|
|
473
|
+
cursor: pointer;
|
|
474
|
+
z-index: 1;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
.copy-btn:hover {
|
|
478
|
+
color: #000;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
.copy-btn .material-icons {
|
|
482
|
+
font-size: 1.15rem;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
.cancel-btn {
|
|
486
|
+
position: absolute;
|
|
487
|
+
bottom: 0.5rem;
|
|
488
|
+
right: 0.65rem;
|
|
489
|
+
padding: 0.5rem 1rem;
|
|
490
|
+
background: #e0e0e0;
|
|
491
|
+
color: #333;
|
|
492
|
+
border: none;
|
|
493
|
+
border-radius: 4px;
|
|
494
|
+
cursor: pointer;
|
|
495
|
+
font-size: 0.9rem;
|
|
496
|
+
font-weight: 500;
|
|
497
|
+
z-index: 1;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
.cancel-btn:hover {
|
|
501
|
+
background: #d0d0d0;
|
|
502
|
+
}
|
|
503
|
+
</style>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text Response Plugin - Tool Definition
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { ToolDefinition } from "gui-chat-protocol";
|
|
6
|
+
|
|
7
|
+
export const TOOL_NAME = "text-response";
|
|
8
|
+
|
|
9
|
+
export const TOOL_DEFINITION: ToolDefinition = {
|
|
10
|
+
type: "function",
|
|
11
|
+
name: TOOL_NAME,
|
|
12
|
+
description: "Render plain text content from the assistant.",
|
|
13
|
+
parameters: {
|
|
14
|
+
type: "object",
|
|
15
|
+
properties: {
|
|
16
|
+
text: {
|
|
17
|
+
type: "string",
|
|
18
|
+
description: "Plain text content to display to the user.",
|
|
19
|
+
},
|
|
20
|
+
role: {
|
|
21
|
+
type: "string",
|
|
22
|
+
enum: ["assistant", "system", "user"],
|
|
23
|
+
description: "Speaker role of the message.",
|
|
24
|
+
},
|
|
25
|
+
transportKind: {
|
|
26
|
+
type: "string",
|
|
27
|
+
description: "Identifier for the transport or provider that produced the message.",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
required: ["text"],
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const SYSTEM_PROMPT = "";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text Response Plugin - Vue Implementation
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { ToolPlugin } from "gui-chat-protocol/vue";
|
|
6
|
+
import type { TextResponseData, TextResponseArgs } from "./types";
|
|
7
|
+
import { pluginCore } from "./plugin";
|
|
8
|
+
import { samples } from "./samples";
|
|
9
|
+
import View from "./View.vue";
|
|
10
|
+
import Preview from "./Preview.vue";
|
|
11
|
+
|
|
12
|
+
export const plugin: ToolPlugin<TextResponseData, unknown, TextResponseArgs> = {
|
|
13
|
+
...pluginCore,
|
|
14
|
+
viewComponent: View,
|
|
15
|
+
previewComponent: Preview,
|
|
16
|
+
samples,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type { TextResponseData, TextResponseArgs } from "./types";
|
|
20
|
+
|
|
21
|
+
export { TOOL_NAME, TOOL_DEFINITION, SYSTEM_PROMPT, executeTextResponse, pluginCore } from "./plugin";
|
|
22
|
+
|
|
23
|
+
export { samples } from "./samples";
|
|
24
|
+
|
|
25
|
+
export { View, Preview };
|
|
26
|
+
|
|
27
|
+
export default { plugin };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text Response Plugin Core
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { ToolPluginCore, ToolContext, ToolResult } from "gui-chat-protocol";
|
|
6
|
+
import type { TextResponseData, TextResponseArgs } from "./types";
|
|
7
|
+
import { TOOL_DEFINITION, SYSTEM_PROMPT } from "./definition";
|
|
8
|
+
|
|
9
|
+
export { TOOL_NAME, TOOL_DEFINITION, SYSTEM_PROMPT } from "./definition";
|
|
10
|
+
|
|
11
|
+
export const executeTextResponse = async (_context: ToolContext, args: TextResponseArgs): Promise<ToolResult<TextResponseData, unknown>> => {
|
|
12
|
+
return {
|
|
13
|
+
data: {
|
|
14
|
+
text: args.text,
|
|
15
|
+
role: args.role,
|
|
16
|
+
transportKind: args.transportKind,
|
|
17
|
+
},
|
|
18
|
+
message: args.text,
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const pluginCore: ToolPluginCore<TextResponseData, unknown, TextResponseArgs> = {
|
|
23
|
+
toolDefinition: TOOL_DEFINITION,
|
|
24
|
+
execute: executeTextResponse,
|
|
25
|
+
generatingMessage: "Processing...",
|
|
26
|
+
// Never advertise this pseudo tool to the LLM; only the client uses it.
|
|
27
|
+
isEnabled: () => false,
|
|
28
|
+
systemPrompt: SYSTEM_PROMPT,
|
|
29
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text Response Plugin - Samples
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { ToolSample } from "gui-chat-protocol";
|
|
6
|
+
|
|
7
|
+
export const samples: ToolSample[] = [
|
|
8
|
+
{
|
|
9
|
+
name: "Simple Text",
|
|
10
|
+
args: {
|
|
11
|
+
text: "Hello, this is a simple text response from the assistant.",
|
|
12
|
+
role: "assistant",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: "System Message",
|
|
17
|
+
args: {
|
|
18
|
+
text: "System: Configuration has been updated successfully.",
|
|
19
|
+
role: "system",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: "User Message",
|
|
24
|
+
args: {
|
|
25
|
+
text: "User: What is the weather like today?",
|
|
26
|
+
role: "user",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "Markdown Content",
|
|
31
|
+
args: {
|
|
32
|
+
text: `# Markdown Example
|
|
33
|
+
|
|
34
|
+
This demonstrates **bold** and *italic* text.
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
- List item 1
|
|
38
|
+
- List item 2
|
|
39
|
+
- List item 3
|
|
40
|
+
|
|
41
|
+
### Code Example
|
|
42
|
+
\`\`\`javascript
|
|
43
|
+
function hello() {
|
|
44
|
+
console.log("Hello, World!");
|
|
45
|
+
}
|
|
46
|
+
\`\`\`
|
|
47
|
+
|
|
48
|
+
> This is a blockquote with important information.
|
|
49
|
+
|
|
50
|
+
| Column A | Column B |
|
|
51
|
+
|----------|----------|
|
|
52
|
+
| Data 1 | Data 2 |
|
|
53
|
+
| Data 3 | Data 4 |
|
|
54
|
+
`,
|
|
55
|
+
role: "assistant",
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "JSON Data",
|
|
60
|
+
args: {
|
|
61
|
+
text: JSON.stringify(
|
|
62
|
+
{
|
|
63
|
+
name: "Example",
|
|
64
|
+
version: "1.0.0",
|
|
65
|
+
features: ["markdown", "json", "roles"],
|
|
66
|
+
},
|
|
67
|
+
null,
|
|
68
|
+
2,
|
|
69
|
+
),
|
|
70
|
+
role: "assistant",
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "Think Block",
|
|
75
|
+
args: {
|
|
76
|
+
text: `Let me analyze this problem.
|
|
77
|
+
|
|
78
|
+
<think>
|
|
79
|
+
First, I need to consider the requirements:
|
|
80
|
+
1. The solution should be efficient
|
|
81
|
+
2. It must handle edge cases
|
|
82
|
+
3. Code should be readable
|
|
83
|
+
</think>
|
|
84
|
+
|
|
85
|
+
Based on my analysis, here's my recommendation...`,
|
|
86
|
+
role: "assistant",
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "With Transport",
|
|
91
|
+
args: {
|
|
92
|
+
text: "This response came from a specific transport provider.",
|
|
93
|
+
role: "assistant",
|
|
94
|
+
transportKind: "openai-realtime",
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
];
|