@aceshooting/lyra-ui 23.0.0 → 24.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/CHANGELOG.md +16 -39
- package/README.md +72 -35
- package/custom-elements.json +1 -1
- package/design-tokens.json +1 -1
- package/dist/cli/lyra-rename-ledger.mjs +1 -1
- package/dist/cli/migration-contract.json +1 -1
- package/dist/cli/migration-contract.mjs +1 -1
- package/dist/cli/migration-renames.mjs +2 -2
- package/dist/cli/migration-transforms.mjs +2 -2
- package/dist/components/agent-tools/approval-queue/approval-queue.class.d.ts +1 -4
- package/dist/components/agent-tools/approval-queue/approval-queue.class.js +1 -3
- package/dist/components/agent-tools/compare-panel/compare-panel.class.d.ts +1 -4
- package/dist/components/agent-tools/compare-panel/compare-panel.class.js +1 -1
- package/dist/components/agent-tools/confirm-bar/confirm-bar.class.d.ts +1 -7
- package/dist/components/agent-tools/confirm-bar/confirm-bar.class.js +2 -2
- package/dist/components/agent-tools/context-inspector/context-inspector.class.d.ts +1 -1
- package/dist/components/agent-tools/evaluation-run/evaluation-run.class.d.ts +2 -5
- package/dist/components/agent-tools/evaluation-run/evaluation-run.class.js +1 -3
- package/dist/components/agent-tools/terminal/terminal.class.d.ts +1 -4
- package/dist/components/agent-tools/terminal/terminal.class.js +2 -2
- package/dist/components/agent-tools/tool-approval-dialog/tool-approval-dialog.class.d.ts +1 -7
- package/dist/components/agent-tools/tool-approval-dialog/tool-approval-dialog.class.js +1 -1
- package/dist/components/agent-tools/tool-timeline/tool-timeline.class.d.ts +1 -4
- package/dist/components/agent-tools/tool-timeline/tool-timeline.class.js +1 -3
- package/dist/components/charts/chart/lite-chart-axis-layout.d.ts +13 -0
- package/dist/components/charts/chart/lite-chart-axis-layout.js +1 -0
- package/dist/components/charts/chart/lite-chart.class.d.ts +1 -11
- package/dist/components/charts/chart/lite-chart.class.js +4 -4
- package/dist/components/conversation/agent-workspace/agent-workspace.class.d.ts +13 -3
- package/dist/components/conversation/agent-workspace/agent-workspace.class.js +1 -2
- package/dist/components/conversation/chat-message/chat-message.class.d.ts +3 -9
- package/dist/components/conversation/chat-message/chat-message.class.js +1 -1
- package/dist/components/conversation/code-block/code-block-base.class.js +1 -1
- package/dist/components/conversation/code-block/code-block-core.class.d.ts +6 -8
- package/dist/components/conversation/code-block/code-block-shared.d.ts +1 -4
- package/dist/components/conversation/code-block/code-block.class.d.ts +4 -6
- package/dist/components/conversation/markdown/markdown-base.class.d.ts +1 -3
- package/dist/components/conversation/markdown/markdown-base.class.js +1 -1
- package/dist/components/conversation/markdown/markdown-core.class.d.ts +1 -4
- package/dist/components/conversation/markdown/markdown.class.d.ts +1 -4
- package/dist/components/conversation/message-actions/message-actions.class.d.ts +1 -4
- package/dist/components/conversation/message-actions/message-actions.class.js +1 -1
- package/dist/components/conversation/message-feedback/message-feedback.class.d.ts +1 -4
- package/dist/components/conversation/message-feedback/message-feedback.class.js +2 -2
- package/dist/components/conversation/message-parts/message-parts.class.d.ts +2 -5
- package/dist/components/conversation/message-parts/message-parts.class.js +3 -3
- package/dist/components/conversation/streaming-text/streaming-text-base.class.d.ts +1 -1
- package/dist/components/conversation/streaming-text/streaming-text-core.class.d.ts +2 -0
- package/dist/components/conversation/streaming-text/streaming-text-core.class.js +0 -1
- package/dist/components/conversation/streaming-text/streaming-text.class.d.ts +2 -0
- package/dist/components/conversation/streaming-text/streaming-text.class.js +0 -1
- package/dist/components/conversation/thread-list/thread-list.class.d.ts +6 -17
- package/dist/components/conversation/thread-list/thread-list.class.js +6 -6
- package/dist/components/data/context-meter/context-meter.class.d.ts +1 -6
- package/dist/components/data/context-meter/context-meter.class.js +1 -1
- package/dist/components/data/data-grid/data-grid.class.d.ts +0 -1
- package/dist/components/data/data-grid/data-grid.class.js +2 -2
- package/dist/components/data/document-library/document-library.class.d.ts +6 -13
- package/dist/components/data/document-library/document-library.class.js +1 -2
- package/dist/components/data/heatmap/heatmap-grid-navigation.d.ts +7 -0
- package/dist/components/data/heatmap/heatmap-grid-navigation.js +1 -0
- package/dist/components/data/heatmap/heatmap.class.d.ts +3 -23
- package/dist/components/data/heatmap/heatmap.class.js +2 -2
- package/dist/components/data/sequence-strip/sequence-strip.class.d.ts +3 -9
- package/dist/components/data/sequence-strip/sequence-strip.class.js +3 -3
- package/dist/components/data/table/table.class.d.ts +5 -14
- package/dist/components/data/table/table.class.js +6 -6
- package/dist/components/forms/button/button.class.d.ts +2 -2
- package/dist/components/forms/button/button.class.js +9 -9
- package/dist/components/forms/combobox/combobox.class.d.ts +1 -4
- package/dist/components/forms/combobox/combobox.class.js +2 -2
- package/dist/components/forms/input/time-input.class.d.ts +1 -1
- package/dist/components/forms/input/time-input.class.js +1 -1
- package/dist/components/forms/select/select.class.d.ts +1 -2
- package/dist/components/forms/swatch-picker/swatch-picker.class.d.ts +3 -1
- package/dist/components/forms/swatch-picker/swatch-picker.class.js +1 -1
- package/dist/components/layout/app-rail/app-rail-item.class.d.ts +3 -6
- package/dist/components/layout/app-rail/app-rail-item.class.js +1 -1
- package/dist/components/layout/app-rail/app-rail.class.d.ts +2 -4
- package/dist/components/layout/app-rail/app-rail.class.js +1 -1
- package/dist/components/layout/app-rail-group/app-rail-group.class.d.ts +2 -6
- package/dist/components/layout/app-rail-group/app-rail-group.class.js +1 -1
- package/dist/components/layout/carousel/carousel.class.d.ts +1 -4
- package/dist/components/layout/carousel/carousel.class.js +2 -2
- package/dist/components/layout/command-palette/command-palette.class.js +1 -1
- package/dist/components/layout/details/details.class.d.ts +2 -4
- package/dist/components/layout/details/details.class.js +1 -1
- package/dist/components/layout/dock-panel/dock-panel.class.d.ts +3 -7
- package/dist/components/layout/dock-panel/dock-panel.class.js +1 -1
- package/dist/components/layout/menu/menu.class.js +1 -1
- package/dist/components/layout/multi-split/multi-split.class.d.ts +2 -4
- package/dist/components/layout/multi-split/multi-split.class.js +1 -1
- package/dist/components/layout/navigation-menu-item/navigation-menu-item.class.d.ts +2 -4
- package/dist/components/layout/navigation-menu-item/navigation-menu-item.class.js +1 -1
- package/dist/components/layout/reorder-list/reorder-item.class.d.ts +1 -4
- package/dist/components/layout/reorder-list/reorder-item.class.js +2 -2
- package/dist/components/media/attachment-trigger/attachment-trigger.class.d.ts +5 -9
- package/dist/components/media/attachment-trigger/attachment-trigger.class.js +5 -5
- package/dist/components/media/av-player/av-player.class.js +3 -3
- package/dist/components/media/file-input/file-input.class.d.ts +3 -6
- package/dist/components/media/file-input/file-input.class.js +3 -3
- package/dist/components/media/lightbox/lightbox.class.d.ts +11 -20
- package/dist/components/media/lightbox/lightbox.class.js +1 -1
- package/dist/components/media/map/map-data-layers.d.ts +20 -0
- package/dist/components/media/map/map-data-layers.js +1 -0
- package/dist/components/media/map/map.class.js +3 -3
- package/dist/components/media/media-time.d.ts +2 -0
- package/dist/components/media/media-time.js +1 -0
- package/dist/components/media/video/video.class.js +5 -5
- package/dist/components/media/video-playlist/video-playlist.class.js +2 -2
- package/dist/components/overlays/callout/callout.class.d.ts +2 -5
- package/dist/components/overlays/callout/callout.class.js +2 -2
- package/dist/components/overlays/dialog/dialog.class.d.ts +4 -7
- package/dist/components/overlays/dialog/dialog.class.js +2 -2
- package/dist/components/overlays/overlay/dropdown.class.d.ts +5 -10
- package/dist/components/overlays/overlay/dropdown.class.js +2 -2
- package/dist/components/overlays/overlay/popover.class.d.ts +2 -3
- package/dist/components/overlays/popup/popup.class.js +1 -1
- package/dist/components/overlays/progress/progress-bar.class.d.ts +1 -4
- package/dist/components/overlays/progress/progress-bar.class.js +2 -2
- package/dist/components/overlays/progress/progress-ring.class.d.ts +1 -4
- package/dist/components/overlays/progress/progress-ring.class.js +2 -2
- package/dist/components/overlays/progress/progress-shared.d.ts +3 -3
- package/dist/components/overlays/progress/progress-shared.js +1 -1
- package/dist/components/overlays/toast/toast-item.class.js +1 -1
- package/dist/components/retrieval/graph/graph.class.d.ts +5 -10
- package/dist/components/retrieval/graph/graph.class.js +1 -1
- package/dist/components/retrieval/knowledge-base/knowledge-base.class.d.ts +7 -14
- package/dist/components/retrieval/knowledge-base/knowledge-base.class.js +2 -3
- package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.d.ts +2 -8
- package/dist/components/retrieval/memory-panel/memory-panel.class.js +0 -4
- package/dist/components/retrieval/rag-answer/rag-answer.class.js +1 -1
- package/dist/components/utility/export-button/export-button.class.d.ts +6 -10
- package/dist/components/utility/export-button/export-button.class.js +1 -1
- package/dist/components/utility/mention-popover/mention-popover.class.js +1 -1
- package/dist/components/viewers/geojson-view/geojson-view.class.d.ts +1 -1
- package/dist/components/viewers/highlight-layer/highlight-layer-timing.js +1 -1
- package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +4 -4
- package/dist/events.d.ts +17 -78
- package/dist/framework-types.d.ts +1 -1
- package/dist/internal/catalog-picker.js +1 -1
- package/dist/internal/css-motion-time.d.ts +7 -0
- package/dist/internal/css-motion-time.js +1 -0
- package/dist/internal/data-state-renderer.d.ts +1 -3
- package/dist/internal/data-state-renderer.js +1 -1
- package/dist/internal/localization-runtime.d.ts +2 -0
- package/dist/internal/localization-runtime.js +1 -1
- package/dist/internal/lyra-element.js +2 -2
- package/dist/internal/package-metadata.d.ts +1 -1
- package/dist/internal/package-metadata.js +1 -1
- package/dist/looks/data.css +1 -1
- package/dist/looks/terminal.css +1 -1
- package/dist/lyra.d.ts +1 -592
- package/dist/lyra.js +1 -1
- package/dist/testing/event-factory.d.ts +2 -2
- package/dist/testing/interaction-drivers.d.ts +5 -3
- package/dist/testing/lyra-tag-event-map.js +1 -1
- package/dist/theme/looks/data.d.ts +1 -1
- package/dist/theme/looks/data.js +1 -1
- package/dist/theme/looks/terminal.d.ts +1 -1
- package/dist/theme/looks/terminal.js +1 -1
- package/dist/theme/theme.d.ts +2 -80
- package/dist/theme/theme.js +1 -1
- package/llms/components/lr-agent-workspace.md +24 -2
- package/llms/components/lr-alert.md +1 -1
- package/llms/components/lr-animation.md +1 -1
- package/llms/components/lr-app-rail.md +8 -10
- package/llms/components/lr-approval-queue.md +2 -4
- package/llms/components/lr-attachment-trigger.md +3 -4
- package/llms/components/lr-badge.md +2 -2
- package/llms/components/lr-button.md +45 -99
- package/llms/components/lr-callout.md +3 -4
- package/llms/components/lr-carousel.md +3 -5
- package/llms/components/lr-chat-message.md +1 -2
- package/llms/components/lr-claim-evidence.md +1 -1
- package/llms/components/lr-code-block-core.md +2 -2
- package/llms/components/lr-code-block.md +5 -6
- package/llms/components/lr-color-picker.md +1 -1
- package/llms/components/lr-combobox.md +5 -6
- package/llms/components/lr-compare-panel.md +2 -4
- package/llms/components/lr-confirm-bar.md +3 -7
- package/llms/components/lr-context-inspector.md +3 -2
- package/llms/components/lr-context-menu.md +2 -2
- package/llms/components/lr-context-meter.md +2 -4
- package/llms/components/lr-copy-button.md +1 -1
- package/llms/components/lr-data-grid.md +4 -7
- package/llms/components/lr-details.md +3 -3
- package/llms/components/lr-dialog.md +4 -6
- package/llms/components/lr-dock-panel.md +5 -6
- package/llms/components/lr-document-library.md +5 -7
- package/llms/components/lr-drawer.md +3 -3
- package/llms/components/lr-dropdown.md +4 -5
- package/llms/components/lr-eval-run.md +3 -5
- package/llms/components/lr-export-button.md +4 -7
- package/llms/components/lr-file-input.md +0 -5
- package/llms/components/lr-funnel.md +1 -1
- package/llms/components/lr-graph.md +3 -7
- package/llms/components/lr-icon.md +1 -1
- package/llms/components/lr-include.md +1 -1
- package/llms/components/lr-input.md +31 -79
- package/llms/components/lr-json-viewer.md +1 -1
- package/llms/components/lr-knowledge-base.md +4 -6
- package/llms/components/lr-knowledge-graph-explorer.md +2 -5
- package/llms/components/lr-known-date.md +1 -1
- package/llms/components/lr-lightbox.md +9 -7
- package/llms/components/lr-lite-chart.md +1 -5
- package/llms/components/lr-markdown-core.md +3 -4
- package/llms/components/lr-markdown.md +3 -5
- package/llms/components/lr-mcp-app.md +1 -1
- package/llms/components/lr-message-actions.md +2 -3
- package/llms/components/lr-message-feedback.md +1 -3
- package/llms/components/lr-message-parts.md +4 -5
- package/llms/components/lr-multi-split.md +8 -7
- package/llms/components/lr-native-time-input.md +1 -1
- package/llms/components/lr-navigation-menu.md +5 -5
- package/llms/components/lr-number-input.md +3 -1
- package/llms/components/lr-otp-input.md +2 -0
- package/llms/components/lr-page.md +1 -1
- package/llms/components/lr-pan-zoom.md +1 -1
- package/llms/components/lr-phone-input.md +3 -1
- package/llms/components/lr-popover.md +2 -2
- package/llms/components/lr-progress-bar.md +3 -5
- package/llms/components/lr-progress-ring.md +5 -7
- package/llms/components/lr-prompt-input.md +1 -1
- package/llms/components/lr-prompt-queue.md +1 -1
- package/llms/components/lr-prompt-studio.md +1 -1
- package/llms/components/lr-rag-eval-dashboard.md +1 -1
- package/llms/components/lr-rating.md +2 -2
- package/llms/components/lr-realtime-session.md +1 -1
- package/llms/components/lr-reorder-item.md +1 -1
- package/llms/components/lr-reorder-list.md +2 -3
- package/llms/components/lr-retrieval-compare.md +1 -1
- package/llms/components/lr-select.md +3 -1
- package/llms/components/lr-selection-toolbar.md +1 -1
- package/llms/components/lr-sequence-strip.md +3 -8
- package/llms/components/lr-span-waterfall.md +1 -1
- package/llms/components/lr-split-panel.md +1 -1
- package/llms/components/lr-streaming-text-core.md +2 -1
- package/llms/components/lr-streaming-text.md +3 -2
- package/llms/components/lr-subagent-panel.md +1 -1
- package/llms/components/lr-swatch-picker.md +7 -6
- package/llms/components/lr-switch.md +3 -1
- package/llms/components/lr-table.md +33 -85
- package/llms/components/lr-terminal.md +2 -5
- package/llms/components/lr-textarea.md +1 -1
- package/llms/components/lr-thread-list.md +8 -14
- package/llms/components/lr-time-input.md +1 -1
- package/llms/components/lr-toggle-group.md +2 -2
- package/llms/components/lr-toggle.md +1 -1
- package/llms/components/lr-tool-approval-dialog.md +4 -7
- package/llms/components/lr-tool-call-block.md +1 -1
- package/llms/components/lr-tool-timeline.md +2 -5
- package/llms/components/lr-video-playlist.md +1 -1
- package/llms/components/lr-video.md +1 -1
- package/llms/components/lr-widget-renderer.md +7 -6
- package/llms/components/lr-zoomable-frame.md +1 -1
- package/llms/index.md +3 -618
- package/llms/migration.md +614 -614
- package/llms/shared/events-and-types.md +32 -31
- package/llms/shared/frameworks-and-ssr.md +7 -3
- package/llms/shared/imports-and-registration.md +22 -22
- package/llms/shared/localization-and-rtl.md +2 -2
- package/llms/shared/native-styles-and-utilities.md +263 -0
- package/llms/shared/styles-and-tokens.md +85 -676
- package/llms/shared/testing-and-utilities.md +12 -11
- package/llms/shared/v23-to-v24-migration.md +167 -0
- package/llms/shared.md +149 -494
- package/llms/tokens.md +3 -3
- package/llms.txt +9 -4
- package/package.json +7 -311
- package/registrations.json +1 -1
- package/vscode-html-data.json +1 -1
- package/web-types.json +1 -1
- package/dist/ssr-loader.d.ts +0 -2
- package/dist/ssr-loader.js +0 -1
- package/dist/theme/presets/shadcn.d.ts +0 -22
- package/dist/theme/presets/shadcn.js +0 -1
- package/dist/theme/presets.d.ts +0 -49
- package/dist/theme/presets.js +0 -1
- package/dist/themes/shadcn.css +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{
|
|
1
|
+
import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{keyed}from"lit/directives/keyed.js";import{LyraElement}from"../../../internal/lyra-element.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{styles}from"./approval-queue.styles.js";import{overallSemanticLabel}from"../semantic-owner.js";import{firstByIdentity}from"../collection-identity.js";import{LYRA_DEFAULT_approvalQueueEmpty,LYRA_DEFAULT_approvalQueueLabel,LYRA_DEFAULT_approvalQueueLimit,LYRA_DEFAULT_approvalQueueOpen,LYRA_DEFAULT_approvalQueuePending,LYRA_DEFAULT_approvalQueuePendingCount,LYRA_DEFAULT_confirmApproved,LYRA_DEFAULT_confirmDenied}from"../../../internal/default-strings.generated.js";const MAX_RENDERED_REQUESTS=500;class LyraApprovalQueue extends LyraElement{constructor(){super(...arguments),this.requests=[],this.selectedInvocationId=null,this.open=!1,this.readonly=!1,this.nestedCloseInvocationId=null,this.decisionDispatching=!1}static{this.defaultStrings={...super.defaultStrings,approvalQueueEmpty:LYRA_DEFAULT_approvalQueueEmpty,approvalQueueLabel:LYRA_DEFAULT_approvalQueueLabel,approvalQueueLimit:LYRA_DEFAULT_approvalQueueLimit,approvalQueueOpen:LYRA_DEFAULT_approvalQueueOpen,approvalQueuePending:LYRA_DEFAULT_approvalQueuePending,approvalQueuePendingCount:LYRA_DEFAULT_approvalQueuePendingCount,confirmApproved:LYRA_DEFAULT_confirmApproved,confirmDenied:LYRA_DEFAULT_confirmDenied}}emitApprovalDecisionRequest(detail){return this.emit("lr-approval-decision-request",Object.freeze(detail),{cancelable:!0})}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["requests"])}static{this.styles=[LyraElement.styles,styles]}normalizedRequestsFor(value){const requests=Array.isArray(value)?value:[];return firstByIdentity(requests,request=>request.id)}get normalizedRequests(){return this.normalizedRequestsFor(this.requests)}get selectedRequest(){return this.normalizedRequests.find(request=>request.id===this.selectedInvocationId)}willUpdate(changed){if(super.willUpdate(changed),!changed.has("requests")&&!changed.has("selectedInvocationId"))return;const selectedInvocationId=this.selectedInvocationId,selected=this.selectedRequest;if(selected&&(selected.status??"pending")==="pending")return;const previousSelected=selectedInvocationId!==null&&changed.has("requests")?this.normalizedRequestsFor(changed.get("requests")).find(request=>request.id===selectedInvocationId):void 0,invalidated=this.hasUpdated&&!changed.has("selectedInvocationId")&&selectedInvocationId!==null&&previousSelected!==void 0&&(previousSelected.status??"pending")==="pending",nestedCloseInSameCycle=this.nestedCloseInvocationId===selectedInvocationId;this.selectedInvocationId=null,this.open=!1,invalidated&&!nestedCloseInSameCycle&&this.emit("lr-approval-close",{invocationId:selectedInvocationId,reason:"request-invalidated"})}updated(changed){super.updated(changed),this.nestedCloseInvocationId=null}pendingCount(){return this.normalizedRequests.filter(request=>(request.status??"pending")==="pending").length}formatCount(value){return getNumberFormat(this.effectiveLocale).format(value)}statusLabel(status){return status==="approved"?this.localize("confirmApproved"):status==="denied"?this.localize("confirmDenied"):this.localize("approvalQueuePending")}statusVariant(status){return status==="approved"?"success":status==="denied"?"danger":"warning"}select(request){(request.status??"pending")==="pending"&&(this.selectedInvocationId=request.id,this.open=!0,this.emit("lr-approval-select",{invocationId:request.id}))}onApprove(request,event){if(!this.decisionDispatching){this.decisionDispatching=!0;try{if(event.stopPropagation(),(request.status??"pending")!=="pending")return;this.emitApprovalDecisionRequest({invocationId:request.id,approved:!0,args:event.detail.args}).defaultPrevented&&event.preventDefault()}finally{this.decisionDispatching=!1}}}onDeny(request,event){if(!this.decisionDispatching){this.decisionDispatching=!0;try{if(event.stopPropagation(),(request.status??"pending")!=="pending")return;this.emitApprovalDecisionRequest({invocationId:request.id,approved:!1}).defaultPrevented&&event.preventDefault()}finally{this.decisionDispatching=!1}}}onClose(request,event){if(event.stopPropagation(),this.nestedCloseInvocationId=request.id,request.id===this.selectedInvocationId){const wasOpen=this.open;this.open=!1,wasOpen||this.requestUpdate()}else this.requestUpdate();this.emit("lr-approval-close",{invocationId:request.id,reason:event.detail.reason})}renderRequest(request){const status=request.status??"pending",statusId=`approval-queue-status-${request.id}`;return html`<div role="listitem"><button
|
|
2
2
|
part="request"
|
|
3
3
|
type="button"
|
|
4
4
|
data-selected=${request.id===this.selectedInvocationId?"true":"false"}
|
|
@@ -22,9 +22,7 @@ import{__decorate}from"tslib";import{warnDeprecatedUsage}from"../../../internal/
|
|
|
22
22
|
.toolName=${request.toolName}
|
|
23
23
|
.args=${request.args}
|
|
24
24
|
.readonly=${this.readonly}
|
|
25
|
-
@lr-approve=${event=>event.stopPropagation()}
|
|
26
25
|
@lr-approve-request=${event=>this.onApprove(request,event)}
|
|
27
|
-
@lr-deny=${event=>event.stopPropagation()}
|
|
28
26
|
@lr-deny-request=${event=>this.onDeny(request,event)}
|
|
29
27
|
@lr-close=${event=>this.onClose(request,event)}
|
|
30
28
|
></lr-tool-approval-dialog>`):nothing}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import{type TemplateResult,type PropertyValues}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';export type CompareVote='a'|'b'|'tie'|'both-bad';export interface LyraComparePanelEventMap{
|
|
2
|
-
/** @deprecated Use `lr-vote-request`. */
|
|
3
|
-
'lr-vote':LyraComparePanelEventMap['lr-vote-request'];'lr-vote-request':CustomEvent<{choice:CompareVote;itemId:string;}>;}
|
|
1
|
+
import{type TemplateResult,type PropertyValues}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';export type CompareVote='a'|'b'|'tie'|'both-bad';export interface LyraComparePanelEventMap{'lr-vote-request':CustomEvent<{choice:CompareVote;itemId:string;}>;}
|
|
4
2
|
/**
|
|
5
3
|
* `<lr-compare-panel>` — side-by-side A/B output comparison with a winner
|
|
6
4
|
* vote (LMSYS-arena / LangSmith-pairwise style): two slotted panes, a vote
|
|
@@ -14,7 +12,6 @@ import{type TemplateResult,type PropertyValues}from'lit';import{LyraElement}from
|
|
|
14
12
|
* @slot a - The first output (any content — a chat message, markdown, a viewer).
|
|
15
13
|
* @slot b - The second output.
|
|
16
14
|
* @slot prompt - Optional shared-input header above both panes.
|
|
17
|
-
* @event lr-vote - Deprecated cancelable compatibility alias of `lr-vote-request`.
|
|
18
15
|
* @event lr-vote-request - `detail: { choice, itemId }`. Cancelable; preventing it preserves the prior vote.
|
|
19
16
|
* @csspart base - The outer wrapper.
|
|
20
17
|
* @csspart prompt - The optional prompt header, hidden when the `prompt` slot is empty.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{
|
|
1
|
+
import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{styles}from"./compare-panel.styles.js";import{overallSemanticLabel,overallSemanticRole}from"../semantic-owner.js";import{collectInitialSlotAssignment}from"../../../internal/initial-slot-collection.js";import{LYRA_DEFAULT_comparePanel,LYRA_DEFAULT_compareResponseA,LYRA_DEFAULT_compareResponseB,LYRA_DEFAULT_compareVoteBetter,LYRA_DEFAULT_compareVoteBothBad,LYRA_DEFAULT_compareVoteLabel,LYRA_DEFAULT_compareVoteRecorded,LYRA_DEFAULT_compareVoteTie}from"../../../internal/default-strings.generated.js";class LyraComparePanel extends LyraElement{constructor(){super(...arguments),this.hasPromptSlot=!1,this._labelA="",this._labelB="",this._vote=null,this._itemId="",this._syncScroll=!1,this._disabled=!1,this.pendingScrollReset=!1,this.suppressSync=!1,this.ownerRealmGeneration=0,this.voteAssignedInCommit=!1,this.voteWriteVersion=0,this.allowedVotes=["a","b","tie","both-bad"],this.onPromptSlotChange=e=>{this.collectPromptSlotContent(e.target)},this.voteDispatching=!1,this.onPaneScroll=source=>()=>{if(!this.syncScroll||this.suppressSync)return;const from=source==="a"?this.paneAEl:this.paneBEl,to=source==="a"?this.paneBEl:this.paneAEl;if(!from||!to)return;const fromMax=from.scrollHeight-from.clientHeight,toMax=to.scrollHeight-to.clientHeight;if(fromMax<=0)return;const ownerDocument=this.ownerDocument,ownerWindow=ownerDocument.defaultView;if(!ownerWindow||!this.isConnected)return;const fraction=from.scrollTop/fromMax;this.suppressSync=!0,to.scrollTop=fraction*toMax;const generation=this.ownerRealmGeneration,handle=ownerWindow.requestAnimationFrame(()=>{this.syncScrollRafId!==handle||this.syncScrollRafOwner!==ownerWindow||this.syncScrollRafDocument!==ownerDocument||this.ownerRealmGeneration!==generation||!this.isConnected||this.ownerDocument!==ownerDocument||(this.syncScrollRafId=void 0,this.syncScrollRafOwner=void 0,this.syncScrollRafDocument=void 0,this.suppressSync=!1)});this.syncScrollRafId=handle,this.syncScrollRafOwner=ownerWindow,this.syncScrollRafDocument=ownerDocument}}static{this.defaultStrings={...super.defaultStrings,comparePanel:LYRA_DEFAULT_comparePanel,compareResponseA:LYRA_DEFAULT_compareResponseA,compareResponseB:LYRA_DEFAULT_compareResponseB,compareVoteBetter:LYRA_DEFAULT_compareVoteBetter,compareVoteBothBad:LYRA_DEFAULT_compareVoteBothBad,compareVoteLabel:LYRA_DEFAULT_compareVoteLabel,compareVoteRecorded:LYRA_DEFAULT_compareVoteRecorded,compareVoteTie:LYRA_DEFAULT_compareVoteTie}}emitVoteRequest(detail){return this.emit("lr-vote-request",Object.freeze(detail),{cancelable:!0})}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["allowedVotes"])}static{this.styles=[LyraElement.styles,styles]}static{this.properties={labelA:{attribute:"label-a",noAccessor:!0},labelB:{attribute:"label-b",noAccessor:!0},vote:{reflect:!0,noAccessor:!0},itemId:{attribute:"item-id",noAccessor:!0},syncScroll:{type:Boolean,attribute:"sync-scroll",noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0}}}get labelA(){return this._labelA}set labelA(next){const old=this._labelA;this._labelA=next??"",this.requestUpdate("labelA",old)}get labelB(){return this._labelB}set labelB(next){const old=this._labelB;this._labelB=next??"",this.requestUpdate("labelB",old)}get vote(){return this._vote}set vote(next){this.voteWriteVersion++,this.voteAssignedInCommit=!0;const old=this._vote;this._vote=next??null,this._vote?this.setAttribute("vote",this._vote):this.removeAttribute("vote"),this.requestUpdate("vote",old)}get itemId(){return this._itemId}set itemId(next){const old=this._itemId;this._itemId=next??"",old!==this._itemId&&(this.pendingScrollReset=!0),this.requestUpdate("itemId",old)}get syncScroll(){return this._syncScroll}set syncScroll(next){const old=this._syncScroll;this._syncScroll=!!next,this.requestUpdate("syncScroll",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this.requestUpdate("disabled",old)}collectPromptSlotContent(slot){this.hasPromptSlot=slot.assignedNodes({flatten:!0}).length>0}disconnectedCallback(){this.resetScrollSyncFrame(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.resetScrollSyncFrame()}resetScrollSyncFrame(){this.ownerRealmGeneration+=1,this.syncScrollRafId!==void 0&&this.syncScrollRafOwner?.cancelAnimationFrame(this.syncScrollRafId),this.syncScrollRafId=void 0,this.syncScrollRafOwner=void 0,this.syncScrollRafDocument=void 0,this.suppressSync=!1}castVote(choice){if(!this.voteDispatching){this.voteDispatching=!0;try{if(this.disabled)return;const itemId=this.itemId,voteVersion=this.voteWriteVersion,labelAText=this.labelA||this.localize("compareResponseA"),labelBText=this.labelB||this.localize("compareResponseB"),label=choice==="a"?labelAText:choice==="b"?labelBText:choice==="tie"?this.localize("compareVoteTie"):this.localize("compareVoteBothBad");if(this.emitVoteRequest({choice,itemId}).defaultPrevented||this.disabled||this.itemId===itemId&&this.voteWriteVersion!==voteVersion)return;this.itemId===itemId&&(this.vote=choice),this.liveRegion?.announce(this.localize("compareVoteRecorded",void 0,{label}),{force:!0})}finally{this.voteDispatching=!1}}}voteButton(choice,label){return!Array.isArray(this.allowedVotes)||!this.allowedVotes.includes(choice)?nothing:html`<button
|
|
2
2
|
part="vote-button"
|
|
3
3
|
type="button"
|
|
4
4
|
?disabled=${this.disabled}
|
|
@@ -21,11 +21,7 @@ export type ConfirmBarReturnFocusTarget=HTMLElement|null|(()=>HTMLElement|null);
|
|
|
21
21
|
* finalizes the decision, a rejection restores the undecided state. Calling it more than once (from
|
|
22
22
|
* one listener or several) waits for all of them.
|
|
23
23
|
*/
|
|
24
|
-
export type ConfirmBarWaitUntil=(promise:Promise<unknown>)=>void;export interface LyraConfirmBarEventMap{
|
|
25
|
-
/** @deprecated Use `lr-deny-request`. */
|
|
26
|
-
'lr-deny':LyraConfirmBarEventMap['lr-deny-request'];
|
|
27
|
-
/** @deprecated Use `lr-approve-request`. */
|
|
28
|
-
'lr-approve':LyraConfirmBarEventMap['lr-approve-request'];'lr-approve-request':CustomEvent<{args:unknown;waitUntil:ConfirmBarWaitUntil;}>;'lr-deny-request':CustomEvent<{waitUntil:ConfirmBarWaitUntil;}>;'lr-decision-settled':CustomEvent<{decision:ApprovalDecision;}>;}
|
|
24
|
+
export type ConfirmBarWaitUntil=(promise:Promise<unknown>)=>void;export interface LyraConfirmBarEventMap{'lr-approve-request':CustomEvent<{args:unknown;waitUntil:ConfirmBarWaitUntil;}>;'lr-deny-request':CustomEvent<{waitUntil:ConfirmBarWaitUntil;}>;'lr-decision-settled':CustomEvent<{decision:ApprovalDecision;}>;}
|
|
29
25
|
/**
|
|
30
26
|
* `<lr-confirm-bar>` — an inline, non-modal approve/deny block for one proposed action: the
|
|
31
27
|
* in-flow sibling of `<lr-tool-approval-dialog>` for confirmations that should sit in the
|
|
@@ -112,14 +108,12 @@ export type ConfirmBarWaitUntil=(promise:Promise<unknown>)=>void;export interfac
|
|
|
112
108
|
* the proposed change).
|
|
113
109
|
* @slot footer - Extra content at the start of the action row (e.g. a "remember this choice"
|
|
114
110
|
* checkbox), mirroring `lr-tool-approval-dialog`'s own `footer` slot.
|
|
115
|
-
* @event lr-approve - Deprecated cancelable compatibility alias of `lr-approve-request`.
|
|
116
111
|
* @event lr-approve-request - `detail: { args, waitUntil }` — `args` is the `args` prop as-is (no editing in
|
|
117
112
|
* the bar), matching `lr-tool-approval-dialog`'s own `args` detail. Cancelable: a listener calling
|
|
118
113
|
* `preventDefault()` sets `pendingAction` to `'approve'` instead of finalizing synchronously; set
|
|
119
114
|
* `.decision` (or clear `.pendingAction` back to `null`) once your async work settles. `waitUntil(promise)`
|
|
120
115
|
* does the same thing declaratively and needs no `preventDefault()`: the bar stays pending until
|
|
121
116
|
* the promise settles, then finalizes on resolution or bounces back on rejection.
|
|
122
|
-
* @event lr-deny - Deprecated cancelable compatibility alias of `lr-deny-request`.
|
|
123
117
|
* @event lr-deny-request - `detail: { waitUntil }`, the same resolver `lr-approve-request` carries and no other data,
|
|
124
118
|
* matching the dialog's detail-free `lr-deny-request`. Cancelable, same `pendingAction` mechanism as `lr-approve-request`.
|
|
125
119
|
* @event lr-decision-settled - `detail: { decision }`. Emitted after the decided `[part="status"]`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{
|
|
1
|
+
import{__decorate}from"tslib";import{html,nothing,svg}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{hasRealContent,hostAriaLabel,nextId}from"../../../internal/a11y.js";import{resolveHeadingLevel}from"../../../internal/heading-level.js";import{deferComposedFocusRepair,focusFirstAvailable,isComposedFocusAvailable,repairComposedFocus}from"../../../internal/focus-navigation.js";import{devWarnOnce}from"../../../internal/dev-mode-attribute-warning.js";import{markVetoGuardWrite,VetoWriteGuard}from"../../../internal/veto-write-guard.js";import{resolveLocalizedParts}from"../../../internal/localization-runtime.js";import"../../layout/details/details.class.js";import"../../utility/json-viewer/json-viewer.class.js";import"../../utility/live-region/live-region.class.js";import"../../forms/button/button.class.js";import{styles}from"./confirm-bar.styles.js";import{approvalAction}from"../approval-state.js";import{LYRA_DEFAULT_approve,LYRA_DEFAULT_collapse,LYRA_DEFAULT_confirmApproved,LYRA_DEFAULT_confirmApprovedAnnounce,LYRA_DEFAULT_confirmDenied,LYRA_DEFAULT_confirmDeniedAnnounce,LYRA_DEFAULT_deny,LYRA_DEFAULT_details,LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_progress,LYRA_DEFAULT_restore,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_toolApprovalArgsLabel,LYRA_DEFAULT_toolApprovalGenericTool,LYRA_DEFAULT_toolApprovalHeading}from"../../../internal/default-strings.generated.js";const ICON_VIEW_BOX="0 0 24 24",ICON_STROKE_WIDTH="1.75";function approvedIcon(){return svg`
|
|
2
2
|
<svg width="1em" height="1em" viewBox=${ICON_VIEW_BOX} fill="none" stroke="currentColor" stroke-width=${ICON_STROKE_WIDTH} stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">
|
|
3
3
|
<circle cx="12" cy="12" r="9"></circle>
|
|
4
4
|
<polyline points="8 12.5 11 15.5 16 9.5"></polyline>
|
|
@@ -9,7 +9,7 @@ import{__decorate}from"tslib";import{warnDeprecatedUsage}from"../../../internal/
|
|
|
9
9
|
<line x1="9" y1="9" x2="15" y2="15"></line>
|
|
10
10
|
<line x1="15" y1="9" x2="9" y2="15"></line>
|
|
11
11
|
</svg>
|
|
12
|
-
`}class LyraConfirmBar extends LyraElement{constructor(){super(...arguments),this.toolName="",this.heading="",this.headingLevel="none",this.args=void 0,this._decision=null,this._pending=null,this.dispatchWriteGuard=new VetoWriteGuard,this.disabled=!1,this.variant="neutral",this.size="m",this.frame="card",this.autofocus=!1,this.escapeDenies=!1,this.returnFocusTo=null,this.hasBodySlot=!1,this.headingId=nextId("confirm-bar-heading"),this.deferralGeneration=0,this.onBodySlotChange=e=>{this.hasBodySlot=hasRealContent(e.target.assignedNodes({flatten:!0}))},this.onBaseKeyDown=event=>{if(!this.escapeDenies||event.key!=="Escape")return;const decisionBefore=this.decision,pendingBefore=this.pendingAction;this.decide("denied"),(this.decision!==decisionBefore||this.pendingAction!==pendingBefore)&&event.stopPropagation()},this.decisionDispatching=!1}static{this.defaultStrings={...super.defaultStrings,approve:LYRA_DEFAULT_approve,collapse:LYRA_DEFAULT_collapse,confirmApproved:LYRA_DEFAULT_confirmApproved,confirmApprovedAnnounce:LYRA_DEFAULT_confirmApprovedAnnounce,confirmDenied:LYRA_DEFAULT_confirmDenied,confirmDeniedAnnounce:LYRA_DEFAULT_confirmDeniedAnnounce,deny:LYRA_DEFAULT_deny,details:LYRA_DEFAULT_details,fieldRequired:LYRA_DEFAULT_fieldRequired,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,progress:LYRA_DEFAULT_progress,restore:LYRA_DEFAULT_restore,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,toolApprovalArgsLabel:LYRA_DEFAULT_toolApprovalArgsLabel,toolApprovalGenericTool:LYRA_DEFAULT_toolApprovalGenericTool,toolApprovalHeading:LYRA_DEFAULT_toolApprovalHeading}}emitApproveRequest(detail){
|
|
12
|
+
`}class LyraConfirmBar extends LyraElement{constructor(){super(...arguments),this.toolName="",this.heading="",this.headingLevel="none",this.args=void 0,this._decision=null,this._pending=null,this.dispatchWriteGuard=new VetoWriteGuard,this.disabled=!1,this.variant="neutral",this.size="m",this.frame="card",this.autofocus=!1,this.escapeDenies=!1,this.returnFocusTo=null,this.hasBodySlot=!1,this.headingId=nextId("confirm-bar-heading"),this.deferralGeneration=0,this.onBodySlotChange=e=>{this.hasBodySlot=hasRealContent(e.target.assignedNodes({flatten:!0}))},this.onBaseKeyDown=event=>{if(!this.escapeDenies||event.key!=="Escape")return;const decisionBefore=this.decision,pendingBefore=this.pendingAction;this.decide("denied"),(this.decision!==decisionBefore||this.pendingAction!==pendingBefore)&&event.stopPropagation()},this.decisionDispatching=!1}static{this.defaultStrings={...super.defaultStrings,approve:LYRA_DEFAULT_approve,collapse:LYRA_DEFAULT_collapse,confirmApproved:LYRA_DEFAULT_confirmApproved,confirmApprovedAnnounce:LYRA_DEFAULT_confirmApprovedAnnounce,confirmDenied:LYRA_DEFAULT_confirmDenied,confirmDeniedAnnounce:LYRA_DEFAULT_confirmDeniedAnnounce,deny:LYRA_DEFAULT_deny,details:LYRA_DEFAULT_details,fieldRequired:LYRA_DEFAULT_fieldRequired,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,progress:LYRA_DEFAULT_progress,restore:LYRA_DEFAULT_restore,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,toolApprovalArgsLabel:LYRA_DEFAULT_toolApprovalArgsLabel,toolApprovalGenericTool:LYRA_DEFAULT_toolApprovalGenericTool,toolApprovalHeading:LYRA_DEFAULT_toolApprovalHeading}}emitApproveRequest(detail){return this.emit("lr-approve-request",Object.freeze(detail),{cancelable:!0})}emitDenyRequest(detail){return this.emit("lr-deny-request",Object.freeze(detail),{cancelable:!0})}static{this.styles=[LyraElement.styles,styles]}get decision(){return this._decision}set decision(value){const previous=this._decision;this._decision=value,markVetoGuardWrite(this.dispatchWriteGuard),this.requestUpdate("decision",previous)}get pendingAction(){return this._pending}set pendingAction(value){const previous=this._pending;this._pending=value,markVetoGuardWrite(this.dispatchWriteGuard),this.requestUpdate("pendingAction",previous)}willUpdate(changed){if(super.willUpdate(changed),!this.hasUpdated){const defaultSlotNodes=Array.from(this.childNodes).filter(node=>node.nodeType!==Node.ELEMENT_NODE||!node.getAttribute("slot"));this.hasBodySlot=hasRealContent(defaultSlotNodes)}changed.has("decision")&&changed.get("decision")!==void 0&&this.decision!=null&&this.pendingAction!=null&&(this.handOffDecidedFocus(),this.pendingAction=null)}firstUpdated(changed){super.firstUpdated(changed),this.autofocus&&this.focusInitial()}focusInitial(){this.updateComplete.then(async()=>{if(!this.isConnected)return;const deny=this.renderRoot.querySelector('[part="deny-button"]');if(await deny?.updateComplete,!this.isConnected)return;(deny&&isComposedFocusAvailable(deny)?deny:this.statusEl)?.focus()})}decide(next){if(!this.decisionDispatching){this.decisionDispatching=!0;try{if(this.disabled||this.decision!=null||this.pendingAction!=null)return;const deferrals=[];let dispatching=!0;const waitUntil=promise=>{if(!dispatching){devWarnOnce("lyra-confirm-bar-wait-until-after-dispatch","<lr-confirm-bar>: waitUntil() was called after its lr-approve-request/lr-deny-request dispatch had finished, so it did nothing. Call it synchronously from the listener; the promise it receives may settle whenever it likes.");return}deferrals.push(Promise.resolve(promise))};this.dispatchWriteGuard.open();const event=next==="approved"?this.emitApproveRequest({args:this.args,waitUntil}):this.emitDenyRequest({waitUntil});dispatching=!1;const listenerResolvedItself=this.dispatchWriteGuard.touched;if(deferrals.length>0||event.defaultPrevented){if(this.statusEl?.focus(),listenerResolvedItself){for(const deferral of deferrals)deferral.catch(()=>{});return}this.pendingAction=approvalAction(next),deferrals.length>0&&this.awaitDeferredDecision(Promise.all(deferrals),next);return}if(listenerResolvedItself)return;this.handOffDecidedFocus(),this.decision=next}finally{this.decisionDispatching=!1}}}awaitDeferredDecision(promise,next){const action=approvalAction(next);this.deferralGeneration+=1;const generation=this.deferralGeneration,stillOurs=()=>generation===this.deferralGeneration&&this.decision==null&&this.pendingAction===action;promise.then(()=>{stillOurs()&&(this.decision=next)},()=>{stillOurs()&&(this.pendingAction=null,this.returnFocusAfterBounce(action))})}returnFocusAfterBounce(action){this.updateComplete.then(()=>{!this.isConnected||this.decision!=null||this.pendingAction!=null||repairComposedFocus(this,()=>this.renderRoot.querySelector(`[part="${action}-button"]`))})}resolvedReturnFocusTarget(){const target=this.returnFocusTo;return typeof target=="function"?target():target}handOffDecidedFocus(){const target=this.resolvedReturnFocusTarget();target&&focusFirstAvailable([target])||(focusFirstAvailable([this.statusEl]),typeof this.returnFocusTo=="function"&&this.statusEl&&deferComposedFocusRepair(this,this.statusEl,()=>this.resolvedReturnFocusTarget()))}updated(changed){super.updated(changed);const decision=this.decision;if(changed.has("decision")&&changed.get("decision")!==void 0&&decision!=null){const key=decision==="approved"?"confirmApprovedAnnounce":"confirmDeniedAnnounce";this.liveRegion?.announce(this.localize(key),{force:!0}),this.emit("lr-decision-settled",{decision})}}renderHeading(){if(this.heading)return html`${this.heading}`;const toolName=this.toolName||this.localize("toolApprovalGenericTool"),template=this.localize("toolApprovalHeading"),pieces=resolveLocalizedParts(template,marker=>this.localize("toolApprovalHeading",void 0,{tool:marker}));return html`${pieces.map((piece,index)=>index<pieces.length-1?html`${piece}<span part="tool-name">${toolName}</span>`:piece)}`}statusText(){return this.decision==="approved"?this.localize("confirmApproved"):this.localize("confirmDenied")}stopNestedLifecycle(event){event.stopPropagation()}render(){const decided=this.decision!=null,hostLabel=hostAriaLabel(this),headingLevel=resolveHeadingLevel(this.headingLevel??"none");return html`
|
|
13
13
|
<div
|
|
14
14
|
part="base"
|
|
15
15
|
role="group"
|
|
@@ -52,7 +52,7 @@ redactions?:readonly ContextInspectorRedaction[];}export interface LyraContextIn
|
|
|
52
52
|
* clipboard failure.
|
|
53
53
|
* @event lr-toolbar-actions-change - No-detail coordination event surfaced unchanged from the
|
|
54
54
|
* embedded copy button when its logical toolbar action changes availability or backing trigger.
|
|
55
|
-
* @event lr-export - `detail: { format }`, surfaced by the embedded `lr-export-button`, one row
|
|
55
|
+
* @event lr-export-request - `detail: { format }`, surfaced by the embedded `lr-export-button`, one row
|
|
56
56
|
* per segment. Cancelable — see that component's own contract for substituting a
|
|
57
57
|
* server-generated export.
|
|
58
58
|
* @event lr-export-complete - `detail: { format }`, fired after a non-cancelled export completes.
|
|
@@ -37,11 +37,9 @@ export interface EvalExampleToggleDetail{exampleId:string;expanded:boolean;}
|
|
|
37
37
|
* host doesn't need to walk the DOM to find out which example's evidence was activated. */
|
|
38
38
|
export interface EvalCitationSelectDetail{exampleId:string;citation:Citation;}
|
|
39
39
|
/** `detail` for `lr-example-tool-approval-decide-request` -- the nested per-example `<lr-tool-timeline>`'s
|
|
40
|
-
* own `lr-tool-approval-decide` detail (`ToolTimelineApprovalDetail`), correlated with the
|
|
40
|
+
* own `lr-tool-approval-decide-request` detail (`ToolTimelineApprovalDetail`), correlated with the
|
|
41
41
|
* example it came from. */
|
|
42
|
-
export interface EvalToolApprovalDetail extends ToolTimelineApprovalDetail{exampleId:string;}export interface EvalToolActivateDetail extends ToolTimelineActivateDetail{exampleId:string;}export interface EvalToolRenderErrorDetail extends ToolTimelineRenderErrorDetail{exampleId:string;}export interface EvalClaimSelectDetail{exampleId:string;claim:GroundedClaim;}export interface LyraEvalRunEventMap{
|
|
43
|
-
/** @deprecated Use `lr-example-tool-approval-decide-request`. */
|
|
44
|
-
'lr-example-tool-approval-decide':LyraEvalRunEventMap['lr-example-tool-approval-decide-request'];'lr-example-toggle':CustomEvent<EvalExampleToggleDetail>;'lr-example-citation-select':CustomEvent<LyraEventDetailSnapshot<EvalCitationSelectDetail>>;'lr-example-claim-select':CustomEvent<LyraEventDetailSnapshot<EvalClaimSelectDetail>>;'lr-example-tool-approval-decide-request':CustomEvent<EvalToolApprovalDetail>;'lr-example-tool-activate':CustomEvent<EvalToolActivateDetail>;'lr-example-tool-render-error':CustomEvent<EvalToolRenderErrorDetail>;}
|
|
42
|
+
export interface EvalToolApprovalDetail extends ToolTimelineApprovalDetail{exampleId:string;}export interface EvalToolActivateDetail extends ToolTimelineActivateDetail{exampleId:string;}export interface EvalToolRenderErrorDetail extends ToolTimelineRenderErrorDetail{exampleId:string;}export interface EvalClaimSelectDetail{exampleId:string;claim:GroundedClaim;}export interface LyraEvalRunEventMap{'lr-example-toggle':CustomEvent<EvalExampleToggleDetail>;'lr-example-citation-select':CustomEvent<LyraEventDetailSnapshot<EvalCitationSelectDetail>>;'lr-example-claim-select':CustomEvent<LyraEventDetailSnapshot<EvalClaimSelectDetail>>;'lr-example-tool-approval-decide-request':CustomEvent<EvalToolApprovalDetail>;'lr-example-tool-activate':CustomEvent<EvalToolActivateDetail>;'lr-example-tool-render-error':CustomEvent<EvalToolRenderErrorDetail>;}
|
|
45
43
|
/**
|
|
46
44
|
* `<lr-eval-run>` — an evaluation batch's live progress: an overall `<lr-progress-bar>`
|
|
47
45
|
* counting terminal (done/error/cancelled) examples against the batch total, plus one
|
|
@@ -67,7 +65,6 @@ export interface EvalToolApprovalDetail extends ToolTimelineApprovalDetail{examp
|
|
|
67
65
|
* expanded }`.
|
|
68
66
|
* @event lr-example-citation-select - An evidence citation in a nested `<lr-grounding-summary>`
|
|
69
67
|
* was activated. `detail: { exampleId, citation }`.
|
|
70
|
-
* @event lr-example-tool-approval-decide - Deprecated cancelable compatibility alias of `lr-example-tool-approval-decide-request`.
|
|
71
68
|
* @event lr-example-tool-approval-decide-request - A pending tool call in a nested `<lr-tool-timeline>`
|
|
72
69
|
* was approved or denied. `detail: { exampleId, invocationId, approved, args? }`. Cancelable:
|
|
73
70
|
* preventing this correlated event vetoes the nested decision and preserves its pending dialog.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{
|
|
1
|
+
import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,state,query}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{finiteCount}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{AGENT_STATUS_VARIANTS}from"../../../internal/agent-status-variants.js";import{firstByIdentity}from"../collection-identity.js";import{styles}from"./evaluation-run.styles.js";import{agentStatusKind,agentStatusLabel,agentStatusMessage,agentStatusVariant,isAgentStatusTerminal}from"../agent-status-presentation.js";import{overallSemanticLabel,overallSemanticRole}from"../semantic-owner.js";import{LYRA_DEFAULT_agentRunStatusCollecting,LYRA_DEFAULT_agentRunStatusQueued,LYRA_DEFAULT_evaluationRunExampleCancelledAnnounce,LYRA_DEFAULT_evaluationRunExampleCompletedAnnounce,LYRA_DEFAULT_evaluationRunExampleFailedAnnounce,LYRA_DEFAULT_evaluationRunExampleLabel,LYRA_DEFAULT_evaluationRunExampleLimit,LYRA_DEFAULT_evaluationRunExampleStartedAnnounce,LYRA_DEFAULT_evaluationRunExampleWaitingApprovalAnnounce,LYRA_DEFAULT_evaluationRunExampleWaitingInputAnnounce,LYRA_DEFAULT_evaluationRunFailedCount,LYRA_DEFAULT_evaluationRunGroundingHeading,LYRA_DEFAULT_evaluationRunInputHeading,LYRA_DEFAULT_evaluationRunLabel,LYRA_DEFAULT_evaluationRunOutputHeading,LYRA_DEFAULT_evaluationRunProgressLabel,LYRA_DEFAULT_evaluationRunProgressSummary,LYRA_DEFAULT_evaluationRunRunningCount,LYRA_DEFAULT_evaluationRunStatusCancelled,LYRA_DEFAULT_evaluationRunStatusIdle,LYRA_DEFAULT_evaluationRunStatusWaitingApproval,LYRA_DEFAULT_evaluationRunStatusWaitingInput,LYRA_DEFAULT_evaluationRunToolTraceHeading,LYRA_DEFAULT_noData,LYRA_DEFAULT_statusError,LYRA_DEFAULT_statusRunning,LYRA_DEFAULT_statusSuccess}from"../../../internal/default-strings.generated.js";const RUNNING_ERROR_KINDS=["running","error"],MAX_RENDERED_EXAMPLES=500;class LyraEvalRun extends LyraElement{constructor(){super(...arguments),this.examples=[],this.total=null,this.label="",this.expandedIds=new Set,this.isMounting=!0,this.previousStatusById=new Map,this.decisionDispatching=!1}static{this.defaultStrings={...super.defaultStrings,agentRunStatusCollecting:LYRA_DEFAULT_agentRunStatusCollecting,agentRunStatusQueued:LYRA_DEFAULT_agentRunStatusQueued,evaluationRunExampleCancelledAnnounce:LYRA_DEFAULT_evaluationRunExampleCancelledAnnounce,evaluationRunExampleCompletedAnnounce:LYRA_DEFAULT_evaluationRunExampleCompletedAnnounce,evaluationRunExampleFailedAnnounce:LYRA_DEFAULT_evaluationRunExampleFailedAnnounce,evaluationRunExampleLabel:LYRA_DEFAULT_evaluationRunExampleLabel,evaluationRunExampleLimit:LYRA_DEFAULT_evaluationRunExampleLimit,evaluationRunExampleStartedAnnounce:LYRA_DEFAULT_evaluationRunExampleStartedAnnounce,evaluationRunExampleWaitingApprovalAnnounce:LYRA_DEFAULT_evaluationRunExampleWaitingApprovalAnnounce,evaluationRunExampleWaitingInputAnnounce:LYRA_DEFAULT_evaluationRunExampleWaitingInputAnnounce,evaluationRunFailedCount:LYRA_DEFAULT_evaluationRunFailedCount,evaluationRunGroundingHeading:LYRA_DEFAULT_evaluationRunGroundingHeading,evaluationRunInputHeading:LYRA_DEFAULT_evaluationRunInputHeading,evaluationRunLabel:LYRA_DEFAULT_evaluationRunLabel,evaluationRunOutputHeading:LYRA_DEFAULT_evaluationRunOutputHeading,evaluationRunProgressLabel:LYRA_DEFAULT_evaluationRunProgressLabel,evaluationRunProgressSummary:LYRA_DEFAULT_evaluationRunProgressSummary,evaluationRunRunningCount:LYRA_DEFAULT_evaluationRunRunningCount,evaluationRunStatusCancelled:LYRA_DEFAULT_evaluationRunStatusCancelled,evaluationRunStatusIdle:LYRA_DEFAULT_evaluationRunStatusIdle,evaluationRunStatusWaitingApproval:LYRA_DEFAULT_evaluationRunStatusWaitingApproval,evaluationRunStatusWaitingInput:LYRA_DEFAULT_evaluationRunStatusWaitingInput,evaluationRunToolTraceHeading:LYRA_DEFAULT_evaluationRunToolTraceHeading,noData:LYRA_DEFAULT_noData,statusError:LYRA_DEFAULT_statusError,statusRunning:LYRA_DEFAULT_statusRunning,statusSuccess:LYRA_DEFAULT_statusSuccess}}emitExampleToolApprovalDecideRequest(detail){return this.emit("lr-example-tool-approval-decide-request",Object.freeze(detail),{cancelable:!0})}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["examples"])}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-example-citation-select","lr-example-claim-select"])}get normalizedExamples(){return firstByIdentity(Array.isArray(this.examples)?this.examples:[],example=>example.id)}willUpdate(changed){if(super.willUpdate(changed),!changed.has("examples"))return;const ids=new Set(this.normalizedExamples.map(example=>example.id));let pruned;for(const id of this.expandedIds)ids.has(id)||(pruned??=new Set(this.expandedIds),pruned.delete(id));pruned&&(this.expandedIds=pruned)}updated(changed){super.updated(changed);const wasMounting=this.isMounting;this.isMounting=!1,changed.has("examples")&&this.diffAndAnnounce(wasMounting)}statusCounts(){const counts={};for(const example of this.normalizedExamples){const kind=agentStatusKind(example.status);counts[kind]=(counts[kind]??0)+1}return counts}exampleLabel(example,index){return example.label||this.localize("evaluationRunExampleLabel",void 0,{index:getNumberFormat(this.effectiveLocale).format(index+1)})}statusText(status){const override=agentStatusLabel(status);if(override!==void 0)return override;const kind=agentStatusKind(status);switch(kind){case"idle":return this.localize("evaluationRunStatusIdle");case"running":return this.localize("statusRunning");case"queued":return this.localize("agentRunStatusQueued");case"collecting":return this.localize("agentRunStatusCollecting");case"waiting-input":return this.localize("evaluationRunStatusWaitingInput");case"waiting-approval":return this.localize("evaluationRunStatusWaitingApproval");case"done":return this.localize("statusSuccess");case"error":return this.localize("statusError");case"cancelled":return this.localize("evaluationRunStatusCancelled");default:return kind.replace(/[-_]+/g," ").replace(/\b\w/g,letter=>letter.toUpperCase())}}diffAndAnnounce(firstSight){const region=this.liveRegion,nextStatusById=new Map;this.normalizedExamples.forEach((example,index)=>{const kind=agentStatusKind(example.status);if(nextStatusById.set(example.id,kind),firstSight||!region)return;const previous=this.previousStatusById.get(example.id);if(previous===void 0||previous===kind)return;const label=this.exampleLabel(example,index);switch(kind){case"running":region.mode="polite",region.announce(this.localize("evaluationRunExampleStartedAnnounce",void 0,{label}),{force:!0});break;case"done":region.mode="polite",region.announce(this.localize("evaluationRunExampleCompletedAnnounce",void 0,{label}),{force:!0});break;case"error":region.mode="assertive",region.announce(this.localize("evaluationRunExampleFailedAnnounce",void 0,{label}),{force:!0});break;case"cancelled":region.mode="polite",region.announce(this.localize("evaluationRunExampleCancelledAnnounce",void 0,{label}),{force:!0});break;case"waiting-input":region.mode="polite",region.announce(this.localize("evaluationRunExampleWaitingInputAnnounce",void 0,{label}),{force:!0});break;case"waiting-approval":region.mode="polite",region.announce(this.localize("evaluationRunExampleWaitingApprovalAnnounce",void 0,{label}),{force:!0});break;case"idle":break}}),this.previousStatusById=nextStatusById}onExampleToggle(id,event){event.stopPropagation();const{expanded}=event.detail,next=new Set(this.expandedIds);expanded?next.add(id):next.delete(id),this.expandedIds=next,this.emit("lr-example-toggle",{exampleId:id,expanded})}onCitationSelect(exampleId,event){event.stopPropagation(),this.emit("lr-example-citation-select",{exampleId,citation:event.detail.citation})}onClaimSelect(exampleId,event){event.stopPropagation(),this.emit("lr-example-claim-select",{exampleId,claim:event.detail.claim})}onToolApprovalDecide(exampleId,event){if(!this.decisionDispatching){this.decisionDispatching=!0;try{event.stopPropagation(),this.emitExampleToolApprovalDecideRequest({exampleId,...event.detail}).defaultPrevented&&event.preventDefault()}finally{this.decisionDispatching=!1}}}onToolActivate(exampleId,event){event.stopPropagation(),this.emit("lr-example-tool-activate",{exampleId,...event.detail})}onToolRenderError(exampleId,event){event.stopPropagation(),this.emit("lr-example-tool-render-error",{exampleId,...event.detail})}stopOwnedEvent(event){event.stopPropagation()}renderContent(content,part){const text=typeof content?.text=="string"?content.text:"";return content?.format==="code"?html`<lr-code-block
|
|
2
2
|
part=${part}
|
|
3
3
|
code=${text}
|
|
4
4
|
language=${content.language??""}
|
|
@@ -12,7 +12,6 @@ import{__decorate}from"tslib";import{warnDeprecatedUsage}from"../../../internal/
|
|
|
12
12
|
></lr-code-block>`:html`<lr-markdown
|
|
13
13
|
part=${part}
|
|
14
14
|
content=${text}
|
|
15
|
-
@lr-link-click=${this.stopOwnedEvent}
|
|
16
15
|
@lr-render-error=${this.stopOwnedEvent}
|
|
17
16
|
@lr-highlight-activate=${this.stopOwnedEvent}
|
|
18
17
|
@lr-text-select=${this.stopOwnedEvent}
|
|
@@ -35,7 +34,6 @@ import{__decorate}from"tslib";import{warnDeprecatedUsage}from"../../../internal/
|
|
|
35
34
|
<lr-tool-timeline
|
|
36
35
|
part="tool-trace"
|
|
37
36
|
.entries=${toolTrace}
|
|
38
|
-
@lr-tool-approval-decide=${event=>event.stopPropagation()}
|
|
39
37
|
@lr-tool-approval-decide-request=${e=>this.onToolApprovalDecide(example.id,e)}
|
|
40
38
|
@lr-tool-activate=${e=>this.onToolActivate(example.id,e)}
|
|
41
39
|
@lr-tool-render-error=${e=>this.onToolRenderError(example.id,e)}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import{type TemplateResult,type PropertyValues}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import type{LyraAnchor,LyraHighlight,HighlightActivateDetail,TextSelectDetail}from'../../viewers/document-viewer/anchors.js';export type{LyraAnchor,LyraHighlight,LyraHighlightTone,HighlightActivateDetail,TextSelectDetail,}from'../../viewers/document-viewer/anchors.js';import type{LyraFrame,LyraSize}from'../../../internal/variants.js';import type{LyraSearchChangeDetail}from'../../../internal/text-viewer-target.js';import{type LyraClipboardWriteFailure,type LyraClipboardWriteSuccess}from'../../../internal/clipboard.js';export interface LyraTerminalEventMap{
|
|
2
|
-
/** @deprecated Use `lr-download-request`. */
|
|
3
|
-
'lr-download':LyraTerminalEventMap['lr-download-request'];'lr-copy':CustomEvent<LyraClipboardWriteSuccess>;'lr-error':CustomEvent<null>;'lr-copy-error':CustomEvent<LyraClipboardWriteFailure>;'lr-download-request':CustomEvent<{filename:string;}>;'lr-follow-change':CustomEvent<{following:boolean;}>;'lr-search-change':CustomEvent<LyraSearchChangeDetail>;'lr-highlight-activate':CustomEvent<HighlightActivateDetail>;'lr-text-select':CustomEvent<TextSelectDetail>;}
|
|
1
|
+
import{type TemplateResult,type PropertyValues}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import type{LyraAnchor,LyraHighlight,HighlightActivateDetail,TextSelectDetail}from'../../viewers/document-viewer/anchors.js';export type{LyraAnchor,LyraHighlight,LyraHighlightTone,HighlightActivateDetail,TextSelectDetail,}from'../../viewers/document-viewer/anchors.js';import type{LyraFrame,LyraSize}from'../../../internal/variants.js';import type{LyraSearchChangeDetail}from'../../../internal/text-viewer-target.js';import{type LyraClipboardWriteFailure,type LyraClipboardWriteSuccess}from'../../../internal/clipboard.js';export interface LyraTerminalEventMap{'lr-copy':CustomEvent<LyraClipboardWriteSuccess>;'lr-error':CustomEvent<null>;'lr-copy-error':CustomEvent<LyraClipboardWriteFailure>;'lr-download-request':CustomEvent<{filename:string;}>;'lr-follow-change':CustomEvent<{following:boolean;}>;'lr-search-change':CustomEvent<LyraSearchChangeDetail>;'lr-highlight-activate':CustomEvent<HighlightActivateDetail>;'lr-text-select':CustomEvent<TextSelectDetail>;}
|
|
4
2
|
/**
|
|
5
3
|
* `<lr-terminal>` — read-only ANSI console for streamed agent/tool output. Not a PTY: no
|
|
6
4
|
* stdin/keystroke handling, no cursor-addressed full-screen apps. Split ANSI sequences retain at
|
|
@@ -27,7 +25,6 @@ import{type TemplateResult,type PropertyValues}from'lit';import{LyraElement}from
|
|
|
27
25
|
* @event lr-copy - `detail: { ok: true, text }` — the plain-text clipboard write completed.
|
|
28
26
|
* @event lr-error - The clipboard write failed; generic no-detail notification.
|
|
29
27
|
* @event lr-copy-error - `detail: { ok: false, text, reason, error }` — typed clipboard failure.
|
|
30
|
-
* @event lr-download - Deprecated cancelable compatibility alias of `lr-download-request`.
|
|
31
28
|
* @event lr-download-request - `detail: { filename }` — the download button was activated. Cancelable: by
|
|
32
29
|
* default this component itself builds an in-memory Blob of the current plain-text log and
|
|
33
30
|
* triggers a browser download via a synthetic `<a download>` click; a host that calls
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{
|
|
1
|
+
import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{guard}from"lit/directives/guard.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{specialistTokens}from"../../../internal/specialist-tokens.styles.js";import{srOnly}from"../../../internal/a11y.js";import{Announcer,acquireAnnouncementSink}from"../../../internal/announcer.js";import{createAnsiParser}from"../../../internal/ansi.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{finiteCount}from"../../../internal/numbers.js";import{sanitizeCssColor}from"../../../internal/safe-css.js";import{snapshotLyraHighlights}from"../../../internal/highlight-collection.js";import{boundedSelectionRects,boundedSelectionText}from"../../../internal/text-quote.js";import{styles}from"./terminal.styles.js";import{presenceTrueDefaultBooleanConverter as trueDefaultBooleanConverter}from"../../../internal/converters.js";import{writeClipboardText}from"../../../internal/clipboard.js";import{LYRA_DEFAULT_accessibleLabelSeparator,LYRA_DEFAULT_copied,LYRA_DEFAULT_copy,LYRA_DEFAULT_copyFailed,LYRA_DEFAULT_highlightWithLabel,LYRA_DEFAULT_jumpToLatest,LYRA_DEFAULT_terminalDownload,LYRA_DEFAULT_terminalHighlightLine,LYRA_DEFAULT_terminalLabel}from"../../../internal/default-strings.generated.js";const EMPTY_CELL_STYLES={bold:!1,dim:!1,italic:!1,underline:!1,inverse:!1},ANNOUNCE_THROTTLE_MS=10,MAX_SEARCH_MATCHES=1e4,MAX_INPUT_CHARACTERS=1e6,MAX_CELLS_PER_LINE=2e4,MAX_RETAINED_CELLS=2e5,MAX_SCROLLBACK_LINES=1e4,SCROLLBACK_PRUNE_BATCH=256,TONE_BACKGROUND_VAR={accent:"var(--lr-terminal-highlight-accent-bg, var(--lr-color-brand-quiet))",success:"var(--lr-terminal-highlight-success-bg, var(--lr-color-success-quiet))",warning:"var(--lr-terminal-highlight-warning-bg, var(--lr-color-warning-quiet))",danger:"var(--lr-terminal-highlight-danger-bg, var(--lr-color-danger-quiet))",neutral:"var(--lr-terminal-highlight-neutral-bg, var(--lr-color-surface))"};function plainTextOfLine(line){return line.cells.map(c=>c.char).join("")}function groupCells(cells){const segments=[];for(const cell of cells){const last=segments[segments.length-1];last&&stylesEqual(last.styles,cell.styles)?last.text+=cell.char:segments.push({text:cell.char,styles:cell.styles})}return segments}function stylesEqual(a,b){return a.bold===b.bold&&a.dim===b.dim&&a.italic===b.italic&&a.underline===b.underline&&a.inverse===b.inverse&&a.fg===b.fg&&a.bg===b.bg}class LyraTerminal extends LyraElement{constructor(){super(...arguments),this.content="",this.maxScrollback=5e3,this.follow=!0,this.withoutWrap=!1,this.withoutCopyButton=!1,this.downloadable=!1,this.filename="terminal.log",this.announceOutput=!1,this.accessibleLabel="",this._highlights=snapshotLyraHighlights([]),this.activeHighlightId=null,this.size="m",this.frame="card",this.anchorKinds=["line-range"],this.lines=[],this.scrollTargetLineNumber=null,this.copyStatus="rest",this.buffer=[],this.retainedCellCount=0,this.lineSeq=0,this.column=0,this.appliedContent="",this.terminalLineKey=item=>item.number,this.ansiParser=createAnsiParser(),this.copyGeneration=0,this.pendingAnnounceText="",this.announcer=new Announcer({throttleMs:ANNOUNCE_THROTTLE_MS,onFlush:text=>{this.pendingAnnounceText="",this.sink?.announce(text),this.announceRegionEl&&(this.announceRegionEl.textContent=text)}}),this.searchQuery="",this.searchMatches=[],this.searchMatchCountExact=!0,this.searchActiveIndex=-1,this.jumpToLatest=()=>{const changed=!this.follow;this.scrollToBottom(),changed&&this.emit("lr-follow-change",{following:!0})},this.onLineKeyDown=(e,h)=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this.activateHighlight(h))},this.onCopy=()=>{this.copyOutput()},this.downloadDispatching=!1,this.onDownload=()=>{if(!this.downloadDispatching){this.downloadDispatching=!0;try{const filename=this.filename||"terminal.log";if(this.emitDownloadRequest({filename}).defaultPrevented)return;const ownerWindow=this.ownerDocument.defaultView;if(!ownerWindow)return;const blob=new ownerWindow.Blob([this.getPlainText()],{type:"text/plain"}),url=ownerWindow.URL.createObjectURL(blob),a=this.ownerDocument.createElement("a");a.href=url,a.download=filename,a.click(),ownerWindow.setTimeout(()=>ownerWindow.URL.revokeObjectURL(url),5e3)}finally{this.downloadDispatching=!1}}},this.onVisibleRangeChanged=e=>{e.stopPropagation();const atBottom=this.lines.length===0||e.detail.end>=this.lines.length-1;atBottom!==this.follow&&(this.follow=atBottom,this.emit("lr-follow-change",{following:atBottom}))},this.onViewportKeyDown=e=>{e.key==="End"&&this.jumpToLatest()},this.onViewportPointerUp=()=>{const shadowGetSelection=root=>root?.getSelection?.(),listShadow=this.renderRoot.querySelector("lr-virtual-list")?.shadowRoot,selection=shadowGetSelection(listShadow)??shadowGetSelection(this.shadowRoot)??this.ownerDocument.getSelection();if(!selection||selection.isCollapsed)return;let range;try{range=selection.getRangeAt(0)}catch{return}const text=boundedSelectionText(range);if(text==="")return;const lineNumberOf=node=>{let el=node;for(;el;){if(el.nodeType===1){const attr=el.getAttribute("data-line-number");if(attr!==null)return Number(attr)}el=el.parentNode??el.host??null}return null},startLine=lineNumberOf(selection.anchorNode),endLine=lineNumberOf(selection.focusNode),anchor=startLine!==null&&endLine!==null?{kind:"line-range",start:Math.min(startLine,endLine),end:Math.max(startLine,endLine)}:null;let rects=Object.freeze([]);try{rects=boundedSelectionRects(range)}catch{}this.emit("lr-text-select",{text,anchor,rects})},this.renderLine=(line,highlightByLine,highlightOwnerLines,matchedLineNumbers,activeMatchLineNumber)=>{const isMatchLine=matchedLineNumbers.has(line.number),isActiveMatchLine=activeMatchLineNumber!==null&&activeMatchLineNumber===line.number,highlight=highlightByLine.get(line.number),highlightOwner=highlight&&highlightOwnerLines.get(highlight)===line.number?highlight:void 0,tone=highlight?.tone,lineLabel=plainTextOfLine(line).trim()||this.localize("terminalHighlightLine",void 0,{line:getNumberFormat(this.effectiveLocale).format(line.number)}),highlightLabel=highlightOwner?.label?[this.localize("highlightWithLabel",void 0,{label:highlightOwner.label}),lineLabel].join(this.localize("accessibleLabelSeparator")):lineLabel,stateParts=["line",highlightOwner?"line-interactive":"",tone?`line-highlight-${tone}`:"",isMatchLine?"line-match":"",isActiveMatchLine?"line-active-match":""].filter(Boolean).join(" ");return html`
|
|
2
2
|
<div
|
|
3
3
|
part=${stateParts}
|
|
4
4
|
dir="ltr"
|
|
@@ -13,7 +13,7 @@ import{__decorate}from"tslib";import{warnDeprecatedUsage}from"../../../internal/
|
|
|
13
13
|
@click=${highlightOwner?()=>this.activateHighlight(highlightOwner):nothing}
|
|
14
14
|
@keydown=${highlightOwner?e=>this.onLineKeyDown(e,highlightOwner):nothing}
|
|
15
15
|
>${groupCells(line.cells).map(seg=>html`<span style=${styleMap(this.segmentStyle(seg.styles))}>${seg.text}</span>`)}</div>
|
|
16
|
-
`}}static{this.defaultStrings={...super.defaultStrings,accessibleLabelSeparator:LYRA_DEFAULT_accessibleLabelSeparator,copied:LYRA_DEFAULT_copied,copy:LYRA_DEFAULT_copy,copyFailed:LYRA_DEFAULT_copyFailed,highlightWithLabel:LYRA_DEFAULT_highlightWithLabel,jumpToLatest:LYRA_DEFAULT_jumpToLatest,terminalDownload:LYRA_DEFAULT_terminalDownload,terminalHighlightLine:LYRA_DEFAULT_terminalHighlightLine,terminalLabel:LYRA_DEFAULT_terminalLabel}}emitDownloadRequest(detail){
|
|
16
|
+
`}}static{this.defaultStrings={...super.defaultStrings,accessibleLabelSeparator:LYRA_DEFAULT_accessibleLabelSeparator,copied:LYRA_DEFAULT_copied,copy:LYRA_DEFAULT_copy,copyFailed:LYRA_DEFAULT_copyFailed,highlightWithLabel:LYRA_DEFAULT_highlightWithLabel,jumpToLatest:LYRA_DEFAULT_jumpToLatest,terminalDownload:LYRA_DEFAULT_terminalDownload,terminalHighlightLine:LYRA_DEFAULT_terminalHighlightLine,terminalLabel:LYRA_DEFAULT_terminalLabel}}emitDownloadRequest(detail){return this.emit("lr-download-request",Object.freeze(detail),{cancelable:!0})}static{this.collectionSupport=collectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-text-select"])}static{this.styles=[LyraElement.styles,specialistTokens,styles,srOnly]}get highlights(){return this._highlights}set highlights(value){const previous=this._highlights;this._highlights=snapshotLyraHighlights(value),this.requestUpdate("highlights",previous)}get normalizedHighlights(){return this.highlights}connectedCallback(){super.connectedCallback();const ownerWindow=this.ownerDocument.defaultView;ownerWindow&&this.announcer.setTimerHost(ownerWindow),this.sink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this})}disconnectedCallback(){super.disconnectedCallback(),this.resetCopyFeedback(),this.cancelPendingAnnouncement(),this.sink?.release(),this.sink=void 0}adoptedCallback(){super.adoptedCallback(),this.resetCopyFeedback();const ownerWindow=this.ownerDocument.defaultView;ownerWindow&&this.announcer.setTimerHost(ownerWindow)}firstUpdated(changed){super.firstUpdated(changed),this.announceRegionEl=this.renderRoot.querySelector('[part="announcer"]')??void 0}willUpdate(changed){super.willUpdate(changed),changed.has("content")&&this.commitPendingContent(),changed.has("maxScrollback")&&this.trimScrollback(),changed.has("announceOutput")&&!this.announceOutput&&this.cancelPendingAnnouncement()}resetBuffer(){this.ansiParser.reset(),this.buffer=[],this.retainedCellCount=0,this.lineSeq=0,this.column=0,this.lines=[],this.scrollTargetLineNumber=null,this.searchQuery="",this.searchMatches=[],this.searchMatchCountExact=!0,this.searchActiveIndex=-1}appendLine(){this.buffer.push({number:++this.lineSeq,cells:[]});const max=this.effectiveMaxScrollback();this.buffer.length-max>=SCROLLBACK_PRUNE_BATCH&&this.trimScrollback(!1),this.column=0}effectiveMaxScrollback(){return Math.max(1,finiteCount(this.maxScrollback,5e3,MAX_SCROLLBACK_LINES))}trimScrollback(notifySearch=!0){const previousSearch=this.searchState(),max=this.effectiveMaxScrollback(),removeCount=Math.max(0,this.buffer.length-max),removed=removeCount>0?this.buffer.splice(0,removeCount):[];for(const line of removed)this.retainedCellCount-=line.cells.length;let resourceTrimmed=!1;for(;this.retainedCellCount>MAX_RETAINED_CELLS&&this.buffer.length>1;){const line=this.buffer.shift();line&&(this.retainedCellCount-=line.cells.length),resourceTrimmed=!0}(removed.length>0||resourceTrimmed)&&(this.lines=[...this.buffer],this.searchQuery&&this.recomputeSearchMatches(),this.scrollTargetLineNumber!==null&&!this.buffer.some(line=>line.number===this.scrollTargetLineNumber)&&(this.scrollTargetLineNumber=this.buffer[0]?.number??null),notifySearch&&this.emitSearchChangeIfChanged(previousSearch))}putChar(ch,styles2){this.buffer.length===0&&this.appendLine();const line=this.buffer[this.buffer.length-1];if(!(this.column>=MAX_CELLS_PER_LINE)){if(this.column<line.cells.length)line.cells[this.column]={char:ch,styles:styles2};else{const before=line.cells.length;for(;line.cells.length<this.column&&line.cells.length<MAX_CELLS_PER_LINE;)line.cells.push({char:" ",styles:EMPTY_CELL_STYLES});line.cells.push({char:ch,styles:styles2}),this.retainedCellCount+=line.cells.length-before}this.column=Math.min(MAX_CELLS_PER_LINE,this.column+1)}}applyChunk(text,styles2){for(const ch of text)ch===`
|
|
17
17
|
`?this.appendLine():ch==="\r"?this.column=0:ch==="\b"?this.column=Math.max(0,this.column-1):ch===" "?this.column=Math.min(MAX_CELLS_PER_LINE,(Math.floor(this.column/8)+1)*8):this.putChar(ch,styles2)}writeInternal(raw,notifySearch=!0){const previousSearch=this.searchState(),previousText=this.getPlainText(),boundedRaw=raw.slice(0,MAX_INPUT_CHARACTERS);if(boundedRaw!==""){const segments=this.ansiParser.push(boundedRaw);for(const seg of segments)this.applyChunk(seg.text,seg.styles)}if(this.trimScrollback(!1),this.lines=[...this.buffer],this.searchQuery&&this.recomputeSearchMatches(),this.follow){const last=this.buffer[this.buffer.length-1];this.scrollTargetLineNumber=last?last.number:null}const nextText=this.getPlainText(),visibleAnnouncement=nextText.startsWith(previousText)?nextText.slice(previousText.length):nextText;this.hasUpdated&&this.announceOutput&&visibleAnnouncement!==""&&(this.pendingAnnounceText+=(this.pendingAnnounceText?`
|
|
18
18
|
`:"")+visibleAnnouncement,this.announcer.announce(this.pendingAnnounceText)),notifySearch&&this.emitSearchChangeIfChanged(previousSearch)}write(chunk){this.commitPendingContent(),this.writeInternal(typeof chunk=="string"?chunk:String(chunk))}replace(content){this.content=typeof content=="string"?content:String(content),this.commitPendingContent()}commitPendingContent(){if(this.appliedContent===this.content)return;const previousSearch=this.searchState();this.cancelPendingAnnouncement(),this.resetBuffer(),this.appliedContent=this.content,this.writeInternal(this.content??"",!1),this.emitSearchChangeIfChanged(previousSearch)}clear(){const previousSearch=this.searchState();this.cancelPendingAnnouncement(),this.appliedContent=this.content,this.resetBuffer(),this.emitSearchChangeIfChanged(previousSearch)}getPlainText(){return this.buffer.map(plainTextOfLine).join(`
|
|
19
19
|
`)}scrollToBottom(){this.follow=!0;const last=this.buffer[this.buffer.length-1];this.scrollTargetLineNumber=last?last.number:null}recomputeSearchMatches(){if(this.searchMatches=[],this.searchMatchCountExact=!0,!this.searchQuery)return;const needle=this.searchQuery.toLocaleLowerCase(this.effectiveLocale);for(const line of this.buffer){const haystack=plainTextOfLine(line).toLocaleLowerCase(this.effectiveLocale);let from=0;for(;;){const idx=haystack.indexOf(needle,from);if(idx<0)break;if(this.searchMatches.push({lineNumber:line.number}),this.searchMatches.length>=MAX_SEARCH_MATCHES){this.searchMatchCountExact=!1;break}from=idx+needle.length}if(this.searchMatches.length>=MAX_SEARCH_MATCHES)break}this.searchActiveIndex>=this.searchMatches.length&&(this.searchActiveIndex=this.searchMatches.length>0?0:-1)}emitSearchChange(){this.emit("lr-search-change",{query:this.searchQuery,matchCount:this.searchMatches.length,matchCountExact:this.searchMatchCountExact,activeIndex:this.searchActiveIndex})}searchState(){return{query:this.searchQuery,matchCount:this.searchMatches.length,matchCountExact:this.searchMatchCountExact,activeIndex:this.searchActiveIndex}}emitSearchChangeIfChanged(previous){(previous.query!==this.searchQuery||previous.matchCount!==this.searchMatches.length||previous.matchCountExact!==this.searchMatchCountExact||previous.activeIndex!==this.searchActiveIndex)&&this.emitSearchChange()}jumpToActiveMatch(){const match=this.searchMatches[this.searchActiveIndex];match&&(this.follow&&(this.follow=!1),this.scrollTargetLineNumber=match.lineNumber)}async search(query){const previousSearch=this.searchState();return this.searchQuery=query,this.recomputeSearchMatches(),this.searchActiveIndex=this.searchMatches.length>0?0:-1,this.emitSearchChangeIfChanged(previousSearch),this.searchActiveIndex>=0&&this.jumpToActiveMatch(),this.requestUpdate(),await this.updateComplete,this.searchMatches.length}async searchNext(){if(this.searchMatches.length===0)return!1;const previousSearch=this.searchState();return this.searchActiveIndex=(this.searchActiveIndex+1)%this.searchMatches.length,this.emitSearchChangeIfChanged(previousSearch),this.jumpToActiveMatch(),!0}async searchPrevious(){if(this.searchMatches.length===0)return!1;const previousSearch=this.searchState();return this.searchActiveIndex=(this.searchActiveIndex-1+this.searchMatches.length)%this.searchMatches.length,this.emitSearchChangeIfChanged(previousSearch),this.jumpToActiveMatch(),!0}clearSearch(){const previousSearch=this.searchState();this.searchQuery="",this.searchMatches=[],this.searchMatchCountExact=!0,this.searchActiveIndex=-1,this.emitSearchChangeIfChanged(previousSearch),this.requestUpdate()}resolvedHighlightLines(){const perLine=new Map,owners=new Map,highlights=this.normalizedHighlights;if(this.lines.length===0||highlights.length===0)return{perLine,owners};const minLine=this.lines[0].number,maxLine=this.lines[this.lines.length-1].number;for(const highlight of highlights){if(highlight.anchor.kind!=="line-range")continue;const start=Math.max(highlight.anchor.start,minLine),end=Math.min(highlight.anchor.end??highlight.anchor.start,maxLine);for(let lineNumber=start;lineNumber<=end;lineNumber++)perLine.has(lineNumber)||(perLine.set(lineNumber,highlight),owners.has(highlight)||owners.set(highlight,lineNumber))}return{perLine,owners}}activateHighlight(h){this.activeHighlightId=h.id,this.emit("lr-highlight-activate",{highlightId:h.id})}async scrollToAnchor(target){let start;if(typeof target=="string"){const highlight=this.normalizedHighlights.find(h=>h.id===target);highlight?.anchor.kind==="line-range"&&(start=highlight.anchor.start)}else target.kind==="line-range"&&(start=target.start);return start===void 0||!this.buffer.some(line=>line.number===start)?!1:(this.follow&&(this.follow=!1),this.scrollTargetLineNumber=start,await this.updateComplete,!0)}async copyOutput(){const text=this.getPlainText(),ownerWindow=this.isConnected?this.ownerDocument.defaultView:null,generation=++this.copyGeneration;this.clearCopyTimeout(),this.copyStatus="rest";const outcome=await writeClipboardText(ownerWindow,text);if(!(!ownerWindow||!this.isCurrentCopy(generation,ownerWindow))){if(!outcome.ok){this.showCopyStatus("error",generation,ownerWindow),this.emit("lr-error"),this.emit("lr-copy-error",outcome);return}this.showCopyStatus("success",generation,ownerWindow),this.emit("lr-copy",outcome)}}isCurrentCopy(generation,ownerWindow){return this.isConnected&&generation===this.copyGeneration&&this.ownerDocument.defaultView===ownerWindow}showCopyStatus(status,generation,ownerWindow){this.copyStatus=status,this.clearCopyTimeout(),this.copyTimeoutWindow=ownerWindow,this.copyTimeoutGeneration=generation,this.copyTimeoutId=ownerWindow.setTimeout(()=>{this.copyTimeoutWindow!==ownerWindow||this.copyTimeoutGeneration!==generation||generation!==this.copyGeneration||!this.isConnected||this.ownerDocument.defaultView!==ownerWindow||(this.copyTimeoutId=void 0,this.copyTimeoutWindow=void 0,this.copyTimeoutGeneration=void 0,this.copyStatus="rest")},1500)}resetCopyFeedback(){this.copyGeneration+=1,this.clearCopyTimeout(),this.copyStatus="rest"}clearCopyTimeout(){this.copyTimeoutId!==void 0&&this.copyTimeoutWindow?.clearTimeout(this.copyTimeoutId),this.copyTimeoutId=void 0,this.copyTimeoutWindow=void 0,this.copyTimeoutGeneration=void 0}cancelPendingAnnouncement(){this.pendingAnnounceText="",this.announcer.cancel(),this.announceRegionEl&&(this.announceRegionEl.textContent="")}lineStateStyle(highlight,interactive,isMatchLine,isActiveMatchLine){return{cursor:interactive?"pointer":"",outline:isMatchLine?`var(--lr-size-2px) solid ${isActiveMatchLine?"var(--lr-terminal-search-active-outline-color, var(--lr-color-brand))":"var(--lr-terminal-search-outline-color, var(--lr-color-warning))"}`:"",background:highlight?.tone?TONE_BACKGROUND_VAR[highlight.tone]:""}}segmentStyle(s){const fg=sanitizeCssColor(s.fg)??"var(--lr-color-text)",bg=sanitizeCssColor(s.bg);return{"font-weight":s.bold?"bold":"normal",opacity:s.dim?"0.7":"1","font-style":s.italic?"italic":"normal","text-decoration":s.underline?"underline":"none",color:s.inverse?bg??"var(--lr-terminal-surface-color, var(--lr-color-surface-raised))":fg,"background-color":s.inverse?fg:bg??"transparent"}}render(){const hasToolbar=!this.withoutCopyButton||this.downloadable,ariaLabel=this.accessibleLabel||this.localize("terminalLabel"),{perLine:highlightByLine,owners:highlightOwnerLines}=this.resolvedHighlightLines(),matchedLineNumbers=new Set(this.searchMatches.map(m=>m.lineNumber)),activeMatchLineNumber=this.searchMatches[this.searchActiveIndex]?.lineNumber??null;return html`
|
|
@@ -18,11 +18,7 @@ export type ToolApprovalDialogCloseReason='escape'|'backdrop'|'approve'|'deny'|'
|
|
|
18
18
|
*/
|
|
19
19
|
export type ToolApprovalDialogPending=ApprovalAction|null;
|
|
20
20
|
/** The accepted dismissal reason. */
|
|
21
|
-
export interface LyraToolApprovalDialogCloseDetail{reason:ToolApprovalDialogCloseReason;}export interface LyraToolApprovalDialogEventMap{
|
|
22
|
-
/** @deprecated Use `lr-deny-request`. */
|
|
23
|
-
'lr-deny':LyraToolApprovalDialogEventMap['lr-deny-request'];
|
|
24
|
-
/** @deprecated Use `lr-approve-request`. */
|
|
25
|
-
'lr-approve':LyraToolApprovalDialogEventMap['lr-approve-request'];'lr-approve-request':CustomEvent<{args:unknown;}>;'lr-deny-request':CustomEvent<null>;'lr-close':CustomEvent<LyraToolApprovalDialogCloseDetail>;blur:CustomEvent<null>;focus:CustomEvent<null>;}
|
|
21
|
+
export interface LyraToolApprovalDialogCloseDetail{reason:ToolApprovalDialogCloseReason;}export interface LyraToolApprovalDialogEventMap{'lr-approve-request':CustomEvent<{args:unknown;}>;'lr-deny-request':CustomEvent<null>;'lr-close':CustomEvent<LyraToolApprovalDialogCloseDetail>;blur:CustomEvent<null>;focus:CustomEvent<null>;}
|
|
26
22
|
/**
|
|
27
23
|
* `<lr-tool-approval-dialog>` — a human-in-the-loop gate: presents one
|
|
28
24
|
* proposed tool/function call (`toolName` + `args`) and blocks an agent from
|
|
@@ -106,13 +102,11 @@ export interface LyraToolApprovalDialogCloseDetail{reason:ToolApprovalDialogClos
|
|
|
106
102
|
* @customElement lr-tool-approval-dialog
|
|
107
103
|
* @slot footer - Optional supplementary content (e.g. a "remember this
|
|
108
104
|
* choice" checkbox), rendered before the built-in Deny/Edit/Approve buttons.
|
|
109
|
-
* @event lr-approve - Deprecated cancelable compatibility alias of `lr-approve-request`.
|
|
110
105
|
* @event lr-approve-request - The call was approved. `detail: { args }` — the
|
|
111
106
|
* current, already-parsed arguments object: the original `args` prop, or (if
|
|
112
107
|
* an edit was in progress) the user's edited-and-validated version. Cancelable: a listener
|
|
113
108
|
* calling `preventDefault()` sets `pendingAction` to `'approve'` instead of closing. Otherwise always
|
|
114
109
|
* followed by `lr-close` with reason `'approve'`.
|
|
115
|
-
* @event lr-deny - Deprecated cancelable compatibility alias of `lr-deny-request`.
|
|
116
110
|
* @event lr-deny-request - The call was denied (no detail). Cancelable, same `pendingAction` mechanism as
|
|
117
111
|
* `lr-approve-request` (`pendingAction` is set to `'deny'`). Otherwise always followed by `lr-close` with
|
|
118
112
|
* reason `'deny'`.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{NativeModalCarrier}from"../../../internal/native-modal-carrier.js";import{nativeModalCarrierStyles}from"../../../internal/native-modal-carrier.styles.js";import{
|
|
1
|
+
import{__decorate}from"tslib";import{NativeModalCarrier}from"../../../internal/native-modal-carrier.js";import{nativeModalCarrierStyles}from"../../../internal/native-modal-carrier.styles.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{DeferredFocusReturn,captureFocusReturnOpener}from"../../../internal/deferred-focus-return.js";import{activateOverlay}from"../../../internal/overlay-manager.js";import{nextId}from"../../../internal/a11y.js";import{resolveLocalizedParts}from"../../../internal/localization-runtime.js";import{styles}from"./tool-approval-dialog.styles.js";import"../../utility/json-viewer/json-viewer.class.js";import"../../forms/button/button.class.js";import{trueDefaultSpellcheckConverter as spellcheckConverter}from"../../../internal/converters.js";import{activeElementIn}from"../../../internal/active-element.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{markVetoGuardWrite,VetoWriteGuard}from"../../../internal/veto-write-guard.js";import{LYRA_DEFAULT_approve,LYRA_DEFAULT_cancel,LYRA_DEFAULT_deny,LYRA_DEFAULT_edit,LYRA_DEFAULT_invalidJson,LYRA_DEFAULT_toolApprovalArgsLabel,LYRA_DEFAULT_toolApprovalGenericTool,LYRA_DEFAULT_toolApprovalHeading}from"../../../internal/default-strings.generated.js";class LyraToolApprovalDialog extends LyraElement{constructor(){super(...arguments),this._open=!1,this._pendingAction=null,this.dispatchWriteGuard=new VetoWriteGuard,this.lightDismiss=!1,this.proposalKey="",this.toolName="",this.accessibleLabel=null,this.args={},this.readonly=!1,this.spellcheck=!1,this.autocapitalize="off",this.autoCorrect="off",this.autocomplete="off",this.wrap="soft",this.inputMode="",this.enterKeyHint="",this.editing=!1,this.draftText="",this.draftError="",this.nativeModal=new NativeModalCarrier(this,{onCancel:()=>{!this.open||!this.overlay?.isTopmost()||this.pendingAction!=null||this.close("escape")},onUnexpectedClose:()=>{this.open&&(this.nativeModal.hide(),this.close("api"))}}),this.focusReturnOpener=null,this.deferredFocusReturn=new DeferredFocusReturn,this.suppressNextErrorAnnouncement=!0,this.titleId=nextId("tool-approval-dialog-title"),this.errorId=nextId("tool-approval-dialog-error"),this.onBackdropClick=()=>{this.overlay?.dismissBackdrop()},this.toggleEdit=()=>{this.pendingAction==null&&(this.editing?(this.editing=!1,this.draftText="",this.draftError=""):(this.editing=!0,this.draftText=this.stringifyArgs(),this.draftError=""))},this.onDraftInput=e=>{if(this.pendingAction!=null){e.stopPropagation();return}const value=e.target.value;this.draftText=value;try{JSON.parse(value),this.draftError=""}catch{this.draftError=this.localize("invalidJson")}e.stopPropagation()},this.onEditorFocus=()=>{this.emit("focus")},this.onEditorBlur=()=>{this.emit("blur")},this.decisionDispatching=!1,this.onApprove=()=>{if(!this.decisionDispatching){this.decisionDispatching=!0;try{if(this.pendingAction!=null)return;let currentArgs=this.args;if(this.editing)try{currentArgs=JSON.parse(this.draftText)}catch{return}if(this.dispatchWriteGuard.open(),this.emitApproveRequest({args:currentArgs}).defaultPrevented){this.dispatchWriteGuard.touched||(this.pendingAction="approve");return}this.dispatchWriteGuard.touched||this.close("approve")}finally{this.decisionDispatching=!1}}},this.onDeny=()=>{if(!this.decisionDispatching){this.decisionDispatching=!0;try{if(this.pendingAction!=null)return;if(this.dispatchWriteGuard.open(),this.emitDenyRequest(null).defaultPrevented){this.dispatchWriteGuard.touched||(this.pendingAction="deny");return}this.dispatchWriteGuard.touched||this.close("deny")}finally{this.decisionDispatching=!1}}}}static{this.defaultStrings={...super.defaultStrings,approve:LYRA_DEFAULT_approve,cancel:LYRA_DEFAULT_cancel,deny:LYRA_DEFAULT_deny,edit:LYRA_DEFAULT_edit,invalidJson:LYRA_DEFAULT_invalidJson,toolApprovalArgsLabel:LYRA_DEFAULT_toolApprovalArgsLabel,toolApprovalGenericTool:LYRA_DEFAULT_toolApprovalGenericTool,toolApprovalHeading:LYRA_DEFAULT_toolApprovalHeading}}emitApproveRequest(detail){return this.emit("lr-approve-request",Object.freeze(detail),{cancelable:!0})}emitDenyRequest(detail){return this.emit("lr-deny-request",Object.freeze(detail),{cancelable:!0})}static{this.styles=[LyraElement.styles,nativeModalCarrierStyles,styles]}get open(){return this._open}set open(value){const previous=this._open;this._open=value,markVetoGuardWrite(this.dispatchWriteGuard),this.requestUpdate("open",previous)}get pendingAction(){return this._pendingAction}set pendingAction(value){const previous=this._pendingAction;this._pendingAction=value,markVetoGuardWrite(this.dispatchWriteGuard),this.requestUpdate("pendingAction",previous)}resetProposalState(){this.editing=!1,this.draftText="",this.draftError="",this.pendingAction=null}willUpdate(changed){if(super.willUpdate(changed),this.hasUpdated&&!this.suppressNextErrorAnnouncement&&changed.has("draftError")&&this.draftError&&!changed.get("draftError")&&this.errorAnnouncementSink?.announce(this.draftError),changed.has("open"))if(this.open)this.deferredFocusReturn.cancel(),this.focusReturnOpener=captureFocusReturnOpener(this),this.nativeModal.prepare(),this.activateOverlay(),this.resetProposalState();else{const hadOverlay=this.overlay!==void 0;this.nativeModal.hide(),this.overlay?.deactivate(),this.overlay=void 0;const opener=this.focusReturnOpener;this.focusReturnOpener=null,hadOverlay&&opener&&this.isConnected&&this.deferredFocusReturn.schedule({host:this,candidates:()=>[opener],isCurrent:()=>!this.open})}const proposalChanged=changed.has("proposalKey")||changed.has("toolName")||changed.has("args");this.hasUpdated&&proposalChanged&&!(changed.has("open")&&this.open)&&this.resetProposalState(),changed.has("readonly")&&this.readonly&&this.editing&&(this.editing=!1,this.draftText="",this.draftError="")}updated(changed){if(super.updated(changed),this.open&&this.nativeModal.show(),this.suppressNextErrorAnnouncement=!1,changed.has("open")&&this.open){this.overlay?.focusInitial();return}changed.has("editing")&&(this.editing?this.shadowRoot?.querySelector('[part="args-editor"]')?.focus():this.open&&!activeElementIn(this.shadowRoot)&&this.shadowRoot?.querySelector('[part="deny-button"]')?.focus())}connectedCallback(){super.connectedCallback(),this.errorAnnouncementSink?.element.ownerDocument!==this.ownerDocument&&(this.errorAnnouncementSink?.release(),this.errorAnnouncementSink=acquireAnnouncementSink("assertive",{document:this.ownerDocument,source:this})),this.hasUpdated&&(this.suppressNextErrorAnnouncement=!0,this.requestUpdate()),this.hasUpdated&&this.open&&(this.nativeModal.prepare(),this.requestUpdate(),this.activateOverlay(),this.overlay?.focusInitial(),this.updateComplete.then(()=>{!this.open||!this.isConnected||(this.nativeModal.show(),this.overlay?.focusInitial())}))}disconnectedCallback(){super.disconnectedCallback(),this.nativeModal.hide(),this.overlay?.suspend(),this.deferredFocusReturn.cancel(),this.errorAnnouncementSink?.release(),this.errorAnnouncementSink=void 0,this.suppressNextErrorAnnouncement=!0}activateOverlay(){if(this.overlay?.isActive()){this.overlay.resume();return}this.overlay=activateOverlay({host:this,panel:()=>this.shadowRoot?.querySelector('[part="panel"]')??null,onEscape:()=>{this.pendingAction==null&&this.close("escape")},onBackdrop:()=>{this.pendingAction!=null||!this.lightDismiss||this.close("backdrop")},preferredInitialFocus:()=>this.shadowRoot?.querySelector('[part="deny-button"]')??null,lockScroll:!0,suspendWhenUnrendered:!0})}close(reason="api"){this.open&&(this.open=!1,this.emit("lr-close",{reason}))}show(){this.open||(this.open=!0)}hide(reason="api"){this.close(reason)}stringifyArgs(){try{return JSON.stringify(this.args,null,2)??"null"}catch{return"null"}}render(){const hasError=this.editing&&this.draftError.length>0,toolName=this.toolName||this.localize("toolApprovalGenericTool"),headingTemplate=this.localize("toolApprovalHeading"),headingParts=resolveLocalizedParts(headingTemplate,marker=>this.localize("toolApprovalHeading",void 0,{tool:marker})),hostLabel=this.getAttribute("aria-label"),panelLabel=hostLabel?.trim()?hostLabel:typeof this.accessibleLabel=="string"&&this.accessibleLabel.trim()?this.accessibleLabel:null;return this.nativeModal.render(html`
|
|
2
2
|
<div part="backdrop" @click=${this.onBackdropClick}></div>
|
|
3
3
|
<div
|
|
4
4
|
part="panel"
|
|
@@ -46,9 +46,7 @@ approved?:boolean;}
|
|
|
46
46
|
*/
|
|
47
47
|
export interface ToolTimelineApprovalDetail extends ToolApprovalEventDetail{args?:unknown;sourceKey?:string;}export interface ToolTimelineActivateDetail{invocationId:string;sourceKey?:string;}export interface ToolTimelineRenderErrorDetail extends ToolTimelineActivateDetail{toolName:string;error:unknown;}
|
|
48
48
|
/** Which approval action is waiting for a host that vetoed `lr-tool-approval-decide-request` to settle it. */
|
|
49
|
-
export type ToolTimelineApprovalPending=ApprovalAction|null;export interface LyraToolTimelineEventMap{
|
|
50
|
-
/** @deprecated Use `lr-tool-approval-decide-request`. */
|
|
51
|
-
'lr-tool-approval-decide':LyraToolTimelineEventMap['lr-tool-approval-decide-request'];'lr-tool-approval-decide-request':CustomEvent<ToolTimelineApprovalDetail>;'lr-tool-activate':CustomEvent<ToolTimelineActivateDetail>;'lr-tool-render-error':CustomEvent<ToolTimelineRenderErrorDetail>;}
|
|
49
|
+
export type ToolTimelineApprovalPending=ApprovalAction|null;export interface LyraToolTimelineEventMap{'lr-tool-approval-decide-request':CustomEvent<ToolTimelineApprovalDetail>;'lr-tool-activate':CustomEvent<ToolTimelineActivateDetail>;'lr-tool-render-error':CustomEvent<ToolTimelineRenderErrorDetail>;}
|
|
52
50
|
/**
|
|
53
51
|
* `<lr-tool-timeline>` — a chronological list of an agent run's tool/function calls, each
|
|
54
52
|
* rendered through `<lr-tool-call-chip>` (name/status/duration) and `<lr-tool-result-view>`
|
|
@@ -107,7 +105,6 @@ export type ToolTimelineApprovalPending=ApprovalAction|null;export interface Lyr
|
|
|
107
105
|
* array does not update the view.
|
|
108
106
|
*
|
|
109
107
|
* @customElement lr-tool-timeline
|
|
110
|
-
* @event lr-tool-approval-decide - Deprecated cancelable compatibility alias of `lr-tool-approval-decide-request`.
|
|
111
108
|
* @event lr-tool-approval-decide-request - A pending entry's approval dialog was resolved.
|
|
112
109
|
* `detail: { invocationId, approved, args? }` — `args` (the dialog's current, possibly
|
|
113
110
|
* host-edited arguments) is present only when `approved` is `true`. Cancelable; preventing it
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{warnDeprecatedUsage}from"../../../internal/dev-mode-attribute-warning.js";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{LyraElement}from"../../../internal/lyra-element.js";import{getDateTimeFormat,getNumberFormat}from"../../../internal/intl-cache.js";import{finiteCount}from"../../../internal/numbers.js";import{eyeOffIcon}from"../../../internal/icons.js";import{srOnly}from"../../../internal/a11y.js";import{styles}from"./tool-timeline.styles.js";import{overallSemanticLabel}from"../semantic-owner.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{getOwnDataDescriptor,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{TOOL_CALL_STATUSES}from"../tool-status.js";import{EMPTY_REDACTION_PATHS,projectedRedactionFields,redactToolDetail}from"../tool-redaction.js";import{LYRA_DEFAULT_confirmApproved,LYRA_DEFAULT_confirmDenied,LYRA_DEFAULT_envListValueHidden,LYRA_DEFAULT_noData,LYRA_DEFAULT_retry,LYRA_DEFAULT_toolTimelineDetailsFor,LYRA_DEFAULT_toolTimelineLimit}from"../../../internal/default-strings.generated.js";const MAX_RENDERED_ENTRIES=500,TOOL_STATUSES=new Set(TOOL_CALL_STATUSES);function descriptorValue(value,property2){return getOwnDataDescriptor(value,property2)}function projectToolTimelineEntry(value){try{if(value===null||typeof value!="object"||Array.isArray(value))return;const idDescriptor=descriptorValue(value,"id"),nameDescriptor=descriptorValue(value,"name"),displayNameDescriptor=descriptorValue(value,"displayName"),argsDescriptor=descriptorValue(value,"args"),statusDescriptor=descriptorValue(value,"status"),resultDescriptor=descriptorValue(value,"result"),errorDescriptor=descriptorValue(value,"error"),sourceKeyDescriptor=descriptorValue(value,"sourceKey"),iconDescriptor=descriptorValue(value,"icon"),startedAtDescriptor=descriptorValue(value,"startedAt"),endedAtDescriptor=descriptorValue(value,"endedAt"),retryCountDescriptor=descriptorValue(value,"retryCount"),redactedFieldsDescriptor=descriptorValue(value,"redactedFields"),needsApprovalDescriptor=descriptorValue(value,"needsApproval"),approvedDescriptor=descriptorValue(value,"approved");if([idDescriptor,nameDescriptor,displayNameDescriptor,argsDescriptor,statusDescriptor,resultDescriptor,errorDescriptor,sourceKeyDescriptor,iconDescriptor,startedAtDescriptor,endedAtDescriptor,retryCountDescriptor,redactedFieldsDescriptor,needsApprovalDescriptor,approvedDescriptor].some(descriptor=>descriptor===UNSAFE_OWN_DATA_DESCRIPTOR))return;const valueOf=descriptor=>{if(!(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR))return descriptor.value},id=valueOf(idDescriptor);if(typeof id!="string"||id.trim().length===0)return;const redactedFieldsValue=valueOf(redactedFieldsDescriptor),redactedFields=redactedFieldsValue===void 0?EMPTY_REDACTION_PATHS:projectedRedactionFields(redactedFieldsValue);if(redactedFields===void 0)return;const name=valueOf(nameDescriptor),displayName=valueOf(displayNameDescriptor),status=valueOf(statusDescriptor),result=valueOf(resultDescriptor),error=valueOf(errorDescriptor),sourceKey=valueOf(sourceKeyDescriptor),icon=valueOf(iconDescriptor),startedAt=valueOf(startedAtDescriptor),endedAt=valueOf(endedAtDescriptor),retryCount=valueOf(retryCountDescriptor),needsApproval=valueOf(needsApprovalDescriptor),approved=valueOf(approvedDescriptor);return Object.freeze({source:value,id,name:typeof name=="string"?name:"",...typeof displayName=="string"?{displayName}:{},args:valueOf(argsDescriptor),status:TOOL_STATUSES.has(status)?status:"pending",...result===void 0?{}:{result},...typeof error=="string"?{error}:{},...typeof sourceKey=="string"?{sourceKey}:{},...typeof icon=="string"?{icon}:{},...typeof startedAt=="number"?{startedAt}:{},...typeof endedAt=="number"?{endedAt}:{},...typeof retryCount=="number"?{retryCount}:{},redactedFields,...typeof needsApproval=="boolean"?{needsApproval}:{},...typeof approved=="boolean"?{approved}:{}})}catch{return}}function entrySourceKey(entry){return entry.sourceKey?.trim()?entry.sourceKey:void 0}function entryIdentity(entry){return JSON.stringify([entrySourceKey(entry)??null,entry.id])}function entryCorrelation(entry){const sourceKey=entrySourceKey(entry);return sourceKey===void 0?{invocationId:entry.id}:{invocationId:entry.id,sourceKey}}function defaultFormatTimestamp(date,locale){return getDateTimeFormat(locale,{hour:"numeric",minute:"2-digit"}).format(date)}class LyraToolTimeline extends LyraElement{constructor(){super(...arguments),this.entries=[],this.approvalReadonly=!1,this.approvalPending=null,this.openedEntryIds=new Set,this.projectedEntriesCache=[],this.projectionTruncated=!1,this.redactionCache=new WeakMap,this.limitAnnouncementInitialized=!1,this.previouslyTruncated=!1,this.decisionDispatching=!1,this.onDialogApprove=event=>{if(!this.decisionDispatching){this.decisionDispatching=!0;try{event.stopPropagation();const entry=this.reviewingEntry;if(entry===void 0)return;const key=entryIdentity(entry);if(this.emitToolApprovalDecideRequest({...entryCorrelation(entry),approved:!0,args:event.detail.args}).defaultPrevented&&this.entryStillNeedsApproval(key)){this.approvalPending="approve",event.preventDefault();return}this.approvalPending=null,this.reviewingEntryKey=void 0}finally{this.decisionDispatching=!1}}},this.onDialogDeny=event=>{if(!this.decisionDispatching){this.decisionDispatching=!0;try{event.stopPropagation();const entry=this.reviewingEntry;if(entry===void 0)return;const key=entryIdentity(entry);if(this.emitToolApprovalDecideRequest({...entryCorrelation(entry),approved:!1}).defaultPrevented&&this.entryStillNeedsApproval(key)){this.approvalPending="deny",event.preventDefault();return}this.approvalPending=null,this.reviewingEntryKey=void 0}finally{this.decisionDispatching=!1}}},this.onDialogClose=event=>{event.stopPropagation(),this.approvalPending=null,this.reviewingEntryKey=void 0}}static{this.defaultStrings={...super.defaultStrings,confirmApproved:LYRA_DEFAULT_confirmApproved,confirmDenied:LYRA_DEFAULT_confirmDenied,envListValueHidden:LYRA_DEFAULT_envListValueHidden,noData:LYRA_DEFAULT_noData,retry:LYRA_DEFAULT_retry,toolTimelineDetailsFor:LYRA_DEFAULT_toolTimelineDetailsFor,toolTimelineLimit:LYRA_DEFAULT_toolTimelineLimit}}emitToolApprovalDecideRequest(detail){const request=this.emit("lr-tool-approval-decide-request",Object.freeze(detail),{cancelable:!0});return this.emit("lr-tool-approval-decide",Object.freeze(detail),{cancelable:!0}).defaultPrevented&&(warnDeprecatedUsage(this,"event","lr-tool-approval-decide","lr-tool-approval-decide-request"),request.preventDefault()),request}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["entries"])}static{this.identityCollectionProperties=Object.freeze(["entries"])}static{this.styles=[LyraElement.styles,styles,srOnly]}connectedCallback(){super.connectedCallback(),this.syncLimitAnnouncementSink(),this.limitAnnouncementInitialized=this.hasUpdated,this.previouslyTruncated=this.projectionTruncated}disconnectedCallback(){this.limitAnnouncementSink?.release(),this.limitAnnouncementSink=void 0,super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.limitAnnouncementSink?.release(),this.limitAnnouncementSink=void 0,this.syncLimitAnnouncementSink()}syncLimitAnnouncementSink(){!this.isConnected||this.limitAnnouncementSink?.element.ownerDocument===this.ownerDocument||(this.limitAnnouncementSink?.release(),this.limitAnnouncementSink=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}))}get pendingApproval(){return this.approvalPending}willUpdate(changed){if(super.willUpdate(changed),!changed.has("entries"))return;this.rebuildProjection();const projected=this.projectedEntriesCache,identities=new Set(projected.map(entryIdentity));if(this.reviewingEntryKey!==void 0){const still=projected.find(entry=>entryIdentity(entry)===this.reviewingEntryKey);(!still||!(still.needsApproval&&still.approved===void 0))&&(this.reviewingEntryKey=void 0,this.approvalPending=null)}const opened=new Set([...this.openedEntryIds].filter(key=>identities.has(key)));opened.size!==this.openedEntryIds.size&&(this.openedEntryIds=opened)}updated(changed){super.updated(changed),this.limitAnnouncementInitialized&&this.projectionTruncated&&!this.previouslyTruncated&&this.limitAnnouncementSink?.announce(this.localize("toolTimelineLimit",void 0,{count:getNumberFormat(this.effectiveLocale).format(MAX_RENDERED_ENTRIES)})),this.limitAnnouncementInitialized=!0,this.previouslyTruncated=this.projectionTruncated}rebuildProjection(){const entries=Array.isArray(this.entries)?this.entries:[],projected=[],projectedIndex=new Map,reservedKeys=new Set(this.openedEntryIds);this.reviewingEntryKey!==void 0&&reservedKeys.add(this.reviewingEntryKey);const displacedReserved=new Map,seen=new Set;for(const sourceEntry of entries){const entry=projectToolTimelineEntry(sourceEntry);if(!entry)continue;const key=entryIdentity(entry);seen.has(key)||(seen.add(key),projected.length<MAX_RENDERED_ENTRIES?(projectedIndex.set(key,projected.length),projected.push(entry)):reservedKeys.has(key)&&displacedReserved.set(key,entry))}for(const[key,entry]of displacedReserved){if(projectedIndex.has(key))continue;let replacement=projected.length-1;for(;replacement>=0&&reservedKeys.has(entryIdentity(projected[replacement]));)replacement--;if(replacement<0)break;projectedIndex.delete(entryIdentity(projected[replacement])),projected[replacement]=entry,projectedIndex.set(key,replacement)}this.projectedEntriesCache=projected,this.projectionTruncated=seen.size>projected.length}get sortedEntries(){return this.projectedEntriesCache.map((entry,index)=>({entry,index})).sort((a,b)=>{const ak=Number.isFinite(a.entry.startedAt)?a.entry.startedAt:Number.POSITIVE_INFINITY,bk=Number.isFinite(b.entry.startedAt)?b.entry.startedAt:Number.POSITIVE_INFINITY;return ak!==bk?ak-bk:a.index-b.index}).map(({entry})=>entry)}get reviewingEntry(){return this.reviewingEntryKey===void 0?void 0:this.projectedEntriesCache.find(entry=>entryIdentity(entry)===this.reviewingEntryKey)}durationFor(entry){if(entry.startedAt==null||entry.endedAt==null)return;const diff=entry.endedAt-entry.startedAt;return Number.isFinite(diff)?diff:void 0}normalizedDate(ms){if(ms==null||!Number.isFinite(ms))return;const date=new Date(ms);return Number.isNaN(date.getTime())?void 0:date}onChipSelect(entry,event){if(event.stopPropagation(),entry.needsApproval&&entry.approved===void 0){this.reviewingEntryKey=entryIdentity(entry);return}this.emit("lr-tool-activate",entryCorrelation(entry))}entryStillNeedsApproval(key){const entries=Array.isArray(this.entries)?this.entries:[];for(const sourceEntry of entries){const projected=projectToolTimelineEntry(sourceEntry);if(projected!==void 0&&entryIdentity(projected)===key)return projected.needsApproval===!0&&projected.approved===void 0}return!1}finalizePendingApproval(){this.approvalPending!==null&&(this.approvalPending=null,this.reviewingEntryKey=void 0)}revertPendingApproval(){this.approvalPending!==null&&(this.approvalPending=null)}onDetailsToggle(entry,event){event.stopPropagation();const key=entryIdentity(entry),next=new Set(this.openedEntryIds);event.detail.expanded??event.detail.open?next.add(key):next.delete(key),this.openedEntryIds=next}stopOwnedEvent(event){event.stopPropagation()}onRenderError(entry,event){event.stopPropagation(),this.emit("lr-tool-render-error",{...entryCorrelation(entry),...event.detail})}redactedEntry(entry,placeholder){const redacted=redactToolDetail({args:entry.args,result:entry.result,error:entry.error},entry.redactedFields,placeholder,this.redactionCache.get(entry));return this.redactionCache.set(entry,redacted),redacted}openedDetailsTemplate(entry,placeholder){const redacted=this.redactedEntry(entry,placeholder);return html`
|
|
1
|
+
import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{LyraElement}from"../../../internal/lyra-element.js";import{getDateTimeFormat,getNumberFormat}from"../../../internal/intl-cache.js";import{finiteCount}from"../../../internal/numbers.js";import{eyeOffIcon}from"../../../internal/icons.js";import{srOnly}from"../../../internal/a11y.js";import{styles}from"./tool-timeline.styles.js";import{overallSemanticLabel}from"../semantic-owner.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{getOwnDataDescriptor,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{TOOL_CALL_STATUSES}from"../tool-status.js";import{EMPTY_REDACTION_PATHS,projectedRedactionFields,redactToolDetail}from"../tool-redaction.js";import{LYRA_DEFAULT_confirmApproved,LYRA_DEFAULT_confirmDenied,LYRA_DEFAULT_envListValueHidden,LYRA_DEFAULT_noData,LYRA_DEFAULT_retry,LYRA_DEFAULT_toolTimelineDetailsFor,LYRA_DEFAULT_toolTimelineLimit}from"../../../internal/default-strings.generated.js";const MAX_RENDERED_ENTRIES=500,TOOL_STATUSES=new Set(TOOL_CALL_STATUSES);function descriptorValue(value,property2){return getOwnDataDescriptor(value,property2)}function projectToolTimelineEntry(value){try{if(value===null||typeof value!="object"||Array.isArray(value))return;const idDescriptor=descriptorValue(value,"id"),nameDescriptor=descriptorValue(value,"name"),displayNameDescriptor=descriptorValue(value,"displayName"),argsDescriptor=descriptorValue(value,"args"),statusDescriptor=descriptorValue(value,"status"),resultDescriptor=descriptorValue(value,"result"),errorDescriptor=descriptorValue(value,"error"),sourceKeyDescriptor=descriptorValue(value,"sourceKey"),iconDescriptor=descriptorValue(value,"icon"),startedAtDescriptor=descriptorValue(value,"startedAt"),endedAtDescriptor=descriptorValue(value,"endedAt"),retryCountDescriptor=descriptorValue(value,"retryCount"),redactedFieldsDescriptor=descriptorValue(value,"redactedFields"),needsApprovalDescriptor=descriptorValue(value,"needsApproval"),approvedDescriptor=descriptorValue(value,"approved");if([idDescriptor,nameDescriptor,displayNameDescriptor,argsDescriptor,statusDescriptor,resultDescriptor,errorDescriptor,sourceKeyDescriptor,iconDescriptor,startedAtDescriptor,endedAtDescriptor,retryCountDescriptor,redactedFieldsDescriptor,needsApprovalDescriptor,approvedDescriptor].some(descriptor=>descriptor===UNSAFE_OWN_DATA_DESCRIPTOR))return;const valueOf=descriptor=>{if(!(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR))return descriptor.value},id=valueOf(idDescriptor);if(typeof id!="string"||id.trim().length===0)return;const redactedFieldsValue=valueOf(redactedFieldsDescriptor),redactedFields=redactedFieldsValue===void 0?EMPTY_REDACTION_PATHS:projectedRedactionFields(redactedFieldsValue);if(redactedFields===void 0)return;const name=valueOf(nameDescriptor),displayName=valueOf(displayNameDescriptor),status=valueOf(statusDescriptor),result=valueOf(resultDescriptor),error=valueOf(errorDescriptor),sourceKey=valueOf(sourceKeyDescriptor),icon=valueOf(iconDescriptor),startedAt=valueOf(startedAtDescriptor),endedAt=valueOf(endedAtDescriptor),retryCount=valueOf(retryCountDescriptor),needsApproval=valueOf(needsApprovalDescriptor),approved=valueOf(approvedDescriptor);return Object.freeze({source:value,id,name:typeof name=="string"?name:"",...typeof displayName=="string"?{displayName}:{},args:valueOf(argsDescriptor),status:TOOL_STATUSES.has(status)?status:"pending",...result===void 0?{}:{result},...typeof error=="string"?{error}:{},...typeof sourceKey=="string"?{sourceKey}:{},...typeof icon=="string"?{icon}:{},...typeof startedAt=="number"?{startedAt}:{},...typeof endedAt=="number"?{endedAt}:{},...typeof retryCount=="number"?{retryCount}:{},redactedFields,...typeof needsApproval=="boolean"?{needsApproval}:{},...typeof approved=="boolean"?{approved}:{}})}catch{return}}function entrySourceKey(entry){return entry.sourceKey?.trim()?entry.sourceKey:void 0}function entryIdentity(entry){return JSON.stringify([entrySourceKey(entry)??null,entry.id])}function entryCorrelation(entry){const sourceKey=entrySourceKey(entry);return sourceKey===void 0?{invocationId:entry.id}:{invocationId:entry.id,sourceKey}}function defaultFormatTimestamp(date,locale){return getDateTimeFormat(locale,{hour:"numeric",minute:"2-digit"}).format(date)}class LyraToolTimeline extends LyraElement{constructor(){super(...arguments),this.entries=[],this.approvalReadonly=!1,this.approvalPending=null,this.openedEntryIds=new Set,this.projectedEntriesCache=[],this.projectionTruncated=!1,this.redactionCache=new WeakMap,this.limitAnnouncementInitialized=!1,this.previouslyTruncated=!1,this.decisionDispatching=!1,this.onDialogApprove=event=>{if(!this.decisionDispatching){this.decisionDispatching=!0;try{event.stopPropagation();const entry=this.reviewingEntry;if(entry===void 0)return;const key=entryIdentity(entry);if(this.emitToolApprovalDecideRequest({...entryCorrelation(entry),approved:!0,args:event.detail.args}).defaultPrevented&&this.entryStillNeedsApproval(key)){this.approvalPending="approve",event.preventDefault();return}this.approvalPending=null,this.reviewingEntryKey=void 0}finally{this.decisionDispatching=!1}}},this.onDialogDeny=event=>{if(!this.decisionDispatching){this.decisionDispatching=!0;try{event.stopPropagation();const entry=this.reviewingEntry;if(entry===void 0)return;const key=entryIdentity(entry);if(this.emitToolApprovalDecideRequest({...entryCorrelation(entry),approved:!1}).defaultPrevented&&this.entryStillNeedsApproval(key)){this.approvalPending="deny",event.preventDefault();return}this.approvalPending=null,this.reviewingEntryKey=void 0}finally{this.decisionDispatching=!1}}},this.onDialogClose=event=>{event.stopPropagation(),this.approvalPending=null,this.reviewingEntryKey=void 0}}static{this.defaultStrings={...super.defaultStrings,confirmApproved:LYRA_DEFAULT_confirmApproved,confirmDenied:LYRA_DEFAULT_confirmDenied,envListValueHidden:LYRA_DEFAULT_envListValueHidden,noData:LYRA_DEFAULT_noData,retry:LYRA_DEFAULT_retry,toolTimelineDetailsFor:LYRA_DEFAULT_toolTimelineDetailsFor,toolTimelineLimit:LYRA_DEFAULT_toolTimelineLimit}}emitToolApprovalDecideRequest(detail){return this.emit("lr-tool-approval-decide-request",Object.freeze(detail),{cancelable:!0})}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["entries"])}static{this.identityCollectionProperties=Object.freeze(["entries"])}static{this.styles=[LyraElement.styles,styles,srOnly]}connectedCallback(){super.connectedCallback(),this.syncLimitAnnouncementSink(),this.limitAnnouncementInitialized=this.hasUpdated,this.previouslyTruncated=this.projectionTruncated}disconnectedCallback(){this.limitAnnouncementSink?.release(),this.limitAnnouncementSink=void 0,super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.limitAnnouncementSink?.release(),this.limitAnnouncementSink=void 0,this.syncLimitAnnouncementSink()}syncLimitAnnouncementSink(){!this.isConnected||this.limitAnnouncementSink?.element.ownerDocument===this.ownerDocument||(this.limitAnnouncementSink?.release(),this.limitAnnouncementSink=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}))}get pendingApproval(){return this.approvalPending}willUpdate(changed){if(super.willUpdate(changed),!changed.has("entries"))return;this.rebuildProjection();const projected=this.projectedEntriesCache,identities=new Set(projected.map(entryIdentity));if(this.reviewingEntryKey!==void 0){const still=projected.find(entry=>entryIdentity(entry)===this.reviewingEntryKey);(!still||!(still.needsApproval&&still.approved===void 0))&&(this.reviewingEntryKey=void 0,this.approvalPending=null)}const opened=new Set([...this.openedEntryIds].filter(key=>identities.has(key)));opened.size!==this.openedEntryIds.size&&(this.openedEntryIds=opened)}updated(changed){super.updated(changed),this.limitAnnouncementInitialized&&this.projectionTruncated&&!this.previouslyTruncated&&this.limitAnnouncementSink?.announce(this.localize("toolTimelineLimit",void 0,{count:getNumberFormat(this.effectiveLocale).format(MAX_RENDERED_ENTRIES)})),this.limitAnnouncementInitialized=!0,this.previouslyTruncated=this.projectionTruncated}rebuildProjection(){const entries=Array.isArray(this.entries)?this.entries:[],projected=[],projectedIndex=new Map,reservedKeys=new Set(this.openedEntryIds);this.reviewingEntryKey!==void 0&&reservedKeys.add(this.reviewingEntryKey);const displacedReserved=new Map,seen=new Set;for(const sourceEntry of entries){const entry=projectToolTimelineEntry(sourceEntry);if(!entry)continue;const key=entryIdentity(entry);seen.has(key)||(seen.add(key),projected.length<MAX_RENDERED_ENTRIES?(projectedIndex.set(key,projected.length),projected.push(entry)):reservedKeys.has(key)&&displacedReserved.set(key,entry))}for(const[key,entry]of displacedReserved){if(projectedIndex.has(key))continue;let replacement=projected.length-1;for(;replacement>=0&&reservedKeys.has(entryIdentity(projected[replacement]));)replacement--;if(replacement<0)break;projectedIndex.delete(entryIdentity(projected[replacement])),projected[replacement]=entry,projectedIndex.set(key,replacement)}this.projectedEntriesCache=projected,this.projectionTruncated=seen.size>projected.length}get sortedEntries(){return this.projectedEntriesCache.map((entry,index)=>({entry,index})).sort((a,b)=>{const ak=Number.isFinite(a.entry.startedAt)?a.entry.startedAt:Number.POSITIVE_INFINITY,bk=Number.isFinite(b.entry.startedAt)?b.entry.startedAt:Number.POSITIVE_INFINITY;return ak!==bk?ak-bk:a.index-b.index}).map(({entry})=>entry)}get reviewingEntry(){return this.reviewingEntryKey===void 0?void 0:this.projectedEntriesCache.find(entry=>entryIdentity(entry)===this.reviewingEntryKey)}durationFor(entry){if(entry.startedAt==null||entry.endedAt==null)return;const diff=entry.endedAt-entry.startedAt;return Number.isFinite(diff)?diff:void 0}normalizedDate(ms){if(ms==null||!Number.isFinite(ms))return;const date=new Date(ms);return Number.isNaN(date.getTime())?void 0:date}onChipSelect(entry,event){if(event.stopPropagation(),entry.needsApproval&&entry.approved===void 0){this.reviewingEntryKey=entryIdentity(entry);return}this.emit("lr-tool-activate",entryCorrelation(entry))}entryStillNeedsApproval(key){const entries=Array.isArray(this.entries)?this.entries:[];for(const sourceEntry of entries){const projected=projectToolTimelineEntry(sourceEntry);if(projected!==void 0&&entryIdentity(projected)===key)return projected.needsApproval===!0&&projected.approved===void 0}return!1}finalizePendingApproval(){this.approvalPending!==null&&(this.approvalPending=null,this.reviewingEntryKey=void 0)}revertPendingApproval(){this.approvalPending!==null&&(this.approvalPending=null)}onDetailsToggle(entry,event){event.stopPropagation();const key=entryIdentity(entry),next=new Set(this.openedEntryIds);event.detail.expanded?next.add(key):next.delete(key),this.openedEntryIds=next}stopOwnedEvent(event){event.stopPropagation()}onRenderError(entry,event){event.stopPropagation(),this.emit("lr-tool-render-error",{...entryCorrelation(entry),...event.detail})}redactedEntry(entry,placeholder){const redacted=redactToolDetail({args:entry.args,result:entry.result,error:entry.error},entry.redactedFields,placeholder,this.redactionCache.get(entry));return this.redactionCache.set(entry,redacted),redacted}openedDetailsTemplate(entry,placeholder){const redacted=this.redactedEntry(entry,placeholder);return html`
|
|
2
2
|
<lr-tool-result-view
|
|
3
3
|
part="entry-result"
|
|
4
4
|
tool-name=${entry.name}
|
|
@@ -70,9 +70,7 @@ import{__decorate}from"tslib";import{warnDeprecatedUsage}from"../../../internal/
|
|
|
70
70
|
.open=${reviewing!==void 0}
|
|
71
71
|
@focus=${this.stopOwnedEvent}
|
|
72
72
|
@blur=${this.stopOwnedEvent}
|
|
73
|
-
@lr-approve=${event=>event.stopPropagation()}
|
|
74
73
|
@lr-approve-request=${this.onDialogApprove}
|
|
75
|
-
@lr-deny=${event=>event.stopPropagation()}
|
|
76
74
|
@lr-deny-request=${this.onDialogDeny}
|
|
77
75
|
@lr-close=${this.onDialogClose}
|
|
78
76
|
></lr-tool-approval-dialog>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type CategoryLabelGrowth='middle'|'left'|'right';export type CategoryLabelMax=number|'auto'|undefined|null;export interface CategoryLabelSelectionBounds{readonly characterWidth:number;readonly laneInset:number;readonly maxContentWidth:number;readonly maxRenderedRecords:number;}
|
|
2
|
+
/** Whether a category tick's resolved text paints anything. */
|
|
3
|
+
export declare function hasCategoryLabelText(label:string|null|undefined):boolean;
|
|
4
|
+
/** Visual side a category label grows toward from its tick. */
|
|
5
|
+
export declare function categoryLabelGrowth(index:number,count:number):CategoryLabelGrowth;
|
|
6
|
+
/** Computes the largest deterministic per-character estimate among sampled labels. */
|
|
7
|
+
export declare function widestEstimatedCategoryLabel(labels:readonly string[],renderedIndexes:readonly number[],characterWidth:number):number;
|
|
8
|
+
/** Automatic selection against sampled tick coordinates; returns null for unsorted positions. */
|
|
9
|
+
export declare function automaticCategoryLabelIndexes(count:number,renderedIndexes:readonly number[],positions:readonly number[],labels:readonly string[],bounds:Pick<CategoryLabelSelectionBounds,'characterWidth'|'laneInset'>,estimatedWidth?:number):Set<number> |undefined|null;
|
|
10
|
+
/** Pure selection contract used by LiteChart's class wrapper and direct boundary tests. */
|
|
11
|
+
export declare function visibleCategoryLabelIndexes(count:number,plotWidth:number,renderedIndexes:readonly number[],labels:readonly string[],maxLabels:CategoryLabelMax,positions:readonly number[]|undefined,bounds:CategoryLabelSelectionBounds,estimatedWidth?:number):Set<number> |undefined;
|
|
12
|
+
/** Pre-layout extent estimate for a sparse label with one or more blank neighboring slots. */
|
|
13
|
+
export declare function sparseCategoryLabelExtent(labels:readonly string[],xs:readonly number[],position:number,grow:CategoryLabelGrowth,pitch:number,width:number,margin:number,maxContentWidth:number):number;
|