|
| 1 | +# Copyright 2025 The Chromium Authors. All rights reserved. |
| 2 | +# Use of this source code is governed by a BSD-style license that can be |
| 3 | +# found in the LICENSE file. |
| 4 | + |
| 5 | +import("../../../scripts/build/ninja/devtools_entrypoint.gni") |
| 6 | +import("../../../scripts/build/ninja/devtools_module.gni") |
| 7 | +import("../../../scripts/build/ninja/generate_css.gni") |
| 8 | +import("../../../scripts/build/typescript/typescript.gni") |
| 9 | +import("../visibility.gni") |
| 10 | + |
| 11 | +generate_css("css_files") { |
| 12 | + sources = [ |
| 13 | + "ui/chatView.css", |
| 14 | + ] |
| 15 | +} |
| 16 | + |
| 17 | +devtools_module("ai_chat") { |
| 18 | + sources = [ |
| 19 | + "ui/AIChatPanel.ts", |
| 20 | + "ui/ChatView.ts", |
| 21 | + "ai_chat_impl.ts", |
| 22 | + "core/Graph.ts", |
| 23 | + "core/State.ts", |
| 24 | + "core/Types.ts", |
| 25 | + "core/AgentService.ts", |
| 26 | + "core/GraphConfigs.ts", |
| 27 | + "core/OpenAIClient.ts", |
| 28 | + "core/ConfigurableGraph.ts", |
| 29 | + "core/BaseOrchestratorAgent.ts", |
| 30 | + "core/PageInfoManager.ts", |
| 31 | + "core/AgentNodes.ts", |
| 32 | + "core/ChatOpenAI.ts", |
| 33 | + "core/GraphHelpers.ts", |
| 34 | + "core/StateGraph.ts", |
| 35 | + "tools/Tools.ts", |
| 36 | + "tools/CritiqueTool.ts", |
| 37 | + "tools/FetcherTool.ts", |
| 38 | + "tools/FinalizeWithCritiqueTool.ts", |
| 39 | + "tools/VisitHistoryManager.ts", |
| 40 | + "tools/HTMLToMarkdownTool.ts", |
| 41 | + "tools/SchemaBasedExtractorTool.ts", |
| 42 | + "tools/CombinedExtractionTool.ts", |
| 43 | + "tools/FullPageAccessibilityTreeToMarkdownTool.ts", |
| 44 | + "agent_framework/ConfigurableAgentTool.ts", |
| 45 | + "agent_framework/AgentRunner.ts", |
| 46 | + "agent_framework/implementation/ConfiguredAgents.ts", |
| 47 | + "common/utils.ts", |
| 48 | + "common/log.ts", |
| 49 | + "common/context.ts", |
| 50 | + "common/page.ts", |
| 51 | + ] |
| 52 | + |
| 53 | + deps = [ |
| 54 | + ":css_files", |
| 55 | + "../../core/common:bundle", |
| 56 | + "../../core/i18n:bundle", |
| 57 | + "../../core/sdk:bundle", |
| 58 | + "../../generated:protocol", |
| 59 | + "../../models/logs:bundle", |
| 60 | + "../../ui/components/helpers:bundle", |
| 61 | + "../../ui/components/markdown_view:bundle", |
| 62 | + "../../ui/components/text_editor:bundle", |
| 63 | + "../../ui/legacy:bundle", |
| 64 | + "../../ui/lit:bundle", |
| 65 | + "../../ui/visual_logging:bundle", |
| 66 | + ] |
| 67 | +} |
| 68 | + |
| 69 | +# List of source files also used to determine JS outputs for metadata |
| 70 | +_ai_chat_sources = [ |
| 71 | + "ui/AIChatPanel.ts", |
| 72 | + "ui/ChatView.ts", |
| 73 | + "ai_chat_impl.ts", |
| 74 | + "core/Graph.ts", |
| 75 | + "core/State.ts", |
| 76 | + "core/Types.ts", |
| 77 | + "core/AgentService.ts", |
| 78 | + "core/GraphConfigs.ts", |
| 79 | + "core/OpenAIClient.ts", |
| 80 | + "core/ConfigurableGraph.ts", |
| 81 | + "core/BaseOrchestratorAgent.ts", |
| 82 | + "core/PageInfoManager.ts", |
| 83 | + "core/AgentNodes.ts", |
| 84 | + "core/ChatOpenAI.ts", |
| 85 | + "core/GraphHelpers.ts", |
| 86 | + "core/StateGraph.ts", |
| 87 | + "tools/Tools.ts", |
| 88 | + "tools/CritiqueTool.ts", |
| 89 | + "tools/FetcherTool.ts", |
| 90 | + "tools/FinalizeWithCritiqueTool.ts", |
| 91 | + "tools/VisitHistoryManager.ts", |
| 92 | + "tools/HTMLToMarkdownTool.ts", |
| 93 | + "tools/SchemaBasedExtractorTool.ts", |
| 94 | + "tools/CombinedExtractionTool.ts", |
| 95 | + "tools/FullPageAccessibilityTreeToMarkdownTool.ts", |
| 96 | + "agent_framework/ConfigurableAgentTool.ts", |
| 97 | + "agent_framework/AgentRunner.ts", |
| 98 | + "agent_framework/implementation/ConfiguredAgents.ts", |
| 99 | + "common/utils.ts", |
| 100 | + "common/log.ts", |
| 101 | + "common/context.ts", |
| 102 | + "common/page.ts", |
| 103 | +] |
| 104 | + |
| 105 | +# Construct the expected JS output paths for the metadata |
| 106 | +_ai_chat_js_outputs_for_metadata = [] |
| 107 | +_ai_chat_module_target_gen_dir = get_label_info(":ai_chat", "target_gen_dir") |
| 108 | + |
| 109 | +foreach(src, _ai_chat_sources) { |
| 110 | + _extension = get_path_info(src, "extension") |
| 111 | + _relative_file_name = rebase_path(src, ".") |
| 112 | + _fileName = get_path_info(_relative_file_name, "dir") + "/" + |
| 113 | + get_path_info(_relative_file_name, "name") |
| 114 | + |
| 115 | + # Only consider .ts files that aren't definition files (.d.ts) and .js files |
| 116 | + if ((_extension == "ts" && |
| 117 | + get_path_info(get_path_info(src, "name"), "extension") != "d") || |
| 118 | + _extension == "js") { |
| 119 | + _ai_chat_js_outputs_for_metadata += |
| 120 | + [ "$_ai_chat_module_target_gen_dir/${_fileName}.js" ] |
| 121 | + } |
| 122 | +} |
| 123 | + |
| 124 | +# This target generates the metadata needed for the release GRD check |
| 125 | +generated_file("ai_chat_release_js_metadata") { |
| 126 | + outputs = [ "$target_gen_dir/ai_chat_release_js_metadata-tsconfig.json" ] |
| 127 | + contents = "{\"files\":[],\"compilerOptions\":{\"composite\":true}}" |
| 128 | + |
| 129 | + # Make sure the actual JS files are built first |
| 130 | + deps = [ ":ai_chat" ] |
| 131 | + |
| 132 | + metadata = { |
| 133 | + # These paths should match the format ts_library would produce in debug |
| 134 | + grd_files = _ai_chat_js_outputs_for_metadata |
| 135 | + } |
| 136 | +} |
| 137 | + |
| 138 | +# Metadata target for the CSS file, needed for release GRD check |
| 139 | +_css_module_target_gen_dir = get_label_info(":css_files", "target_gen_dir") |
| 140 | +_css_outputs_for_metadata = [ |
| 141 | + "$_css_module_target_gen_dir/ui/chatView.css.js", |
| 142 | +] |
| 143 | + |
| 144 | +generated_file("ai_chat_release_css_metadata") { |
| 145 | + outputs = [ "$target_gen_dir/ai_chat_release_css_metadata-tsconfig.json" ] |
| 146 | + contents = "{\"files\":[],\"compilerOptions\":{\"composite\":true}}" |
| 147 | + |
| 148 | + # Make sure the actual CSS file is built first |
| 149 | + deps = [ ":css_files" ] |
| 150 | + |
| 151 | + metadata = { |
| 152 | + grd_files = _css_outputs_for_metadata |
| 153 | + } |
| 154 | +} |
| 155 | + |
| 156 | +devtools_entrypoint("bundle") { |
| 157 | + entrypoint = "ai_chat.ts" |
| 158 | + |
| 159 | + deps = [ |
| 160 | + ":ai_chat", |
| 161 | + ":css_files", |
| 162 | + ":ai_chat_release_js_metadata", # Add dependency on the metadata target |
| 163 | + ":ai_chat_release_css_metadata", # Add dependency on the CSS metadata target |
| 164 | + ] |
| 165 | + |
| 166 | + visibility = [ |
| 167 | + ":*", |
| 168 | + "../../entrypoints/*", |
| 169 | + ] |
| 170 | + |
| 171 | + visibility += devtools_panels_visibility |
| 172 | +} |
| 173 | + |
| 174 | +devtools_entrypoint("meta") { |
| 175 | + entrypoint = "ai_chat-meta.ts" |
| 176 | + |
| 177 | + deps = [ ":bundle" ] |
| 178 | + |
| 179 | + visibility = [ "../../entrypoints/*" ] |
| 180 | +} |
0 commit comments