orcheo-studio 0.21.1
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/.bumpversion.cfg +14 -0
- package/.eslintrc +1 -0
- package/CHANGELOG.md +32 -0
- package/README.md +60 -0
- package/bin/orcheo-studio.js +39 -0
- package/components.json +21 -0
- package/dist/assets/arc-BbeTokFd.js +1 -0
- package/dist/assets/architectureDiagram-VXUJARFQ-CN00R9LC.js +36 -0
- package/dist/assets/avatar-01-CIAd4XAq.svg +1 -0
- package/dist/assets/avatar-02-BkgLJWQZ.svg +1 -0
- package/dist/assets/avatar-03-DVVcnD3b.svg +1 -0
- package/dist/assets/avatar-04-ydqFTDdh.svg +1 -0
- package/dist/assets/avatar-05-CSIhgJow.svg +1 -0
- package/dist/assets/avatar-06-B-h1Nz9Y.svg +1 -0
- package/dist/assets/avatar-07-BgkDZuBW.svg +1 -0
- package/dist/assets/avatar-08-C5KZjVH6.svg +1 -0
- package/dist/assets/avatar-09-2EGeSlPh.svg +1 -0
- package/dist/assets/avatar-10-DRf4ZGD2.svg +1 -0
- package/dist/assets/avatar-11-CEzBCpib.svg +1 -0
- package/dist/assets/avatar-12-COVngNEy.svg +1 -0
- package/dist/assets/avatar-13-D1i1tZVO.svg +1 -0
- package/dist/assets/avatar-14-B68CNAEs.svg +1 -0
- package/dist/assets/avatar-15-B9NsRNUX.svg +1 -0
- package/dist/assets/avatar-16-DQ_JJRGR.svg +1 -0
- package/dist/assets/avatar-17-DfDJkGv5.svg +1 -0
- package/dist/assets/avatar-18-BuxiqOaJ.svg +1 -0
- package/dist/assets/avatar-19-C2mJfrwW.svg +1 -0
- package/dist/assets/avatar-20-DPE_yE1a.svg +1 -0
- package/dist/assets/avatar-21-DbB0Lj6t.svg +1 -0
- package/dist/assets/blockDiagram-VD42YOAC-BPpieIRz.js +122 -0
- package/dist/assets/c4Diagram-YG6GDRKO-DAhuY1fj.js +10 -0
- package/dist/assets/channel-DtVQHWfl.js +1 -0
- package/dist/assets/chunk-4BX2VUAB-7RJQCroR.js +1 -0
- package/dist/assets/chunk-55IACEB6-CEN5yOA_.js +1 -0
- package/dist/assets/chunk-B4BG7PRW-vdlAz_3Q.js +165 -0
- package/dist/assets/chunk-DI55MBZ5-BTmKjGVg.js +220 -0
- package/dist/assets/chunk-FMBD7UC4-CwWvFfrg.js +15 -0
- package/dist/assets/chunk-QN33PNHL-XH90lUUN.js +1 -0
- package/dist/assets/chunk-QZHKN3VN-DMoMVES0.js +1 -0
- package/dist/assets/chunk-TZMSLE5B-Bx2XTXDY.js +1 -0
- package/dist/assets/classDiagram-2ON5EDUG-pw6P8q-u.js +1 -0
- package/dist/assets/classDiagram-v2-WZHVMYZB-pw6P8q-u.js +1 -0
- package/dist/assets/clone-DJq6GzHg.js +1 -0
- package/dist/assets/cose-bilkent-S5V4N54A-DS1MNwZB.js +1 -0
- package/dist/assets/cytoscape.esm-BQaXIfA_.js +331 -0
- package/dist/assets/dagre-6UL2VRFP-DdklXSXB.js +4 -0
- package/dist/assets/defaultLocale-C4B-KCzX.js +1 -0
- package/dist/assets/diagram-PSM6KHXK-BKBo8pqg.js +24 -0
- package/dist/assets/diagram-QEK2KX5R-DaavZhFO.js +43 -0
- package/dist/assets/diagram-S2PKOQOG-DkTwknYd.js +24 -0
- package/dist/assets/erDiagram-Q2GNP2WA-ClR5qEsI.js +60 -0
- package/dist/assets/flowDiagram-NV44I4VS-Cxt_sJHB.js +162 -0
- package/dist/assets/ganttDiagram-JELNMOA3-CIbs3JPJ.js +267 -0
- package/dist/assets/gitGraphDiagram-V2S2FVAM-DmqLh_uo.js +65 -0
- package/dist/assets/graph-zo28rS-a.js +1 -0
- package/dist/assets/index-B0_h2wCA.css +1 -0
- package/dist/assets/index-Be29_rJf.js +775 -0
- package/dist/assets/infoDiagram-HS3SLOUP-D9_rMkAf.js +2 -0
- package/dist/assets/init-Gi6I4Gst.js +1 -0
- package/dist/assets/isUndefined-C59bc74c.js +1 -0
- package/dist/assets/journeyDiagram-XKPGCS4Q-4ZuggLXE.js +139 -0
- package/dist/assets/kanban-definition-3W4ZIXB7-BQDNrhHL.js +89 -0
- package/dist/assets/katex-CBSAILhF.js +261 -0
- package/dist/assets/layout-CXbNm-Yo.js +1 -0
- package/dist/assets/linear-DQWATg1F.js +1 -0
- package/dist/assets/min-DJjRzMm8.js +1 -0
- package/dist/assets/mindmap-definition-VGOIOE7T-DiZQmsHT.js +68 -0
- package/dist/assets/ordinal-Cboi1Yqb.js +1 -0
- package/dist/assets/pieDiagram-ADFJNKIX-Bkju7jCD.js +30 -0
- package/dist/assets/quadrantDiagram-AYHSOK5B-CIB47UvU.js +7 -0
- package/dist/assets/requirementDiagram-UZGBJVZJ-BSB3uACk.js +64 -0
- package/dist/assets/sankeyDiagram-TZEHDZUN-rB8wD2kd.js +10 -0
- package/dist/assets/sequenceDiagram-WL72ISMW-Cd9s3Q_1.js +145 -0
- package/dist/assets/stateDiagram-FKZM4ZOC-zAxtjcM9.js +1 -0
- package/dist/assets/stateDiagram-v2-4FDKWEC3-C4DctH65.js +1 -0
- package/dist/assets/timeline-definition-IT6M3QCI-Et89F1F3.js +61 -0
- package/dist/assets/treemap-GDKQZRPO-6mZVX2Gv.js +162 -0
- package/dist/assets/xychartDiagram-PRI3JC2R-CgyY8dNz.js +7 -0
- package/dist/favicon.ico +0 -0
- package/dist/index.html +19 -0
- package/dist/robots.txt +2 -0
- package/eslint.config.js +49 -0
- package/index.html +18 -0
- package/package.json +183 -0
- package/postcss.config.js +6 -0
- package/public/favicon.ico +0 -0
- package/public/robots.txt +2 -0
- package/src/App.tsx +115 -0
- package/src/assets/avatars/avatar-01.svg +1 -0
- package/src/assets/avatars/avatar-02.svg +1 -0
- package/src/assets/avatars/avatar-03.svg +1 -0
- package/src/assets/avatars/avatar-04.svg +1 -0
- package/src/assets/avatars/avatar-05.svg +1 -0
- package/src/assets/avatars/avatar-06.svg +1 -0
- package/src/assets/avatars/avatar-07.svg +1 -0
- package/src/assets/avatars/avatar-08.svg +1 -0
- package/src/assets/avatars/avatar-09.svg +1 -0
- package/src/assets/avatars/avatar-10.svg +1 -0
- package/src/assets/avatars/avatar-11.svg +1 -0
- package/src/assets/avatars/avatar-12.svg +1 -0
- package/src/assets/avatars/avatar-13.svg +1 -0
- package/src/assets/avatars/avatar-14.svg +1 -0
- package/src/assets/avatars/avatar-15.svg +1 -0
- package/src/assets/avatars/avatar-16.svg +1 -0
- package/src/assets/avatars/avatar-17.svg +1 -0
- package/src/assets/avatars/avatar-18.svg +1 -0
- package/src/assets/avatars/avatar-19.svg +1 -0
- package/src/assets/avatars/avatar-20.svg +1 -0
- package/src/assets/avatars/avatar-21.svg +1 -0
- package/src/assets/avatars/index.ts +99 -0
- package/src/design-system/ui/alert-dialog.tsx +141 -0
- package/src/design-system/ui/alert.tsx +59 -0
- package/src/design-system/ui/avatar.tsx +51 -0
- package/src/design-system/ui/badge.tsx +38 -0
- package/src/design-system/ui/button.tsx +59 -0
- package/src/design-system/ui/card.tsx +83 -0
- package/src/design-system/ui/dialog.tsx +122 -0
- package/src/design-system/ui/dropdown-menu.tsx +201 -0
- package/src/design-system/ui/input.tsx +22 -0
- package/src/design-system/ui/label.tsx +26 -0
- package/src/design-system/ui/scroll-area.tsx +48 -0
- package/src/design-system/ui/select.tsx +159 -0
- package/src/design-system/ui/separator.tsx +31 -0
- package/src/design-system/ui/sheet.tsx +141 -0
- package/src/design-system/ui/skeleton.tsx +15 -0
- package/src/design-system/ui/switch.tsx +29 -0
- package/src/design-system/ui/table.tsx +120 -0
- package/src/design-system/ui/tabs.tsx +55 -0
- package/src/design-system/ui/textarea.tsx +22 -0
- package/src/design-system/ui/toast.tsx +132 -0
- package/src/design-system/ui/toaster.tsx +35 -0
- package/src/design-system/ui/toggle-group.tsx +61 -0
- package/src/design-system/ui/toggle.tsx +46 -0
- package/src/design-system/ui/tooltip.tsx +32 -0
- package/src/features/MODULES.md +199 -0
- package/src/features/account/components/settings/appearance-settings-tab.tsx +24 -0
- package/src/features/account/components/theme-settings.tsx +70 -0
- package/src/features/account/components/use-theme-preferences.ts +106 -0
- package/src/features/account/pages/profile/components/profile-general-tab.tsx +89 -0
- package/src/features/account/pages/profile/types.ts +7 -0
- package/src/features/account/pages/profile.tsx +71 -0
- package/src/features/account/pages/service-tokens.tsx +522 -0
- package/src/features/account/pages/settings.tsx +42 -0
- package/src/features/account/pages/workspace-management.tsx +63 -0
- package/src/features/account/pages/workspace-members.tsx +335 -0
- package/src/features/auth/components/auto-login.tsx +51 -0
- package/src/features/auth/components/require-auth.tsx +56 -0
- package/src/features/auth/lib/auth-session.ts +448 -0
- package/src/features/auth/lib/oidc-client.ts +565 -0
- package/src/features/auth/pages/login.tsx +24 -0
- package/src/features/auth/pages/oauth-callback.tsx +63 -0
- package/src/features/chatkit/components/chatkit-surface.tsx +60 -0
- package/src/features/chatkit/components/public-chat-config.ts +70 -0
- package/src/features/chatkit/components/public-chat-error-boundary.tsx +74 -0
- package/src/features/chatkit/components/public-chat-widget.tsx +150 -0
- package/src/features/chatkit/components/studio-chat-bubble.tsx +451 -0
- package/src/features/chatkit/lib/chatkit-attachments.ts +31 -0
- package/src/features/chatkit/lib/chatkit-client.ts +195 -0
- package/src/features/chatkit/lib/chatkit-theme.ts +20 -0
- package/src/features/chatkit/lib/telemetry.ts +29 -0
- package/src/features/chatkit/lib/workflow-session.ts +70 -0
- package/src/features/chatkit/pages/public-chat.tsx +445 -0
- package/src/features/shared/components/chat-interface-options.ts +325 -0
- package/src/features/shared/components/chat-interface.types.ts +47 -0
- package/src/features/shared/components/top-navigation/account-menu.tsx +172 -0
- package/src/features/shared/components/top-navigation/active-workspace-indicator.tsx +280 -0
- package/src/features/shared/components/top-navigation/studio-brand.tsx +59 -0
- package/src/features/shared/components/top-navigation/top-navigation-types.ts +22 -0
- package/src/features/shared/components/top-navigation/version-status.tsx +280 -0
- package/src/features/shared/components/top-navigation.tsx +42 -0
- package/src/features/shared/components/workspace-bootstrap-gate.tsx +235 -0
- package/src/features/workflow/components/dialogs/add-credential-dialog.tsx +245 -0
- package/src/features/workflow/components/dialogs/confirm-delete-workflow-dialog.tsx +52 -0
- package/src/features/workflow/components/dialogs/credential-access-badge.tsx +34 -0
- package/src/features/workflow/components/dialogs/credential-status-badge.tsx +45 -0
- package/src/features/workflow/components/dialogs/credentials-table.tsx +453 -0
- package/src/features/workflow/components/dialogs/credentials-vault.tsx +85 -0
- package/src/features/workflow/components/dialogs/edit-credential-dialog.tsx +264 -0
- package/src/features/workflow/components/dialogs/update-workflow-dialog.tsx +214 -0
- package/src/features/workflow/components/dialogs/upload-workflow-dialog.tsx +288 -0
- package/src/features/workflow/components/forms/schema-config-form.tsx +41 -0
- package/src/features/workflow/components/layouts/sidebar-layout.tsx +288 -0
- package/src/features/workflow/components/layouts/use-sidebar-resize.ts +164 -0
- package/src/features/workflow/components/layouts/workflow-page-layout.tsx +69 -0
- package/src/features/workflow/components/panels/json-object-field.tsx +138 -0
- package/src/features/workflow/components/panels/rjsf-basic-widgets.tsx +21 -0
- package/src/features/workflow/components/panels/rjsf-input-widgets.tsx +105 -0
- package/src/features/workflow/components/panels/rjsf-templates.tsx +147 -0
- package/src/features/workflow/components/panels/rjsf-text-widgets.tsx +139 -0
- package/src/features/workflow/components/panels/rjsf-theme.tsx +10 -0
- package/src/features/workflow/components/panels/schema-dnd.ts +79 -0
- package/src/features/workflow/components/panels/workflow-diff-dialog.tsx +207 -0
- package/src/features/workflow/components/panels/workflow-history-filters.tsx +62 -0
- package/src/features/workflow/components/panels/workflow-history-footer.tsx +28 -0
- package/src/features/workflow/components/panels/workflow-history-header.tsx +47 -0
- package/src/features/workflow/components/panels/workflow-history-table.tsx +148 -0
- package/src/features/workflow/components/panels/workflow-history.tsx +150 -0
- package/src/features/workflow/components/panels/workflow-tabs.tsx +29 -0
- package/src/features/workflow/components/trace/agent-prism/Avatar.tsx +146 -0
- package/src/features/workflow/components/trace/agent-prism/Badge.tsx +95 -0
- package/src/features/workflow/components/trace/agent-prism/BrandLogo.tsx +102 -0
- package/src/features/workflow/components/trace/agent-prism/Button.tsx +124 -0
- package/src/features/workflow/components/trace/agent-prism/CollapseAndExpandControls.tsx +45 -0
- package/src/features/workflow/components/trace/agent-prism/CollapsibleSection.tsx +124 -0
- package/src/features/workflow/components/trace/agent-prism/CopyButton.tsx +63 -0
- package/src/features/workflow/components/trace/agent-prism/DetailsView/DetailsView.tsx +146 -0
- package/src/features/workflow/components/trace/agent-prism/DetailsView/DetailsViewAttributesTab.tsx +125 -0
- package/src/features/workflow/components/trace/agent-prism/DetailsView/DetailsViewContentViewer.tsx +51 -0
- package/src/features/workflow/components/trace/agent-prism/DetailsView/DetailsViewHeader.tsx +100 -0
- package/src/features/workflow/components/trace/agent-prism/DetailsView/DetailsViewInputOutputTab.tsx +401 -0
- package/src/features/workflow/components/trace/agent-prism/DetailsView/DetailsViewJsonOutput.tsx +33 -0
- package/src/features/workflow/components/trace/agent-prism/DetailsView/DetailsViewRawDataTab.tsx +27 -0
- package/src/features/workflow/components/trace/agent-prism/IconButton.tsx +75 -0
- package/src/features/workflow/components/trace/agent-prism/PriceBadge.tsx +14 -0
- package/src/features/workflow/components/trace/agent-prism/SearchInput.tsx +17 -0
- package/src/features/workflow/components/trace/agent-prism/SpanBadge.tsx +54 -0
- package/src/features/workflow/components/trace/agent-prism/SpanCard/SpanCard.tsx +480 -0
- package/src/features/workflow/components/trace/agent-prism/SpanCard/SpanCardBadges.tsx +23 -0
- package/src/features/workflow/components/trace/agent-prism/SpanCard/SpanCardConnector.tsx +36 -0
- package/src/features/workflow/components/trace/agent-prism/SpanCard/SpanCardTimeline.tsx +60 -0
- package/src/features/workflow/components/trace/agent-prism/SpanCard/SpanCardToggle.tsx +39 -0
- package/src/features/workflow/components/trace/agent-prism/SpanStatus.tsx +80 -0
- package/src/features/workflow/components/trace/agent-prism/TabSelector.tsx +35 -0
- package/src/features/workflow/components/trace/agent-prism/Tabs.tsx +140 -0
- package/src/features/workflow/components/trace/agent-prism/TextInput.tsx +143 -0
- package/src/features/workflow/components/trace/agent-prism/TimestampBadge.tsx +22 -0
- package/src/features/workflow/components/trace/agent-prism/TokensBadge.tsx +27 -0
- package/src/features/workflow/components/trace/agent-prism/TraceList/TraceList.tsx +123 -0
- package/src/features/workflow/components/trace/agent-prism/TraceList/TraceListItem.tsx +86 -0
- package/src/features/workflow/components/trace/agent-prism/TraceList/TraceListItemHeader.tsx +37 -0
- package/src/features/workflow/components/trace/agent-prism/TraceViewer/TraceViewer.tsx +208 -0
- package/src/features/workflow/components/trace/agent-prism/TraceViewer/TraceViewerDesktopLayout.tsx +99 -0
- package/src/features/workflow/components/trace/agent-prism/TraceViewer/TraceViewerMobileLayout.tsx +103 -0
- package/src/features/workflow/components/trace/agent-prism/TraceViewer/TraceViewerPlaceholder.tsx +5 -0
- package/src/features/workflow/components/trace/agent-prism/TraceViewer/TraceViewerSearchAndControls.tsx +30 -0
- package/src/features/workflow/components/trace/agent-prism/TraceViewer/TraceViewerTreeViewContainer.tsx +76 -0
- package/src/features/workflow/components/trace/agent-prism/TraceViewer/useTraceSelection.ts +186 -0
- package/src/features/workflow/components/trace/agent-prism/TreeView.tsx +73 -0
- package/src/features/workflow/components/trace/agent-prism/index.ts +7 -0
- package/src/features/workflow/components/trace/agent-prism/shared.ts +170 -0
- package/src/features/workflow/components/trace/agent-prism/theme/index.ts +101 -0
- package/src/features/workflow/components/trace/agent-prism/theme/theme.css +247 -0
- package/src/features/workflow/data/templates/assets/vibe-agent/config.json +5 -0
- package/src/features/workflow/data/templates/candidate-badges.ts +138 -0
- package/src/features/workflow/data/templates/index.ts +29 -0
- package/src/features/workflow/data/templates/template-definition.ts +77 -0
- package/src/features/workflow/data/templates/template-owner.ts +7 -0
- package/src/features/workflow/data/workflow-data.ts +8 -0
- package/src/features/workflow/data/workflow-types.ts +57 -0
- package/src/features/workflow/lib/mermaid-renderer.ts +334 -0
- package/src/features/workflow/lib/workflow-diff.ts +191 -0
- package/src/features/workflow/lib/workflow-execution-builders.ts +103 -0
- package/src/features/workflow/lib/workflow-execution-formatters.ts +145 -0
- package/src/features/workflow/lib/workflow-execution-storage.ts +63 -0
- package/src/features/workflow/lib/workflow-execution.types.ts +80 -0
- package/src/features/workflow/lib/workflow-storage-api.ts +581 -0
- package/src/features/workflow/lib/workflow-storage-helpers.ts +373 -0
- package/src/features/workflow/lib/workflow-storage-versioning.ts +127 -0
- package/src/features/workflow/lib/workflow-storage.constants.ts +21 -0
- package/src/features/workflow/lib/workflow-storage.ts +482 -0
- package/src/features/workflow/lib/workflow-storage.types.ts +261 -0
- package/src/features/workflow/pages/workflow/components/settings-tab-content.tsx +428 -0
- package/src/features/workflow/pages/workflow/components/trace-tab-content.tsx +183 -0
- package/src/features/workflow/pages/workflow/components/workflow-config-sheet.tsx +207 -0
- package/src/features/workflow/pages/workflow/components/workflow-config-sheet.utils.ts +275 -0
- package/src/features/workflow/pages/workflow/components/workflow-layout.tsx +143 -0
- package/src/features/workflow/pages/workflow/components/workflow-tab-content.tsx +766 -0
- package/src/features/workflow/pages/workflow/handlers/credentials.ts +338 -0
- package/src/features/workflow/pages/workflow/helpers/execution.ts +39 -0
- package/src/features/workflow/pages/workflow/helpers/trace.ts +838 -0
- package/src/features/workflow/pages/workflow/helpers/types.ts +28 -0
- package/src/features/workflow/pages/workflow/hooks/controller/build-layout-props.ts +171 -0
- package/src/features/workflow/pages/workflow/hooks/controller/use-workflow-controller.ts +19 -0
- package/src/features/workflow/pages/workflow/hooks/controller/use-workflow-core.ts +84 -0
- package/src/features/workflow/pages/workflow/hooks/controller/use-workflow-execution-controller.ts +167 -0
- package/src/features/workflow/pages/workflow/hooks/controller/use-workflow-lifecycle.ts +37 -0
- package/src/features/workflow/pages/workflow/hooks/controller/use-workflow-resources.ts +57 -0
- package/src/features/workflow/pages/workflow/hooks/execution-log-helpers.ts +75 -0
- package/src/features/workflow/pages/workflow/hooks/execution-node-status.ts +46 -0
- package/src/features/workflow/pages/workflow/hooks/execution-record-updater.ts +119 -0
- package/src/features/workflow/pages/workflow/hooks/execution-record.ts +31 -0
- package/src/features/workflow/pages/workflow/hooks/execution-runtime-updates.ts +96 -0
- package/src/features/workflow/pages/workflow/hooks/use-execution-trace.ts +512 -0
- package/src/features/workflow/pages/workflow/hooks/use-execution-updates.ts +125 -0
- package/src/features/workflow/pages/workflow/hooks/use-pause-workflow.ts +70 -0
- package/src/features/workflow/pages/workflow/hooks/use-studio-ui-state.ts +10 -0
- package/src/features/workflow/pages/workflow/hooks/use-workflow-chat.ts +212 -0
- package/src/features/workflow/pages/workflow/hooks/use-workflow-credential-readiness.ts +72 -0
- package/src/features/workflow/pages/workflow/hooks/use-workflow-credentials.ts +167 -0
- package/src/features/workflow/pages/workflow/hooks/use-workflow-execution-state.ts +20 -0
- package/src/features/workflow/pages/workflow/hooks/use-workflow-listeners.ts +182 -0
- package/src/features/workflow/pages/workflow/hooks/use-workflow-loader.ts +236 -0
- package/src/features/workflow/pages/workflow/hooks/use-workflow-metadata-state.ts +56 -0
- package/src/features/workflow/pages/workflow/hooks/use-workflow-saver.ts +191 -0
- package/src/features/workflow/pages/workflow/hooks/use-workflow-storage-listener.ts +81 -0
- package/src/features/workflow/pages/workflow/hooks/workflow-runner-websocket.ts +150 -0
- package/src/features/workflow/pages/workflow-gallery/types.ts +3 -0
- package/src/features/workflow/pages/workflow-gallery/use-workflow-gallery-actions.ts +223 -0
- package/src/features/workflow/pages/workflow-gallery/use-workflow-gallery-state.ts +206 -0
- package/src/features/workflow/pages/workflow-gallery/use-workflow-gallery.ts +14 -0
- package/src/features/workflow/pages/workflow-gallery/workflow-card-size.ts +8 -0
- package/src/features/workflow/pages/workflow-gallery/workflow-card.tsx +327 -0
- package/src/features/workflow/pages/workflow-gallery/workflow-gallery-tabs.tsx +173 -0
- package/src/features/workflow/pages/workflow-gallery.tsx +96 -0
- package/src/features/workflow/pages/workflow.tsx +119 -0
- package/src/features/workflow/types/credential-vault.ts +52 -0
- package/src/hooks/browser-context-provider.tsx +19 -0
- package/src/hooks/use-browser-context.ts +188 -0
- package/src/hooks/use-color-scheme.ts +77 -0
- package/src/hooks/use-credential-vault.ts +442 -0
- package/src/hooks/use-page-context.ts +39 -0
- package/src/hooks/use-toast.ts +182 -0
- package/src/hooks/use-uploads-allowed.ts +28 -0
- package/src/index.css +95 -0
- package/src/lib/api.ts +445 -0
- package/src/lib/auth-fetch.ts +35 -0
- package/src/lib/config.ts +102 -0
- package/src/lib/theme.ts +109 -0
- package/src/lib/utils.ts +6 -0
- package/src/lib/workspace-routing.ts +67 -0
- package/src/lib/workspace-session.ts +66 -0
- package/src/lib/workspace-slug.ts +10 -0
- package/src/main.tsx +28 -0
- package/src/vite-env.d.ts +17 -0
- package/tailwind.config.js +153 -0
- package/tsconfig.app.json +30 -0
- package/tsconfig.json +16 -0
- package/tsconfig.node.json +21 -0
- package/vite.config.ts +122 -0
|
@@ -0,0 +1,838 @@
|
|
|
1
|
+
import {
|
|
2
|
+
flattenSpans,
|
|
3
|
+
openTelemetrySpanAdapter,
|
|
4
|
+
} from "@evilmartians/agent-prism-data";
|
|
5
|
+
import type {
|
|
6
|
+
OpenTelemetryDocument,
|
|
7
|
+
OpenTelemetryEvent,
|
|
8
|
+
OpenTelemetrySpan,
|
|
9
|
+
TraceRecord,
|
|
10
|
+
TraceSpan,
|
|
11
|
+
TraceSpanStatus,
|
|
12
|
+
TraceSpanAttribute,
|
|
13
|
+
TraceSpanAttributeValue,
|
|
14
|
+
} from "@evilmartians/agent-prism-types";
|
|
15
|
+
import { nanoid } from "nanoid";
|
|
16
|
+
|
|
17
|
+
import type { BadgeProps } from "@features/workflow/components/trace/agent-prism/Badge";
|
|
18
|
+
import type { TraceViewerData } from "@features/workflow/components/trace/agent-prism";
|
|
19
|
+
|
|
20
|
+
export interface TraceSpanStatusResponse {
|
|
21
|
+
code: "OK" | "ERROR" | "UNSET";
|
|
22
|
+
message?: string | null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface TraceSpanEventResponse {
|
|
26
|
+
name: string;
|
|
27
|
+
time?: string | null;
|
|
28
|
+
attributes?: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface TraceSpanResponse {
|
|
32
|
+
span_id: string;
|
|
33
|
+
parent_span_id?: string | null;
|
|
34
|
+
name?: string | null;
|
|
35
|
+
start_time?: string | null;
|
|
36
|
+
end_time?: string | null;
|
|
37
|
+
attributes: Record<string, unknown>;
|
|
38
|
+
events?: TraceSpanEventResponse[];
|
|
39
|
+
status?: TraceSpanStatusResponse;
|
|
40
|
+
links?: Array<Record<string, unknown>>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface TraceExecutionMetadataResponse {
|
|
44
|
+
id: string;
|
|
45
|
+
status: string;
|
|
46
|
+
thread_id?: string | null;
|
|
47
|
+
started_at?: string | null;
|
|
48
|
+
finished_at?: string | null;
|
|
49
|
+
trace_id?: string | null;
|
|
50
|
+
token_usage?: {
|
|
51
|
+
input?: number;
|
|
52
|
+
output?: number;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface TracePageInfoResponse {
|
|
57
|
+
has_next_page: boolean;
|
|
58
|
+
cursor?: string | null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface TraceResponse {
|
|
62
|
+
execution: TraceExecutionMetadataResponse;
|
|
63
|
+
spans: TraceSpanResponse[];
|
|
64
|
+
page_info: TracePageInfoResponse;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface TraceUpdateMessage {
|
|
68
|
+
type: "trace:update";
|
|
69
|
+
execution_id: string;
|
|
70
|
+
trace_id: string;
|
|
71
|
+
spans: TraceSpanResponse[];
|
|
72
|
+
complete: boolean;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export type TraceEntryStatus = "idle" | "loading" | "ready" | "error";
|
|
76
|
+
|
|
77
|
+
export interface TraceArtifactMetadata {
|
|
78
|
+
id: string;
|
|
79
|
+
downloadUrl?: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface TraceSpanMetadata {
|
|
83
|
+
artifacts: TraceArtifactMetadata[];
|
|
84
|
+
nodeId?: string;
|
|
85
|
+
nodeKind?: string;
|
|
86
|
+
nodeStatus?: string;
|
|
87
|
+
tokenInput?: number;
|
|
88
|
+
tokenOutput?: number;
|
|
89
|
+
workflowStateBefore?: Record<string, unknown>;
|
|
90
|
+
workflowStateAfter?: Record<string, unknown>;
|
|
91
|
+
workflowStateRedacted?: boolean;
|
|
92
|
+
workflowStateTruncated?: boolean;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface ExecutionTraceEntry {
|
|
96
|
+
executionId: string;
|
|
97
|
+
traceId: string | null;
|
|
98
|
+
metadata?: TraceExecutionMetadataResponse;
|
|
99
|
+
spansById: Record<string, TraceSpanResponse>;
|
|
100
|
+
spanMetadata: Record<string, TraceSpanMetadata>;
|
|
101
|
+
status: TraceEntryStatus;
|
|
102
|
+
error?: string;
|
|
103
|
+
isComplete: boolean;
|
|
104
|
+
hasNextPage: boolean;
|
|
105
|
+
nextCursor?: string;
|
|
106
|
+
lastUpdatedAt?: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export type ExecutionTraceState = Record<string, ExecutionTraceEntry>;
|
|
110
|
+
|
|
111
|
+
export interface BuildViewerDataOptions {
|
|
112
|
+
resolveArtifactUrl?: (artifactId: string) => string;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const STATUS_CODE_MAP: Record<TraceSpanStatusResponse["code"], string> = {
|
|
116
|
+
OK: "STATUS_CODE_OK",
|
|
117
|
+
ERROR: "STATUS_CODE_ERROR",
|
|
118
|
+
UNSET: "STATUS_CODE_UNSET",
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const SUCCESS_STATUSES = new Set(["completed", "success", "succeeded"]);
|
|
122
|
+
const ERROR_STATUSES = new Set(["error", "failed", "cancelled", "canceled"]);
|
|
123
|
+
const PENDING_STATUSES = new Set(["running", "pending", "queued"]);
|
|
124
|
+
|
|
125
|
+
const MS_TO_NANO = BigInt(1_000_000);
|
|
126
|
+
|
|
127
|
+
const ensureDateNano = (value?: string | null): string => {
|
|
128
|
+
if (!value) {
|
|
129
|
+
return "0";
|
|
130
|
+
}
|
|
131
|
+
const ms = Date.parse(value);
|
|
132
|
+
if (Number.isNaN(ms)) {
|
|
133
|
+
return "0";
|
|
134
|
+
}
|
|
135
|
+
return (BigInt(ms) * MS_TO_NANO).toString();
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const toAttributeValue = (value: unknown): TraceSpanAttributeValue => {
|
|
139
|
+
if (typeof value === "string") {
|
|
140
|
+
return { stringValue: value };
|
|
141
|
+
}
|
|
142
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
143
|
+
return { intValue: String(value) };
|
|
144
|
+
}
|
|
145
|
+
if (typeof value === "boolean") {
|
|
146
|
+
return { boolValue: value };
|
|
147
|
+
}
|
|
148
|
+
if (value == null) {
|
|
149
|
+
return { stringValue: "" };
|
|
150
|
+
}
|
|
151
|
+
if (typeof value === "object") {
|
|
152
|
+
return { stringValue: JSON.stringify(value) };
|
|
153
|
+
}
|
|
154
|
+
return { stringValue: String(value) };
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const toAttributes = (
|
|
158
|
+
attributes: Record<string, unknown>,
|
|
159
|
+
): TraceSpanAttribute[] =>
|
|
160
|
+
Object.entries(attributes).map(([key, value]) => ({
|
|
161
|
+
key,
|
|
162
|
+
value: toAttributeValue(value),
|
|
163
|
+
}));
|
|
164
|
+
|
|
165
|
+
const toEvents = (
|
|
166
|
+
events: TraceSpanEventResponse[] | undefined,
|
|
167
|
+
): OpenTelemetryEvent[] | undefined => {
|
|
168
|
+
if (!events?.length) {
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
171
|
+
return events.map((event) => ({
|
|
172
|
+
name: event.name,
|
|
173
|
+
timeUnixNano: ensureDateNano(event.time),
|
|
174
|
+
attributes: event.attributes ? toAttributes(event.attributes) : undefined,
|
|
175
|
+
}));
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
const createSpanMetadata = (span: TraceSpanResponse): TraceSpanMetadata => {
|
|
179
|
+
const artifactsValue = span.attributes?.["orcheo.artifact.ids"];
|
|
180
|
+
const artifacts: TraceArtifactMetadata[] = Array.isArray(artifactsValue)
|
|
181
|
+
? artifactsValue
|
|
182
|
+
.map((value) => ({ id: String(value) }))
|
|
183
|
+
.filter((item) => item.id.trim().length > 0)
|
|
184
|
+
: [];
|
|
185
|
+
|
|
186
|
+
const metadata: TraceSpanMetadata = {
|
|
187
|
+
artifacts,
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
const nodeId = span.attributes?.["orcheo.node.id"];
|
|
191
|
+
if (nodeId) {
|
|
192
|
+
metadata.nodeId = String(nodeId);
|
|
193
|
+
}
|
|
194
|
+
const nodeKind = span.attributes?.["orcheo.node.kind"];
|
|
195
|
+
if (nodeKind) {
|
|
196
|
+
metadata.nodeKind = String(nodeKind);
|
|
197
|
+
}
|
|
198
|
+
const nodeStatus = span.attributes?.["orcheo.node.status"];
|
|
199
|
+
if (nodeStatus) {
|
|
200
|
+
metadata.nodeStatus = String(nodeStatus);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const input = span.attributes?.["orcheo.token.input"];
|
|
204
|
+
const output = span.attributes?.["orcheo.token.output"];
|
|
205
|
+
if (typeof input === "number" && Number.isFinite(input)) {
|
|
206
|
+
metadata.tokenInput = input;
|
|
207
|
+
}
|
|
208
|
+
if (typeof output === "number" && Number.isFinite(output)) {
|
|
209
|
+
metadata.tokenOutput = output;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const workflowStateBefore = span.attributes?.["orcheo.workflow.state.before"];
|
|
213
|
+
if (
|
|
214
|
+
workflowStateBefore &&
|
|
215
|
+
typeof workflowStateBefore === "object" &&
|
|
216
|
+
!Array.isArray(workflowStateBefore)
|
|
217
|
+
) {
|
|
218
|
+
metadata.workflowStateBefore = workflowStateBefore as Record<
|
|
219
|
+
string,
|
|
220
|
+
unknown
|
|
221
|
+
>;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const workflowStateAfter = span.attributes?.["orcheo.workflow.state.after"];
|
|
225
|
+
if (
|
|
226
|
+
workflowStateAfter &&
|
|
227
|
+
typeof workflowStateAfter === "object" &&
|
|
228
|
+
!Array.isArray(workflowStateAfter)
|
|
229
|
+
) {
|
|
230
|
+
metadata.workflowStateAfter = workflowStateAfter as Record<string, unknown>;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (span.attributes?.["orcheo.workflow.state.redacted"] === true) {
|
|
234
|
+
metadata.workflowStateRedacted = true;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (span.attributes?.["orcheo.workflow.state.truncated"] === true) {
|
|
238
|
+
metadata.workflowStateTruncated = true;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return metadata;
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
const normalizeThreadId = (value: unknown): string | undefined => {
|
|
245
|
+
if (typeof value !== "string") {
|
|
246
|
+
return undefined;
|
|
247
|
+
}
|
|
248
|
+
const normalized = value.trim();
|
|
249
|
+
return normalized || undefined;
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
const mergeAttributes = (
|
|
253
|
+
existing: Record<string, unknown>,
|
|
254
|
+
incoming: Record<string, unknown>,
|
|
255
|
+
): Record<string, unknown> => ({
|
|
256
|
+
...existing,
|
|
257
|
+
...incoming,
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
const mergeEvents = (
|
|
261
|
+
existing: TraceSpanEventResponse[] | undefined,
|
|
262
|
+
incoming: TraceSpanEventResponse[] | undefined,
|
|
263
|
+
): TraceSpanEventResponse[] | undefined => {
|
|
264
|
+
if (!existing?.length) {
|
|
265
|
+
return incoming?.slice();
|
|
266
|
+
}
|
|
267
|
+
if (!incoming?.length) {
|
|
268
|
+
return existing;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
const combined = [...existing];
|
|
272
|
+
const seen = new Set(combined.map((event) => JSON.stringify(event)));
|
|
273
|
+
for (const event of incoming) {
|
|
274
|
+
const key = JSON.stringify(event);
|
|
275
|
+
if (!seen.has(key)) {
|
|
276
|
+
combined.push(event);
|
|
277
|
+
seen.add(key);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return combined;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
const mergeSpan = (
|
|
284
|
+
existing: TraceSpanResponse | undefined,
|
|
285
|
+
update: TraceSpanResponse,
|
|
286
|
+
): TraceSpanResponse => {
|
|
287
|
+
if (!existing) {
|
|
288
|
+
return { ...update, attributes: { ...update.attributes } };
|
|
289
|
+
}
|
|
290
|
+
return {
|
|
291
|
+
span_id: update.span_id || existing.span_id,
|
|
292
|
+
parent_span_id:
|
|
293
|
+
update.parent_span_id !== undefined
|
|
294
|
+
? update.parent_span_id
|
|
295
|
+
: existing.parent_span_id,
|
|
296
|
+
name: update.name ?? existing.name,
|
|
297
|
+
start_time: update.start_time ?? existing.start_time,
|
|
298
|
+
end_time: update.end_time ?? existing.end_time,
|
|
299
|
+
attributes: update.attributes
|
|
300
|
+
? mergeAttributes(existing.attributes, update.attributes)
|
|
301
|
+
: existing.attributes,
|
|
302
|
+
events: mergeEvents(existing.events, update.events),
|
|
303
|
+
status: update.status ?? existing.status,
|
|
304
|
+
links: update.links ?? existing.links,
|
|
305
|
+
};
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
export const createEmptyTraceEntry = (
|
|
309
|
+
executionId: string,
|
|
310
|
+
): ExecutionTraceEntry => ({
|
|
311
|
+
executionId,
|
|
312
|
+
traceId: null,
|
|
313
|
+
metadata: undefined,
|
|
314
|
+
spansById: {},
|
|
315
|
+
spanMetadata: {},
|
|
316
|
+
status: "idle",
|
|
317
|
+
error: undefined,
|
|
318
|
+
isComplete: false,
|
|
319
|
+
hasNextPage: false,
|
|
320
|
+
nextCursor: undefined,
|
|
321
|
+
lastUpdatedAt: undefined,
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
export interface ApplyTraceResponseOptions {
|
|
325
|
+
replaceSpans?: boolean;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
const updateEntryWithSpan = (
|
|
329
|
+
entry: ExecutionTraceEntry,
|
|
330
|
+
span: TraceSpanResponse,
|
|
331
|
+
): ExecutionTraceEntry => {
|
|
332
|
+
const merged = mergeSpan(entry.spansById[span.span_id], span);
|
|
333
|
+
return {
|
|
334
|
+
...entry,
|
|
335
|
+
spansById: {
|
|
336
|
+
...entry.spansById,
|
|
337
|
+
[merged.span_id]: merged,
|
|
338
|
+
},
|
|
339
|
+
spanMetadata: {
|
|
340
|
+
...entry.spanMetadata,
|
|
341
|
+
[merged.span_id]: createSpanMetadata(merged),
|
|
342
|
+
},
|
|
343
|
+
lastUpdatedAt: new Date().toISOString(),
|
|
344
|
+
};
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
export const applyTraceResponse = (
|
|
348
|
+
entry: ExecutionTraceEntry,
|
|
349
|
+
response: TraceResponse,
|
|
350
|
+
options: ApplyTraceResponseOptions = {},
|
|
351
|
+
): ExecutionTraceEntry => {
|
|
352
|
+
const baseEntry = options.replaceSpans
|
|
353
|
+
? {
|
|
354
|
+
...entry,
|
|
355
|
+
spansById: {},
|
|
356
|
+
spanMetadata: {},
|
|
357
|
+
}
|
|
358
|
+
: entry;
|
|
359
|
+
const priorIsComplete = options.replaceSpans ? false : baseEntry.isComplete;
|
|
360
|
+
|
|
361
|
+
let next = {
|
|
362
|
+
...baseEntry,
|
|
363
|
+
status: "ready" as TraceEntryStatus,
|
|
364
|
+
metadata: response.execution,
|
|
365
|
+
traceId: response.execution.trace_id ?? baseEntry.traceId,
|
|
366
|
+
error: undefined,
|
|
367
|
+
hasNextPage: response.page_info.has_next_page,
|
|
368
|
+
nextCursor: response.page_info.cursor ?? undefined,
|
|
369
|
+
isComplete:
|
|
370
|
+
priorIsComplete ||
|
|
371
|
+
Boolean(response.execution.finished_at) ||
|
|
372
|
+
response.page_info.has_next_page === false,
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
for (const span of response.spans) {
|
|
376
|
+
next = updateEntryWithSpan(next, span);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
return next;
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
export const applyTraceUpdate = (
|
|
383
|
+
entry: ExecutionTraceEntry,
|
|
384
|
+
update: TraceUpdateMessage,
|
|
385
|
+
): ExecutionTraceEntry => {
|
|
386
|
+
let next: ExecutionTraceEntry = {
|
|
387
|
+
...entry,
|
|
388
|
+
traceId: update.trace_id,
|
|
389
|
+
lastUpdatedAt: new Date().toISOString(),
|
|
390
|
+
};
|
|
391
|
+
for (const span of update.spans) {
|
|
392
|
+
next = updateEntryWithSpan(next, span);
|
|
393
|
+
}
|
|
394
|
+
if (update.complete) {
|
|
395
|
+
next = {
|
|
396
|
+
...next,
|
|
397
|
+
isComplete: true,
|
|
398
|
+
hasNextPage: false,
|
|
399
|
+
nextCursor: undefined,
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
return next;
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
const toOpenTelemetrySpan = (
|
|
406
|
+
traceId: string,
|
|
407
|
+
span: TraceSpanResponse,
|
|
408
|
+
): OpenTelemetrySpan => ({
|
|
409
|
+
traceId,
|
|
410
|
+
spanId: span.span_id,
|
|
411
|
+
parentSpanId: span.parent_span_id ?? undefined,
|
|
412
|
+
name: span.name ?? "span",
|
|
413
|
+
kind: "SPAN_KIND_INTERNAL",
|
|
414
|
+
startTimeUnixNano: ensureDateNano(span.start_time),
|
|
415
|
+
endTimeUnixNano: ensureDateNano(span.end_time ?? span.start_time),
|
|
416
|
+
attributes: toAttributes(span.attributes ?? {}),
|
|
417
|
+
status: {
|
|
418
|
+
code: STATUS_CODE_MAP[span.status?.code ?? "UNSET"],
|
|
419
|
+
message: span.status?.message ?? undefined,
|
|
420
|
+
},
|
|
421
|
+
flags: 0,
|
|
422
|
+
events: toEvents(span.events),
|
|
423
|
+
links: undefined,
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
const buildTraceRecord = (
|
|
427
|
+
entry: ExecutionTraceEntry,
|
|
428
|
+
spans: TraceSpan[],
|
|
429
|
+
): TraceRecord => {
|
|
430
|
+
const startedAt = entry.metadata?.started_at
|
|
431
|
+
? Date.parse(entry.metadata.started_at)
|
|
432
|
+
: undefined;
|
|
433
|
+
const finishedAt = entry.metadata?.finished_at
|
|
434
|
+
? Date.parse(entry.metadata.finished_at)
|
|
435
|
+
: undefined;
|
|
436
|
+
const durationMs =
|
|
437
|
+
startedAt && finishedAt ? Math.max(finishedAt - startedAt, 0) : 0;
|
|
438
|
+
const totalTokens =
|
|
439
|
+
(entry.metadata?.token_usage?.input ?? 0) +
|
|
440
|
+
(entry.metadata?.token_usage?.output ?? 0);
|
|
441
|
+
|
|
442
|
+
return {
|
|
443
|
+
id: entry.executionId,
|
|
444
|
+
name: entry.metadata?.trace_id ?? entry.executionId,
|
|
445
|
+
spansCount: spans.length,
|
|
446
|
+
durationMs,
|
|
447
|
+
agentDescription: entry.metadata?.status ?? "unknown",
|
|
448
|
+
totalTokens,
|
|
449
|
+
startTime: startedAt,
|
|
450
|
+
};
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
const resolveEntryThreadId = (
|
|
454
|
+
entry: ExecutionTraceEntry,
|
|
455
|
+
): string | undefined => {
|
|
456
|
+
const metadataThreadId = normalizeThreadId(entry.metadata?.thread_id);
|
|
457
|
+
if (metadataThreadId) {
|
|
458
|
+
return metadataThreadId;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
for (const span of Object.values(entry.spansById)) {
|
|
462
|
+
if (span.parent_span_id) {
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
const rootThreadId = normalizeThreadId(
|
|
466
|
+
span.attributes["orcheo.execution.thread_id"] ??
|
|
467
|
+
span.attributes["thread_id"] ??
|
|
468
|
+
span.attributes["threadId"],
|
|
469
|
+
);
|
|
470
|
+
if (rootThreadId) {
|
|
471
|
+
return rootThreadId;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
return undefined;
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
const attachMetadataToSpan = (
|
|
479
|
+
span: TraceSpan,
|
|
480
|
+
metadata: Record<string, TraceSpanMetadata>,
|
|
481
|
+
resolver?: (artifactId: string) => string,
|
|
482
|
+
): TraceSpan => {
|
|
483
|
+
const meta = metadata[span.id];
|
|
484
|
+
if (meta) {
|
|
485
|
+
span.metadata = {
|
|
486
|
+
...meta,
|
|
487
|
+
artifacts: meta.artifacts.map((artifact) => {
|
|
488
|
+
if (!resolver) {
|
|
489
|
+
return { id: artifact.id };
|
|
490
|
+
}
|
|
491
|
+
try {
|
|
492
|
+
return {
|
|
493
|
+
id: artifact.id,
|
|
494
|
+
downloadUrl: resolver(artifact.id),
|
|
495
|
+
};
|
|
496
|
+
} catch {
|
|
497
|
+
return { id: artifact.id };
|
|
498
|
+
}
|
|
499
|
+
}),
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
if (span.children?.length) {
|
|
503
|
+
span.children = span.children.map((child) =>
|
|
504
|
+
attachMetadataToSpan(child, metadata, resolver),
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
return span;
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
const sortChildrenByStart = (span: TraceSpan): TraceSpan => {
|
|
511
|
+
if (span.children?.length) {
|
|
512
|
+
span.children = span.children
|
|
513
|
+
.map((child) => sortChildrenByStart(child))
|
|
514
|
+
.sort((a, b) => a.startTime.getTime() - b.startTime.getTime());
|
|
515
|
+
}
|
|
516
|
+
return span;
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
export const buildTraceViewerData = (
|
|
520
|
+
entry: ExecutionTraceEntry,
|
|
521
|
+
options: BuildViewerDataOptions = {},
|
|
522
|
+
): TraceViewerData | undefined => {
|
|
523
|
+
const traceId = entry.traceId ?? entry.metadata?.trace_id;
|
|
524
|
+
if (!traceId) {
|
|
525
|
+
return undefined;
|
|
526
|
+
}
|
|
527
|
+
const spans = Object.values(entry.spansById);
|
|
528
|
+
if (spans.length === 0) {
|
|
529
|
+
return undefined;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
const document: OpenTelemetryDocument = {
|
|
533
|
+
resourceSpans: [
|
|
534
|
+
{
|
|
535
|
+
resource: { attributes: [] },
|
|
536
|
+
scopeSpans: [
|
|
537
|
+
{
|
|
538
|
+
scope: { name: "orcheo.trace" },
|
|
539
|
+
spans: spans.map((span) => toOpenTelemetrySpan(traceId, span)),
|
|
540
|
+
},
|
|
541
|
+
],
|
|
542
|
+
},
|
|
543
|
+
],
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
const spanTree =
|
|
547
|
+
openTelemetrySpanAdapter.convertRawDocumentsToSpans(document);
|
|
548
|
+
|
|
549
|
+
const enrichedTree = spanTree
|
|
550
|
+
.map((span) =>
|
|
551
|
+
attachMetadataToSpan(
|
|
552
|
+
span,
|
|
553
|
+
entry.spanMetadata,
|
|
554
|
+
options.resolveArtifactUrl,
|
|
555
|
+
),
|
|
556
|
+
)
|
|
557
|
+
.map((span) => sortChildrenByStart(span));
|
|
558
|
+
|
|
559
|
+
const flattened = flattenSpans(enrichedTree);
|
|
560
|
+
const traceRecord = buildTraceRecord(entry, flattened);
|
|
561
|
+
|
|
562
|
+
const badges: BadgeProps[] = [];
|
|
563
|
+
if (entry.metadata?.status) {
|
|
564
|
+
badges.push({ label: `Status: ${entry.metadata.status}` });
|
|
565
|
+
}
|
|
566
|
+
const inputTokens = entry.metadata?.token_usage?.input ?? 0;
|
|
567
|
+
const outputTokens = entry.metadata?.token_usage?.output ?? 0;
|
|
568
|
+
if (inputTokens || outputTokens) {
|
|
569
|
+
badges.push({
|
|
570
|
+
label: `Tokens in/out: ${inputTokens}/${outputTokens}`,
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
if (!entry.isComplete) {
|
|
574
|
+
badges.push({
|
|
575
|
+
label: "Live",
|
|
576
|
+
className:
|
|
577
|
+
"bg-agentprism-warning text-agentprism-warning-muted-foreground",
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
return {
|
|
582
|
+
traceRecord,
|
|
583
|
+
spans: enrichedTree,
|
|
584
|
+
badges,
|
|
585
|
+
threadId: resolveEntryThreadId(entry),
|
|
586
|
+
};
|
|
587
|
+
};
|
|
588
|
+
|
|
589
|
+
export const getEntryStatus = (
|
|
590
|
+
entry: ExecutionTraceEntry | undefined,
|
|
591
|
+
): TraceEntryStatus => entry?.status ?? "idle";
|
|
592
|
+
|
|
593
|
+
export const getEntryError = (
|
|
594
|
+
entry: ExecutionTraceEntry | undefined,
|
|
595
|
+
): string | undefined => entry?.error;
|
|
596
|
+
|
|
597
|
+
export const summarizeTrace = (entry: ExecutionTraceEntry) => {
|
|
598
|
+
const spanCount = Object.keys(entry.spansById).length;
|
|
599
|
+
const totalTokens =
|
|
600
|
+
(entry.metadata?.token_usage?.input ?? 0) +
|
|
601
|
+
(entry.metadata?.token_usage?.output ?? 0);
|
|
602
|
+
return {
|
|
603
|
+
spanCount,
|
|
604
|
+
totalTokens,
|
|
605
|
+
};
|
|
606
|
+
};
|
|
607
|
+
|
|
608
|
+
export const upsertTraceError = (
|
|
609
|
+
entry: ExecutionTraceEntry,
|
|
610
|
+
error: string,
|
|
611
|
+
): ExecutionTraceEntry => ({
|
|
612
|
+
...entry,
|
|
613
|
+
status: "error",
|
|
614
|
+
error,
|
|
615
|
+
});
|
|
616
|
+
|
|
617
|
+
export const markTraceLoading = (
|
|
618
|
+
entry: ExecutionTraceEntry,
|
|
619
|
+
): ExecutionTraceEntry => ({
|
|
620
|
+
...entry,
|
|
621
|
+
status: "loading",
|
|
622
|
+
error: undefined,
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
export const markTraceReady = (
|
|
626
|
+
entry: ExecutionTraceEntry,
|
|
627
|
+
): ExecutionTraceEntry => ({
|
|
628
|
+
...entry,
|
|
629
|
+
status: "ready",
|
|
630
|
+
});
|
|
631
|
+
|
|
632
|
+
export const deriveViewerDataList = (
|
|
633
|
+
state: ExecutionTraceState,
|
|
634
|
+
options: BuildViewerDataOptions = {},
|
|
635
|
+
): TraceViewerData[] =>
|
|
636
|
+
Object.values(state)
|
|
637
|
+
.map((entry) => buildTraceViewerData(entry, options))
|
|
638
|
+
.filter((value): value is TraceViewerData => Boolean(value))
|
|
639
|
+
.sort((a, b) => {
|
|
640
|
+
const aStart = a.traceRecord.startTime ?? 0;
|
|
641
|
+
const bStart = b.traceRecord.startTime ?? 0;
|
|
642
|
+
return bStart - aStart;
|
|
643
|
+
});
|
|
644
|
+
|
|
645
|
+
const deriveSpanTimeBounds = (
|
|
646
|
+
spans: TraceSpan[],
|
|
647
|
+
): {
|
|
648
|
+
start: number;
|
|
649
|
+
end: number;
|
|
650
|
+
} => {
|
|
651
|
+
const flattened = flattenSpans(spans);
|
|
652
|
+
if (flattened.length === 0) {
|
|
653
|
+
const now = Date.now();
|
|
654
|
+
return { start: now, end: now };
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
let start = Number.POSITIVE_INFINITY;
|
|
658
|
+
let end = Number.NEGATIVE_INFINITY;
|
|
659
|
+
for (const span of flattened) {
|
|
660
|
+
const spanStart = span.startTime.getTime();
|
|
661
|
+
const spanEnd = span.endTime.getTime();
|
|
662
|
+
if (Number.isFinite(spanStart)) {
|
|
663
|
+
start = Math.min(start, spanStart);
|
|
664
|
+
}
|
|
665
|
+
if (Number.isFinite(spanEnd)) {
|
|
666
|
+
end = Math.max(end, spanEnd);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
if (!Number.isFinite(start) || !Number.isFinite(end)) {
|
|
671
|
+
const now = Date.now();
|
|
672
|
+
return { start: now, end: now };
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
return {
|
|
676
|
+
start,
|
|
677
|
+
end: Math.max(end, start),
|
|
678
|
+
};
|
|
679
|
+
};
|
|
680
|
+
|
|
681
|
+
const resolveSegmentBounds = (
|
|
682
|
+
trace: TraceViewerData,
|
|
683
|
+
): {
|
|
684
|
+
start: number;
|
|
685
|
+
end: number;
|
|
686
|
+
} => {
|
|
687
|
+
const spanBounds = deriveSpanTimeBounds(trace.spans);
|
|
688
|
+
const start = trace.traceRecord.startTime ?? spanBounds.start;
|
|
689
|
+
const durationMs = Math.max(trace.traceRecord.durationMs ?? 0, 0);
|
|
690
|
+
const endFromRecord = start + durationMs;
|
|
691
|
+
const end =
|
|
692
|
+
durationMs > 0 ? endFromRecord : Math.max(spanBounds.end, endFromRecord);
|
|
693
|
+
return { start, end: Math.max(end, start) };
|
|
694
|
+
};
|
|
695
|
+
|
|
696
|
+
const toSpanStatus = (executionStatus: string | undefined): TraceSpanStatus => {
|
|
697
|
+
if (!executionStatus) {
|
|
698
|
+
return "warning";
|
|
699
|
+
}
|
|
700
|
+
const normalized = executionStatus.toLowerCase();
|
|
701
|
+
if (SUCCESS_STATUSES.has(normalized)) {
|
|
702
|
+
return "success";
|
|
703
|
+
}
|
|
704
|
+
if (ERROR_STATUSES.has(normalized)) {
|
|
705
|
+
return "error";
|
|
706
|
+
}
|
|
707
|
+
if (PENDING_STATUSES.has(normalized)) {
|
|
708
|
+
return "pending";
|
|
709
|
+
}
|
|
710
|
+
return "warning";
|
|
711
|
+
};
|
|
712
|
+
|
|
713
|
+
const buildStitchedSegment = (
|
|
714
|
+
trace: TraceViewerData,
|
|
715
|
+
threadId: string,
|
|
716
|
+
segmentIndex: number,
|
|
717
|
+
): TraceSpan => {
|
|
718
|
+
const { start, end } = resolveSegmentBounds(trace);
|
|
719
|
+
return {
|
|
720
|
+
id: `stitched:${threadId}:${trace.traceRecord.id}:${segmentIndex}`,
|
|
721
|
+
title: `Execution ${trace.traceRecord.id}`,
|
|
722
|
+
startTime: new Date(start),
|
|
723
|
+
endTime: new Date(end),
|
|
724
|
+
duration: Math.max(end - start, 0),
|
|
725
|
+
type: "span",
|
|
726
|
+
raw: JSON.stringify({
|
|
727
|
+
stitched: true,
|
|
728
|
+
threadId,
|
|
729
|
+
executionId: trace.traceRecord.id,
|
|
730
|
+
}),
|
|
731
|
+
status: toSpanStatus(trace.traceRecord.agentDescription),
|
|
732
|
+
children: trace.spans,
|
|
733
|
+
metadata: {
|
|
734
|
+
stitched: true,
|
|
735
|
+
isSegment: true,
|
|
736
|
+
threadId,
|
|
737
|
+
executionId: trace.traceRecord.id,
|
|
738
|
+
traceId: trace.traceRecord.name,
|
|
739
|
+
},
|
|
740
|
+
};
|
|
741
|
+
};
|
|
742
|
+
|
|
743
|
+
export const deriveThreadStitchedViewerDataList = (
|
|
744
|
+
data: TraceViewerData[],
|
|
745
|
+
activeTraceId?: string,
|
|
746
|
+
): TraceViewerData[] => {
|
|
747
|
+
const grouped = new Map<string, TraceViewerData[]>();
|
|
748
|
+
for (const trace of data) {
|
|
749
|
+
const key = trace.threadId
|
|
750
|
+
? `thread:${trace.threadId}`
|
|
751
|
+
: `execution:${trace.traceRecord.id}`;
|
|
752
|
+
const existing = grouped.get(key);
|
|
753
|
+
if (existing) {
|
|
754
|
+
existing.push(trace);
|
|
755
|
+
} else {
|
|
756
|
+
grouped.set(key, [trace]);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
const stitched: TraceViewerData[] = [];
|
|
761
|
+
for (const traces of grouped.values()) {
|
|
762
|
+
if (traces.length === 0) {
|
|
763
|
+
continue;
|
|
764
|
+
}
|
|
765
|
+
const sortedByStartDesc = [...traces].sort((a, b) => {
|
|
766
|
+
const aStart = a.traceRecord.startTime ?? 0;
|
|
767
|
+
const bStart = b.traceRecord.startTime ?? 0;
|
|
768
|
+
return bStart - aStart;
|
|
769
|
+
});
|
|
770
|
+
|
|
771
|
+
const latestTrace = sortedByStartDesc[0];
|
|
772
|
+
if (!latestTrace) {
|
|
773
|
+
continue;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
const threadId = latestTrace.threadId;
|
|
777
|
+
if (!threadId || sortedByStartDesc.length === 1) {
|
|
778
|
+
stitched.push(latestTrace);
|
|
779
|
+
continue;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
const sortedByStartAsc = [...sortedByStartDesc].sort((a, b) => {
|
|
783
|
+
const aStart = a.traceRecord.startTime ?? 0;
|
|
784
|
+
const bStart = b.traceRecord.startTime ?? 0;
|
|
785
|
+
return aStart - bStart;
|
|
786
|
+
});
|
|
787
|
+
const representative =
|
|
788
|
+
sortedByStartDesc.find(
|
|
789
|
+
(trace) => trace.traceRecord.id === activeTraceId,
|
|
790
|
+
) ?? sortedByStartDesc[0];
|
|
791
|
+
|
|
792
|
+
const segmentSpans = sortedByStartAsc.map((trace, index) =>
|
|
793
|
+
buildStitchedSegment(trace, threadId, index),
|
|
794
|
+
);
|
|
795
|
+
const earliestStart = Math.min(
|
|
796
|
+
...segmentSpans.map((segment) => segment.startTime.getTime()),
|
|
797
|
+
);
|
|
798
|
+
const latestEnd = Math.max(
|
|
799
|
+
...segmentSpans.map((segment) => segment.endTime.getTime()),
|
|
800
|
+
);
|
|
801
|
+
const totalTokens = sortedByStartDesc.reduce(
|
|
802
|
+
(sum, trace) => sum + (trace.traceRecord.totalTokens ?? 0),
|
|
803
|
+
0,
|
|
804
|
+
);
|
|
805
|
+
|
|
806
|
+
stitched.push({
|
|
807
|
+
traceRecord: {
|
|
808
|
+
id: representative.traceRecord.id,
|
|
809
|
+
name: `Thread ${threadId}`,
|
|
810
|
+
spansCount: sortedByStartDesc.reduce(
|
|
811
|
+
(sum, trace) => sum + trace.traceRecord.spansCount,
|
|
812
|
+
0,
|
|
813
|
+
),
|
|
814
|
+
durationMs: Math.max(latestEnd - earliestStart, 0),
|
|
815
|
+
agentDescription: `${sortedByStartDesc.length} executions`,
|
|
816
|
+
totalTokens,
|
|
817
|
+
startTime: representative.traceRecord.startTime,
|
|
818
|
+
},
|
|
819
|
+
spans: segmentSpans,
|
|
820
|
+
badges: [
|
|
821
|
+
{ label: `Thread: ${threadId}` },
|
|
822
|
+
{ label: `Executions: ${sortedByStartDesc.length}` },
|
|
823
|
+
{ label: "Stitched timeline" },
|
|
824
|
+
],
|
|
825
|
+
threadId,
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
return stitched.sort((a, b) => {
|
|
830
|
+
const aStart = a.traceRecord.startTime ?? 0;
|
|
831
|
+
const bStart = b.traceRecord.startTime ?? 0;
|
|
832
|
+
return bStart - aStart;
|
|
833
|
+
});
|
|
834
|
+
};
|
|
835
|
+
|
|
836
|
+
export const DEFAULT_TRACE_BADGES: BadgeProps[] = [{ label: "Trace" }];
|
|
837
|
+
|
|
838
|
+
export const ensureTraceId = (): string => nanoid();
|