inspect-ai 0.3.62__py3-none-any.whl → 0.3.64__py3-none-any.whl
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.
- inspect_ai/_cli/cache.py +8 -7
- inspect_ai/_cli/common.py +0 -12
- inspect_ai/_cli/eval.py +32 -4
- inspect_ai/_cli/info.py +1 -0
- inspect_ai/_cli/list.py +1 -1
- inspect_ai/_cli/log.py +2 -0
- inspect_ai/_cli/main.py +1 -1
- inspect_ai/_cli/sandbox.py +4 -1
- inspect_ai/_cli/score.py +181 -32
- inspect_ai/_cli/trace.py +10 -0
- inspect_ai/_cli/view.py +4 -2
- inspect_ai/_display/core/active.py +2 -3
- inspect_ai/_display/core/config.py +7 -1
- inspect_ai/_display/textual/widgets/samples.py +4 -3
- inspect_ai/_display/textual/widgets/sandbox.py +6 -0
- inspect_ai/_eval/eval.py +104 -101
- inspect_ai/_eval/evalset.py +75 -75
- inspect_ai/_eval/loader.py +122 -12
- inspect_ai/_eval/registry.py +1 -1
- inspect_ai/_eval/run.py +14 -0
- inspect_ai/_eval/score.py +125 -36
- inspect_ai/_eval/task/log.py +105 -4
- inspect_ai/_eval/task/results.py +92 -38
- inspect_ai/_eval/task/run.py +9 -2
- inspect_ai/_eval/task/sandbox.py +35 -2
- inspect_ai/_eval/task/task.py +49 -46
- inspect_ai/_util/constants.py +1 -1
- inspect_ai/_util/content.py +8 -0
- inspect_ai/_util/error.py +2 -0
- inspect_ai/_util/file.py +15 -1
- inspect_ai/_util/hash.py +1 -1
- inspect_ai/_util/logger.py +4 -2
- inspect_ai/_util/registry.py +7 -1
- inspect_ai/_view/view.py +1 -2
- inspect_ai/_view/www/.vscode/extensions.json +3 -0
- inspect_ai/_view/www/.vscode/settings.json +8 -0
- inspect_ai/_view/www/App.css +97 -29
- inspect_ai/_view/www/README.md +1 -1
- inspect_ai/_view/www/dist/assets/index.css +16663 -14674
- inspect_ai/_view/www/dist/assets/index.js +58808 -51348
- inspect_ai/_view/www/dist/index.html +1 -1
- inspect_ai/_view/www/index.html +2 -2
- inspect_ai/_view/www/log-schema.json +87 -73
- inspect_ai/_view/www/package.json +22 -4
- inspect_ai/_view/www/postcss.config.cjs +8 -9
- inspect_ai/_view/www/src/{App.mjs → App.tsx} +356 -365
- inspect_ai/_view/www/src/AppErrorBoundary.tsx +47 -0
- inspect_ai/_view/www/src/api/api-browser.ts +2 -2
- inspect_ai/_view/www/src/api/api-http.ts +3 -5
- inspect_ai/_view/www/src/api/api-vscode.ts +6 -6
- inspect_ai/_view/www/src/api/client-api.ts +4 -4
- inspect_ai/_view/www/src/api/index.ts +4 -4
- inspect_ai/_view/www/src/api/{Types.ts → types.ts} +25 -9
- inspect_ai/_view/www/src/appearance/colors.ts +9 -0
- inspect_ai/_view/www/src/appearance/fonts.ts +39 -0
- inspect_ai/_view/www/src/appearance/icons.ts +100 -0
- inspect_ai/_view/www/src/appearance/{Styles.mjs → styles.ts} +2 -32
- inspect_ai/_view/www/src/components/AnsiDisplay.tsx +198 -0
- inspect_ai/_view/www/src/components/AsciinemaPlayer.tsx +86 -0
- inspect_ai/_view/www/src/components/Card.css +60 -0
- inspect_ai/_view/www/src/components/Card.tsx +109 -0
- inspect_ai/_view/www/src/components/CopyButton.module.css +11 -0
- inspect_ai/_view/www/src/components/CopyButton.tsx +58 -0
- inspect_ai/_view/www/src/components/DownloadButton.css +4 -0
- inspect_ai/_view/www/src/components/DownloadButton.tsx +25 -0
- inspect_ai/_view/www/src/components/DownloadPanel.css +10 -0
- inspect_ai/_view/www/src/components/DownloadPanel.tsx +30 -0
- inspect_ai/_view/www/src/components/EmptyPanel.css +12 -0
- inspect_ai/_view/www/src/components/EmptyPanel.tsx +15 -0
- inspect_ai/_view/www/src/components/ErrorPanel.css +37 -0
- inspect_ai/_view/www/src/components/ErrorPanel.tsx +39 -0
- inspect_ai/_view/www/src/components/ExpandablePanel.css +40 -0
- inspect_ai/_view/www/src/components/ExpandablePanel.tsx +115 -0
- inspect_ai/_view/www/src/components/FindBand.css +49 -0
- inspect_ai/_view/www/src/components/FindBand.tsx +130 -0
- inspect_ai/_view/www/src/components/HumanBaselineView.css +41 -0
- inspect_ai/_view/www/src/components/HumanBaselineView.tsx +162 -0
- inspect_ai/_view/www/src/components/JsonPanel.css +20 -0
- inspect_ai/_view/www/src/components/JsonPanel.tsx +82 -0
- inspect_ai/_view/www/src/components/LabeledValue.css +20 -0
- inspect_ai/_view/www/src/components/LabeledValue.tsx +41 -0
- inspect_ai/_view/www/src/components/LargeModal.module.css +54 -0
- inspect_ai/_view/www/src/components/LargeModal.tsx +189 -0
- inspect_ai/_view/www/src/components/LightboxCarousel.css +95 -0
- inspect_ai/_view/www/src/components/LightboxCarousel.tsx +132 -0
- inspect_ai/_view/www/src/components/MarkdownDiv.css +3 -0
- inspect_ai/_view/www/src/components/MarkdownDiv.tsx +133 -0
- inspect_ai/_view/www/src/components/MessageBand.css +43 -0
- inspect_ai/_view/www/src/components/MessageBand.tsx +39 -0
- inspect_ai/_view/www/src/components/MorePopOver.css +0 -0
- inspect_ai/_view/www/src/components/MorePopOver.tsx +67 -0
- inspect_ai/_view/www/src/components/NavPills.module.css +18 -0
- inspect_ai/_view/www/src/components/NavPills.tsx +101 -0
- inspect_ai/_view/www/src/components/ProgressBar.module.css +37 -0
- inspect_ai/_view/www/src/components/ProgressBar.tsx +22 -0
- inspect_ai/_view/www/src/components/TabSet.module.css +40 -0
- inspect_ai/_view/www/src/components/TabSet.tsx +215 -0
- inspect_ai/_view/www/src/components/ToolButton.css +3 -0
- inspect_ai/_view/www/src/components/ToolButton.tsx +27 -0
- inspect_ai/_view/www/src/components/VirtualList.module.css +19 -0
- inspect_ai/_view/www/src/components/VirtualList.tsx +292 -0
- inspect_ai/_view/www/src/{index.js → index.tsx} +45 -19
- inspect_ai/_view/www/src/{log → logfile}/remoteLogFile.ts +3 -8
- inspect_ai/_view/www/src/{utils/remoteZipFile.mjs → logfile/remoteZipFile.ts} +86 -80
- inspect_ai/_view/www/src/metadata/MetaDataGrid.tsx +83 -0
- inspect_ai/_view/www/src/metadata/MetaDataView.module.css +35 -0
- inspect_ai/_view/www/src/metadata/MetaDataView.tsx +95 -0
- inspect_ai/_view/www/src/metadata/MetadataGrid.module.css +15 -0
- inspect_ai/_view/www/src/metadata/RenderedContent.module.css +12 -0
- inspect_ai/_view/www/src/{components/RenderedContent/RenderedContent.mjs → metadata/RenderedContent.tsx} +92 -73
- inspect_ai/_view/www/src/metadata/types.ts +18 -0
- inspect_ai/_view/www/src/plan/DatasetDetailView.module.css +3 -0
- inspect_ai/_view/www/src/plan/DatasetDetailView.tsx +37 -0
- inspect_ai/_view/www/src/plan/DetailStep.module.css +9 -0
- inspect_ai/_view/www/src/plan/DetailStep.tsx +31 -0
- inspect_ai/_view/www/src/plan/PlanCard.tsx +28 -0
- inspect_ai/_view/www/src/plan/PlanDetailView.module.css +48 -0
- inspect_ai/_view/www/src/plan/PlanDetailView.tsx +324 -0
- inspect_ai/_view/www/src/plan/ScorerDetailView.module.css +3 -0
- inspect_ai/_view/www/src/plan/ScorerDetailView.tsx +30 -0
- inspect_ai/_view/www/src/plan/SolverDetailView.module.css +15 -0
- inspect_ai/_view/www/src/plan/SolverDetailView.tsx +32 -0
- inspect_ai/_view/www/src/samples/InlineSampleDisplay.module.css +8 -0
- inspect_ai/_view/www/src/samples/InlineSampleDisplay.tsx +53 -0
- inspect_ai/_view/www/src/samples/SampleDialog.tsx +122 -0
- inspect_ai/_view/www/src/samples/SampleDisplay.module.css +29 -0
- inspect_ai/_view/www/src/samples/SampleDisplay.tsx +331 -0
- inspect_ai/_view/www/src/samples/SampleSummaryView.module.css +24 -0
- inspect_ai/_view/www/src/samples/SampleSummaryView.tsx +177 -0
- inspect_ai/_view/www/src/samples/SamplesTools.tsx +52 -0
- inspect_ai/_view/www/src/samples/chat/ChatMessage.module.css +29 -0
- inspect_ai/_view/www/src/samples/chat/ChatMessage.tsx +76 -0
- inspect_ai/_view/www/src/samples/chat/ChatMessageRenderer.tsx +60 -0
- inspect_ai/_view/www/src/samples/chat/ChatMessageRow.module.css +9 -0
- inspect_ai/_view/www/src/samples/chat/ChatMessageRow.tsx +57 -0
- inspect_ai/_view/www/src/samples/chat/ChatView.tsx +47 -0
- inspect_ai/_view/www/src/samples/chat/ChatViewVirtualList.module.css +4 -0
- inspect_ai/_view/www/src/samples/chat/ChatViewVirtualList.tsx +58 -0
- inspect_ai/_view/www/src/samples/chat/MessageContent.module.css +4 -0
- inspect_ai/_view/www/src/samples/chat/MessageContent.tsx +157 -0
- inspect_ai/_view/www/src/samples/chat/MessageContents.module.css +3 -0
- inspect_ai/_view/www/src/samples/chat/MessageContents.tsx +133 -0
- inspect_ai/_view/www/src/samples/chat/messages.ts +112 -0
- inspect_ai/_view/www/src/samples/chat/tools/ToolCallView.tsx +147 -0
- inspect_ai/_view/www/src/samples/chat/tools/ToolInput.module.css +14 -0
- inspect_ai/_view/www/src/samples/chat/tools/ToolInput.tsx +76 -0
- inspect_ai/_view/www/src/samples/chat/tools/ToolOutput.module.css +19 -0
- inspect_ai/_view/www/src/samples/chat/tools/ToolOutput.tsx +60 -0
- inspect_ai/_view/www/src/samples/chat/tools/ToolTitle.module.css +4 -0
- inspect_ai/_view/www/src/samples/chat/tools/ToolTitle.tsx +18 -0
- inspect_ai/_view/www/src/samples/chat/tools/tool.ts +92 -0
- inspect_ai/_view/www/src/samples/descriptor/samplesDescriptor.tsx +365 -0
- inspect_ai/_view/www/src/samples/descriptor/score/BooleanScoreDescriptor.module.css +22 -0
- inspect_ai/_view/www/src/samples/descriptor/score/BooleanScoreDescriptor.tsx +26 -0
- inspect_ai/_view/www/src/samples/descriptor/score/CategoricalScoreDescriptor.tsx +18 -0
- inspect_ai/_view/www/src/samples/descriptor/score/NumericScoreDescriptor.tsx +27 -0
- inspect_ai/_view/www/src/samples/descriptor/score/ObjectScoreDescriptor.module.css +18 -0
- inspect_ai/_view/www/src/samples/descriptor/score/ObjectScoreDescriptor.tsx +71 -0
- inspect_ai/_view/www/src/samples/descriptor/score/OtherScoreDescriptor.tsx +20 -0
- inspect_ai/_view/www/src/samples/descriptor/score/PassFailScoreDescriptor.module.css +28 -0
- inspect_ai/_view/www/src/samples/descriptor/score/PassFailScoreDescriptor.tsx +81 -0
- inspect_ai/_view/www/src/samples/descriptor/score/ScoreDescriptor.tsx +99 -0
- inspect_ai/_view/www/src/samples/descriptor/types.ts +55 -0
- inspect_ai/_view/www/src/samples/error/FlatSampleErrorView.module.css +19 -0
- inspect_ai/_view/www/src/samples/error/FlatSampleErrorView.tsx +22 -0
- inspect_ai/_view/www/src/samples/error/SampleErrorView.module.css +17 -0
- inspect_ai/_view/www/src/samples/error/SampleErrorView.tsx +31 -0
- inspect_ai/_view/www/src/samples/error/error.ts +15 -0
- inspect_ai/_view/www/src/samples/list/SampleFooter.module.css +9 -0
- inspect_ai/_view/www/src/samples/list/SampleFooter.tsx +14 -0
- inspect_ai/_view/www/src/samples/list/SampleHeader.module.css +13 -0
- inspect_ai/_view/www/src/samples/list/SampleHeader.tsx +36 -0
- inspect_ai/_view/www/src/samples/list/SampleList.module.css +11 -0
- inspect_ai/_view/www/src/samples/list/SampleList.tsx +247 -0
- inspect_ai/_view/www/src/samples/list/SampleRow.module.css +33 -0
- inspect_ai/_view/www/src/samples/list/SampleRow.tsx +98 -0
- inspect_ai/_view/www/src/samples/list/SampleSeparator.module.css +6 -0
- inspect_ai/_view/www/src/samples/list/SampleSeparator.tsx +24 -0
- inspect_ai/_view/www/src/samples/sample-tools/EpochFilter.module.css +9 -0
- inspect_ai/_view/www/src/samples/sample-tools/EpochFilter.tsx +51 -0
- inspect_ai/_view/www/src/samples/sample-tools/SelectScorer.module.css +16 -0
- inspect_ai/_view/www/src/samples/sample-tools/SelectScorer.tsx +175 -0
- inspect_ai/_view/www/src/samples/sample-tools/SortFilter.module.css +9 -0
- inspect_ai/_view/www/src/samples/sample-tools/SortFilter.tsx +186 -0
- inspect_ai/_view/www/src/samples/{tools/filters.mjs → sample-tools/filters.ts} +86 -81
- inspect_ai/_view/www/src/samples/sample-tools/sample-filter/SampleFilter.module.css +16 -0
- inspect_ai/_view/www/src/samples/sample-tools/sample-filter/SampleFilter.tsx +288 -0
- inspect_ai/_view/www/src/samples/sample-tools/sample-filter/completions.ts +346 -0
- inspect_ai/_view/www/src/samples/sample-tools/sample-filter/language.ts +19 -0
- inspect_ai/_view/www/src/samples/sample-tools/sample-filter/tokenize.ts +97 -0
- inspect_ai/_view/www/src/samples/{SampleLimit.mjs → sampleLimit.ts} +3 -6
- inspect_ai/_view/www/src/samples/scores/SampleScoreView.module.css +53 -0
- inspect_ai/_view/www/src/samples/scores/SampleScoreView.tsx +168 -0
- inspect_ai/_view/www/src/samples/scores/SampleScores.module.css +5 -0
- inspect_ai/_view/www/src/samples/scores/SampleScores.tsx +37 -0
- inspect_ai/_view/www/src/samples/transcript/ApprovalEventView.tsx +66 -0
- inspect_ai/_view/www/src/samples/transcript/ErrorEventView.tsx +51 -0
- inspect_ai/_view/www/src/samples/transcript/InfoEventView.module.css +3 -0
- inspect_ai/_view/www/src/samples/transcript/InfoEventView.tsx +54 -0
- inspect_ai/_view/www/src/samples/transcript/InputEventView.tsx +48 -0
- inspect_ai/_view/www/src/samples/transcript/LoggerEventView.module.css +6 -0
- inspect_ai/_view/www/src/samples/transcript/LoggerEventView.tsx +36 -0
- inspect_ai/_view/www/src/samples/transcript/ModelEventView.module.css +43 -0
- inspect_ai/_view/www/src/samples/transcript/ModelEventView.tsx +223 -0
- inspect_ai/_view/www/src/samples/transcript/SampleInitEventView.module.css +23 -0
- inspect_ai/_view/www/src/samples/transcript/SampleInitEventView.tsx +112 -0
- inspect_ai/_view/www/src/samples/transcript/SampleLimitEventView.tsx +75 -0
- inspect_ai/_view/www/src/samples/transcript/SampleTranscript.tsx +22 -0
- inspect_ai/_view/www/src/samples/transcript/ScoreEventView.module.css +15 -0
- inspect_ai/_view/www/src/samples/transcript/ScoreEventView.tsx +100 -0
- inspect_ai/_view/www/src/samples/transcript/StepEventView.tsx +171 -0
- inspect_ai/_view/www/src/samples/transcript/SubtaskEventView.module.css +19 -0
- inspect_ai/_view/www/src/samples/transcript/SubtaskEventView.tsx +133 -0
- inspect_ai/_view/www/src/samples/transcript/ToolEventView.module.css +10 -0
- inspect_ai/_view/www/src/samples/transcript/ToolEventView.tsx +92 -0
- inspect_ai/_view/www/src/samples/transcript/TranscriptView.module.css +49 -0
- inspect_ai/_view/www/src/samples/transcript/TranscriptView.tsx +449 -0
- inspect_ai/_view/www/src/samples/transcript/event/EventNav.module.css +5 -0
- inspect_ai/_view/www/src/samples/transcript/event/EventNav.tsx +43 -0
- inspect_ai/_view/www/src/samples/transcript/event/EventNavs.module.css +3 -0
- inspect_ai/_view/www/src/samples/transcript/event/EventNavs.tsx +39 -0
- inspect_ai/_view/www/src/samples/transcript/event/EventPanel.module.css +25 -0
- inspect_ai/_view/www/src/samples/transcript/event/EventPanel.tsx +191 -0
- inspect_ai/_view/www/src/samples/transcript/event/EventRow.module.css +13 -0
- inspect_ai/_view/www/src/samples/transcript/event/EventRow.tsx +32 -0
- inspect_ai/_view/www/src/samples/transcript/event/EventSection.module.css +8 -0
- inspect_ai/_view/www/src/samples/transcript/event/EventSection.tsx +29 -0
- inspect_ai/_view/www/src/samples/transcript/state/StateDiffView.tsx +67 -0
- inspect_ai/_view/www/src/samples/transcript/state/StateEventRenderers.tsx +285 -0
- inspect_ai/_view/www/src/samples/transcript/state/StateEventRenders.module.css +10 -0
- inspect_ai/_view/www/src/samples/transcript/state/StateEventView.module.css +9 -0
- inspect_ai/_view/www/src/samples/transcript/state/StateEventView.tsx +346 -0
- inspect_ai/_view/www/src/samples/transcript/types.ts +58 -0
- inspect_ai/_view/www/src/types/log.d.ts +108 -19
- inspect_ai/_view/www/src/types/prism.d.ts +11 -0
- inspect_ai/_view/www/src/types.ts +71 -0
- inspect_ai/_view/www/src/usage/ModelTokenTable.tsx +28 -0
- inspect_ai/_view/www/src/usage/ModelUsagePanel.module.css +24 -0
- inspect_ai/_view/www/src/usage/ModelUsagePanel.tsx +97 -0
- inspect_ai/_view/www/src/usage/TokenTable.module.css +17 -0
- inspect_ai/_view/www/src/usage/TokenTable.tsx +91 -0
- inspect_ai/_view/www/src/usage/UsageCard.module.css +15 -0
- inspect_ai/_view/www/src/usage/UsageCard.tsx +67 -0
- inspect_ai/_view/www/src/utils/attachments.ts +42 -0
- inspect_ai/_view/www/src/utils/{Base64.mjs → base64.ts} +1 -6
- inspect_ai/_view/www/src/{components/Browser.mjs → utils/browser.ts} +0 -1
- inspect_ai/_view/www/src/utils/debugging.ts +28 -0
- inspect_ai/_view/www/src/utils/dom.ts +30 -0
- inspect_ai/_view/www/src/utils/format.ts +194 -0
- inspect_ai/_view/www/src/utils/git.ts +7 -0
- inspect_ai/_view/www/src/utils/html.ts +6 -0
- inspect_ai/_view/www/src/utils/http.ts +14 -0
- inspect_ai/_view/www/src/utils/{Path.mjs → path.ts} +2 -9
- inspect_ai/_view/www/src/utils/{Print.mjs → print.ts} +34 -26
- inspect_ai/_view/www/src/utils/queue.ts +51 -0
- inspect_ai/_view/www/src/utils/sync.ts +114 -0
- inspect_ai/_view/www/src/utils/{Type.mjs → type.ts} +3 -6
- inspect_ai/_view/www/src/utils/vscode.ts +13 -0
- inspect_ai/_view/www/src/workspace/WorkSpace.tsx +324 -0
- inspect_ai/_view/www/src/workspace/WorkSpaceView.module.css +33 -0
- inspect_ai/_view/www/src/workspace/WorkSpaceView.tsx +158 -0
- inspect_ai/_view/www/src/workspace/error/TaskErrorPanel.module.css +3 -0
- inspect_ai/_view/www/src/workspace/error/TaskErrorPanel.tsx +28 -0
- inspect_ai/_view/www/src/workspace/navbar/Navbar.module.css +54 -0
- inspect_ai/_view/www/src/workspace/navbar/Navbar.tsx +68 -0
- inspect_ai/_view/www/src/workspace/navbar/PrimaryBar.module.css +52 -0
- inspect_ai/_view/www/src/workspace/navbar/PrimaryBar.tsx +114 -0
- inspect_ai/_view/www/src/workspace/navbar/ResultsPanel.module.css +90 -0
- inspect_ai/_view/www/src/workspace/navbar/ResultsPanel.tsx +180 -0
- inspect_ai/_view/www/src/workspace/navbar/SecondaryBar.module.css +28 -0
- inspect_ai/_view/www/src/workspace/navbar/SecondaryBar.tsx +226 -0
- inspect_ai/_view/www/src/workspace/navbar/StatusPanel.module.css +14 -0
- inspect_ai/_view/www/src/workspace/navbar/StatusPanel.tsx +61 -0
- inspect_ai/_view/www/src/workspace/sidebar/EvalStatus.module.css +15 -0
- inspect_ai/_view/www/src/workspace/sidebar/EvalStatus.tsx +71 -0
- inspect_ai/_view/www/src/workspace/sidebar/LogDirectoryTitleView.module.css +5 -0
- inspect_ai/_view/www/src/workspace/sidebar/LogDirectoryTitleView.tsx +56 -0
- inspect_ai/_view/www/src/workspace/sidebar/Sidebar.module.css +68 -0
- inspect_ai/_view/www/src/workspace/sidebar/Sidebar.tsx +85 -0
- inspect_ai/_view/www/src/workspace/sidebar/SidebarLogEntry.module.css +29 -0
- inspect_ai/_view/www/src/workspace/sidebar/SidebarLogEntry.tsx +95 -0
- inspect_ai/_view/www/src/workspace/sidebar/SidebarScoreView.module.css +23 -0
- inspect_ai/_view/www/src/workspace/sidebar/SidebarScoreView.tsx +43 -0
- inspect_ai/_view/www/src/workspace/sidebar/SidebarScoresView.module.css +35 -0
- inspect_ai/_view/www/src/workspace/sidebar/SidebarScoresView.tsx +63 -0
- inspect_ai/_view/www/src/workspace/tabs/InfoTab.module.css +0 -0
- inspect_ai/_view/www/src/workspace/tabs/InfoTab.tsx +70 -0
- inspect_ai/_view/www/src/workspace/tabs/JsonTab.module.css +5 -0
- inspect_ai/_view/www/src/workspace/tabs/JsonTab.tsx +46 -0
- inspect_ai/_view/www/src/workspace/tabs/SamplesTab.tsx +204 -0
- inspect_ai/_view/www/src/workspace/tabs/grouping.ts +195 -0
- inspect_ai/_view/www/src/workspace/tabs/types.ts +19 -0
- inspect_ai/_view/www/src/workspace/types.ts +10 -0
- inspect_ai/_view/www/src/workspace/utils.ts +34 -0
- inspect_ai/_view/www/tsconfig.json +23 -9
- inspect_ai/_view/www/vite.config.js +8 -17
- inspect_ai/_view/www/yarn.lock +627 -556
- inspect_ai/approval/_approval.py +2 -0
- inspect_ai/approval/_approver.py +4 -4
- inspect_ai/approval/_auto.py +1 -1
- inspect_ai/approval/_human/approver.py +3 -0
- inspect_ai/approval/_policy.py +5 -0
- inspect_ai/approval/_registry.py +2 -2
- inspect_ai/dataset/_dataset.py +64 -37
- inspect_ai/dataset/_sources/__init__.py +0 -0
- inspect_ai/dataset/_sources/csv.py +20 -12
- inspect_ai/dataset/_sources/file.py +4 -0
- inspect_ai/dataset/_sources/hf.py +39 -29
- inspect_ai/dataset/_sources/json.py +17 -9
- inspect_ai/log/__init__.py +2 -0
- inspect_ai/log/_convert.py +3 -3
- inspect_ai/log/_file.py +24 -9
- inspect_ai/log/_log.py +101 -13
- inspect_ai/log/_message.py +4 -2
- inspect_ai/log/_recorders/file.py +4 -0
- inspect_ai/log/_recorders/json.py +5 -7
- inspect_ai/log/_recorders/recorder.py +3 -0
- inspect_ai/log/_transcript.py +19 -8
- inspect_ai/model/__init__.py +2 -0
- inspect_ai/model/_cache.py +39 -21
- inspect_ai/model/_call_tools.py +4 -3
- inspect_ai/model/_chat_message.py +14 -4
- inspect_ai/model/_generate_config.py +1 -1
- inspect_ai/model/_model.py +31 -24
- inspect_ai/model/_model_output.py +14 -1
- inspect_ai/model/_openai.py +10 -18
- inspect_ai/model/_providers/anthropic.py +3 -3
- inspect_ai/model/_providers/google.py +9 -5
- inspect_ai/model/_providers/openai.py +5 -9
- inspect_ai/model/_providers/openai_o1.py +3 -5
- inspect_ai/model/_providers/openrouter.py +86 -0
- inspect_ai/model/_providers/providers.py +11 -0
- inspect_ai/scorer/__init__.py +6 -1
- inspect_ai/scorer/_answer.py +7 -7
- inspect_ai/scorer/_classification.py +38 -18
- inspect_ai/scorer/_common.py +2 -8
- inspect_ai/scorer/_match.py +4 -5
- inspect_ai/scorer/_metric.py +87 -28
- inspect_ai/scorer/_metrics/__init__.py +3 -3
- inspect_ai/scorer/_metrics/accuracy.py +8 -10
- inspect_ai/scorer/_metrics/mean.py +3 -17
- inspect_ai/scorer/_metrics/std.py +111 -30
- inspect_ai/scorer/_model.py +12 -12
- inspect_ai/scorer/_pattern.py +3 -3
- inspect_ai/scorer/_reducer/reducer.py +36 -21
- inspect_ai/scorer/_reducer/registry.py +2 -2
- inspect_ai/scorer/_reducer/types.py +7 -1
- inspect_ai/scorer/_score.py +11 -1
- inspect_ai/scorer/_scorer.py +110 -16
- inspect_ai/solver/__init__.py +1 -1
- inspect_ai/solver/_basic_agent.py +19 -22
- inspect_ai/solver/_bridge/__init__.py +0 -3
- inspect_ai/solver/_bridge/bridge.py +3 -3
- inspect_ai/solver/_chain.py +1 -2
- inspect_ai/solver/_critique.py +3 -3
- inspect_ai/solver/_fork.py +2 -2
- inspect_ai/solver/_human_agent/__init__.py +0 -0
- inspect_ai/solver/_human_agent/agent.py +5 -8
- inspect_ai/solver/_human_agent/commands/clock.py +14 -10
- inspect_ai/solver/_human_agent/commands/note.py +1 -1
- inspect_ai/solver/_human_agent/commands/score.py +0 -11
- inspect_ai/solver/_multiple_choice.py +38 -26
- inspect_ai/solver/_prompt.py +7 -7
- inspect_ai/solver/_solver.py +53 -52
- inspect_ai/solver/_task_state.py +80 -69
- inspect_ai/solver/_use_tools.py +9 -9
- inspect_ai/tool/__init__.py +4 -1
- inspect_ai/tool/_tool.py +43 -14
- inspect_ai/tool/_tool_call.py +6 -2
- inspect_ai/tool/_tool_choice.py +3 -1
- inspect_ai/tool/_tool_def.py +10 -8
- inspect_ai/tool/_tool_params.py +24 -0
- inspect_ai/tool/_tool_with.py +7 -7
- inspect_ai/tool/_tools/__init__.py +0 -0
- inspect_ai/tool/{beta → _tools}/_computer/_common.py +2 -2
- inspect_ai/tool/{beta → _tools}/_computer/_computer.py +13 -5
- inspect_ai/tool/_tools/_computer/_resources/tool/__init__.py +0 -0
- inspect_ai/tool/{beta → _tools}/_computer/_resources/tool/_x11_client.py +1 -1
- inspect_ai/tool/_tools/_computer/_resources/tool/requirements.txt +0 -0
- inspect_ai/tool/_tools/_execute.py +23 -11
- inspect_ai/tool/_tools/_web_browser/_resources/README.md +2 -2
- inspect_ai/tool/_tools/_web_browser/_web_browser.py +5 -3
- inspect_ai/tool/_tools/_web_search.py +7 -5
- inspect_ai/tool/beta.py +3 -0
- inspect_ai/util/_concurrency.py +3 -3
- inspect_ai/util/_panel.py +2 -0
- inspect_ai/util/_resource.py +12 -12
- inspect_ai/util/_sandbox/docker/compose.py +23 -20
- inspect_ai/util/_sandbox/docker/config.py +2 -1
- inspect_ai/util/_sandbox/docker/docker.py +42 -86
- inspect_ai/util/_sandbox/docker/service.py +100 -0
- inspect_ai/util/_sandbox/environment.py +99 -96
- inspect_ai/util/_sandbox/self_check.py +124 -16
- inspect_ai/util/_subprocess.py +5 -3
- inspect_ai/util/_subtask.py +15 -16
- {inspect_ai-0.3.62.dist-info → inspect_ai-0.3.64.dist-info}/LICENSE +1 -1
- {inspect_ai-0.3.62.dist-info → inspect_ai-0.3.64.dist-info}/METADATA +11 -6
- inspect_ai-0.3.64.dist-info/RECORD +625 -0
- inspect_ai/_view/www/src/Register.mjs +0 -3
- inspect_ai/_view/www/src/Types.mjs +0 -38
- inspect_ai/_view/www/src/appearance/Colors.mjs +0 -27
- inspect_ai/_view/www/src/appearance/Fonts.mjs +0 -66
- inspect_ai/_view/www/src/appearance/Icons.mjs +0 -240
- inspect_ai/_view/www/src/components/AnsiDisplay.mjs +0 -184
- inspect_ai/_view/www/src/components/AppErrorBoundary.mjs +0 -34
- inspect_ai/_view/www/src/components/AsciiCinemaPlayer.mjs +0 -74
- inspect_ai/_view/www/src/components/Card.mjs +0 -126
- inspect_ai/_view/www/src/components/ChatView.mjs +0 -441
- inspect_ai/_view/www/src/components/CopyButton.mjs +0 -48
- inspect_ai/_view/www/src/components/Dialog.mjs +0 -61
- inspect_ai/_view/www/src/components/DownloadButton.mjs +0 -15
- inspect_ai/_view/www/src/components/DownloadPanel.mjs +0 -29
- inspect_ai/_view/www/src/components/EmptyPanel.mjs +0 -23
- inspect_ai/_view/www/src/components/ErrorPanel.mjs +0 -66
- inspect_ai/_view/www/src/components/ExpandablePanel.mjs +0 -136
- inspect_ai/_view/www/src/components/FindBand.mjs +0 -157
- inspect_ai/_view/www/src/components/HumanBaselineView.mjs +0 -168
- inspect_ai/_view/www/src/components/JsonPanel.mjs +0 -61
- inspect_ai/_view/www/src/components/LabeledValue.mjs +0 -32
- inspect_ai/_view/www/src/components/LargeModal.mjs +0 -190
- inspect_ai/_view/www/src/components/LightboxCarousel.mjs +0 -217
- inspect_ai/_view/www/src/components/MarkdownDiv.mjs +0 -118
- inspect_ai/_view/www/src/components/MessageBand.mjs +0 -48
- inspect_ai/_view/www/src/components/MessageContent.mjs +0 -111
- inspect_ai/_view/www/src/components/MetaDataGrid.mjs +0 -92
- inspect_ai/_view/www/src/components/MetaDataView.mjs +0 -109
- inspect_ai/_view/www/src/components/MorePopOver.mjs +0 -50
- inspect_ai/_view/www/src/components/NavPills.mjs +0 -63
- inspect_ai/_view/www/src/components/ProgressBar.mjs +0 -51
- inspect_ai/_view/www/src/components/RenderedContent/ChatMessageRenderer.mjs +0 -54
- inspect_ai/_view/www/src/components/RenderedContent/Types.mjs +0 -19
- inspect_ai/_view/www/src/components/TabSet.mjs +0 -184
- inspect_ai/_view/www/src/components/ToolButton.mjs +0 -16
- inspect_ai/_view/www/src/components/Tools.mjs +0 -376
- inspect_ai/_view/www/src/components/VirtualList.mjs +0 -280
- inspect_ai/_view/www/src/components/ansi-output.js +0 -932
- inspect_ai/_view/www/src/json/JsonTab.mjs +0 -48
- inspect_ai/_view/www/src/log-reader/Log-Reader.mjs +0 -25
- inspect_ai/_view/www/src/log-reader/Native-Log-Reader.mjs +0 -13
- inspect_ai/_view/www/src/log-reader/Open-AI-Log-Reader.mjs +0 -263
- inspect_ai/_view/www/src/navbar/Navbar.mjs +0 -418
- inspect_ai/_view/www/src/navbar/SecondaryBar.mjs +0 -175
- inspect_ai/_view/www/src/plan/PlanCard.mjs +0 -418
- inspect_ai/_view/www/src/samples/SampleDialog.mjs +0 -123
- inspect_ai/_view/www/src/samples/SampleDisplay.mjs +0 -516
- inspect_ai/_view/www/src/samples/SampleError.mjs +0 -99
- inspect_ai/_view/www/src/samples/SampleList.mjs +0 -427
- inspect_ai/_view/www/src/samples/SampleScoreView.mjs +0 -172
- inspect_ai/_view/www/src/samples/SampleScores.mjs +0 -34
- inspect_ai/_view/www/src/samples/SampleTranscript.mjs +0 -20
- inspect_ai/_view/www/src/samples/SamplesDescriptor.mjs +0 -771
- inspect_ai/_view/www/src/samples/SamplesTab.mjs +0 -399
- inspect_ai/_view/www/src/samples/SamplesTools.mjs +0 -64
- inspect_ai/_view/www/src/samples/tools/EpochFilter.mjs +0 -38
- inspect_ai/_view/www/src/samples/tools/SampleFilter.mjs +0 -756
- inspect_ai/_view/www/src/samples/tools/SelectScorer.mjs +0 -141
- inspect_ai/_view/www/src/samples/tools/SortFilter.mjs +0 -151
- inspect_ai/_view/www/src/samples/transcript/ApprovalEventView.mjs +0 -71
- inspect_ai/_view/www/src/samples/transcript/ErrorEventView.mjs +0 -44
- inspect_ai/_view/www/src/samples/transcript/EventPanel.mjs +0 -271
- inspect_ai/_view/www/src/samples/transcript/EventRow.mjs +0 -46
- inspect_ai/_view/www/src/samples/transcript/EventSection.mjs +0 -33
- inspect_ai/_view/www/src/samples/transcript/InfoEventView.mjs +0 -59
- inspect_ai/_view/www/src/samples/transcript/InputEventView.mjs +0 -44
- inspect_ai/_view/www/src/samples/transcript/LoggerEventView.mjs +0 -32
- inspect_ai/_view/www/src/samples/transcript/ModelEventView.mjs +0 -216
- inspect_ai/_view/www/src/samples/transcript/SampleInitEventView.mjs +0 -107
- inspect_ai/_view/www/src/samples/transcript/SampleLimitEventView.mjs +0 -74
- inspect_ai/_view/www/src/samples/transcript/ScoreEventView.mjs +0 -100
- inspect_ai/_view/www/src/samples/transcript/StepEventView.mjs +0 -187
- inspect_ai/_view/www/src/samples/transcript/SubtaskEventView.mjs +0 -133
- inspect_ai/_view/www/src/samples/transcript/ToolEventView.mjs +0 -88
- inspect_ai/_view/www/src/samples/transcript/TranscriptView.mjs +0 -459
- inspect_ai/_view/www/src/samples/transcript/Types.mjs +0 -44
- inspect_ai/_view/www/src/samples/transcript/state/StateDiffView.mjs +0 -53
- inspect_ai/_view/www/src/samples/transcript/state/StateEventRenderers.mjs +0 -254
- inspect_ai/_view/www/src/samples/transcript/state/StateEventView.mjs +0 -313
- inspect_ai/_view/www/src/sidebar/Sidebar.mjs +0 -418
- inspect_ai/_view/www/src/usage/ModelTokenTable.mjs +0 -72
- inspect_ai/_view/www/src/usage/UsageCard.mjs +0 -159
- inspect_ai/_view/www/src/utils/Format.mjs +0 -260
- inspect_ai/_view/www/src/utils/Git.mjs +0 -12
- inspect_ai/_view/www/src/utils/Html.mjs +0 -21
- inspect_ai/_view/www/src/utils/attachments.mjs +0 -31
- inspect_ai/_view/www/src/utils/debugging.mjs +0 -23
- inspect_ai/_view/www/src/utils/http.mjs +0 -18
- inspect_ai/_view/www/src/utils/queue.mjs +0 -67
- inspect_ai/_view/www/src/utils/sync.mjs +0 -101
- inspect_ai/_view/www/src/workspace/TaskErrorPanel.mjs +0 -17
- inspect_ai/_view/www/src/workspace/WorkSpace.mjs +0 -516
- inspect_ai/tool/beta/__init__.py +0 -5
- inspect_ai-0.3.62.dist-info/RECORD +0 -481
- /inspect_ai/{tool/beta/_computer/_resources/tool → _eval}/__init__.py +0 -0
- /inspect_ai/{tool/beta/_computer/_resources/tool/requirements.txt → _util/__init__.py} +0 -0
- /inspect_ai/_view/www/src/{constants.mjs → constants.ts} +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/__init__.py +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_computer_split.py +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/Dockerfile +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/README.md +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/entrypoint/entrypoint.sh +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/entrypoint/novnc_startup.sh +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/entrypoint/x11vnc_startup.sh +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/entrypoint/xfce_startup.sh +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/entrypoint/xvfb_startup.sh +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/image_home_dir/.config/Code/User/globalStorage/state.vscdb +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/image_home_dir/.config/Code/User/settings.json +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/image_home_dir/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/image_home_dir/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-screensaver.xml +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/image_home_dir/Desktop/Firefox Web Browser.desktop +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/image_home_dir/Desktop/Terminal.desktop +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/image_home_dir/Desktop/Visual Studio Code.desktop +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/tool/_logger.py +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/tool/_run.py +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/tool/_tool_result.py +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/tool/computer_tool.py +0 -0
- {inspect_ai-0.3.62.dist-info → inspect_ai-0.3.64.dist-info}/WHEEL +0 -0
- {inspect_ai-0.3.62.dist-info → inspect_ai-0.3.64.dist-info}/entry_points.txt +0 -0
- {inspect_ai-0.3.62.dist-info → inspect_ai-0.3.64.dist-info}/top_level.txt +0 -0
@@ -1,376 +0,0 @@
|
|
1
|
-
// @ts-check
|
2
|
-
/// <reference path="../types/prism.d.ts" />
|
3
|
-
import Prism from "prismjs";
|
4
|
-
import murmurhash from "murmurhash";
|
5
|
-
|
6
|
-
import "prismjs/components/prism-python";
|
7
|
-
import "prismjs/components/prism-bash";
|
8
|
-
import "prismjs/components/prism-json";
|
9
|
-
|
10
|
-
import { useRef, useEffect } from "preact/hooks";
|
11
|
-
import { html } from "htm/preact";
|
12
|
-
|
13
|
-
import { MessageContent } from "./MessageContent.mjs";
|
14
|
-
import { ExpandablePanel } from "./ExpandablePanel.mjs";
|
15
|
-
import { FontSize } from "../appearance/Fonts.mjs";
|
16
|
-
import { MarkdownDiv } from "./MarkdownDiv.mjs";
|
17
|
-
|
18
|
-
/**
|
19
|
-
* @typedef {Object} ToolCallResult
|
20
|
-
* @property {string} functionCall - The formatted function call with arguments.
|
21
|
-
* @property {string|undefined} input - The primary input for the tool, if available.
|
22
|
-
* @property {string|undefined} inputType - The type of the input (e.g., "bash", "python", "text"), if applicable.
|
23
|
-
*/
|
24
|
-
|
25
|
-
/**
|
26
|
-
* Resolves the input and metadata for a given tool call.
|
27
|
-
* @param { string } fn - The tool call function name
|
28
|
-
* @param { import("../types/log").Arguments } toolArgs - The tool call arguments
|
29
|
-
*
|
30
|
-
* @returns {ToolCallResult} An object containing the following properties:
|
31
|
-
*/
|
32
|
-
export const resolveToolInput = (fn, toolArgs) => {
|
33
|
-
const toolName = fn;
|
34
|
-
|
35
|
-
const [inputKey, inputType] = extractInputMetadata(toolName);
|
36
|
-
const { input, args } = extractInput(inputKey, toolArgs);
|
37
|
-
const functionCall =
|
38
|
-
args.length > 0 ? `${toolName}(${args.join(",")})` : toolName;
|
39
|
-
return {
|
40
|
-
functionCall,
|
41
|
-
input,
|
42
|
-
inputType,
|
43
|
-
};
|
44
|
-
};
|
45
|
-
|
46
|
-
/**
|
47
|
-
* Renders the ToolCallView component.
|
48
|
-
*
|
49
|
-
* @param {Object} props - The parameters for the component.
|
50
|
-
* @param {string} props.functionCall - The function call
|
51
|
-
* @param {string | undefined } props.input - The main input for this call
|
52
|
-
* @param {string | undefined } props.inputType - The input type for this call
|
53
|
-
* @param {import("../types/log").ToolCallContent} props.view - The tool call view
|
54
|
-
* @param {string | number | boolean | import("../types/log").ContentText | import("../types/log").ContentImage | (import("../types/log").ContentText | import("../types/log").ContentImage)[]} props.output - The tool output
|
55
|
-
* @param { "compact" | undefined } props.mode - The display mode for this call
|
56
|
-
* @returns {import("preact").JSX.Element} The SampleTranscript component.
|
57
|
-
*/
|
58
|
-
export const ToolCallView = ({
|
59
|
-
functionCall,
|
60
|
-
input,
|
61
|
-
inputType,
|
62
|
-
view,
|
63
|
-
output,
|
64
|
-
mode,
|
65
|
-
}) => {
|
66
|
-
// don't collapse if output includes an image
|
67
|
-
function isContentImage(value) {
|
68
|
-
if (value && typeof value === "object") {
|
69
|
-
if (value.type === "image") {
|
70
|
-
return true;
|
71
|
-
} else if (value.type === "tool") {
|
72
|
-
if (
|
73
|
-
Array.isArray(value.content) &&
|
74
|
-
value.content.some(isContentImage)
|
75
|
-
) {
|
76
|
-
return true;
|
77
|
-
}
|
78
|
-
}
|
79
|
-
}
|
80
|
-
return false;
|
81
|
-
}
|
82
|
-
const collapse = Array.isArray(output)
|
83
|
-
? output.every((item) => !isContentImage(item))
|
84
|
-
: !isContentImage(output);
|
85
|
-
|
86
|
-
return html`<div>
|
87
|
-
${mode !== "compact" && (!view || view.title)
|
88
|
-
? html`<${ToolTitle} title=${view?.title || functionCall} />`
|
89
|
-
: ""}
|
90
|
-
<div>
|
91
|
-
<div>
|
92
|
-
<${ToolInput}
|
93
|
-
type=${inputType}
|
94
|
-
contents=${input}
|
95
|
-
view=${view}
|
96
|
-
style=${{ marginBottom: "1em" }}
|
97
|
-
/>
|
98
|
-
${output
|
99
|
-
? html`
|
100
|
-
<${ExpandablePanel} collapse=${collapse} border=${true} lines=${15}>
|
101
|
-
<${MessageContent} contents=${normalizeContent(output)} />
|
102
|
-
</${ExpandablePanel}>`
|
103
|
-
: ""}
|
104
|
-
</div>
|
105
|
-
</div>
|
106
|
-
</div>`;
|
107
|
-
};
|
108
|
-
|
109
|
-
/**
|
110
|
-
* Renders the ToolCallView component.
|
111
|
-
*
|
112
|
-
* @param {Object} props - The parameters for the component.
|
113
|
-
* @param {string} props.title - The title for the tool call
|
114
|
-
* @returns {import("preact").JSX.Element} The SampleTranscript component.
|
115
|
-
*/
|
116
|
-
const ToolTitle = ({ title }) => {
|
117
|
-
return html` <i
|
118
|
-
class="bi bi-tools"
|
119
|
-
style=${{
|
120
|
-
marginRight: "0.2rem",
|
121
|
-
opacity: "0.4",
|
122
|
-
}}
|
123
|
-
></i>
|
124
|
-
<code style=${{ fontSize: FontSize.small }}>${title}</code>`;
|
125
|
-
};
|
126
|
-
|
127
|
-
/**
|
128
|
-
* Renders the ToolCallView component.
|
129
|
-
*
|
130
|
-
* @param {string | number | boolean | import("../types/log").ContentImage | import("../types/log").ContentText | (import("../types/log").ContentText | import("../types/log").ContentImage)[]} output - The tool output
|
131
|
-
* @returns {(import("../Types.mjs").ContentTool | import("../types/log").ContentText | import("../types/log").ContentImage)[]} The SampleTranscript component.
|
132
|
-
*/
|
133
|
-
const normalizeContent = (output) => {
|
134
|
-
if (Array.isArray(output)) {
|
135
|
-
return output;
|
136
|
-
} else {
|
137
|
-
return [
|
138
|
-
{
|
139
|
-
type: "tool",
|
140
|
-
content: [
|
141
|
-
{
|
142
|
-
type: "text",
|
143
|
-
text: String(output),
|
144
|
-
},
|
145
|
-
],
|
146
|
-
},
|
147
|
-
];
|
148
|
-
}
|
149
|
-
};
|
150
|
-
|
151
|
-
/**
|
152
|
-
* Renders the ToolInput component.
|
153
|
-
*
|
154
|
-
* @param {Object} props - The parameters for the component.
|
155
|
-
* @param {string} props.type - The function call
|
156
|
-
* @param {string | undefined } props.contents - The main input for this call
|
157
|
-
* @param {Record<string, string>} [props.style] - The style
|
158
|
-
* @param {import("../types/log").ToolCallContent} [props.view] - The tool call view
|
159
|
-
* @returns {import("preact").JSX.Element | string} The SampleTranscript component.
|
160
|
-
*/
|
161
|
-
export const ToolInput = ({ type, contents, view, style }) => {
|
162
|
-
if (!contents && !view?.content) {
|
163
|
-
return "";
|
164
|
-
}
|
165
|
-
|
166
|
-
if (view) {
|
167
|
-
const toolInputRef = useRef(
|
168
|
-
/** @type {import("preact").Component & { base: Element }} */ (null),
|
169
|
-
);
|
170
|
-
useEffect(() => {
|
171
|
-
// Sniff around for code in the view that could be text highlighted
|
172
|
-
if (toolInputRef.current) {
|
173
|
-
// @ts-expect-error: TS doesn't know that `HTMLCollection` is iterable.
|
174
|
-
for (const child of toolInputRef.current.base.children) {
|
175
|
-
if (child.tagName === "PRE") {
|
176
|
-
const childChild = child.firstElementChild;
|
177
|
-
if (childChild && childChild.tagName === "CODE") {
|
178
|
-
const hasLanguageClass = Array.from(childChild.classList).some(
|
179
|
-
(className) => className.startsWith("language-"),
|
180
|
-
);
|
181
|
-
if (hasLanguageClass) {
|
182
|
-
child.classList.add("tool-output");
|
183
|
-
Prism.highlightElement(childChild);
|
184
|
-
}
|
185
|
-
}
|
186
|
-
}
|
187
|
-
}
|
188
|
-
}
|
189
|
-
}, [contents, view, style]);
|
190
|
-
return html`<${MarkdownDiv}
|
191
|
-
markdown=${view.content}
|
192
|
-
ref=${toolInputRef}
|
193
|
-
style=${style}
|
194
|
-
/>`;
|
195
|
-
} else {
|
196
|
-
const toolInputRef = useRef(/** @type {HTMLElement|null} */ (null));
|
197
|
-
useEffect(() => {
|
198
|
-
const tokens = Prism.languages[type];
|
199
|
-
if (toolInputRef.current && tokens) {
|
200
|
-
Prism.highlightElement(toolInputRef.current);
|
201
|
-
}
|
202
|
-
}, [contents, type, view]);
|
203
|
-
|
204
|
-
contents =
|
205
|
-
typeof contents === "object" || Array.isArray(contents)
|
206
|
-
? JSON.stringify(contents)
|
207
|
-
: contents;
|
208
|
-
const key = murmurhash.v3(contents);
|
209
|
-
|
210
|
-
return html`<pre
|
211
|
-
class="tool-output"
|
212
|
-
style=${{
|
213
|
-
padding: "0.5em",
|
214
|
-
marginTop: "0.25em",
|
215
|
-
marginBottom: "1rem",
|
216
|
-
...style,
|
217
|
-
}}
|
218
|
-
>
|
219
|
-
<code ref=${toolInputRef}
|
220
|
-
key=${key}
|
221
|
-
class="sourceCode${type ? ` language-${type}` : ""}" style=${{
|
222
|
-
overflowWrap: "anywhere",
|
223
|
-
whiteSpace: "pre-wrap",
|
224
|
-
}}>
|
225
|
-
${contents}
|
226
|
-
</code>
|
227
|
-
</pre>`;
|
228
|
-
}
|
229
|
-
};
|
230
|
-
|
231
|
-
/**
|
232
|
-
* Renders the ToolOutput component.
|
233
|
-
*
|
234
|
-
* @param {Object} props - The parameters for the component.
|
235
|
-
* @param {string | number | boolean | (import("../types/log").ContentText | import("../types/log").ContentImage)[]} props.output - The tool output
|
236
|
-
* @param {Object} props.style - The style for the element
|
237
|
-
* @returns { import("preact").JSX.Element | import("preact").JSX.Element[] | string} The ToolOutput component.
|
238
|
-
*/
|
239
|
-
export const ToolOutput = ({ output, style }) => {
|
240
|
-
// If there is no output, don't show the tool
|
241
|
-
if (!output) {
|
242
|
-
return "";
|
243
|
-
}
|
244
|
-
|
245
|
-
// First process an array or object into a string
|
246
|
-
const outputs = [];
|
247
|
-
if (Array.isArray(output)) {
|
248
|
-
output.forEach((out) => {
|
249
|
-
if (out.type === "text") {
|
250
|
-
outputs.push(
|
251
|
-
html`<${ToolTextOutput} text=${out.text} style=${style} />`,
|
252
|
-
);
|
253
|
-
} else {
|
254
|
-
if (out.image.startsWith("data:")) {
|
255
|
-
outputs.push(
|
256
|
-
html`<img
|
257
|
-
src="${out.image}"
|
258
|
-
style=${{
|
259
|
-
maxWidth: "800px",
|
260
|
-
border: "solid var(--bs-border-color) 1px",
|
261
|
-
...style,
|
262
|
-
}}
|
263
|
-
/>`,
|
264
|
-
);
|
265
|
-
} else {
|
266
|
-
outputs.push(
|
267
|
-
html`<${ToolTextOutput}
|
268
|
-
text=${String(out.image)}
|
269
|
-
style=${style}
|
270
|
-
/>`,
|
271
|
-
);
|
272
|
-
}
|
273
|
-
}
|
274
|
-
});
|
275
|
-
} else {
|
276
|
-
outputs.push(
|
277
|
-
html`<${ToolTextOutput} text=${String(output)} style=${style} />`,
|
278
|
-
);
|
279
|
-
}
|
280
|
-
return html`<div style=${{ display: "grid" }}>${outputs}</div>`;
|
281
|
-
};
|
282
|
-
|
283
|
-
/**
|
284
|
-
* Renders the ToolTextOutput component.
|
285
|
-
*
|
286
|
-
* @param {Object} props - The parameters for the component.
|
287
|
-
* @param {string} props.text - The tool text
|
288
|
-
* @param {Object} props.style - The style for the element
|
289
|
-
* @returns {import("preact").JSX.Element} The ToolOutput component.
|
290
|
-
*/
|
291
|
-
const ToolTextOutput = ({ text, style }) => {
|
292
|
-
return html`<pre
|
293
|
-
style=${{
|
294
|
-
marginLeft: "2px",
|
295
|
-
padding: "0.5em 0.5em 0.5em 0.5em",
|
296
|
-
whiteSpace: "pre-wrap",
|
297
|
-
marginBottom: "0",
|
298
|
-
...style,
|
299
|
-
}}
|
300
|
-
>
|
301
|
-
<code class="sourceCode" style=${{ wordWrap: "anywhere" }}>
|
302
|
-
${text.trim()}
|
303
|
-
</code>
|
304
|
-
</pre>`;
|
305
|
-
};
|
306
|
-
|
307
|
-
/**
|
308
|
-
* @param {string} toolName
|
309
|
-
* @returns {[string | undefined, string | undefined]}
|
310
|
-
*/
|
311
|
-
const extractInputMetadata = (toolName) => {
|
312
|
-
if (toolName === "bash") {
|
313
|
-
return ["cmd", "bash"];
|
314
|
-
} else if (toolName === "python") {
|
315
|
-
return ["code", "python"];
|
316
|
-
} else if (toolName === "web_search") {
|
317
|
-
return ["query", "text"];
|
318
|
-
} else {
|
319
|
-
return [undefined, undefined];
|
320
|
-
}
|
321
|
-
};
|
322
|
-
|
323
|
-
/**
|
324
|
-
* @param {string} inputKey
|
325
|
-
* @param {Object<string, any>} args
|
326
|
-
* @returns {{ input: string | undefined, args: string[] }}
|
327
|
-
*/
|
328
|
-
const extractInput = (inputKey, args) => {
|
329
|
-
const formatArg = (key, value) => {
|
330
|
-
const quotedValue = typeof value === "string" ? `"${value}"` : value;
|
331
|
-
return `${key}: ${quotedValue}`;
|
332
|
-
};
|
333
|
-
if (args) {
|
334
|
-
if (Object.keys(args).length === 1) {
|
335
|
-
const inputRaw = args[Object.keys(args)[0]];
|
336
|
-
|
337
|
-
let input;
|
338
|
-
if (Array.isArray(inputRaw) || typeof inputRaw === "object") {
|
339
|
-
input = JSON.stringify(inputRaw, undefined, 2);
|
340
|
-
} else {
|
341
|
-
input = String(inputRaw);
|
342
|
-
}
|
343
|
-
|
344
|
-
return {
|
345
|
-
input: input,
|
346
|
-
args: [],
|
347
|
-
};
|
348
|
-
} else if (args[inputKey]) {
|
349
|
-
const input = args[inputKey];
|
350
|
-
const filteredArgs = Object.keys(args)
|
351
|
-
.filter((key) => {
|
352
|
-
return key !== inputKey;
|
353
|
-
})
|
354
|
-
.map((key) => {
|
355
|
-
return formatArg(key, args[key]);
|
356
|
-
});
|
357
|
-
return {
|
358
|
-
input,
|
359
|
-
args: filteredArgs,
|
360
|
-
};
|
361
|
-
} else {
|
362
|
-
const formattedArgs = Object.keys(args).map((key) => {
|
363
|
-
return formatArg(key, args[key]);
|
364
|
-
});
|
365
|
-
|
366
|
-
return {
|
367
|
-
input: undefined,
|
368
|
-
args: formattedArgs,
|
369
|
-
};
|
370
|
-
}
|
371
|
-
}
|
372
|
-
return {
|
373
|
-
input: undefined,
|
374
|
-
args: [],
|
375
|
-
};
|
376
|
-
};
|
@@ -1,280 +0,0 @@
|
|
1
|
-
import { html } from "htm/preact";
|
2
|
-
import { useRef, useState, useEffect, useMemo } from "preact/hooks";
|
3
|
-
import { forwardRef, useImperativeHandle } from "preact/compat";
|
4
|
-
import { throttle } from "../utils/sync.mjs";
|
5
|
-
|
6
|
-
/**
|
7
|
-
* A virtualized list component that efficiently renders large lists by only
|
8
|
-
* rendering the items that are currently visible in the viewport.
|
9
|
-
* Supports dynamic row heights that are measured after rendering.
|
10
|
-
*
|
11
|
-
* @template T
|
12
|
-
* @param {Object} props - The component props
|
13
|
-
* @param {T[]} props.data - Array of items to be rendered in the list
|
14
|
-
* @param {(item: T, index: number) => preact.VNode} props.renderRow - Function to render each row
|
15
|
-
* @param {number} [props.overscanCount=15] - Number of extra rows to render above and below the visible area
|
16
|
-
* @param {number} [props.estimatedRowHeight=50] - Estimated height of each row before measurement
|
17
|
-
* @param {boolean} [props.sync=false] - If true, forces a re-render on scroll
|
18
|
-
* @param {import("preact").RefObject<HTMLElement>} [props.scrollRef] - Optional ref for the scroll container
|
19
|
-
* @param {import("preact").Ref<{ scrollToIndex: (index: number) => void }>} ref - Ref object exposing the list's methods
|
20
|
-
* @returns {preact.VNode} The virtualized list component
|
21
|
-
*/
|
22
|
-
export const VirtualList = forwardRef(
|
23
|
-
(
|
24
|
-
/** @type {props} */ {
|
25
|
-
data,
|
26
|
-
renderRow,
|
27
|
-
overscanCount = 15,
|
28
|
-
estimatedRowHeight = 50,
|
29
|
-
sync = false,
|
30
|
-
scrollRef,
|
31
|
-
...props
|
32
|
-
},
|
33
|
-
ref,
|
34
|
-
) => {
|
35
|
-
const [height, setHeight] = useState(0);
|
36
|
-
const [offset, setOffset] = useState(0);
|
37
|
-
|
38
|
-
const [listMetrics, setListMetrics] = useState({
|
39
|
-
rowHeights: new Map(),
|
40
|
-
totalHeight: data.length * estimatedRowHeight,
|
41
|
-
});
|
42
|
-
|
43
|
-
const baseRef = useRef(null);
|
44
|
-
const containerRef = useRef(null);
|
45
|
-
const rowRefs = useRef(new Map());
|
46
|
-
|
47
|
-
// Function to get row height (measured or estimated)
|
48
|
-
const getRowHeight = (index) => {
|
49
|
-
return listMetrics.rowHeights.get(index) || estimatedRowHeight;
|
50
|
-
};
|
51
|
-
|
52
|
-
// Calculate row positions based on current heights
|
53
|
-
const rowPositions = useMemo(() => {
|
54
|
-
let currentPosition = 0;
|
55
|
-
const positions = new Map();
|
56
|
-
|
57
|
-
for (let i = 0; i < data.length; i++) {
|
58
|
-
positions.set(i, currentPosition);
|
59
|
-
currentPosition += getRowHeight(i);
|
60
|
-
}
|
61
|
-
|
62
|
-
return positions;
|
63
|
-
}, [listMetrics.rowHeights, data.length]);
|
64
|
-
|
65
|
-
// Expose scrollToIndex method via ref
|
66
|
-
useImperativeHandle(
|
67
|
-
ref,
|
68
|
-
() => ({
|
69
|
-
focus: () => {
|
70
|
-
baseRef.current;
|
71
|
-
},
|
72
|
-
scrollToIndex: (index, direction) => {
|
73
|
-
const scrollElement = scrollRef?.current || baseRef.current;
|
74
|
-
if (!scrollElement || index < 0 || index >= data.length) return;
|
75
|
-
|
76
|
-
const currentScrollTop = scrollElement.scrollTop;
|
77
|
-
const viewportHeight = scrollElement.offsetHeight;
|
78
|
-
|
79
|
-
// Get position and height of target row
|
80
|
-
const rowTop = rowPositions.get(index) || 0;
|
81
|
-
const rowHeight = getRowHeight(index);
|
82
|
-
const rowBottom = rowTop + rowHeight;
|
83
|
-
|
84
|
-
// If this is already visible, don't scroll
|
85
|
-
const isVisible =
|
86
|
-
rowTop >= currentScrollTop &&
|
87
|
-
rowBottom <= currentScrollTop + viewportHeight;
|
88
|
-
if (isVisible) {
|
89
|
-
return;
|
90
|
-
}
|
91
|
-
|
92
|
-
// Calculate new scroll position based on direction
|
93
|
-
let newScrollTop;
|
94
|
-
if (direction === "up") {
|
95
|
-
// Align top of element with top of viewport
|
96
|
-
newScrollTop = rowTop;
|
97
|
-
} else {
|
98
|
-
// Align bottom of element with bottom of viewport
|
99
|
-
newScrollTop = rowBottom - viewportHeight;
|
100
|
-
}
|
101
|
-
|
102
|
-
// Clamp scroll position to valid range
|
103
|
-
newScrollTop = Math.max(
|
104
|
-
0,
|
105
|
-
Math.min(newScrollTop, listMetrics.totalHeight - viewportHeight),
|
106
|
-
);
|
107
|
-
scrollElement.scrollTop = newScrollTop;
|
108
|
-
},
|
109
|
-
}),
|
110
|
-
[rowPositions, data.length],
|
111
|
-
);
|
112
|
-
|
113
|
-
// Measure rendered rows and update heights if needed
|
114
|
-
const measureRows = () => {
|
115
|
-
// Keep track of updated heights
|
116
|
-
let updates = [];
|
117
|
-
|
118
|
-
rowRefs.current.forEach((element, index) => {
|
119
|
-
if (element) {
|
120
|
-
const measuredHeight = element.offsetHeight;
|
121
|
-
// If the measured height is different, schedule an update
|
122
|
-
if (
|
123
|
-
measuredHeight &&
|
124
|
-
measuredHeight !== listMetrics.rowHeights.get(index)
|
125
|
-
) {
|
126
|
-
updates.push([index, measuredHeight]);
|
127
|
-
}
|
128
|
-
}
|
129
|
-
});
|
130
|
-
|
131
|
-
// If no rows changed, do nothing
|
132
|
-
if (updates.length === 0) return;
|
133
|
-
|
134
|
-
// Create a new Map of rowHeights so we don't mutate state directly
|
135
|
-
const newHeights = new Map(listMetrics.rowHeights);
|
136
|
-
updates.forEach(([index, height]) => {
|
137
|
-
newHeights.set(index, height);
|
138
|
-
});
|
139
|
-
|
140
|
-
// Recompute total height only once
|
141
|
-
let newTotalHeight = 0;
|
142
|
-
for (let i = 0; i < data.length; i++) {
|
143
|
-
newTotalHeight += newHeights.get(i) || estimatedRowHeight;
|
144
|
-
}
|
145
|
-
|
146
|
-
// Now update our single state object in one go:
|
147
|
-
setListMetrics({
|
148
|
-
rowHeights: newHeights,
|
149
|
-
totalHeight: newTotalHeight,
|
150
|
-
});
|
151
|
-
};
|
152
|
-
|
153
|
-
// Handle container resize
|
154
|
-
const resize = () => {
|
155
|
-
const scrollElement = scrollRef?.current || baseRef.current;
|
156
|
-
if (scrollElement && height !== scrollElement.offsetHeight) {
|
157
|
-
setHeight(scrollElement.offsetHeight);
|
158
|
-
}
|
159
|
-
};
|
160
|
-
|
161
|
-
// Handle scroll with throttling
|
162
|
-
const handleScroll = throttle(() => {
|
163
|
-
const scrollElement = scrollRef?.current || baseRef.current;
|
164
|
-
if (scrollElement) {
|
165
|
-
setOffset(scrollElement.scrollTop);
|
166
|
-
}
|
167
|
-
if (sync) {
|
168
|
-
setOffset((prev) => prev);
|
169
|
-
}
|
170
|
-
}, 100);
|
171
|
-
|
172
|
-
// Setup scroll and resize listeners
|
173
|
-
useEffect(() => {
|
174
|
-
resize();
|
175
|
-
const scrollElement = scrollRef?.current || baseRef.current;
|
176
|
-
|
177
|
-
if (scrollElement) {
|
178
|
-
scrollElement.addEventListener("scroll", handleScroll);
|
179
|
-
window.addEventListener("resize", resize);
|
180
|
-
|
181
|
-
return () => {
|
182
|
-
scrollElement.removeEventListener("scroll", handleScroll);
|
183
|
-
window.removeEventListener("resize", resize);
|
184
|
-
};
|
185
|
-
}
|
186
|
-
}, [scrollRef?.current]);
|
187
|
-
|
188
|
-
// Measure rows after render
|
189
|
-
useEffect(() => {
|
190
|
-
measureRows();
|
191
|
-
});
|
192
|
-
|
193
|
-
const findRowAtOffset = (targetOffset) => {
|
194
|
-
if (targetOffset <= 0) return 0;
|
195
|
-
if (targetOffset >= listMetrics.totalHeight) return data.length - 1;
|
196
|
-
|
197
|
-
let low = 0;
|
198
|
-
let high = data.length - 1;
|
199
|
-
let lastValid = 0;
|
200
|
-
|
201
|
-
while (low <= high) {
|
202
|
-
const mid = Math.floor((low + high) / 2);
|
203
|
-
const rowStart = rowPositions.get(mid) || 0;
|
204
|
-
|
205
|
-
if (rowStart <= targetOffset) {
|
206
|
-
lastValid = mid;
|
207
|
-
low = mid + 1;
|
208
|
-
} else {
|
209
|
-
high = mid - 1;
|
210
|
-
}
|
211
|
-
}
|
212
|
-
return lastValid;
|
213
|
-
};
|
214
|
-
|
215
|
-
const firstVisibleIdx = findRowAtOffset(offset);
|
216
|
-
const lastVisibleIdx = findRowAtOffset(offset + height);
|
217
|
-
|
218
|
-
// Calculate range of rows to render including overscan
|
219
|
-
const start = Math.max(0, firstVisibleIdx - overscanCount);
|
220
|
-
const end = Math.min(data.length, lastVisibleIdx + overscanCount);
|
221
|
-
|
222
|
-
// Memoize the rendered rows to prevent unnecessary re-renders
|
223
|
-
const renderedRows = useMemo(() => {
|
224
|
-
const selection = data.slice(start, end);
|
225
|
-
return selection.map((item, index) => {
|
226
|
-
const actualIndex = start + index;
|
227
|
-
return html`
|
228
|
-
<div
|
229
|
-
key=${`list-item-${actualIndex}`}
|
230
|
-
ref=${(el) => {
|
231
|
-
if (el) {
|
232
|
-
rowRefs.current.set(actualIndex, el);
|
233
|
-
} else {
|
234
|
-
rowRefs.current.delete(actualIndex);
|
235
|
-
}
|
236
|
-
}}
|
237
|
-
>
|
238
|
-
${renderRow(item, actualIndex)}
|
239
|
-
</div>
|
240
|
-
`;
|
241
|
-
});
|
242
|
-
}, [data, start, end, renderRow]);
|
243
|
-
|
244
|
-
const style_inner = {
|
245
|
-
position: "relative",
|
246
|
-
overflow: scrollRef?.current ? "visible" : "hidden",
|
247
|
-
width: "100%",
|
248
|
-
minHeight: "100%",
|
249
|
-
};
|
250
|
-
|
251
|
-
const style_content = {
|
252
|
-
position: "absolute",
|
253
|
-
top: 0,
|
254
|
-
left: 0,
|
255
|
-
height: "100%",
|
256
|
-
width: "100%",
|
257
|
-
overflow: "visible",
|
258
|
-
};
|
259
|
-
|
260
|
-
const top = rowPositions.get(start) || 0;
|
261
|
-
|
262
|
-
// Only attach onscroll to baseRef if no scrollRef is provided
|
263
|
-
const scrollProps = scrollRef ? {} : { onscroll: handleScroll };
|
264
|
-
|
265
|
-
return html`
|
266
|
-
<div ref=${baseRef} ...${props} ...${scrollProps}>
|
267
|
-
<div
|
268
|
-
style=${{ ...style_inner, height: `${listMetrics.totalHeight}px` }}
|
269
|
-
>
|
270
|
-
<div
|
271
|
-
style=${{ ...style_content, top: `${top}px` }}
|
272
|
-
ref=${containerRef}
|
273
|
-
>
|
274
|
-
${renderedRows}
|
275
|
-
</div>
|
276
|
-
</div>
|
277
|
-
</div>
|
278
|
-
`;
|
279
|
-
},
|
280
|
-
);
|