@capagents/forgeqe 2.9.2 → 2.9.4

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.
Files changed (117) hide show
  1. package/HOW_TO_USE.md +72 -11
  2. package/README.md +1 -1
  3. package/dist/docs-site/docs/architecture/index.html +6 -0
  4. package/dist/docs-site/docs/index.html +59 -2
  5. package/dist/docs-site/docs/search.js +1 -1
  6. package/dist/docs-site/docs/web-app/index.html +12 -1
  7. package/dist/forgeqe.js +1752 -1681
  8. package/dist/web/assets/Agent-djRg2i0o.js +7 -0
  9. package/dist/web/assets/ApiTests-Becz5PP-.js +10 -0
  10. package/dist/web/assets/Browse-_TcGuZ8l.js +2 -0
  11. package/dist/web/assets/Chat-VERzcB2r.js +3 -0
  12. package/dist/web/assets/CommandPalette-5QEcqEYi.js +1 -0
  13. package/dist/web/assets/{Compare-CGcGp9qD.js → Compare-Dl4z18KO.js} +1 -1
  14. package/dist/web/assets/Cost-B_i8IzAR.js +1 -0
  15. package/dist/web/assets/Data-DKSQEWFO.js +6 -0
  16. package/dist/web/assets/Desktop-DkNohPJ7.js +1 -0
  17. package/dist/web/assets/DesktopReview-BUgkvk9D.js +1 -0
  18. package/dist/web/assets/Evidence-Bmr0i0nA.js +1 -0
  19. package/dist/web/assets/{Explore-2M7wI0Sf.js → Explore-oz_P_CL1.js} +2 -2
  20. package/dist/web/assets/{Features-DmQ5JiMI.js → Features-CxcjdJkb.js} +1 -1
  21. package/dist/web/assets/{Flags-Bg-l5HxL.js → Flags-DF0H61Vl.js} +2 -2
  22. package/dist/web/assets/{Flaky-DJlkxmHT.js → Flaky-DkjqrHrF.js} +1 -1
  23. package/dist/web/assets/{ForceGraph-B5i3Ewd5.js → ForceGraph-i1zlas5l.js} +1 -1
  24. package/dist/web/assets/Impact-DiTAOm8k.js +3 -0
  25. package/dist/web/assets/Jobs-DR_mV4Mu.js +5 -0
  26. package/dist/web/assets/KindPage-CLRfAada.js +6 -0
  27. package/dist/web/assets/Migration-DQgCEr0G.js +2 -0
  28. package/dist/web/assets/{Product-BHqJVCMn.js → Product-165KSr60.js} +3 -3
  29. package/dist/web/assets/{Production-GL8lbwxD.js → Production-DoF4CcF-.js} +1 -1
  30. package/dist/web/assets/{Quality-jI3YgvqZ.js → Quality-CEVce0Rs.js} +1 -1
  31. package/dist/web/assets/{Readiness-B3OZ51FG.js → Readiness-DcnpsaAD.js} +1 -1
  32. package/dist/web/assets/Record-B7hLtTK5.js +2 -0
  33. package/dist/web/assets/Regression-BMftRz5h.js +5 -0
  34. package/dist/web/assets/{Reports-BAat71wo.js → Reports-sL20ZyMf.js} +2 -2
  35. package/dist/web/assets/{Response-DjqmewrL.js → Response-C2roHnWk.js} +2 -2
  36. package/dist/web/assets/{RunDiff-BbBom2fJ.js → RunDiff-C0AZaAAA.js} +1 -1
  37. package/dist/web/assets/{Runs-CIQWWRl3.js → Runs-CIgHrNZ7.js} +2 -2
  38. package/dist/web/assets/Steps-GPPeoUP-.js +2 -0
  39. package/dist/web/assets/{TestCases-8BBW6RSi.js → TestCases-xpJiurmK.js} +1 -1
  40. package/dist/web/assets/TestData-D07oKCRW.js +2 -0
  41. package/dist/web/assets/TestDebt-BaXdxqnZ.js +1 -0
  42. package/dist/web/assets/Tosca-BfIh2vCw.js +3 -0
  43. package/dist/web/assets/{WhatsNew-CBS7kmGu.js → WhatsNew-rQKGxI3X.js} +1 -1
  44. package/dist/web/assets/{dataParts-B3Fz4S59.js → dataParts-D9LZxYD6.js} +3 -3
  45. package/dist/web/assets/{families-BiqSaqoO.js → families-DlfXDoO8.js} +1 -1
  46. package/dist/web/assets/filters-NVjc0d8i.js +1 -0
  47. package/dist/web/assets/{fold-b2g0_ndv.js → fold-D1JElpyx.js} +1 -1
  48. package/dist/web/assets/frame-CgFXIaLn.js +4 -0
  49. package/dist/web/assets/index-BoLw7yMm.js +73 -0
  50. package/dist/web/assets/index-RzPHjTCW.css +2 -0
  51. package/dist/web/assets/{logos-DSveGjIW.js → logos-BGd4nsug.js} +1 -1
  52. package/dist/web/assets/{palette-CF8GLAVN.js → palette-BWPcuOsU.js} +1 -1
  53. package/dist/web/assets/{parts-D7OvxdrL.js → parts-W2J4TR3o.js} +1 -1
  54. package/dist/web/assets/{productParts-BDM3LIjp.js → productParts-_8gKGn4o.js} +1 -1
  55. package/dist/web/assets/{qualityParts-DP09bVel.js → qualityParts-9olnn4fj.js} +1 -1
  56. package/dist/web/assets/recordTest-etYNiLQy.js +1 -0
  57. package/dist/web/assets/{rows-B0vZ5x5N.js → rows-BWeaaykT.js} +1 -1
  58. package/dist/web/assets/{segmented-BfWimTC0.js → segmented-B7n6eLrO.js} +1 -1
  59. package/dist/web/assets/{thread-DASfqw-f.js → thread-B8W__QtF.js} +1 -1
  60. package/dist/web/assets/{usePageChat-BLEUldCJ.js → usePageChat-DvfE62rZ.js} +1 -1
  61. package/dist/web/index.html +4 -4
  62. package/docs/ARCHITECTURE.md +5 -0
  63. package/docs/WEB_APP.md +17 -1
  64. package/docs/user-guide.html +59 -2
  65. package/forgeqe.example.yaml +3 -1
  66. package/package.json +1 -1
  67. package/prompts/README.md +1 -0
  68. package/prompts/brain.md +9 -0
  69. package/prompts/business-persona.md +62 -0
  70. package/py/forgeqe_desktop/agentdesktop_driver.py +69 -0
  71. package/py/forgeqe_desktop/boxes.py +32 -0
  72. package/py/forgeqe_desktop/handhooks.py +55 -5
  73. package/py/forgeqe_desktop/pywinauto_driver.py +25 -0
  74. package/py/forgeqe_desktop/service.py +85 -3
  75. package/py/forgeqe_engine/brand.py +3 -0
  76. package/py/forgeqe_engine/browser.py +46 -6
  77. package/py/forgeqe_engine/cli.py +10 -1
  78. package/py/forgeqe_engine/recordsession.py +92 -2
  79. package/py/forgeqe_engine/video.py +423 -0
  80. package/py/forgeqe_mobile/hyperexecute.py +1 -1
  81. package/py/forgeqe_mobile/maestro.py +1 -1
  82. package/py/forgeqe_tosca/vendored.py +3 -2
  83. package/skills/bdd-gherkin/SKILL.md +141 -0
  84. package/skills/bdd-gherkin/references/cucumber-js.md +52 -0
  85. package/skills/bdd-gherkin/references/cucumber-jvm.md +54 -0
  86. package/skills/bdd-gherkin/references/python-bdd.md +50 -0
  87. package/skills/bdd-gherkin/references/reqnroll-specflow.md +83 -0
  88. package/skills/bdd-gherkin/references/review-checklist.md +37 -0
  89. package/skills/bdd-scenario-design/SKILL.md +50 -0
  90. package/skills/dynamics-365/SKILL.md +30 -15
  91. package/skills/dynamics-365-automation/SKILL.md +72 -0
  92. package/skills/dynamics-365-automation/references/elements.md +187 -0
  93. package/skills/dynamics-365-automation/references/recipes.md +97 -0
  94. package/dist/web/assets/Agent-BFwkMMHm.js +0 -4
  95. package/dist/web/assets/ApiTests-Bgt4R_yB.js +0 -10
  96. package/dist/web/assets/Browse-B3YI1MeV.js +0 -2
  97. package/dist/web/assets/Chat-K3kp-ji2.js +0 -3
  98. package/dist/web/assets/CommandPalette-nmLCmEsp.js +0 -1
  99. package/dist/web/assets/Cost-BvCShgln.js +0 -1
  100. package/dist/web/assets/Data-3EEe7vIz.js +0 -6
  101. package/dist/web/assets/Desktop-Drj-7jBV.js +0 -1
  102. package/dist/web/assets/Evidence-D1HiXQK6.js +0 -1
  103. package/dist/web/assets/Impact-huKs-mOc.js +0 -3
  104. package/dist/web/assets/Jobs-BwK79TQ8.js +0 -5
  105. package/dist/web/assets/KindPage-C0MoC9da.js +0 -6
  106. package/dist/web/assets/Migration-CTVyQeqW.js +0 -2
  107. package/dist/web/assets/Record-Yw-SGwQ9.js +0 -2
  108. package/dist/web/assets/Regression-v2dpbgs4.js +0 -5
  109. package/dist/web/assets/Steps-DfNHCe8N.js +0 -2
  110. package/dist/web/assets/TestData-BFkACDve.js +0 -2
  111. package/dist/web/assets/TestDebt-CUcklHEN.js +0 -1
  112. package/dist/web/assets/Tosca-DTWwUJBW.js +0 -3
  113. package/dist/web/assets/desktopAppPath-CMac6aJ0.js +0 -1
  114. package/dist/web/assets/filters-B4VDnWbr.js +0 -1
  115. package/dist/web/assets/frame-D-hqu7Oi.js +0 -4
  116. package/dist/web/assets/index-CtX74khE.js +0 -45
  117. package/dist/web/assets/index-DUf5ddb0.css +0 -2
@@ -0,0 +1,187 @@
1
+ # Dynamics 365 Unified Interface: element catalogue
2
+
3
+ Names and locators of D365 model-driven app controls. Taken from Microsoft's EasyRepro
4
+ (`Microsoft.Dynamics365.UIAutomation.Api.UCI/DTO/AppElementReference.cs`, MIT licence, Copyright (c) Microsoft
5
+ Corporation), with CSS equivalents. The "EasyRepro key" column is the key in `AppElements.Xpath`, for repositories
6
+ that use EasyRepro.
7
+
8
+ Placeholders: `<field>` the field's logical name (`parentcustomerid`), `<table>` the table's logical name
9
+ (`account`), `<subgrid>` the subgrid's control name on the form (`Contacts`), `<n>` a 0-based row index,
10
+ `<text>` visible text. `*=` means "contains". These attributes are D365's own and can change between releases:
11
+ check one on the live page before relying on it.
12
+
13
+ ## Application and navigation
14
+ | D365 name | EasyRepro key | Locator |
15
+ |---|---|---|
16
+ | App shell (app is loaded) | App_Shell | `#ApplicationShell` |
17
+ | App switcher (app name, top left) | Nav_UCIAppMenuButton | `a[data-id="appBreadCrumb"]` |
18
+ | App tile on the app landing page | Nav_UCIAppTile | `div[data-type="app-title"][title="<app name>"]` |
19
+ | Site map launcher (≡) | Nav_SiteMapLauncherButton | `button[data-lp-id="sitemap-launcher"]` |
20
+ | Site map entry (a table) | Nav_SitemapMenuItems | `li[data-id*="sitemap-entity"]` (e.g. `li[data-id="sitemap-entity-account"]` when present) |
21
+ | Pinned site map entry | Nav_PinnedSitemapEntity | `li[data-id*="sitemap-entity-Pinned"][role="treeitem"]` |
22
+ | Area switcher (bottom of site map) | Nav_SitemapSwitcherButton | `button[data-id*="sitemap-areaSwitcher-expand-btn"]` |
23
+ | Area switcher flyout | Nav_SitemapSwitcherFlyout | `div[data-lp-id*="sitemap-area-switcher-flyout"]` |
24
+ | Quick Create (+, "New") | Nav_QuickCreateButton | `button[data-id*="quickCreateLauncher"]` |
25
+ | Quick Create menu list / items | Nav_QuickCreateMenuList / Items | `ul[id*="MenuSectionItemsquickCreate"]` / `button[role="menuitem"]` |
26
+ | Global search box (Dataverse search) | Search_Text | `input[aria-label="Search box"]` |
27
+ | Global search launcher (older UI) | Nav_SearchButton | `#searchLauncher > button` |
28
+ | Top-bar launcher (settings, help…) / Guided help | Nav_SettingsLauncherBar / Nav_GuidedHelp | `button[data-id="<name>Launcher"]` / `#helpLauncher > button` |
29
+ | Account manager (avatar) / Sign out | Nav_AccountManagerButton / …SignOutButton | `#mectrl_main_trigger` / `#mectrl_body_signOut` |
30
+
31
+ ## Grids and views (list pages)
32
+ | D365 name | EasyRepro key | Locator |
33
+ |---|---|---|
34
+ | Grid (Power Apps grid control) | Grid_Control | `div[data-lp-id*="MscrmControls.Grid.PCFGridControl"]` |
35
+ | Grid body | Grid_Container | `div[data-id="data-set-body-container"]` |
36
+ | Quick Find ("Search this view") | Grid_QuickFind | `input[id*="quickFind_text"]` |
37
+ | View selector (view name ⌄) | Grid_ViewSelector | `button[id*="ViewSelector"]` |
38
+ | View list | Grid_ViewContainer / …MenuItem | `div[aria-label*="Views"]`, items `li.ms-ContextualMenu-item` |
39
+ | Rows | Grid_Rows | `div[data-id="entity_control-powerapps_onegrid_control_container"] .ag-center-cols-container div[role="row"]` |
40
+ | Row by index | Grid_Row | `.ag-center-cols-container div[row-index="<n>"]` |
41
+ | Cells | Grid_Cells | `div[role="gridcell"]` |
42
+ | Column header (sort, filter) | Grid_SortColumn | XPath `//div[@role='columnheader']//label[@title='<column>']` |
43
+ | Row checkbox / Select All | Grid_RowsContainerCheckbox / Grid_SelectAll | `div[role="checkbox"]` / `button[title*="Select All"]` |
44
+ | Paging | Grid_FirstPage / NextPage / PreviousPage | `button[data-id*="loadFirstPage"]`, `button[data-id*="moveToNextPage"]`, `button[data-id*="moveToPreviousPage"]` |
45
+ | Show chart / chart selector | Grid_ShowChart / Grid_ChartSelector | `button[aria-label*="Show Chart"]` / `span[id*="ChartSelector"]` |
46
+ | Jump bar (A–Z) / All | Grid_JumpBar / Grid_FilterByAll | `#JumpBarItemsList` / `#All_link` |
47
+ | List command bar | Cmd_ContainerGrid | `ul[data-lp-id*="commandbar-HomePageGrid"]` |
48
+
49
+ ## Forms
50
+ | D365 name | EasyRepro key | Locator |
51
+ |---|---|---|
52
+ | Form root | Entity_FormContainer | `[data-id="editFormRoot"]` |
53
+ | Record title (header) | Entity_HeaderTitle | `[data-id="header_title"]` |
54
+ | Header / header flyout / its ⌄ button | Entity_Header / _Flyout / _FlyoutButton | `div[data-id*="form-header"]` / `div[data-id="headerFieldsFlyout"]` / `button[id*="headerFieldsExpandButton"]` |
55
+ | Form selector (form name ⌄) | Entity_FormSelector | `[data-id="form-selector"]` |
56
+ | Tab list / a tab | Entity_TabList / Entity_Tab | `ul[id*="tablist"]` / `li[title="<tab>"]` (or `getByRole('tab', { name })`) |
57
+ | More tabs | Entity_MoreTabs | `div[data-id="more_button"]` |
58
+ | Field container | Entity_TextFieldContainer | `[data-id*="<field>-FieldSectionItemContainer"]` |
59
+ | Field label | Entity_TextFieldLabel | `label[id*="<field>-field-label"]` |
60
+ | Text / number / currency input | Entity_TextFieldValue | `input[data-id*="<field>.fieldControl"]` |
61
+ | Header field (text / lookup / choice / date) | Entity_Header_* | `div[data-id="header_<field>.fieldControl-text-box-container"]`, `div[data-id="header_<field>.fieldControl-Lookup_<field>"]`, `div[data-id="header_<field>"]`, `div[data-id="header_<field>-FieldSectionItemContainer"]` |
62
+ | Read-only / required marker | Field_ReadOnly / Field_RequiredIcon | `[aria-readonly]` / `div[data-id*="required-icon"]` inside the container |
63
+ | Record set navigator (prev/next record) | Entity_RecordSetNavigator | `button[data-lp-id*="recordset-navigator"]`, list `ul[data-id*="recordSetNavList"]` |
64
+
65
+ ## Lookup fields
66
+ | D365 name | EasyRepro key | Locator |
67
+ |---|---|---|
68
+ | Lookup control | Entity_TextFieldLookupFieldContainer | `div[data-id="<field>.fieldControl-Lookup_<field>"]` |
69
+ | Lookup search (magnifier) button | Entity_TextFieldLookupSearchButton | `button[data-id*="<field>.fieldControl-LookupResultsDropdown_<field>_search"]` |
70
+ | Results flyout | Entity_LookupResultsDropdown | `[data-id*="<field>.fieldControl-LookupResultsDropdown_<field>_tab"]` |
71
+ | Result item (a record) | Lookup_ResultRows | `li[data-id*="LookupResultsDropdown"][data-id*="resultsContainer"]` |
72
+ | "No records found" | Entity_LookupFieldNoRecordsText | `[data-id="<field>.fieldControl-LookupResultsDropdown_<field>_No_Records_Text"]` |
73
+ | Selected value (a link) | Entity_LookupFieldExistingValue | `[data-id*="<field>.fieldControl-LookupResultsDropdown_<field>_selected_tag"][role="link"]` |
74
+ | Clear selected value (X) | Entity_LookupFieldDeleteExistingValue | `[data-id*="<field>.fieldControl-LookupResultsDropdown_<field>_selected_tag_delete"]` |
75
+ | Related table filter in the flyout | Lookup_RelatedEntityLabel | `li[aria-label*="<table display name>"][data-id*="LookupResultsDropdown"]` |
76
+ | "+ New" in the flyout | Lookup_NewButton | `button[data-id*="addNewBtnContainer"][data-id*="LookupResultsDropdown"]` |
77
+ | "Advanced lookup" | Lookup_AdvancedLookupButton | XPath `//button[.//label[text()='Advanced lookup']]` |
78
+ | Advanced lookup dialog | AdvancedLookup_Container | `div[data-lp-id*="MscrmControls.FieldControls.AdvancedLookupControl"]` |
79
+ | Advanced lookup search / results / Done | AdvancedLookup_SearchInput / _ResultRows / _DoneButton | `input[type="text"][placeholder="Search"]` / `div[ref="eLeftContainer"] div[role="row"]` / `getByRole('button', { name: 'Done' })` |
80
+
81
+ ## Choices, Yes/No, dates, multi-select
82
+ | D365 name | EasyRepro key | Locator |
83
+ |---|---|---|
84
+ | Choice (option set) | Entity_OptionSetFieldContainer | `div[data-id="<field>.fieldControl-option-set-container"]` (a select or a combo box inside) |
85
+ | Status reason combo box | Entity_OptionsetStatusCombo | `div[data-id*="<field>.fieldControl-pickliststatus-comboBox"]`, list `ul[id*="<field>.fieldControl-pickliststatus-comboBox_list"]` |
86
+ | Yes/No as radio pair | Entity_BooleanFieldRadioContainer | `div[data-id*="<field>.fieldControl-checkbox-container"][role="radiogroup"]` |
87
+ | Yes/No as checkbox | Entity_BooleanFieldCheckbox | `input[data-id*="<field>.fieldControl-checkbox-toggle"]` |
88
+ | Yes/No as list | Entity_BooleanFieldList | `select[data-id*="<field>.fieldControl-checkbox-select"]` |
89
+ | Yes/No as toggle | Entity_BooleanFieldToggle | `div[data-id*="<field>.fieldControl-toggle-container"]` |
90
+ | Date input | Entity_FieldControlDateTimeInputUCI | `input[data-id*="<field>.fieldControl-date-time-input"]` |
91
+ | Time input | Entity_FieldControlDateTimeTimeInputUCI | `div[data-id*="<field>.fieldControl._timecontrol-datetime-container"] input` |
92
+ | Choices (multi-select) container | MultiSelect_DivContainer | `div[data-id*="<field>-FieldSectionItemContainer"]` |
93
+ | Multi-select search / caret / option | MultiSelect_InputSearch / _FlyoutCaret / _FlyoutOption | `input.msos-input` / `button.msos-caret-button` / XPath `//li[label[@title='<option>'] and contains(@class,'msos-option')]` |
94
+ | Multi-select chosen item / remove | MultiSelect_SelectedRecord_Label / _DeleteButton | `span.msos-selected-display-item-text` / `button[data-id*="delete"]` |
95
+
96
+ ## Command bar
97
+ | D365 name | EasyRepro key | Locator |
98
+ |---|---|---|
99
+ | Form command bar | Cmd_Container | `ul[data-lp-id*="commandbar-Form"]` |
100
+ | A command | Cmd_Button | `getByRole('menuitem' or 'button', { name: '<text>' })` inside the bar; EasyRepro: `//*[contains(text(),'<text>')]` |
101
+ | Save | Entity_Save | XPath `//button[@role='menuitem' and .//*[text()='Save']]` (or the bar's `aria-label="Save (CTRL+S)"`) |
102
+ | More commands (⋯) / its flyout | Cmd_MoreCommandsMenu | the bar's `button[data-id*="OverflowButton"]`, flyout `#__flyoutRootNode` |
103
+ | Assign / Delete / Mark as Won / Lost | Entity_Assign / _Delete / _CloseOpportunityWin / _Loss | `button[data-id*="Assign"]`, `button[data-id*="Delete"]`, `button[data-id*="MarkAsWon"]`, `button[data-id*="MarkAsLost"]` |
104
+ | Process / Switch Process | Entity_Process / Entity_SwitchProcess | `button[data-id*="MBPF.ConvertTo"]` / `button[data-id*="SwitchProcess"]` |
105
+
106
+ ## Subgrids and related grids
107
+ | D365 name | EasyRepro key | Locator |
108
+ |---|---|---|
109
+ | Subgrid contents | Entity_SubGridContents | `#dataSetRoot_<subgrid>` |
110
+ | Subgrid rows | Entity_SubGrid_Row | `div[data-id="<subgrid>-pcf_grid_control_container"] div[data-id="grid-container"] div[data-list-index="<n>"]` |
111
+ | Subgrid search | Entity_SubGridSearchBox | `div[data-id*="data-set-quickFind-container"]` |
112
+ | Subgrid command bar | Entity_SubGridCommandBar | `ul[data-id*="CommandBar"]` inside the subgrid; `ul[data-lp-id*="commandbar-SubGridStandard:<subgrid>"]` |
113
+ | Subgrid "+ New <table>" | Entity_SubGridAddButton | `button[data-id*="<table>.AddNewStandard"]` inside that command bar |
114
+ | Subgrid overflow (⋯) | Entity_SubGridCommandOverflowButton | `button[data-id*="OverflowButton"]` inside the subgrid |
115
+ | Subgrid view picker | Entity_SubGridViewPickerButton | `span[id*="ViewSelector"][id*="button"]` |
116
+ | Editable grid rows / cells | Entity_EditableSubGridListCellRows / …Cells | `div.wj-row[role="row"]` / `div[role="gridcell"]` |
117
+ | Related tab's grid command bar | Related_CommandBarButtonList | `ul[data-lp-id*="commandbar-SubGridAssociated"]` |
118
+
119
+ ## Business process flow
120
+ | D365 name | EasyRepro key | Locator |
121
+ |---|---|---|
122
+ | Stage (in the stage bar) | BPF_NextStage_UCI | `li[id*="processHeaderStage"]` (by its text) |
123
+ | Stage flyout | BPF_Flyout_UCI / BPF_FormContext | `div[id*="businessProcessFlowFlyoutHeaderContainer"]` / `div[id*="ProcessStageControl-processHeaderStageFlyoutInnerContainer"]` |
124
+ | Next Stage / Set Active | BPF_NextStageButton_UCI / BPF_SetActiveButton | `button[data-id*="nextButtonContainer"]` / `button[data-id*="setActiveButton"]` |
125
+ | Pin (dock) / close the flyout | BPF_PinStageButton / BPF_CloseStageButton | `button[id*="stageDockModeButton"]` / `button[id*="stageContentClose"]` |
126
+ | A field in a stage | BPF_TextFieldContainer | `div[data-lp-id*="header_process_<field>"]`, container `div[id*="header_process_<field>-FieldSectionItemContainer"]` |
127
+
128
+ ## Quick Create
129
+ | D365 name | EasyRepro key | Locator |
130
+ |---|---|---|
131
+ | Quick Create form | QuickCreate_FormContext | `section[data-id*="quickCreateRoot"]` (fields inside use the form patterns) |
132
+ | Save / Save and Close / Cancel | QuickCreate_SaveButton / _SaveAndCloseButton / _CancelButton | `button[id*="quickCreateSaveBtn"]` / `button[id*="quickCreateSaveAndCloseBtn"]` / `button[id*="quickCreateCancelBtn"]` |
133
+
134
+ ## Dialogs and notifications
135
+ | D365 name | EasyRepro key | Locator |
136
+ |---|---|---|
137
+ | Any dialog | Dialog_DialogContext | `div[role="dialog"]` |
138
+ | Confirm / Cancel / OK (confirm dialogs) | Dialog_ConfirmButton / _CancelButton / _OkButton | `#confirmButton` / `#cancelButton` / `#okButton` |
139
+ | OK / Cancel (data dialogs: Assign, Close opportunity, Set state) | AssignDialog_OKButton, Dialog_SetStateActionButton… | `button[data-id*="ok_id"]` / `button[data-id*="cancel_id"]` |
140
+ | Set state dialog (Activate/Deactivate) | Dialog_SetStateDialog | `div[data-id="SetStateDialog"]` |
141
+ | Assign: Me / User or team | AssignDialog_ToggleField / _UserTeamLookupResults | `label[data-id*="rdoMe_id.fieldControl-checkbox-inner-first"]` / `ul[data-id*="systemuserview_id.fieldControl-LookupResultsDropdown_systemuserview_id_tab"]` |
142
+ | Duplicate records found | Entity_DuplicateDetectionWindowMarker | `div[data-id*="ManageDuplicates"]`; Ignore and save `button[data-id*="ignore_save"]`; Cancel `button[data-id*="close_dialog"]` |
143
+ | Form notification bar | Entity_FormNotifcationBar | `div[data-id*="notificationWrapper"]`; expand `#notificationExpandIcon`; list `ul[data-id="notificationList"]` |
144
+ | Form message bar (read-only form etc.) | Entity_FormMessageBar | `#notificationMessageAndButtons span` |
145
+ | Shared flyout root (menus, overflow) | Cmd_MoreCommandsMenu | `#__flyoutRootNode` |
146
+
147
+ ## Global search results
148
+ | D365 name | EasyRepro key | Locator |
149
+ |---|---|---|
150
+ | Results / a result row | Search_Container / Search_Records | `#searchResultList` / `li[role="row"]` |
151
+ | Result tabs (by table) | Search_RelevanceSearchResultsTab | `section#searchComponent button[role="tab"][name="<table>"]` |
152
+
153
+ ## Timeline, dashboards, Copilot
154
+ | D365 name | EasyRepro key | Locator |
155
+ |---|---|---|
156
+ | Timeline activity Save and Close | Timeline_SaveAndClose | `button[data-id*="<table>.SaveAndClose"]` |
157
+ | Dashboard selector / item | Dashboard_Selector / Dashboard_Item_UCI | `span[id*="Dashboard_Selector"]` / `li[data-text*="<name>"]` |
158
+ | Copilot side pane button / input | CustomerServiceCopilot_ControlButtonId / _UserInput | `button[id="sidepane-tab-button-AppSidePane_MscrmControls.CSIntelligence.AICopilotControl"]` / `textarea[data-id="webchat-sendbox-input"]` |
159
+ | Canvas app control inside a model-driven page | PowerApp_Control | `div[data-control-name="<control>"]` (inside its iframe) |
160
+
161
+ ## Licence of the source
162
+
163
+ The locators above are taken from EasyRepro (https://github.com/microsoft/EasyRepro):
164
+
165
+ ```
166
+ MIT License
167
+
168
+ Copyright (c) Microsoft Corporation. All rights reserved.
169
+
170
+ Permission is hereby granted, free of charge, to any person obtaining a copy
171
+ of this software and associated documentation files (the "Software"), to deal
172
+ in the Software without restriction, including without limitation the rights
173
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
174
+ copies of the Software, and to permit persons to whom the Software is
175
+ furnished to do so, subject to the following conditions:
176
+
177
+ The above copyright notice and this permission notice shall be included in all
178
+ copies or substantial portions of the Software.
179
+
180
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
181
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
182
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
183
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
184
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
185
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
186
+ SOFTWARE
187
+ ```
@@ -0,0 +1,97 @@
1
+ # Dynamics 365: steps for each control
2
+
3
+ Locators are in `elements.md`. "Wait for idle" means `window.UCWorkBlockTracker?.isAppIdle()` returns true, then
4
+ the next element is visible. Examples are Playwright (TypeScript); do the same with the repository's framework.
5
+
6
+ ```ts
7
+ async waitForIdle() {
8
+ await this.page.waitForFunction(() => (window as any).UCWorkBlockTracker?.isAppIdle?.() ?? true)
9
+ }
10
+ const field = (name: string) => this.page.locator(`[data-id="${name}-FieldSectionItemContainer"]`)
11
+ ```
12
+
13
+ ## Text, number, currency
14
+ 1. Fill `input[data-id*="<field>.fieldControl"]` inside the field's container, then press Tab (D365 commits a value on
15
+ blur; without it Save may not see it).
16
+ 2. Currency and number fields reformat on blur (`1000` becomes `$1,000.00`): assert the formatted text.
17
+
18
+ ## Lookup
19
+ 1. Click the lookup's input inside `div[data-id="<field>.fieldControl-Lookup_<field>"]`, type the search text.
20
+ 2. Wait for the results flyout (`…LookupResultsDropdown_<field>_tab`) and for idle; the first results can be the
21
+ recent items list, before the search ends.
22
+ 3. Click the result item whose primary name matches exactly, never by position; for several tables (Customer: Account or
23
+ Contact) pick the table first with the related table filter.
24
+ 4. Assert the selected tag (`…_selected_tag`, role link) shows the name.
25
+ 5. Not in the first results: open "Advanced lookup", search, pick the row, "Done".
26
+ 6. To clear: hover the selected tag, click its delete (`…_selected_tag_delete`).
27
+ - EasyRepro: `xrmApp.Entity.SetValue(new LookupItem { Name = "<field>", Value = "<name>", Index = 0 })`;
28
+ `ClearValue(new LookupItem { Name = "<field>" })`.
29
+
30
+ ## Choice (option set) and status reason
31
+ 1. Within `div[data-id="<field>.fieldControl-option-set-container"]`: a native `select` → `selectOption({ label })`;
32
+ a combo box (Fluent UI) → click it, then the option by role `option` and its name.
33
+ 2. Status reason uses the `pickliststatus-comboBox`; its list opens under `#__flyoutRootNode` on newer versions.
34
+ - EasyRepro: `SetValue(new OptionSet { Name = "<field>", Value = "<label>" })`.
35
+
36
+ ## Yes/No (two options)
37
+ - The same field can render as radio pair, checkbox, list or toggle, depending on the form: find which control the
38
+ container holds, and set it by its label (Yes/No or the custom labels), not by toggling blindly; assert after.
39
+ - EasyRepro: `SetValue(new BooleanItem { Name = "<field>", Value = true })`.
40
+
41
+ ## Date and time
42
+ 1. Fill the date input with the user's format (the field's placeholder shows it; it follows the user's personal
43
+ settings, so read it, never assume M/d/yyyy), press Tab. Time: the input in `…_timecontrol-datetime-container`.
44
+ 2. Compute dates when the test runs. Date-only fields ignore the time; "user local" fields shift by time zone.
45
+ - EasyRepro: `SetValue("<field>", DateTime.Today.AddDays(3), "M/d/yyyy")` with the user's format.
46
+
47
+ ## Choices (multi-select)
48
+ 1. Click the container, type in `input.msos-input`, tick each option by its title, close the flyout (Escape).
49
+ 2. Assert the chosen items (`span.msos-selected-display-item-text`).
50
+ - EasyRepro: `SetValue(new MultiValueOptionSet { Name = "<field>", Values = new[] { "A", "B" } }, removeExistingValues: true)`.
51
+
52
+ ## Save
53
+ 1. Ctrl+S or the command bar's Save; wait for idle.
54
+ 2. Done when the notification bar has no error and the title has no "- Unsaved"; for a new record, the URL gets
55
+ `&id=<guid>`: read the id from the URL for later steps or cleanup.
56
+ 3. An error banner (required fields, business rule): read its text from the notification list; a "Duplicate records
57
+ found" dialog: the test decides (Ignore and save or Cancel), never by default.
58
+
59
+ ## Grid: find and open a record
60
+ 1. Open the list by URL (`pagetype=entitylist&etn=<table>`), choose the view by the view selector if the test needs one.
61
+ 2. Type in Quick Find (`input[id*="quickFind_text"]`), Enter, wait for idle.
62
+ 3. Open the row whose primary-name cell has the exact text (a link in the cell); never row 0 without a filter.
63
+ - EasyRepro: `xrmApp.Grid.SwitchView("..."); xrmApp.Grid.Search("..."); xrmApp.Grid.OpenRecord(0)` (after a search
64
+ that returns one row).
65
+
66
+ ## Subgrid
67
+ 1. Scope everything to `#dataSetRoot_<subgrid>` or its `pcf_grid_control_container`.
68
+ 2. "+ New <table>" opens Quick Create or a full form depending on the table's settings: wait for which appeared.
69
+ 3. "Add Existing" opens a lookup flyout or dialog for the related table.
70
+
71
+ ## Command bar
72
+ - Find the command by its accessible name or `data-id` inside the right bar (form, list, subgrid). If it is not
73
+ visible, open "More commands" (⋯) and look in `#__flyoutRootNode`. Commands show and hide by form state and security
74
+ role: assert it is there, not that it is not, unless that is the test.
75
+ - EasyRepro: `xrmApp.CommandBar.ClickCommand("Deactivate")`, and `ClickCommand("Flow", "Run Flow")` for a submenu.
76
+
77
+ ## Business process flow
78
+ 1. Click the stage in the stage bar, wait for its flyout; fill its fields (`header_process_<field>`), they save with
79
+ the record.
80
+ 2. "Next Stage" moves on only when the stage's required fields are filled; assert the active stage after.
81
+ - EasyRepro: `xrmApp.BusinessProcessFlow.SelectStage("Qualify"); SetValue(...); NextStage("Qualify")`.
82
+
83
+ ## Quick Create
84
+ 1. Open from the top bar's "+" (Quick Create menu) or a subgrid/lookup "+ New".
85
+ 2. Scope fields to `section[data-id*="quickCreateRoot"]`; "Save and Close" (`quickCreateSaveAndCloseBtn`); wait for
86
+ idle and for the panel to close.
87
+ - EasyRepro: `xrmApp.Navigation.QuickCreate("contact"); xrmApp.QuickCreate.SetValue(...); xrmApp.QuickCreate.Save()`.
88
+
89
+ ## Dialogs
90
+ - Scope to `div[role="dialog"]`. Confirm dialogs use `#confirmButton`/`#cancelButton`; data dialogs (Assign, Close
91
+ opportunity, Set state) use `button[data-id*="ok_id"]`/`cancel_id`.
92
+ - "Unsaved changes" when leaving a dirty form: choose by the test's intent; never leave it open.
93
+
94
+ ## Sign-in
95
+ - Reuse a saved session (Playwright `storageState`, a signed-in browser profile) made once by a setup step; sign in in a
96
+ test only when sign-in is what it checks. Users and passwords come from environment variables or the credential
97
+ store; an MFA secret only as an environment variable for a TOTP code, never in the repository.
@@ -1,4 +0,0 @@
1
- import{$t as e,A as t,An as n,Ar as r,C as i,Cn as a,D as o,Dn as s,Fn as c,Gn as l,I as u,Ir as d,M as f,Mn as p,Nr as m,O as h,On as g,Pn as _,Q as v,Qt as y,T as b,Tn as x,Ut as S,Vn as C,a as w,gr as T,gt as E,ht as D,ir as O,it as ee,j as k,o as A,or as te,pr as ne,qn as re,tt as ie,vr as ae}from"./line-icons-CQ-3V8ax.js";import{$ as oe,B as j,J as se,R as M,V as N,Wt as ce,Z as le,_ as ue,a as P,at as de,c as F,d as fe,f as I,h as L,i as pe,it as R,jt as me,l as z,m as he,o as ge,q as _e,r as ve,s as ye,tt as be,z as B}from"./filters-B4VDnWbr.js";import{$t as xe,At as Se,Bt as Ce,Dt as we,Et as Te,Ft as Ee,G as V,Gt as De,Ht as Oe,Jt as ke,K as H,Mt as Ae,Ot as je,Pt as Me,Qt as Ne,Ut as Pe,Vt as Fe,Wt as Ie,Xt as Le,Yt as U,Zt as Re,_t as ze,at as Be,en as Ve,et as He,gt as Ue,it as We,jt as Ge,kt as Ke,n as qe,nt as Je,qt as Ye,r as Xe,rt as W,t as Ze,tn as Qe,tt as G,zt as $e}from"./frame-D-hqu7Oi.js";import{B as et,C as tt,D as nt,E as rt,F as it,I as at,L as ot,O as st,P as ct,R as lt,S as ut,U as dt,m as ft,r as pt,s as mt}from"./index-CtX74khE.js";import{i as ht}from"./Response-DjqmewrL.js";import{n as gt}from"./segmented-BfWimTC0.js";import{t as _t}from"./Data-3EEe7vIz.js";import{a as vt,c as yt,f as bt}from"./dataParts-B3Fz4S59.js";import{t as xt}from"./TestData-BFkACDve.js";import{StatusIcon as St}from"./Runs-CIQWWRl3.js";var K=d(m(),1),q=ce(),Ct=`forgeqe-agent-favourites`,wt=`forgeqe-agent-favourites`;function Tt(){let e=()=>{try{return Ye(localStorage.getItem(Ct))}catch{return[]}},[t,n]=(0,K.useState)(e);return(0,K.useEffect)(()=>{let t=()=>n(e());return window.addEventListener(wt,t),window.addEventListener(`storage`,t),()=>{window.removeEventListener(wt,t),window.removeEventListener(`storage`,t)}},[]),{favs:t,toggle:e=>{let r=t.includes(e)?t.filter(t=>t!==e):[...t,e];n(r);try{localStorage.setItem(Ct,JSON.stringify(r)),window.dispatchEvent(new Event(wt))}catch{}}}}var Et={attention:{label:`Needs attention`,tone:`fail`},partial:{label:`Partly set up`,tone:`warn`},ready:{label:`Ready`,tone:`pass`},unavailable:{label:`Unavailable`,tone:`neutral`}},Dt={pass:`bg-pass`,warn:`bg-warn`,fail:`bg-fail`,neutral:`bg-line-strong`,running:`bg-accent`},Ot=(e,t)=>{let n=Fe(e),r=t?.[n.agent];return{fav:n.id,href:I(`agents`,n.id),name:Pe(n.agent).name,about:n.about,short:n.short,icon:(0,q.jsx)(Ke,{agent:n.agent,px:24,decorative:!0}),tags:r?.tags??[],...r?{status:r.status}:{},note:r?.note??``}},J={active:{label:`Active`,tone:`pass`},changed:{label:`Change waiting`,tone:`warn`},draft:{label:`Draft`,tone:`neutral`},invalid:{label:`Needs fixing`,tone:`fail`},broken:{label:`Cannot run`,tone:`fail`},disabled:{label:`Disabled`,tone:`neutral`}},kt={active:`ready`,changed:`partial`,draft:`partial`,invalid:`attention`,broken:`attention`,disabled:`unavailable`},At=e=>({fav:Oe(e.id),href:I(`agents`,`custom`,e.id),name:e.name,about:e.description||`No description yet.`,short:e.description||J[e.state].label,icon:(0,q.jsx)(Ke,{agent:e.id,icon:e.icon,px:24,decorative:!0}),status:kt[e.state],note:J[e.state].label,tags:[...e.state===`active`?[]:[J[e.state].label],...e.approvedVersion?[`v${e.approvedVersion}`]:[],...e.problems?[`${e.problems} problem${e.problems===1?``:`s`}`]:[]]});function jt({cards:e}){let t=Object.values(e||{});if(!t.length||t.some(e=>e.status!==`unavailable`))return null;let n=[...new Set(t.map(e=>(e.note||``).replace(/:\s*Set up\.?$/,``).trim()).filter(Boolean))],r=n.length>0&&n.every(e=>/^No model/i.test(e));return(0,q.jsxs)(`div`,{role:`status`,className:`flex w-full flex-wrap items-center gap-x-4 gap-y-3 border-y border-line py-4`,children:[(0,q.jsx)(L,{icon:_,size:20,className:`flex-none text-accent-fg`}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_280px] flex-col gap-0.5`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:`No agent can run yet`}),(0,q.jsx)(`span`,{className:`text-sm text-muted [overflow-wrap:anywhere]`,children:n.length?n.join(` · `):`ForgeQE is not set up on this computer.`})]}),(0,q.jsxs)(`a`,{className:B({variant:`primary`}),href:r?I(`settings`,`models`):I(`settings`,`setup`),"data-tip":r?`Add a model key`:`Install what's missing`,children:[(0,q.jsx)(l,{"aria-hidden":`true`}),`Set up`]})]})}function Mt({item:e,favs:t}){let n=t.favs.includes(e.fav),r=e.status?Et[e.status]:void 0,i=[e.about,r&&`${r.label}${e.note?`: ${e.note}`:``}`,e.tags.length?e.tags.join(`, `):``].filter(Boolean).join(`
2
- `);return(0,q.jsxs)(`li`,{className:`relative`,children:[(0,q.jsxs)(`a`,{href:e.href,"data-tip":i,className:`flex min-h-[68px] items-center gap-2.5 rounded-[12px] py-2 pr-8 pl-1.5 @min-[260px]/col:gap-3 @min-[260px]/col:pl-2 @min-[260px]/col:pr-10 text-ink no-underline hover:bg-surface-strong hover:text-ink`,children:[(0,q.jsx)(`span`,{className:`flex size-10 flex-none items-center justify-center rounded-[10px] @min-[260px]/col:size-11 bg-surface-strong`,children:e.icon}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`line-clamp-2 text-[14px] leading-tight font-semibold @min-[260px]/col:text-[14.5px]`,children:e.name}),r&&(0,q.jsx)(`span`,{className:j(`size-[7px] flex-none rounded-full`,Dt[r.tone]),"aria-hidden":`true`})]}),(0,q.jsx)(`span`,{className:`truncate text-[13px] text-muted`,children:e.short}),(0,q.jsxs)(`span`,{className:`sr-only`,children:[r?`${r.label}${e.note?`: ${e.note}`:``}. `:``,e.about,e.tags.length?` ${e.tags.join(`, `)}.`:``]})]})]}),(0,q.jsx)(M,{variant:`icon`,size:`icon`,"aria-pressed":n,"aria-label":n?`Remove ${U(e.name)} from favourites`:`Add ${U(e.name)} to favourites`,"data-tip":n?`Remove from favourites`:`Add to favourites`,onClick:()=>t.toggle(e.fav),className:j(`absolute top-1/2 right-0 size-8 -translate-y-1/2`,n?`text-ink`:`text-muted`),children:(0,q.jsx)(O,{size:14,strokeWidth:1.8,fill:n?`currentColor`:`none`,"aria-hidden":`true`})})]})}function Nt({level:e}){return(0,q.jsx)(`span`,{role:`img`,"aria-label":`Autonomy ${e} of 3`,"data-tip":[``,`Helps you decide`,`Makes the work itself`,`Acts on its own`][e],className:`ml-auto flex items-end gap-[2px]`,children:[1,2,3].map(t=>(0,q.jsx)(`span`,{className:j(`w-[4px] rounded-[1px]`,t<=e?`bg-accent`:`bg-line`),style:{height:4+t*4}},t))})}var Pt={assisted:1,native:2,agentic:3};function Ft({id:e,title:t,short:n,about:r,items:i,empty:a,favs:o,footer:s}){return(0,q.jsxs)(`section`,{"aria-labelledby":`agents-${e}`,className:`@container/col flex min-w-0 flex-col`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-0.5 border-b border-line px-2 pt-1 pb-3 mb-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsxs)(`h2`,{id:`agents-${e}`,"data-tip":r,className:`m-0 text-[16px] font-semibold`,children:[t,(0,q.jsx)(`span`,{className:`ml-2 text-[13px] font-normal text-muted tabular-nums`,children:i.length})]}),Pt[e]&&(0,q.jsx)(Nt,{level:Pt[e]})]}),(0,q.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:n}),r&&(0,q.jsx)(`p`,{className:`sr-only`,children:r})]}),i.length?(0,q.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:i.map(e=>(0,q.jsx)(Mt,{item:e,favs:o},e.fav))}):(0,q.jsx)(z,{center:!0,className:`py-10`,action:s,children:a}),s&&i.length>0&&(0,q.jsx)(`div`,{className:`pt-2`,children:s})]})}function It({items:e,value:t,onChange:n}){return(0,q.jsx)(`div`,{role:`group`,"aria-label":`Show`,className:`flex flex-wrap gap-2`,children:e.map(e=>{let r=t===e.id;return(0,q.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>n(e.id),className:j(`inline-flex h-9 cursor-pointer items-center gap-2 rounded-[8px] border px-3 text-[13px] font-medium`,r?`border-accent bg-accent-soft text-ink`:`border-transparent bg-surface-strong text-ink hover:bg-line`),children:[e.tone&&(0,q.jsx)(`span`,{className:j(`size-2 rounded-[2px]`,Dt[e.tone]),"aria-hidden":`true`}),e.label,e.n!==void 0&&(0,q.jsx)(`span`,{className:j(`tabular-nums`,r?`opacity-70`:`text-muted`),children:e.n})]},e.id)})})}var Lt=`favourites`;function Rt(){return(0,q.jsxs)(`a`,{href:I(`agents`,`custom`,`new`),className:j(B({variant:`primary`}),`no-underline`),"data-tip":`New agent`,children:[(0,q.jsx)(n,{"aria-hidden":`true`}),`New`]})}function zt({onDone:e}){let[t,n]=(0,K.useState)(!1),[i,a]=(0,K.useState)(null),[o,s]=(0,K.useState)(``),[c,l]=(0,K.useState)(``),[u,d]=(0,K.useState)(null),[f,p]=(0,K.useState)(!1),[m,h]=(0,K.useState)(!1),[g,_]=(0,K.useState)(``),v=(0,K.useRef)(null),y=()=>{a(null),s(``),l(``),d(null),p(!1),_(``)},b=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=String(r.result||``),n=e.indexOf(`,`);t(n>=0?e.slice(n+1):e)},r.onerror=()=>n(r.error||Error(`Could not read the package.`)),r.readAsDataURL(e)}),x=async e=>{if(_(``),d(null),e.size>4194304)_(`The package is larger than 4 MB.`);else try{let t=await b(e);a(t),s(e.name);let n=await R.importPreview(t);d(n),l(n.id||``)}catch(e){a(null),_(e.message||`That file is not a valid package.`)}},S=async e=>{if(i){h(!0),_(``);try{let t=await R.importPreview(i,e.trim()||void 0);d(t)}catch(e){_(e.message)}finally{h(!1)}}},C=async()=>{if(i&&u){h(!0),_(``);try{let t=await R.importPack(i,{id:c.trim()||void 0,overwriteKnowledge:f});n(!1),y(),e(t.id)}catch(e){_(e.message)}finally{h(!1)}}},w=u?[...u.missing.environments.map(e=>`environment ${e}`),...u.missing.systems.map(e=>`system ${e}`),...u.missing.capabilities.map(e=>`capability ${e}`),...u.missing.skills.map(e=>`skill ${e}`),...u.missing.knowledge.map(e=>`knowledge ${e}`)]:[],T=!(!u||u.problems.length||u.idTaken);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(M,{size:`sm`,variant:`ghost`,onClick:()=>(n(!0),y()),"data-tip":`Import agent`,children:[(0,q.jsx)(ae,{"aria-hidden":`true`}),`Import`]}),(0,q.jsx)(je,{open:t,onClose:()=>(n(!1),y()),title:`Import a custom agent`,description:`A .forgeqe-agent.zip from Export to share (agent.json plus knowledge and skill files). It becomes a draft here: you edit, try and approve it. Environments and systems of this project must already exist.`,footer:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(M,{variant:`ghost`,onClick:()=>(n(!1),y()),children:[(0,q.jsx)(r,{"aria-hidden":`true`}),`Cancel`]}),(0,q.jsxs)(M,{variant:`primary`,disabled:m||!T||u?.warnings.some(e=>e.includes(`already exists here`)&&e.startsWith(`knowledge`))&&!f,onClick:()=>void C(),"data-tip":`Import as draft`,children:[(0,q.jsx)(ae,{"aria-hidden":`true`}),`Import`]})]}),children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-4 text-sm`,children:[(0,q.jsx)(`input`,{ref:v,type:`file`,accept:`.zip,application/zip`,className:`sr-only`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&x(t)}}),(0,q.jsxs)(M,{size:`sm`,className:`self-start`,onClick:()=>v.current?.click(),"data-tip":o?`Choose another file`:`Choose .zip package`,children:[(0,q.jsx)(E,{"aria-hidden":`true`}),`Choose`]}),o&&(0,q.jsx)(`span`,{className:`text-muted`,children:o}),u&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:`Id`}),(0,q.jsx)(P,{value:c,maxLength:40,spellCheck:!1,onChange:e=>l(e.target.value.toLowerCase()),onBlur:()=>void S(c)}),u.idTaken&&(0,q.jsx)(`span`,{className:`text-[13px] text-warn`,children:`That id is taken here. Choose another before importing.`})]}),u.knowledge.length>0&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:`Knowledge it brings`}),(0,q.jsx)(`ul`,{className:`m-0 list-disc pl-5 text-ink-2`,children:u.knowledge.map(e=>(0,q.jsx)(`li`,{children:e.path},e.path))})]}),u.skills.length>0&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:`Skills it brings`}),(0,q.jsx)(`ul`,{className:`m-0 list-disc pl-5 text-ink-2`,children:u.skills.map(e=>(0,q.jsx)(`li`,{children:e.name},e.name))})]}),w.length>0&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-[12px] bg-warn-soft px-3 py-2 text-warn`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:`This project still needs`}),(0,q.jsx)(`ul`,{className:`m-0 list-disc pl-5`,children:w.map(e=>(0,q.jsx)(`li`,{children:e},e))})]}),u.warnings.some(e=>e.startsWith(`knowledge file `)&&e.endsWith(` already exists here`))&&(0,q.jsxs)(`label`,{className:`flex items-center gap-2.5`,children:[(0,q.jsx)(mt,{checked:f,onCheckedChange:p}),`Replace existing knowledge files of the same path`]}),u.problems.length>0&&(0,q.jsx)(`ul`,{className:`m-0 list-disc pl-5 text-fail`,children:u.problems.map((e,t)=>(0,q.jsx)(`li`,{children:e},t))})]}),g&&(0,q.jsx)(`p`,{className:`m-0 text-fail`,children:g})]})})]})}function Bt(){let[e,t]=(0,K.useState)(null),[n,r]=(0,K.useState)(``),[i,a]=(0,K.useState)(``);return(0,K.useEffect)(()=>{let e=!1;return R.list().then(n=>{e||(ke(n.agents,`replace`),t(n.agents),a(n.off||``))},n=>{e||(t([]),r(n.message))}),()=>{e=!0}},[]),{rows:e,error:n,off:i,setRows:t}}function Vt(){return(0,q.jsxs)(`p`,{role:`status`,className:`m-0 flex flex-wrap items-center gap-x-2 rounded-[12px] bg-surface-muted px-4 py-3 text-sm text-ink-2`,children:[`Custom agents are turned off for this project: none runs, from here, the terminal, the Orchestrator or a schedule.`,(0,q.jsx)(`a`,{href:I(`settings`),children:`Turn them on in Settings, Custom agents`})]})}function Ht({rows:t,onDone:n}){let[i,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)([]),[c,l]=(0,K.useState)(null),[d,f]=(0,K.useState)(``),[p,m]=(0,K.useState)(!1),[h,g]=(0,K.useState)(``),_=t.filter(e=>e.approvedVersion);if(!_.length)return null;let v=_.filter(e=>o.includes(e.id)),y=async()=>{if(c){m(!0);try{let e=await R.bulk(c,o,d);n(e.agents),g(`${c===`disable`?`Disabled`:`Enabled`} ${e.done.length}${e.skipped.length?`; skipped ${e.skipped.map(e=>e.id).join(`, `)} (already ${c}d)`:``}.`),l(null),s([]),a(!1)}catch(e){g(e.message)}finally{m(!1),f(``)}}};return(0,q.jsxs)(`section`,{"aria-labelledby":`custom-bulk`,className:`flex flex-col gap-2`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`h2`,{id:`custom-bulk`,className:`m-0 flex-1 text-[13px] font-semibold text-muted`,children:`Disable or enable several`}),(0,q.jsxs)(M,{size:`sm`,variant:`ghost`,onClick:()=>(a(!i),s([]),g(``)),"data-tip":i?void 0:`Select agents`,children:[i?(0,q.jsx)(r,{"aria-hidden":`true`}):(0,q.jsx)(e,{"aria-hidden":`true`}),i?`Cancel`:`Select`]})]}),i&&(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-[12px] card border p-3`,children:[(0,q.jsxs)(`label`,{className:`flex items-center gap-2.5 text-sm font-medium`,children:[(0,q.jsx)(mt,{checked:o.length===_.length,onCheckedChange:e=>s(e?_.map(e=>e.id):[])}),`All `,_.length,` approved agents`]}),(0,q.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-1 gap-1.5 p-0 sm:grid-cols-2`,children:_.map(e=>(0,q.jsx)(`li`,{children:(0,q.jsxs)(`label`,{className:`flex items-center gap-2.5 text-sm`,children:[(0,q.jsx)(mt,{checked:o.includes(e.id),onCheckedChange:t=>s(t?[...o,e.id]:o.filter(t=>t!==e.id))}),(0,q.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),(0,q.jsx)(F,{tone:J[e.state].tone,icon:!1,children:J[e.state].label})]})},e.id))}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsxs)(M,{size:`sm`,disabled:!o.length,onClick:()=>l(`disable`),children:[(0,q.jsx)(u,{"aria-hidden":`true`}),o.length?`Disable (${o.length})`:`Disable`]}),(0,q.jsxs)(M,{size:`sm`,variant:`ghost`,disabled:!o.length,onClick:()=>l(`enable`),children:[(0,q.jsx)(k,{"aria-hidden":`true`}),o.length?`Enable (${o.length})`:`Enable`]})]})]}),h&&(0,q.jsx)(`p`,{role:`status`,className:`m-0 text-[13px] text-muted`,children:h}),c&&(0,q.jsx)(je,{open:!0,onClose:()=>(l(null),f(``)),title:`${c===`disable`?`Disable`:`Enable`} ${v.length} agent${v.length===1?``:`s`}`,description:c===`disable`?`None of them runs (not you, your team, the Orchestrator or their schedules) until a person enables it again. Their versions and history are kept.`:`Their approved versions run again, and their schedules come back.`,footer:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(M,{variant:`ghost`,onClick:()=>(l(null),f(``)),children:[(0,q.jsx)(r,{"aria-hidden":`true`}),`Cancel`]}),(0,q.jsxs)(M,{variant:`primary`,disabled:p||d!==String(v.length),onClick:()=>void y(),children:[c===`disable`?(0,q.jsx)(u,{"aria-hidden":`true`}):(0,q.jsx)(k,{"aria-hidden":`true`}),c===`disable`?`Disable`:`Enable`]})]}),children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-3 text-sm`,children:[(0,q.jsx)(`span`,{className:`text-ink-2`,children:v.map(e=>e.name).join(`, `)}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(`span`,{children:[`Type `,v.length,` to confirm`]}),(0,q.jsx)(P,{value:d,onChange:e=>f(e.target.value),autoComplete:`off`,inputMode:`numeric`})]})]})})]})}function Ut({only:e}){let t=Tt(),r=Bt(),[i,a]=(0,K.useState)(null);(0,K.useEffect)(()=>{se.directory().then(e=>a(e.agents),()=>a({}))},[]);let[o,s]=(0,K.useState)([]);(0,K.useEffect)(()=>{le.list().then(e=>s(e.approvals.filter(e=>e.state===`waiting`)),()=>{})},[]);let[c,l]=(0,K.useState)(``),[u,d]=(0,K.useState)(`all`),f=e?Ee.find(t=>t.id===e):void 0,p=(0,K.useMemo)(()=>Ie(c,f?.id),[c,f]),m=(0,K.useMemo)(()=>!f||f.id===`custom`?De(r.rows||[],c):[],[r.rows,c,f]),h=e=>e===`custom`?m.map(At):p.filter(t=>t.category===e).map(e=>Ot(e.id,i)),g=e=>[...e.filter(e=>t.favs.includes(e.fav)),...e.filter(e=>!t.favs.includes(e.fav))],_=(f?[f]:Ee).map(e=>({c:e,all:g(h(e.id))})),v=_.flatMap(e=>e.all),y=e=>u===`all`||(u===Lt?t.favs.includes(e.fav):e.status===u),b=e=>v.filter(t=>t.status===e).length,x=[{id:`all`,label:`All`,n:v.length},...[`attention`,`partial`,`ready`,`unavailable`].filter(e=>b(e)>0||e!==`unavailable`).map(e=>({id:e,label:Et[e].label,n:b(e),tone:Et[e].tone})),{id:Lt,label:`Favourites`,n:v.filter(e=>t.favs.includes(e.fav)).length}],S=u!==`all`||!!c.trim(),C=(e,t)=>S?`None here.`:e===`custom`?r.rows===null?`Reading your custom agents…`:r.error?`Your custom agents cannot be read: ${r.error}`:(0,q.jsxs)(`span`,{className:`flex flex-col items-center gap-2`,children:[(0,q.jsx)(ue,{name:Ue.agents,px:22}),(0,q.jsx)(`span`,{className:`text-[15px] font-medium text-ink`,children:`No custom agents yet`}),(0,q.jsx)(`span`,{children:`Make one for a job your team repeats.`})]}):`No ${t.toLowerCase()} yet.`;return(0,q.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,q.jsx)(Xe,{}),(0,q.jsxs)(`main`,{className:j(Ze,`max-w-[1400px] flex-auto gap-4`),children:[f&&(0,q.jsxs)(`a`,{href:I(`agents`),className:`inline-flex items-center gap-1.5 self-start text-sm`,children:[(0,q.jsx)(w,{size:16,"aria-hidden":`true`}),`All agents`]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-6 gap-y-3`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-[1_1_480px] flex-col gap-1.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsx)(Te,{pixel:Ue.agents,size:`lg`}),(0,q.jsx)(`h1`,{className:`m-0 text-[26px] font-semibold tracking-[-0.01em]`,children:f?f.label:`Agents`})]}),(0,q.jsx)(`p`,{className:`m-0 max-w-[76ch] text-[14px] leading-relaxed text-ink-2`,children:f?f.about:`Open an agent to chat with it and see what it can do.`})]}),(!f||f.id===`custom`)&&!r.off&&(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 self-center`,children:[(0,q.jsx)(zt,{onDone:e=>{R.list().then(e=>{ke(e.agents,`replace`),r.setRows(e.agents)}),location.hash=I(`agents`,`custom`,e)}}),(0,q.jsx)(Rt,{})]})]}),(0,q.jsx)(jt,{cards:i}),o.length>0&&(0,q.jsx)(`a`,{href:I(`agents`,`custom`,o[0].agent),role:`status`,className:`flex items-center gap-2 self-start rounded-[12px] bg-warn-soft px-3 py-2 text-sm font-medium text-warn no-underline hover:text-warn`,children:o.length===1?`${o[0].agent} is waiting for your approval`:`${o.length} requests from your agents are waiting for your approval`}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(pe,{id:`agents-search`,label:f?`Find an agent in ${f.label}`:`Find an agent`,value:c,onChange:l}),(0,q.jsx)(`span`,{className:`mx-2 hidden h-6 w-px bg-line sm:block`,"aria-hidden":`true`}),(0,q.jsx)(It,{items:x,value:u,onChange:d})]}),r.off&&(!f||f.id===`custom`)&&(0,q.jsx)(Vt,{}),f?.id===`custom`&&r.rows&&(0,q.jsx)(Ht,{rows:r.rows,onDone:r.setRows}),(0,q.jsx)(`div`,{className:`@container`,children:(0,q.jsx)(`div`,{className:j(`grid items-start gap-x-6 gap-y-8`,f?`max-w-[720px] grid-cols-1`:`grid-cols-1 @2xl:grid-cols-2 @5xl:grid-cols-4`),children:_.map(({c:e,all:i})=>(0,q.jsx)(Ft,{id:e.id,title:e.label,short:e.short,about:e.id===`custom`?`Agents your team makes for its own work, held to the environments and actions you choose.`:e.about,items:i.filter(y),empty:C(e.id,e.label),favs:t,footer:e.id===`custom`&&!r.off&&!S?(0,q.jsxs)(`a`,{href:I(`agents`,`custom`,`new`),className:j(B({variant:`outline`,size:`sm`}),`justify-center gap-2 no-underline`,(r.rows?.length??0)>0&&`w-full`),"data-tip":`Make a custom agent`,children:[(0,q.jsx)(n,{"aria-hidden":`true`}),`New`]}):void 0},e.id))})})]})]})}function Wt({value:e,onChange:t,id:n}){let r=Ve(e)?e:Re,[i,a]=(0,K.useState)(``),[o,s]=(0,K.useState)(10),[c,l]=(0,K.useState)(()=>!!(Se(`ph:robot`)||Se(`lucide:bot`)));(0,K.useEffect)(()=>{Ge().then(()=>l(!0))},[]),(0,K.useEffect)(()=>{s(10)},[i]);let u=!!i.trim(),{hits:d,total:f}=(0,K.useMemo)(()=>u?Ae(i,o,0):Ae(``,o,Le.length),[i,o,u]),p=Me.length,m=u?f>o:o<p,h=u?Math.max(0,f-o):Math.max(0,p-o);return(0,q.jsxs)(`div`,{id:n,className:`flex flex-col gap-3`,children:[(0,q.jsxs)(`label`,{className:`relative block`,children:[(0,q.jsx)(C,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted`}),(0,q.jsx)(P,{value:i,onChange:e=>a(e.target.value),placeholder:`Search Phosphor and Lucide icons…`,"aria-label":`Search icons`,className:`pl-9`,spellCheck:!1})]}),!u&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`mb-2 text-[13px] text-muted`,children:`ForgeQE faces`}),(0,q.jsx)(`div`,{role:`listbox`,"aria-label":`ForgeQE faces`,className:`flex flex-wrap gap-2`,children:Le.map(e=>(0,q.jsx)(Gt,{icon:e,label:Ne(e),selected:e===r,ready:!0,onPick:t},e))})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`p`,{className:`mb-2 text-[13px] text-muted`,children:u?`Top matches (${f})`:`Library icons (Phosphor and Lucide)`}),(0,q.jsxs)(`div`,{role:`listbox`,"aria-label":u?`Icon search results`:`Library icons`,className:`flex flex-wrap gap-2`,children:[d.map(e=>(0,q.jsx)(Gt,{icon:e.id,label:e.label,selected:e.id===r,ready:c||e.kind===`face`,onPick:t},e.id)),d.length===0&&(0,q.jsx)(`p`,{className:`text-[13px] text-muted`,children:`No icons match that search.`})]}),m&&(0,q.jsxs)(`button`,{type:`button`,className:`mt-3 inline-flex items-center gap-1 text-[13px] font-medium text-accent underline-offset-4 hover:underline`,"data-tip":`Show ${Math.min(10,h)} of ${h} more`,onClick:()=>s(e=>e+10),children:[(0,q.jsx)(b,{size:14,"aria-hidden":`true`}),`More (`,h,`)`]})]}),Qe(r)&&(0,q.jsxs)(`p`,{className:`text-[13px] text-muted`,children:[`Selected `,(0,q.jsx)(`span`,{className:`font-mono text-fg`,children:r})]})]})}function Gt({icon:e,label:t,selected:n,ready:r,onPick:i}){return(0,q.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":n,"aria-label":t,"data-tip":t,disabled:!r&&!!Qe(e),className:j(`inline-flex size-11 cursor-pointer items-center justify-center rounded-[10px] border bg-bg text-fg transition-colors disabled:cursor-wait disabled:opacity-50`,n?`border-accent ring-2 ring-accent/30`:`border-line-soft hover:border-line`),onClick:()=>i(e),children:xe(e)?(0,q.jsx)(ue,{name:e,px:28}):(0,q.jsx)(Ke,{agent:`custom`,icon:e,px:28,decorative:!0})})}var Kt=[{label:`Defect retest`,about:`Each morning, retests the defects resolved since yesterday and says which are really fixed.`,text:`Every morning, find the defects resolved in our tracker since yesterday, retest each one on QA by rerunning its test or following its steps in a real browser, and tell me which are really fixed and which still fail, with screenshots. Add the result as a comment on each defect.`},{label:`Nightly smoke`,about:`Each night, runs the critical flows on QA and tells the team what broke and why.`,text:`Every night, run our critical flows (sign-in, search, checkout) on QA in a real browser, and tell the team in our channel what broke, with screenshots and the likely cause.`},{label:`Pull request test check`,about:`Reviews a pull request's tests, runs the ones it touches, and says what is missing or risky.`,text:`When I give it a pull request, review its tests and changes, run the automated tests it touches, and tell me what is missing or risky before I merge.`},{label:`Release readiness`,about:`Runs a release's regression pack and says whether it is ready to ship and what blocks it.`,text:`For a release I name, run its regression pack on QA, look at its test cases' results and its open defects, and tell me if it is ready to ship and what blocks it.`},{label:`API contracts`,about:`Checks an API against its contracts after each deploy and explains any break.`,text:`Check our order API against its contracts after each deploy and explain any break`},{label:`Test case quality`,about:`Reviews a story's test cases and says what is missing or vague.`,text:`Review a story's test cases and tell me what is missing or vague`}];function qt(){let[e,t]=(0,K.useState)(``),[n,r]=(0,K.useState)(!1),[i,a]=(0,K.useState)(``),[o,s]=(0,K.useState)([]),[c,u]=(0,K.useState)([]);(0,K.useEffect)(()=>{oe.list().then(e=>s(e.sessions.filter(e=>!e.saved)),()=>{}),R.templates().then(e=>u(e.templates),()=>{})},[]);let d=async()=>{if(e.trim()){r(!0),a(``);try{let t=await oe.start(e.trim());location.hash=I(`agents`,`custom`,`build`,t.sid)}catch(e){a(e.message),r(!1)}}};return(0,q.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,q.jsxs)(`header`,{className:`flex items-center gap-1 px-5 py-3.5`,children:[(0,q.jsx)(qe,{}),(0,q.jsxs)(`a`,{href:I(`agents`,`category`,`custom`),className:`inline-flex min-h-9 items-center gap-1.5 text-sm`,children:[(0,q.jsx)(w,{size:16,"aria-hidden":`true`}),`Custom agents`]})]}),(0,q.jsx)(`main`,{className:`flex flex-auto flex-col items-center justify-center px-5 pt-6 pb-[120px]`,children:(0,q.jsxs)(`div`,{className:`flex w-full max-w-[780px] flex-col items-center gap-9`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col items-center gap-3.5 text-center`,children:[(0,q.jsx)(he,{state:n?`working`:`idle`,px:112,label:n?`ForgeQE is working it out`:`ForgeQE is ready to build an agent`,className:`mb-1`}),(0,q.jsx)(`h1`,{className:`m-0 text-[34px] leading-tight font-semibold tracking-[-0.015em] text-ink`,children:`What should your agent do?`}),(0,q.jsx)(`p`,{className:`m-0 max-w-[54ch] text-[15px] leading-relaxed text-ink-2`,children:`Say it in your own words. ForgeQE works out what it needs from what your project has, asks only what it cannot decide, and builds it with you step by step.`})]}),(0,q.jsx)(lt,{id:`build-goal`,label:`What your agent should do`,value:e,onChange:e=>{t(e),a(``)},onSend:()=>void d(),busy:n,disabled:n,placeholder:`An agent that checks the checkout on QA and tells me what broke…`}),i&&(0,q.jsx)(`p`,{role:`alert`,className:`m-0 -mt-6 text-sm text-fail`,children:i}),(0,q.jsxs)(`section`,{"aria-labelledby":`build-starters`,className:`flex w-full flex-col gap-2`,children:[(0,q.jsx)(`h2`,{id:`build-starters`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Or start from one of these, and change it to fit`}),(0,q.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-1 gap-2 p-0 sm:grid-cols-2`,children:Kt.map(n=>(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,"aria-pressed":e===n.text,onClick:()=>{t(n.text),a(``),document.getElementById(`build-goal`)?.focus()},className:j(`flex h-full w-full cursor-pointer flex-col items-start gap-0.5 rounded-[12px] border px-3.5 py-2.5 text-left hover:bg-surface-muted`,e===n.text?`border-accent bg-accent-soft`:`border-line-soft bg-transparent`),children:[(0,q.jsx)(`span`,{className:`text-[14px] font-medium text-ink`,children:n.label}),(0,q.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:n.about})]})},n.label))})]}),o.length>0&&(0,q.jsxs)(`section`,{"aria-labelledby":`build-resume`,className:`flex w-full flex-col gap-2`,children:[(0,q.jsx)(`h2`,{id:`build-resume`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Pick up where you left off`}),(0,q.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-1.5`,children:o.slice(0,5).map(e=>(0,q.jsx)(`li`,{children:(0,q.jsxs)(`a`,{href:I(`agents`,`custom`,`build`,e.sid),className:`flex min-h-11 items-center gap-3 rounded-[8px] px-3 py-1.5 text-ink no-underline hover:bg-surface-muted hover:text-ink`,children:[(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[14px]`,children:e.goal}),(0,q.jsxs)(`span`,{className:`flex-none text-[12.5px] text-muted`,children:[Jt[e.step].label,` · `,pt(e.updatedAt)]})]})},e.sid))})]}),c.length>0&&(0,q.jsxs)(`section`,{"aria-labelledby":`build-templates`,className:`flex w-full flex-col gap-2`,children:[(0,q.jsx)(`h2`,{id:`build-templates`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Or start from a template, and review it before you save`}),(0,q.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-1.5`,children:c.map(e=>(0,q.jsx)(`li`,{children:(0,q.jsxs)(`a`,{href:I(`agents`,`custom`,`new`,`template`,e.id),className:`flex min-h-11 items-center gap-3 rounded-[8px] px-3 py-1.5 text-ink no-underline hover:bg-surface-muted hover:text-ink`,children:[(0,q.jsx)(`span`,{className:`flex-none text-[14px]`,children:e.title}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 text-[12.5px] text-muted`,children:e.why||e.about})]})},e.id))})]}),(0,q.jsxs)(`a`,{href:I(`agents`,`custom`,`new`,`form`),className:`inline-flex items-center gap-1.5 text-[13px]`,children:[(0,q.jsx)(l,{size:14,"aria-hidden":`true`}),`Or set every option yourself`]})]})})]})}var Jt={understand:{label:`Understand`,title:`Let's understand your requirements`,next:`Make the plan`,working:`Working out the plan…`,thinking:`Reading what you want, and what your project has…`},plan:{label:`Plan`,title:`Here's how your agent will work`,next:`Set its boundaries`,working:`Working out what it may do…`,thinking:`Planning how your agent will do it, step by step…`},boundaries:{label:`Boundaries`,title:`Where it works and what it may do`,next:`Choose what it knows`,working:`Looking for what it should know…`,thinking:``},knowledge:{label:`Knowledge`,title:`What it should know`,next:`Review it`,working:`Putting it together…`,thinking:``},review:{label:`Review`,title:`Your agent`,next:`Save it as a draft`,working:`Saving it…`,thinking:`Naming it, and writing its instructions…`},try:{label:`Try`,title:`Try it, then approve it`,next:``,working:``,thinking:``}};function Yt({sid:e}){let[t,n]=(0,K.useState)(null),[r,i]=(0,K.useState)(``),[a,o]=(0,K.useState)(null),[s,c]=(0,K.useState)(!1);if((0,K.useEffect)(()=>{oe.view(e).then(e=>{n(e),o(Math.min(e.reached,e.steps.length-1))},e=>i(e.message))},[e]),(0,K.useEffect)(()=>{if(!t?.working)return;let r=setTimeout(()=>{oe.view(e).then(n,()=>{})},1500);return()=>clearTimeout(r)},[t,e]),r&&!t)return(0,q.jsx)(Xt,{children:(0,q.jsxs)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail`,children:[r,` `,(0,q.jsx)(`a`,{href:I(`agents`,`custom`,`new`),children:`Start again`})]})});if(!t||a===null)return(0,q.jsx)(Xt,{children:(0,q.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})});let l=t.steps[a].id,u=Jt[l],d=s||t.working===l,f=async t=>{if(l!==`try`){c(!0),i(``);try{let r=await oe.answer(e,l,t);n(r),o(Math.min(a+1,r.steps.length-1)),window.scrollTo({top:0})}catch(e){i(e.message)}finally{c(!1)}}};return(0,q.jsxs)(Xt,{children:[(0,q.jsxs)(`a`,{href:I(`agents`,`category`,`custom`),className:`inline-flex items-center gap-1.5 self-start text-sm`,children:[(0,q.jsx)(w,{size:16,"aria-hidden":`true`}),`Custom agents`]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`span`,{className:`text-[13px] text-muted`,children:`New agent`}),(0,q.jsxs)(`p`,{className:`m-0 text-[15px] text-ink-2 [overflow-wrap:anywhere]`,children:[`“`,t.goal,`”`]})]}),(0,q.jsx)(Zt,{v:t,at:a,onGo:e=>!s&&o(e)}),(0,q.jsxs)(`section`,{"aria-labelledby":`build-step`,className:`flex flex-col gap-5`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,q.jsx)(he,{state:d?`working`:`idle`,px:36,label:d?u.working:`ForgeQE`,className:`flex-none`}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,q.jsx)(`h1`,{id:`build-step`,className:`m-0 text-[22px] font-semibold tracking-[-0.01em]`,children:u.title}),(0,q.jsx)(`p`,{className:`m-0 max-w-[72ch] text-[15px] leading-relaxed text-ink-2`,children:d?t.working===l?Jt[l].thinking:u.working:t.says[l]}),!d&&t.source?.[l]&&(0,q.jsx)(`span`,{className:`text-[12px] text-muted`,children:t.source[l]===`model`?`Worked out by ForgeQE's model from what you said and what your project has.`:t.note||`Worked out by ForgeQE's rules: no model is set up.`})]})]}),r&&(0,q.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:r}),t.working===l?null:l===`understand`&&(0,q.jsx)($t,{v:t,busy:s,onNext:f,next:u.next},`u-${t.updatedAt}`),t.working!==l&&l===`plan`&&(0,q.jsx)(tn,{v:t,busy:s,onNext:f,onBack:()=>o(a-1),next:u.next},`p-${t.updatedAt}`),l===`boundaries`&&(0,q.jsx)(nn,{v:t,busy:s,onNext:f,onBack:()=>o(a-1),next:u.next},`b-${t.updatedAt}`),l===`knowledge`&&(0,q.jsx)(rn,{v:t,busy:s,onNext:f,onBack:()=>o(a-1),next:u.next},`k-${t.updatedAt}`),t.working!==l&&l===`review`&&(0,q.jsx)(an,{v:t,busy:s,onNext:f,onBack:()=>o(a-1),next:u.next},`r-${t.updatedAt}`),l===`try`&&(0,q.jsx)(on,{v:t})]})]})}function Xt({children:e}){return(0,q.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,q.jsx)(Xe,{}),(0,q.jsx)(`main`,{className:j(Ze,`max-w-[920px] flex-auto gap-6`),children:e})]})}function Zt({v:e,at:t,onGo:n}){return(0,q.jsx)(`nav`,{"aria-label":`Steps`,children:(0,q.jsx)(`ol`,{className:`m-0 flex list-none flex-wrap gap-x-1 gap-y-2 p-0`,children:e.steps.map((r,a)=>{let o=a<=e.reached,s=a===t;return(0,q.jsxs)(`li`,{className:`flex items-center gap-1`,children:[(0,q.jsxs)(`button`,{type:`button`,disabled:!o,"aria-current":s?`step`:void 0,onClick:()=>n(a),className:j(`inline-flex min-h-9 items-center gap-2 rounded-[8px] border-0 px-2.5 text-[13px] font-medium`,s?`bg-accent-soft text-ink`:o?`cursor-pointer bg-transparent text-ink-2 hover:bg-surface-strong`:`bg-transparent text-muted`),children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:j(`inline-flex size-5 items-center justify-center rounded-full text-[11px] tabular-nums`,r.done&&!s?`bg-pass-soft text-pass`:s?`bg-accent text-accent-ink`:`bg-surface-strong text-muted`),children:r.done&&!s?(0,q.jsx)(i,{size:12,strokeWidth:3}):a+1}),Jt[r.id].label]}),a<e.steps.length-1&&(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`h-px w-4 bg-line`})]},r.id)})})})}function Qt({busy:e,onBack:t,next:n,onNext:r,disabled:a,aside:o}){let s=n.startsWith(`Save`);return(0,q.jsxs)(`div`,{className:`sticky bottom-0 flex flex-wrap items-center gap-3 border-t border-line-soft bg-bg py-3`,children:[(0,q.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:o}),t&&(0,q.jsxs)(M,{variant:`ghost`,disabled:e,onClick:t,children:[(0,q.jsx)(w,{"aria-hidden":`true`}),`Back`]}),(0,q.jsxs)(M,{variant:`primary`,disabled:e||a,onClick:r,"data-tip":n,children:[s?(0,q.jsx)(i,{"aria-hidden":`true`}):(0,q.jsx)(A,{"aria-hidden":`true`}),s?`Save`:`Next`]})]})}function Y({on:e,label:t,why:n,recommended:r,onToggle:a}){return(0,q.jsxs)(`button`,{type:`button`,"aria-pressed":e,onClick:a,className:j(`flex min-h-11 w-full cursor-pointer items-start gap-3 rounded-[12px] border px-3.5 py-2.5 text-left`,e?`border-accent bg-accent-soft`:`border-line-soft bg-bg hover:bg-surface-muted`),children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:j(`mt-0.5 inline-flex size-4 flex-none items-center justify-center rounded-[4px] border`,e?`border-accent bg-accent text-accent-ink`:`border-muted`),children:e&&(0,q.jsx)(i,{size:12,strokeWidth:3})}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-[14px] font-medium text-ink`,children:[t,r&&(0,q.jsx)(F,{tone:`running`,icon:!1,children:`Recommended`})]}),n&&(0,q.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:n})]})]})}function $t({v:e,busy:t,onNext:n,next:r}){let[i,a]=(0,K.useState)(()=>Object.fromEntries(e.questions.map(e=>[e.id,e.answer]))),[o,s]=(0,K.useState)([]),c=(e,t,n)=>a(r=>{let i=r[e]||[];return{...r,[e]:t===`one`?[n]:i.includes(n)?i.filter(e=>e!==n):[...i,n]}});return(0,q.jsxs)(q.Fragment,{children:[e.questions.map(e=>{let t=e.assumed&&!o.includes(e.id);return(0,q.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 rounded-[14px] card border p-4`,children:[(0,q.jsx)(`legend`,{className:`sr-only`,children:e.text}),(0,q.jsx)(`span`,{className:`text-[15px] font-semibold`,children:e.text}),t?(0,q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm text-ink-2`,children:[(0,q.jsx)(L,{icon:k,size:16,className:`text-pass`}),e.assumed,!(i[e.id]||[]).every(t=>e.assumed?.includes(t))&&(0,q.jsxs)(`span`,{className:`text-muted`,children:[`(`,i[e.id]?.join(`, `),`)`]}),(0,q.jsx)(M,{size:`sm`,variant:`ghost`,onClick:()=>s([...o,e.id]),"aria-label":`Change the answer`,"data-tip":`Change the answer`,children:(0,q.jsx)(x,{"aria-hidden":`true`})})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`text-[13px] text-muted`,children:e.why}),(0,q.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:e.options.map(t=>(0,q.jsx)(Y,{on:(i[e.id]||[]).includes(t.id),label:t.label,why:t.why,recommended:t.recommended,onToggle:()=>c(e.id,e.kind,t.id)},t.id))})]})]},e.id)}),(0,q.jsx)(Qt,{busy:t,next:r,onNext:()=>n({answers:i}),disabled:e.questions.some(e=>e.id===`environment`&&!(i[e.id]||[]).length),aside:e.environments.length===0?(0,q.jsx)(`span`,{className:`text-fail`,children:`Add a test environment in Settings first: an agent needs one to work in.`}):void 0})]})}var en={ready:{icon:k,label:`Ready`,tone:`text-pass`},partial:{icon:f,label:`Partly set up`,tone:`text-warn`},needs_setup:{icon:u,label:`Not set up here yet`,tone:`text-muted`}};function tn({v:e,busy:t,onNext:r,onBack:i,next:a}){let[o,s]=(0,K.useState)(()=>e.plan.filter(e=>e.on).map(e=>e.capability)),[c,l]=(0,K.useState)(!1),u=o.map(t=>e.plan.find(e=>e.capability===t)).filter(Boolean),d=e.plan.filter(e=>!o.includes(e.capability));return(0,q.jsxs)(q.Fragment,{children:[e.planSteps&&e.planSteps.length>0&&(0,q.jsx)(`ol`,{"aria-label":`How it will work`,className:`m-0 flex list-none flex-col gap-0 rounded-[14px] card border p-0`,children:e.planSteps.map((t,n)=>(0,q.jsxs)(`li`,{className:j(`flex items-start gap-3 px-4 py-3`,n>0&&`border-t border-line-soft`),children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex size-7 flex-none items-center justify-center rounded-full bg-accent-soft text-[13px] font-semibold text-accent-fg tabular-nums`,children:n+1}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,q.jsx)(`span`,{className:`text-[15px] font-semibold`,children:t.title}),(0,q.jsx)(`span`,{className:`text-[13.5px] text-ink-2`,children:t.why}),t.without&&(0,q.jsxs)(`span`,{className:`text-[12.5px] text-muted`,children:[`Without it: `,t.without]}),(0,q.jsx)(`span`,{className:`flex flex-wrap gap-1.5 pt-1`,children:t.uses.map(t=>{let n=e.plan.find(e=>e.capability===t);return(0,q.jsx)(`span`,{className:`rounded-[6px] bg-surface-strong px-2 py-0.5 text-[12px] text-ink-2`,children:n?.title||t},t)})})]})]},n))}),e.planSteps&&e.planSteps.length>0&&(0,q.jsx)(`h2`,{className:`m-0 mt-2 text-[13px] font-semibold text-muted`,children:`What it uses`}),(0,q.jsx)(`ol`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:u.map((e,t)=>{let n=en[e.state];return(0,q.jsxs)(`li`,{className:`flex items-start gap-3 rounded-[14px] card border p-4`,children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex size-7 flex-none items-center justify-center rounded-full bg-accent-soft text-[13px] font-semibold text-accent-fg tabular-nums`,children:t+1}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,q.jsx)(`span`,{className:`text-[15px] font-semibold`,children:e.title}),e.why&&(0,q.jsx)(`span`,{className:`text-[13.5px] text-ink-2`,children:e.why}),(0,q.jsx)(`span`,{className:`line-clamp-2 text-[13px] text-muted`,children:e.summary}),(0,q.jsxs)(`span`,{className:j(`flex items-center gap-1.5 text-[12.5px]`,n.tone),children:[(0,q.jsx)(L,{icon:n.icon,size:14}),n.label,e.state!==`ready`&&e.gaps.length?`: ${e.gaps.join(`; `)}`:``]})]}),(0,q.jsx)(M,{variant:`icon`,size:`icon`,"aria-label":`Leave out ${e.title}`,"data-tip":`Leave out ${e.title}`,onClick:()=>s(o.filter(t=>t!==e.capability)),children:(0,q.jsx)(ne,{"aria-hidden":`true`})})]},e.capability)})}),c?(0,q.jsxs)(`section`,{"aria-labelledby":`build-add`,className:`flex flex-col gap-2 rounded-[14px] card border p-4`,children:[(0,q.jsx)(`h2`,{id:`build-add`,className:`m-0 text-[14px] font-semibold`,children:`What else should it do?`}),(0,q.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-1 gap-2 p-0 sm:grid-cols-2`,children:d.map(e=>(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,onClick:()=>s([...o,e.capability]),className:`flex h-full w-full cursor-pointer items-start gap-2 rounded-[10px] border border-line-soft bg-bg px-3 py-2 text-left hover:bg-surface-muted`,children:[(0,q.jsx)(n,{size:16,"aria-hidden":`true`,className:`mt-0.5 flex-none text-muted`}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,q.jsx)(`span`,{className:`text-[13.5px] font-medium`,children:e.title}),(0,q.jsx)(`span`,{className:`line-clamp-2 text-[12px] text-muted`,children:e.summary})]})]})},e.capability))})]}):(0,q.jsxs)(M,{size:`sm`,className:`self-start`,onClick:()=>l(!0),"data-tip":`Add something it should also do`,children:[(0,q.jsx)(n,{"aria-hidden":`true`}),`Add`]}),(0,q.jsx)(Qt,{busy:t,onBack:i,next:a,onNext:()=>r({capabilities:o}),disabled:!o.length})]})}function X({text:e,help:t,on:n,onChange:r,locked:i}){return(0,q.jsxs)(`div`,{className:`flex items-start gap-4 border-t border-line-soft py-3 first:border-t-0`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,q.jsx)(`span`,{className:`text-[14px] text-ink`,children:e}),(t||i)&&(0,q.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:i||t})]}),i?(0,q.jsx)(re,{size:18,"aria-label":`Always`,className:`mt-0.5 flex-none text-muted`}):(0,q.jsx)(ze,{checked:n,onChange:e=>r?.(e),label:e})]})}function nn({v:e,busy:t,onNext:n,onBack:r,next:i}){let a=e.boundaries,[o,s]=(0,K.useState)(a.environments),[c,l]=(0,K.useState)(a.actions),[u,d]=(0,K.useState)(a.approve),[f,p]=(0,K.useState)(a.shell),[m,h]=(0,K.useState)(a.repository),[g,_]=(0,K.useState)(a.unattended),[v,y]=(0,K.useState)(a.trust||[]),[b,x]=(0,K.useState)((a.production||[]).includes(`run`)),S=o.some(t=>e.production.includes(t)),C=(e,t)=>y(t?[...new Set([...v,e])]:v.filter(t=>t!==e)),w=e.plan.filter(e=>e.on&&e.capability.startsWith(`system:`)),T=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],E=e=>c.includes(e),D=(e,t)=>l(t?[...new Set([...c,e])]:c.filter(t=>t!==e)),O=(e,t)=>d(t?[...new Set([...u,e])]:u.filter(t=>t!==e)),ee=o.join(` and `)||`its environments`;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 rounded-[14px] card border p-4`,children:[(0,q.jsx)(`legend`,{className:`sr-only`,children:`Where it works`}),(0,q.jsx)(`span`,{className:`text-[15px] font-semibold`,children:`Where it works`}),(0,q.jsx)(`span`,{className:`text-[13px] text-muted`,children:`Every run, test and call goes only here. In production it reads without asking, and a person approves every change.`}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,q.jsx)(ve,{items:e.environments.map(t=>({id:t,label:t,...e.production.includes(t)&&!/prod/i.test(t)?{note:`production`,noteClass:`text-warn`}:{}})),value:o,onChange:s})}),S&&(0,q.jsx)(`span`,{className:`text-[12.5px] text-warn`,children:`In production, it reads without asking; a person approves every change there, on a schedule too (it waits, and the team is told). Before a step that could reach real customers, it asks you itself.`})]}),(0,q.jsxs)(`section`,{"aria-labelledby":`build-may`,className:`flex flex-col rounded-[14px] card border px-4 py-1`,children:[(0,q.jsx)(`h2`,{id:`build-may`,className:`sr-only`,children:`What it may do`}),(0,q.jsx)(X,{text:`Read test cases, runs, reports and your systems' data`,on:!0,locked:`Always: it cannot work without it, and it changes nothing.`}),e.needs?.run&&(0,q.jsx)(X,{text:`Run tests and apps in ${ee}`,help:`Browser runs, tests, API calls and database queries.`,on:E(`run`),onChange:e=>D(`run`,e)}),e.needs?.run&&E(`run`)&&(0,q.jsx)(X,{text:`Ask me before each run`,help:`Recommended while it is new; turn it off once you trust it.`,on:u.includes(`run`),onChange:e=>O(`run`,e)}),e.needs?.run&&E(`run`)&&S&&(0,q.jsx)(X,{text:`Ask me before each run in production`,help:`Off: browser runs, tests and API calls there go ahead without asking. Each question also offers to allow the rest of the run.`,on:!b,onChange:e=>x(!e)}),(0,q.jsx)(X,{text:`Change test assets on this computer`,help:`Regression packs, API contracts, page memory, recordings. Off unless its job is to make them.`,on:E(`change`),onChange:e=>D(`change`,e)}),E(`change`)&&(0,q.jsx)(X,{text:`Ask me before each change`,on:u.includes(`change`),onChange:e=>O(`change`,e)}),e.needs?.external&&(0,q.jsx)(X,{text:`Change other systems as you asked`,help:`Work items or the team's channel, as you chose.`,on:E(`external`),onChange:e=>D(`external`,e)}),E(`external`)&&(0,q.jsx)(X,{text:`Ask me before each change to another system`,help:`Recommended. Off: it comments, updates and attaches as its job says, without asking.`,on:!v.includes(`external`),onChange:e=>C(`external`,!e)}),e.needs?.repository&&(0,q.jsx)(X,{text:`Change your repository to write or heal tests`,help:`A coding agent does it on this computer.`,on:m===`write`,onChange:e=>(h(e?`write`:`read`),e&&D(`change`,!0))}),e.needs?.repository&&m===`write`&&(0,q.jsx)(X,{text:`Ask me before the coding agent works`,help:`Off: it writes and heals tests without asking. The tests it runs can reach any address, so ForgeQE first looks in your test project's config and env files, and asks you when they name an address outside its environments.`,on:!v.includes(`coding`),onChange:e=>C(`coding`,!e)}),(0,q.jsx)(X,{text:`Use the shell`,help:`Commands on this computer, and fetching web pages. A person approves each one; ForgeQE's secrets stay out of reach.`,on:f,onChange:p})]}),e.schedule&&(0,q.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 rounded-[14px] card border p-4`,children:[(0,q.jsx)(`legend`,{className:`sr-only`,children:`What it may do alone`}),(0,q.jsxs)(`span`,{className:`text-[15px] font-semibold`,children:[`When it runs `,e.schedule.toLowerCase(),`, with nobody watching`]}),(0,q.jsx)(`span`,{className:`text-[13px] text-muted`,children:`What it may do without asking. Anything else waits for a person: the team is told, and no answer in four hours is a no. It may always ask a person itself.`}),(0,q.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[E(`run`)&&(0,q.jsx)(Y,{on:g.includes(`run`),label:`Run tests and apps`,why:`Recommended: what it is there to do.`,recommended:!0,onToggle:()=>_(T(g,`run`))}),E(`change`)&&(0,q.jsx)(Y,{on:g.includes(`change`),label:`Change test assets`,onToggle:()=>_(T(g,`change`))}),m===`write`&&v.includes(`coding`)&&(0,q.jsx)(Y,{on:g.includes(`coding`),label:`Write or heal tests`,why:`The coding agent, when its test project names no address outside its environments.`,onToggle:()=>_(T(g,`coding`))}),w.map(e=>(0,q.jsx)(Y,{on:g.includes(`${e.capability.slice(7)}_*`),label:`Change ${e.title.replace(/^Work with /,``)}`,why:`Comment, update states, attach evidence, without a person approving each.`,onToggle:()=>_(T(g,`${e.capability.slice(7)}_*`))},e.capability))]})]}),(0,q.jsx)(Qt,{busy:t,onBack:r,next:i,onNext:()=>n({environments:o,actions:c,approve:u,repository:m,shell:f,unattended:g,trust:v,production:b?[`run`]:[]}),disabled:!o.length})]})}function rn({v:e,busy:t,onNext:n,onBack:r,next:i}){let a=e.knowledge,[o,s]=(0,K.useState)(a.files.filter(e=>e.on).map(e=>e.file)),[c,l]=(0,K.useState)(a.skills.filter(e=>e.on).map(e=>e.name)),[u,d]=(0,K.useState)(a.notes),f=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],p=e=>[...e].sort((e,t)=>Number(!!t.why)-Number(!!e.why));return(0,q.jsxs)(q.Fragment,{children:[(a.files.length>0||a.skills.length>0)&&(0,q.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[p(a.files).map(e=>(0,q.jsx)(Y,{on:o.includes(e.file),label:e.title,why:e.why||e.file,recommended:e.on,onToggle:()=>s(f(o,e.file))},e.file)),p(a.skills).map(e=>(0,q.jsx)(Y,{on:c.includes(e.name),label:`Skill: ${e.name}`,why:e.why||e.about,recommended:e.on,onToggle:()=>l(f(c,e.name))},e.name))]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-[15px] font-semibold`,children:`Anything else it should know?`}),(0,q.jsx)(`span`,{className:`text-[13px] text-muted`,children:`Business rules, what “done” looks like, which test accounts to use (never passwords). It is kept as this agent's own knowledge.`}),(0,q.jsx)(ye,{rows:5,value:u,maxLength:2e4,onChange:e=>d(e.target.value),placeholder:`A declined card shows “Payment failed” and keeps the basket.`})]}),(0,q.jsx)(Qt,{busy:t,onBack:r,next:i,onNext:()=>n({files:o,skills:c,notes:u})})]})}function an({v:e,busy:t,onNext:n,onBack:r,next:i}){let a=e.review,[o,s]=(0,K.useState)(a.name),[c,u]=(0,K.useState)(a.id),[d,f]=(0,K.useState)(a.description),[p,m]=(0,K.useState)(a.icon||`context-engine`),[h,g]=(0,K.useState)(a.starters[0]?.text||e.goal),_=e.plan.filter(e=>e.on),v=e.boundaries,y=e.knowledge,b=[[`It works in`,v.environments.join(`, `)],[`It does`,_.map(e=>e.title).join(`; `)],[`It may`,[v.actions.includes(`run`)?`run tests and apps${v.approve.includes(`run`)?` (asking you first)`:``}`:``,v.actions.includes(`change`)?`change test assets`:``,v.actions.includes(`external`)?`change other systems${(v.trust||[]).includes(`external`)?` (without asking)`:` (asking you first)`}`:``,v.repository===`write`?`write or heal tests${(v.trust||[]).includes(`coding`)?` (without asking, unless its test project names an address outside its environments)`:` (asking you first)`}`:``].filter(Boolean).join(`; `)||`only read`],[`Runs by itself`,e.schedule?`${e.schedule.toLowerCase()}, with nobody watching${v.unattended.length?`; alone it may ${v.unattended.map(e=>e===`run`?`run tests and apps`:e===`change`?`change test assets`:e===`coding`?`write or heal tests`:`change ${e.replace(/_\*$/,``).replace(/_/g,` `)}`).join(`, `)}`:``}`:`no: you, your team or the Orchestrator start it`],...v.shell?[[`Shell`,`yes, a person approves each command`]]:[],[`It knows`,[...y.files.filter(e=>e.on).map(e=>e.title),...y.skills.filter(e=>e.on).map(e=>e.name),...y.notes.trim()?[`your notes`]:[]].join(`, `)||`nothing extra`]];return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:`Name`}),(0,q.jsx)(P,{value:o,maxLength:60,onChange:e=>s(e.target.value)})]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:`Id`}),(0,q.jsx)(P,{value:c,maxLength:40,spellCheck:!1,disabled:!!e.saved,onChange:e=>u(e.target.value.toLowerCase())})]})]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:`What it is for`}),(0,q.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:`One line. The Orchestrator reads it to know when to hand it work.`}),(0,q.jsx)(P,{value:d,maxLength:300,onChange:e=>f(e.target.value)})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:`Icon`}),(0,q.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:`What it wears on the Agents page. Pick one of ForgeQE's agent icons.`}),(0,q.jsx)(Wt,{value:p,onChange:m})]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:`Its first request`}),(0,q.jsx)(P,{value:h,maxLength:500,onChange:e=>g(e.target.value)})]}),(0,q.jsx)(`dl`,{className:`m-0 grid grid-cols-1 gap-x-6 gap-y-2 rounded-[14px] bg-surface-muted px-4 py-3 text-sm sm:grid-cols-[140px_1fr]`,children:b.map(([e,t])=>(0,q.jsxs)(`div`,{className:`contents`,children:[(0,q.jsx)(`dt`,{className:`text-muted`,children:e}),(0,q.jsx)(`dd`,{className:`m-0 text-ink [overflow-wrap:anywhere]`,children:t})]},e))}),e.advice.filter(e=>e.blocking).length>0&&(0,q.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:e.advice.filter(e=>e.blocking).map((e,t)=>(0,q.jsxs)(`li`,{className:`flex flex-col gap-0.5 rounded-[12px] bg-warn-soft px-4 py-3 text-sm`,children:[(0,q.jsx)(`span`,{className:`font-medium text-warn`,children:e.about}),(0,q.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:e.fix})]},t))}),(0,q.jsx)(Qt,{busy:t,onBack:r,next:e.saved?`Save the changes`:i,onNext:()=>n({name:o,id:c,description:d,icon:p,starters:[{label:`Run it now`,text:h}]}),disabled:!o.trim()||!c.trim(),aside:(0,q.jsxs)(`a`,{href:e.saved?I(`agents`,`custom`,e.saved,`edit`):I(`agents`,`custom`,`new`,`form`),className:`inline-flex items-center gap-1.5`,children:[(0,q.jsx)(l,{size:14,"aria-hidden":`true`}),`Advanced settings`]})})]})}function on({v:e}){let t=e.saved,[n,r]=(0,K.useState)(e.review?.starters[0]?.text||e.goal),[i,a]=(0,K.useState)(``),[o,c]=(0,K.useState)(!1),[l,u]=(0,K.useState)(``),[d,f]=(0,K.useState)(!1),p=async()=>{c(!0);try{let{id:e}=await be.start(n.trim(),{agent:t,try:!0});location.hash=I(`chats`,e)}catch(e){u(e.message),c(!1)}},m=async()=>{c(!0),u(``);try{await R.act(t,`approve`,{confirm:i,note:`Made with the agent builder`}),f(!0)}catch(e){u(e.message)}finally{c(!1)}};return d?(0,q.jsxs)(`div`,{className:`flex flex-col items-start gap-3 rounded-[14px] bg-pass-soft px-4 py-4`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-2 text-[15px] font-semibold text-pass`,children:[(0,q.jsx)(k,{size:18,"aria-hidden":`true`}),U(e.review?.name||`agent`,!0),` is ready.`]}),(0,q.jsx)(`span`,{className:`text-sm text-ink-2`,children:`You, your team and the Orchestrator can hand it work now.`}),(0,q.jsxs)(`a`,{href:I(`agents`,`custom`,t),className:j(B({variant:`primary`,size:`sm`}),`no-underline`),"data-tip":`Open the agent`,children:[(0,q.jsx)(A,{"aria-hidden":`true`}),`Open`]})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`section`,{"aria-labelledby":`build-try`,className:`flex flex-col gap-2 rounded-[14px] card border p-4`,children:[(0,q.jsx)(`h2`,{id:`build-try`,className:`m-0 text-[15px] font-semibold`,children:`1. Try it on a real request`}),(0,q.jsx)(ye,{rows:2,"aria-label":`What to try`,value:n,onChange:e=>r(e.target.value)}),(0,q.jsxs)(M,{variant:`primary`,size:`sm`,className:`self-start`,disabled:o||!n.trim(),onClick:()=>void p(),"data-tip":`Try it in a chat`,children:[(0,q.jsx)(s,{"aria-hidden":`true`}),`Try`]}),(0,q.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:`It opens as a chat. Come back here to approve it: Agents, Custom agents, then this agent.`})]}),(0,q.jsxs)(`section`,{"aria-labelledby":`build-approve`,className:`flex flex-col gap-2 rounded-[14px] card border p-4`,children:[(0,q.jsx)(`h2`,{id:`build-approve`,className:`m-0 text-[15px] font-semibold`,children:`2. Approve it`}),(0,q.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[`Only an approved version runs. Type its id to confirm: `,t]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(P,{"aria-label":`Type ${t} to confirm`,className:`w-[260px]`,value:i,spellCheck:!1,autoComplete:`off`,onChange:e=>a(e.target.value),placeholder:t}),(0,q.jsxs)(M,{size:`sm`,disabled:o||i!==t,onClick:()=>void m(),children:[(0,q.jsx)(k,{"aria-hidden":`true`}),`Approve`]})]})]}),l&&(0,q.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-fail [overflow-wrap:anywhere]`,children:l}),(0,q.jsx)(`a`,{href:I(`agents`,`custom`,t),className:`self-start text-[13px]`,children:`Open its page`})]})}function sn({id:e}){let[t,n]=(0,K.useState)(null),[r,i]=(0,K.useState)(``),[a,o]=(0,K.useState)(!1),s=(0,K.useCallback)(()=>{R.view(e).then(e=>{ke([{id:e.id,icon:e.icon}]),n(e),i(``)},e=>i(e.message))},[e]);(0,K.useEffect)(()=>s(),[s]);let[c,l]=(0,K.useState)(null);return $e.test(e)?(0,q.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[t?(0,q.jsx)(ln,{view:t,detailsOpen:a,onDetails:o}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`header`,{className:`flex items-center gap-1 px-5 py-3.5 short:py-2`,children:[(0,q.jsx)(qe,{}),(0,q.jsxs)(`a`,{href:I(`agents`,`category`,`custom`),className:`inline-flex min-h-9 items-center gap-1.5 text-sm`,children:[(0,q.jsx)(w,{size:16,"aria-hidden":`true`}),`Custom agents`]})]}),(0,q.jsx)(`main`,{className:`flex flex-auto flex-col items-center justify-center px-5 py-10`,children:r?(0,q.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:r}):(0,q.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`})})]}),t&&c&&(0,q.jsx)(Cn,{view:t,action:c.action,to:c.to,onClose:()=>l(null),onDone:e=>{`deleted`in e?(l(null),location.hash=I(`agents`,`category`,`custom`)):(n(e),l(null))}}),t&&(0,q.jsx)(hn,{view:t,open:a,onClose:()=>o(!1),onAct:l})]}):(0,q.jsx)(cn,{})}function cn(){return(0,q.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,q.jsx)(`header`,{className:`flex items-center gap-1 px-5 py-3.5`,children:(0,q.jsx)(qe,{})}),(0,q.jsxs)(`p`,{className:`m-0 px-6 py-10 text-sm text-muted`,children:[`There is no such agent. `,(0,q.jsx)(`a`,{href:I(`agents`),children:`See every agent`}),`.`]})]})}var Z=e=>e.length?e.join(`, `):`none`;function ln({view:e,detailsOpen:t,onDetails:n}){let r=dt(),i=[...e.problems.working,...e.problems.active,...e.problems.other],o=e.state===`active`||e.state===`changed`,c=!!e.working,l=J[e.state],[u,d]=(0,K.useState)(e.starters[0]?.text||``),[f,p]=(0,K.useState)(``),[m,h]=(0,K.useState)(``),[g,_]=(0,K.useState)(!1),v=st(),{setup:y}=v,b=`custom-agent-${e.id}`,S=et(u,e=>{d(e),p(``)},b,{code:v.tools.code}),C=ot(`custom-${e.id}`,e=>{d(e),at(b)}),T=async()=>{h(``);try{let t=await R.pack(e.id),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${e.id}.forgeqe-agent.zip`,r.click(),setTimeout(()=>URL.revokeObjectURL(n),1e3),h(`Zip downloaded. A teammate imports it as a draft, then edits and approves it.`)}catch(e){h(e.message)}},E=async(t,n=u)=>{if(!(g||!n.trim()&&!S.hasFiles)&&(t||o)&&(!t||c)){_(!0),p(``);try{let r=await S.wrap(n.trim());if(!r.trim()){_(!1);return}let{id:i}=await be.start(r,{...v.choice,agent:e.id,...t||!o?{try:!0}:{}});S.reset({keep:!0}),location.hash=I(`chats`,i)}catch(e){p(e.message),_(!1)}}},D=!o&&!c;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`header`,{className:`flex items-center gap-1 px-5 py-3.5 short:py-2`,children:[(0,q.jsx)(qe,{}),(0,q.jsxs)(`a`,{href:I(`agents`,`category`,`custom`),className:`inline-flex min-h-9 items-center gap-1.5 text-sm`,children:[(0,q.jsx)(w,{size:16,"aria-hidden":`true`}),`Custom agents`]}),(0,q.jsxs)(`span`,{className:`ml-auto flex items-center gap-1`,children:[(0,q.jsx)(F,{tone:l.tone,children:l.label}),(0,q.jsx)(M,{variant:`icon`,size:`icon`,onClick:()=>void T(),"aria-label":`Export to share`,"data-tip":`Export to share`,children:(0,q.jsx)(ie,{size:18,"aria-hidden":`true`})}),(0,q.jsx)(M,{variant:`icon`,size:`icon`,onClick:()=>n(!t),"aria-label":`Details`,"aria-pressed":t,"data-tip":`Details`,children:(0,q.jsx)(a,{size:18,"aria-hidden":`true`})}),(0,q.jsx)(`a`,{href:I(`agents`,`custom`,e.id,`edit`),className:j(B({variant:`icon`,size:`icon`}),`no-underline`),"aria-label":`Edit`,"data-tip":`Edit`,children:(0,q.jsx)(x,{size:18,"aria-hidden":`true`})})]})]}),(0,q.jsx)(`main`,{className:`flex flex-auto flex-col items-center justify-center px-5 pt-6 pb-[120px] short:pt-0 short:pb-8`,children:(0,q.jsxs)(`div`,{className:`flex w-full max-w-[780px] flex-col items-center gap-9 short:gap-6`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col items-center gap-3.5 text-center short:gap-2.5`,children:[(0,q.jsx)(Ke,{agent:e.id,icon:e.icon,px:r?64:96,decorative:!0,working:g,className:`mb-1`}),(0,q.jsx)(`h1`,{className:`m-0 text-[34px] leading-tight font-semibold tracking-[-0.015em] text-ink short:text-[28px] [overflow-wrap:anywhere]`,children:e.name}),(0,q.jsx)(`p`,{className:`m-0 max-w-[52ch] text-[15px] leading-relaxed text-ink-2 short:max-w-[72ch]`,children:e.description||(o?`Ask ${U(e.name)}. It runs version ${e.approvedVersion}, within its limits.`:c?`Try ${U(e.name)}. It has no approved version yet: a try runs its manifest as it is.`:`Fix ${U(e.name)}'s manifest before it can be tried or approved.`)})]}),m&&(0,q.jsx)(`p`,{role:`status`,className:j(`m-0 -mt-4 text-center text-[13px]`,/downloaded|Zip/.test(m)?`text-muted`:`text-fail`),children:m}),i.length>0&&(0,q.jsxs)(`div`,{role:`alert`,className:`flex w-full flex-col gap-1 rounded-[12px] bg-fail-soft px-4 py-3 text-left text-sm text-fail`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:e.state===`invalid`?`Its manifest needs fixing before it can be tried or approved:`:`It cannot run as it is:`}),(0,q.jsx)(`ul`,{className:`m-0 list-disc pl-5 [overflow-wrap:anywhere]`,children:i.map((e,t)=>(0,q.jsx)(`li`,{children:e},t))})]}),(0,q.jsx)(dn,{agent:e.id}),e.state===`changed`&&e.changes.length>0&&(0,q.jsxs)(`section`,{"aria-labelledby":`ca-changes`,className:`flex w-full flex-col gap-2 text-left`,children:[(0,q.jsxs)(`h2`,{id:`ca-changes`,className:`m-0 text-[13px] font-semibold text-muted`,children:[`Changed since `,e.approvedVersion,` was approved`]}),(0,q.jsx)(`p`,{className:`m-0 text-[13px] text-muted`,children:`The approved version keeps running until this change is approved.`}),(0,q.jsx)(ht,{diff:e.changes})]}),D?(0,q.jsx)(`p`,{className:`m-0 max-w-[54ch] text-center text-sm text-muted`,children:`Open Details for what is wrong, or Edit the agent.`}):(0,q.jsxs)(q.Fragment,{children:[y&&!y.ready&&(0,q.jsx)(nt,{project:y.project}),y?.ready&&(0,q.jsx)(rt,{c:v}),(0,q.jsx)(lt,{id:b,label:`Message ${U(e.name)}`,value:u,onChange:e=>{d(e),p(``)},onSend:()=>void E(!o),disabled:g||!!y&&!y.ready||C.running,canSend:!!u.trim()||S.hasFiles,onEdit:S.onEdit,onKey:S.onKeyDown,onFiles:S.onFiles,dropping:S.dropping,drop:S.drop,mentions:S.mentions,combo:S.combo,placeholder:`Ask ${U(e.name)} to…`,top:(0,q.jsxs)(q.Fragment,{children:[S.chips,C.state&&(0,q.jsx)(it,{state:C.state,onStop:()=>void C.stop(),onUndo:C.undo,onClose:C.close})]}),left:(0,q.jsxs)(q.Fragment,{children:[S.paperclip,(0,q.jsx)(ut,{c:v}),(0,q.jsx)(ct,{running:C.running,disabled:!u.trim()||g||!!y&&!y.ready,onClick:()=>void C.start(u)})]}),right:(0,q.jsx)(tt,{c:v})}),(0,q.jsx)(`p`,{role:`status`,"aria-live":`polite`,className:j(`-mt-5 m-0 text-center text-sm text-ink-2 short:-mt-3`,!(f||S.error)&&`sr-only`),children:(0,q.jsx)(`span`,{className:S.error&&!f?`text-fail`:``,children:f||S.error||``})}),(0,q.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-3`,children:[e.starters.map(e=>(0,q.jsx)(M,{onClick:()=>{d(e.text),p(``),document.getElementById(b)?.focus()},children:e.label},e.label)),o&&c&&(0,q.jsxs)(M,{disabled:g||!u.trim(),onClick:()=>void E(!0),"data-tip":`Try the manifest`,children:[(0,q.jsx)(s,{"aria-hidden":`true`}),`Try`]})]})]}),(0,q.jsx)(un,{view:e})]})})]})}function un({view:e}){let t=e.capabilities;if(!t.length)return null;let n=t.some(e=>e.state===`needs_setup`)?`needs_setup`:t.some(e=>e.state===`partial`)?`partial`:`ready`,r=n===`ready`?`pass`:n===`partial`?`warn`:`neutral`,i=n===`ready`?`Ready`:n===`partial`?`Partly set up`:`Needs setup`,a=t.filter(e=>e.state!==`ready`);return(0,q.jsxs)(`div`,{className:`flex w-full flex-col gap-6 pt-2 text-left`,children:[a.length>0&&(0,q.jsxs)(`section`,{"aria-labelledby":`ca-needs`,className:`flex flex-col gap-2`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`h2`,{id:`ca-needs`,className:`m-0 text-[13px] font-semibold text-muted`,children:`What it needs`}),(0,q.jsx)(F,{tone:r,children:i})]}),(0,q.jsx)(`p`,{className:`m-0 text-[12.5px] text-muted`,children:n===`needs_setup`?`${U(e.name,!0)} cannot work until these are set up.`:`${U(e.name,!0)} works, without the parts below.`}),(0,q.jsx)(`ul`,{"aria-label":`What ${U(e.name)} needs`,className:`m-0 flex list-none flex-col rounded-[12px] card border p-0`,children:a.map((e,t)=>(0,q.jsxs)(`li`,{className:j(`flex items-center gap-3 px-3 py-2.5`,t>0&&`border-t border-line-soft`),children:[(0,q.jsx)(L,{icon:mn[e.state].icon,size:16,className:j(`flex-none`,mn[e.state].cls)}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,q.jsx)(`span`,{className:`text-[14px] font-medium`,children:e.title}),(0,q.jsx)(`span`,{className:`text-[12.5px] text-muted [overflow-wrap:anywhere]`,children:e.gaps.join(`; `)||mn[e.state].label})]})]},e.id))})]}),(0,q.jsxs)(`section`,{"aria-labelledby":`ca-caps`,className:`flex flex-col gap-2`,children:[(0,q.jsx)(`h2`,{id:`ca-caps`,className:`m-0 text-[13px] font-semibold text-muted`,children:`What it can use`}),(0,q.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-0`,children:t.map((e,t)=>{let n=mn[e.state];return(0,q.jsxs)(`li`,{className:j(`flex items-start gap-3 px-3 py-2.5`,t>0&&`border-t border-line-soft`),children:[(0,q.jsx)(L,{icon:n.icon,size:16,className:j(`mt-0.5 flex-none`,n.cls)}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,q.jsx)(`span`,{className:`text-[14px] font-medium`,children:e.title}),(0,q.jsxs)(`span`,{className:`text-[12.5px] text-muted`,children:[n.label,e.gaps.length?`: ${e.gaps.join(`; `)}`:``]})]})]},e.id)})})]})]})}function dn({agent:e}){let[t,n]=(0,K.useState)([]),[r,a]=(0,K.useState)(``),[o,s]=(0,K.useState)(``),c=(0,K.useCallback)(()=>{le.list().then(t=>n(t.approvals.filter(t=>t.agent===e&&t.state===`waiting`)),()=>{})},[e]);if((0,K.useEffect)(()=>{c();let e=setInterval(c,15e3);return()=>clearInterval(e)},[c]),!t.length)return null;let l=async(t,n)=>{a(t.id),s(``);try{await le.answer(e,t.id,n),c()}catch(e){s(e.message)}finally{a(``)}};return(0,q.jsxs)(`section`,{"aria-labelledby":`ca-waiting`,className:`flex w-full flex-col gap-2 rounded-[14px] border border-warn bg-warn-soft p-4 text-left`,children:[(0,q.jsx)(`h2`,{id:`ca-waiting`,className:`m-0 text-base font-semibold text-warn`,children:`Waiting for you`}),(0,q.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-3 p-0`,children:t.map(e=>(0,q.jsxs)(`li`,{className:`flex flex-wrap items-start gap-3 rounded-[12px] bg-bg px-4 py-3`,children:[(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-[1_1_320px] flex-col gap-0.5`,children:[(0,q.jsx)(`span`,{className:`text-[14px] font-medium [overflow-wrap:anywhere]`,children:e.title}),e.detail&&(0,q.jsx)(`span`,{className:`text-[13px] text-ink-2 [overflow-wrap:anywhere]`,children:e.detail}),(e.lines||[]).map((e,t)=>(0,q.jsx)(`span`,{className:`text-[12.5px] text-muted [overflow-wrap:anywhere]`,children:e},t)),(0,q.jsxs)(`span`,{className:`text-[12px] text-muted`,children:[`Asked `,pt(e.createdAt),`; no answer by `,e.until.slice(0,16).replace(`T`,` `),` UTC is a no.`]})]}),(0,q.jsxs)(`span`,{className:`flex gap-2`,children:[(0,q.jsxs)(M,{size:`sm`,variant:`primary`,disabled:!!r,onClick:()=>void l(e,`allow`),children:[(0,q.jsx)(i,{"aria-hidden":`true`}),`Allow`]}),e.forRun&&(0,q.jsxs)(M,{size:`sm`,variant:`outline`,disabled:!!r,onClick:()=>void l(e,`allow_run`),"data-tip":`Allow for the rest of this run`,children:[(0,q.jsx)(i,{"aria-hidden":`true`}),`Allow run`]}),(0,q.jsxs)(M,{size:`sm`,variant:`ghost`,disabled:!!r,onClick:()=>void l(e,`deny`),children:[(0,q.jsx)(u,{"aria-hidden":`true`}),`Deny`]})]})]},e.id))}),o&&(0,q.jsx)(`p`,{className:`m-0 text-[13px] text-fail`,children:o})]})}var fn={approved:`Approved`,disabled:`Disabled`,enabled:`Enabled`,"rolled-back":`Rolled back to`};function pn(e){let t=/\s*\(web\)$/i.test(e),n=e.replace(/\s*\(web\)$/i,``).trim(),r=/^(?:\d+\+)?([^@\s]+)@users\.noreply\.github\.com$/i.exec(n);return r?n=r[1]:n.includes(`@`)&&n.length>24&&(n=n.slice(0,n.indexOf(`@`))),t?`${n} · web`:n}var mn={ready:{icon:k,label:`Ready`,cls:`text-pass`},partial:{icon:f,label:`Partly set up`,cls:`text-warn`},needs_setup:{icon:u,label:`Needs setup`,cls:`text-muted`}};function hn({view:e,open:t,onClose:n,onAct:i}){let a=e.active||e.working,o=!!e.working&&(e.state===`draft`||e.state===`changed`||e.state===`broken`&&e.working!==void 0);return(0,q.jsx)(je,{open:t,onClose:n,wide:!0,title:`Details`,description:`${e.name} · ${e.id}`,footer:(0,q.jsxs)(M,{variant:`ghost`,onClick:n,children:[(0,q.jsx)(r,{"aria-hidden":`true`}),`Close`]}),children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[a&&(0,q.jsx)(_n,{spec:a,view:e}),(0,q.jsx)(vn,{view:e,approvable:o,onAct:i}),(0,q.jsx)(xn,{view:e})]})})}function gn({id:e,title:t,children:n,aside:r}){return(0,q.jsxs)(`section`,{"aria-labelledby":e,className:`flex flex-col gap-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,q.jsx)(`h2`,{id:e,className:`m-0 flex-1 text-[13px] font-semibold text-muted`,children:t}),r]}),n]})}function _n({spec:e,view:t}){let n=(t.active?t.describe?.active:t.describe?.working)||[],r=[...n.length?n.map(n=>[n.label,n.label===`Agents it may start`?Z(e.agents.map(e=>t.agentNames[e]||e)):n.text]):[[`Environments`,Z(e.environments)],[`Agents it may start`,Z(e.agents.map(e=>t.agentNames[e]||e))],[`It may`,Z(e.actions.map(e=>yn[e]||e))],[`A person approves first`,Z(e.approve.map(e=>yn[e]||e))],[`Repository`,e.repository===`write`?`may change files`:`read only`]],...n.some(e=>e.label===`Runs by itself`)?[]:[[`Runs by itself`,e.schedule?`${e.schedule.every?`every ${e.schedule.every}`:`at ${e.schedule.cron}`}: “${e.schedule.request}”`:`no: you, your team or the Orchestrator start it`]],[`Skills`,Z(e.skills)],[`Knowledge`,Z(e.knowledge)]];return(0,q.jsxs)(gn,{id:`ca-reach`,title:t.active?`What version ${t.approvedVersion} may reach`:`What its manifest may reach`,children:[(0,q.jsx)(`dl`,{className:`m-0 grid grid-cols-1 gap-x-6 gap-y-2 rounded-[12px] card border px-4 py-3 text-sm sm:grid-cols-[160px_1fr]`,children:r.map(([e,t])=>(0,q.jsxs)(`div`,{className:`contents`,children:[(0,q.jsx)(`dt`,{className:`text-muted`,children:e}),(0,q.jsx)(`dd`,{className:`m-0 text-ink [overflow-wrap:anywhere]`,children:t})]},e))}),e.policies.length>0&&(0,q.jsxs)(`p`,{className:`m-0 text-[13px] text-muted`,children:[`Guidance it is given (not a limit): `,e.policies.join(`; `)]})]})}function vn({view:e,approvable:t,onAct:n}){return(0,q.jsxs)(gn,{id:`ca-versions`,title:`Versions`,aside:(0,q.jsxs)(`span`,{className:`flex flex-wrap gap-2`,children:[t&&(0,q.jsxs)(M,{size:`sm`,onClick:()=>n({action:`approve`}),"data-tip":`Approve ${e.manifestVersion}`,children:[(0,q.jsx)(k,{"aria-hidden":`true`}),`Approve`]}),e.approvedVersion&&(0,q.jsxs)(M,{size:`sm`,variant:`ghost`,onClick:()=>n({action:e.disabled?`enable`:`disable`}),children:[e.disabled?(0,q.jsx)(k,{"aria-hidden":`true`}):(0,q.jsx)(u,{"aria-hidden":`true`}),e.disabled?`Enable`:`Disable`]}),(0,q.jsxs)(M,{size:`sm`,variant:`danger`,onClick:()=>n({action:`delete`}),children:[(0,q.jsx)(ne,{"aria-hidden":`true`}),`Delete`]})]}),children:[e.tried&&e.manifestVersion&&(0,q.jsxs)(`p`,{className:`m-0 text-[13px] text-muted`,children:[`Last try of manifest `,e.manifestVersion,`: `,e.tried.outcome,`.`]}),e.events.length===0?(0,q.jsx)(z,{className:`py-4`,children:`No version has been approved yet. Try it, then approve it: only an approved version runs, for you, your team and the Orchestrator.`}):(0,q.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-1.5`,children:[...e.events].reverse().map((t,r)=>{let i=t.event===`approved`||t.event===`rolled-back`?t.version===e.approvedVersion:!1,a=t.event===`approved`&&t.version!==e.approvedVersion&&!e.events.slice(e.events.indexOf(t)+1).some(e=>e.event===`approved`&&e.version===t.version);return(0,q.jsxs)(`li`,{className:`flex min-h-11 flex-wrap items-center gap-3 rounded-[8px] px-3 py-1.5`,children:[(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-[14px] font-medium`,children:[(0,q.jsxs)(`span`,{children:[fn[t.event],` `,t.version]}),i&&r===0?(0,q.jsx)(F,{tone:`pass`,children:`Running`}):null]}),(0,q.jsxs)(`span`,{className:`text-[12.5px] text-muted [overflow-wrap:anywhere]`,children:[pn(t.by),` · `,pt(t.at),t.note?` · ${t.note}`:``,t.tried?` · tried: ${t.tried.outcome}`:``]})]}),a&&(0,q.jsx)(M,{size:`sm`,variant:`ghost`,onClick:()=>n({action:`rollback`,to:t.version}),"aria-label":`Roll back to ${t.version}`,"data-tip":`Roll back to ${t.version}`,children:(0,q.jsx)(c,{"aria-hidden":`true`})})]},`${t.at}-${r}`)})})]})}var yn={read:`read`,run:`run tests and apps`,change:`change files`,external:`change other systems`,schedule:`schedule work`},bn={run:`Asked`,try:`Tried`,orchestrator:`From the Orchestrator`};function xn({view:e}){let[t,n]=(0,K.useState)(``),r=async()=>{n(``);try{let t=await R.audit(e.id),n=URL.createObjectURL(new Blob([t],{type:`application/x-ndjson;charset=utf-8`})),r=document.createElement(`a`);r.href=n,r.download=`${e.id}-audit.jsonl`,r.click(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}catch(e){n(e.message)}};return(0,q.jsxs)(gn,{id:`ca-runs`,title:`Recent runs`,aside:(0,q.jsxs)(M,{size:`sm`,variant:`ghost`,onClick:()=>void r(),"data-tip":`Download its whole record, for audit`,children:[(0,q.jsx)(ie,{"aria-hidden":`true`}),`Download`]}),children:[t&&(0,q.jsx)(`p`,{className:`m-0 text-[13px] text-fail`,children:t}),e.runs.length===0?(0,q.jsxs)(z,{className:`py-4`,children:[U(e.name,!0),` has not run yet.`]}):(0,q.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-0`,children:e.runs.map((e,t)=>(0,q.jsx)(`li`,{className:j(t>0&&`border-t border-line-soft`),children:(0,q.jsxs)(`details`,{className:`group px-3 py-2.5`,children:[(0,q.jsxs)(`summary`,{className:`flex cursor-pointer list-none flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,q.jsx)(F,{tone:e.outcome===`done`?`pass`:e.outcome===`running`?`running`:e.outcome===`stopped`||e.outcome===`needs_input`?`neutral`:`fail`,children:e.outcome.replace(`_`,` `)}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[14px] font-medium`,"data-tip":e.request,children:e.request}),(0,q.jsxs)(`span`,{className:`text-[12.5px] text-muted tabular-nums`,children:[bn[e.trigger],` · `,e.version,` · `,e.calls,` `,e.calls===1?`call`:`calls`,e.refused?`, ${e.refused} refused`:``,` · `,pt(e.startedAt)]})]}),(0,q.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2 pl-1 text-[13px]`,children:[(0,q.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,q.jsxs)(`span`,{className:`text-muted`,children:[`By `,e.by]}),e.session&&(0,q.jsxs)(`a`,{href:I(`runs`,encodeURIComponent(e.session)),className:`inline-flex items-center gap-1`,children:[`Open the run`,(0,q.jsx)(A,{size:14,"aria-hidden":`true`})]})]}),e.error&&(0,q.jsx)(`span`,{className:`text-fail [overflow-wrap:anywhere]`,children:e.error}),e.decisions.length>0&&(0,q.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:e.decisions.map((e,t)=>(0,q.jsxs)(`li`,{className:`flex items-start gap-2`,children:[e.allowed?(0,q.jsx)(k,{size:14,"aria-label":`Allowed`,className:`mt-0.5 flex-none text-pass`}):(0,q.jsx)(T,{size:14,"aria-label":`Refused`,className:`mt-0.5 flex-none text-fail`}),(0,q.jsxs)(`span`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:[(0,q.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.tool}),e.allowed?(0,q.jsxs)(`span`,{className:`text-muted`,children:[` · `,yn[e.action||``]||e.action,e.approved?`, approved by a person`:``]}):(0,q.jsxs)(`span`,{className:`text-fail`,children:[` · `,e.reason]})]})]},t))})]})]})},e.run))})]})}var Sn={approve:{title:`Approve this version`,button:`Approve`,icon:k},disable:{title:`Disable this agent`,button:`Disable`,icon:u},enable:{title:`Enable this agent`,button:`Enable`,icon:k},rollback:{title:`Run an earlier version`,button:`Roll back`,icon:c},delete:{title:`Delete this agent`,button:`Delete`,icon:ne}};function Cn({view:e,action:t,to:n,onClose:i,onDone:a}){let[o,s]=(0,K.useState)(``),[c,l]=(0,K.useState)(``),[u,d]=(0,K.useState)(!1),[f,p]=(0,K.useState)(``),m=Sn[t],h=t===`approve`?`Version ${e.manifestVersion} becomes what runs, for you, your team and the Orchestrator${e.approvedVersion?`, in place of ${e.approvedVersion}`:``}.${e.tried?` Its last try: ${e.tried.outcome}.`:` It was never tried.`} Commit .forgeqe/agents/.releases/${e.id} so your team has it.`:t===`disable`?`Nothing of it runs (not you, your team, the Orchestrator or its schedule) until a person enables it again, here or with forgeqe agent enable.`:t===`enable`?`Version ${e.approvedVersion} runs again.`:t===`delete`?`${e.name} will be removed for good: its manifest, approved versions, runs and waiting approvals. Knowledge files and skills it named stay in the project.`:`Version ${n} runs from now on, in place of ${e.approvedVersion}.`,g=async()=>{d(!0),p(``);try{a(await R.act(e.id,t,{confirm:o,...c.trim()?{note:c.trim()}:{},...n?{to:n}:{}}))}catch(e){p(e.message),d(!1)}};return(0,q.jsx)(je,{open:!0,onClose:i,title:m.title,description:h,footer:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(M,{variant:`ghost`,onClick:i,children:[(0,q.jsx)(r,{"aria-hidden":`true`}),`Cancel`]}),(0,q.jsxs)(M,{variant:t===`delete`?`destructive`:`primary`,disabled:u||o!==e.id,onClick:()=>void g(),children:[(0,q.jsx)(m.icon,{"aria-hidden":`true`}),m.button]})]}),children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,q.jsxs)(`span`,{children:[`Type `,(0,q.jsx)(`span`,{className:`font-mono`,children:e.id}),` to confirm`]}),(0,q.jsx)(P,{value:o,onChange:e=>s(e.target.value),autoComplete:`off`,spellCheck:!1})]}),(0,q.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,q.jsx)(`span`,{children:`Note (optional)`}),(0,q.jsx)(P,{value:c,maxLength:200,onChange:e=>l(e.target.value),placeholder:t===`rollback`?`Why it goes back`:`What changed, or why`})]}),f&&(0,q.jsx)(`p`,{role:`alert`,className:`m-0 text-sm text-fail [overflow-wrap:anywhere]`,children:f})]})})}var wn={id:``,name:``,version:`1.0.0`,icon:Re,description:``,instructions:``,scope:{agents:[],capabilities:[],skills:[],knowledge:[],environments:[]},permissions:{repository:`read`,actions:[`read`],approve:[]},runtime:{maxDelegationDepth:1},policies:[],starters:[]};function Tn(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^[^a-z]+/,``).replace(/-+$/,``).slice(0,40).replace(/-+$/,``)}var En={read:{label:`Read`,help:`Test cases, runs, reports, the repository, systems' data. Changes nothing.`},run:{label:`Run`,help:`Browser runs, tests, API calls and database queries, in its environments only.`},change:{label:`Change files`,help:`Test assets on this computer: packs, contracts, page memory, recordings.`},external:{label:`Change other systems`,help:`Work items, pull requests, pipelines, channels.`}},Dn={ready:{icon:k,label:`Ready`,cls:`text-pass`},partial:{icon:f,label:`Partly set up`,cls:`text-warn`},needs_setup:{icon:u,label:`Needs setup`,cls:`text-muted`}},Q=(e,t,n)=>n?[...new Set([...e,t])]:e.filter(e=>e!==t);function $({checked:e,onChange:t,disabled:n,children:r,help:i}){return(0,q.jsxs)(`label`,{className:j(`flex items-start gap-2.5 text-sm`,n?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,q.jsx)(mt,{checked:e,disabled:n,onCheckedChange:t,className:`mt-0.5`}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,q.jsx)(`span`,{className:`text-ink`,children:r}),i&&(0,q.jsx)(`span`,{className:`text-[12.5px] text-muted`,children:i})]})]})}function On({id:e,template:t}){let r=!e,[a,s]=(0,K.useState)(r&&!t?wn:null),[c,l]=(0,K.useState)(null),[u,d]=(0,K.useState)(null),[f,p]=(0,K.useState)(``),[m,h]=(0,K.useState)([]),[g,_]=(0,K.useState)([]),[v,y]=(0,K.useState)(!1),[b,x]=(0,K.useState)(!1),[S,C]=(0,K.useState)(!1);(0,K.useEffect)(()=>{R.choices().then(d,e=>p(e.message)),t&&R.template(t).then(e=>{l(e),s({...wn,...e.fields,scope:{...wn.scope,...e.fields.scope},permissions:{...wn.permissions,...e.fields.permissions}}),C(!0)},e=>p(e.message)),e&&R.view(e).then(t=>t.form?s({...wn,...t.form,runtime:{maxDelegationDepth:t.form.runtime.maxDelegationDepth,...t.form.runtime.maxTokens?{maxTokens:t.form.runtime.maxTokens}:{}}}):p(`${e}'s manifest is not one the editor can read. Fix it in .forgeqe/agents/${e}.yaml.`),e=>p(e.message))},[e,t]);let T=(0,K.useRef)(0);(0,K.useEffect)(()=>{if(!a)return;let e=++T.current;y(!0);let t=setTimeout(()=>{R.validate(a).then(t=>e===T.current&&(h(t.problems||[]),_(t.advice||[]),y(!1)),t=>e===T.current&&(h([t.message]),y(!1)))},350);return()=>clearTimeout(t)},[a]);let E=e=>s(t=>t&&{...t,...e}),D=e=>s(t=>t&&{...t,scope:{...t.scope,...e}}),O=e=>s(t=>t&&{...t,permissions:{...t.permissions,...e}}),ee=(0,K.useMemo)(()=>{let e=new Map;for(let t of u?.capabilities||[])e.set(t.area,[...e.get(t.area)||[],t]);return[...e]},[u]),k=async()=>{if(a){x(!0),p(``);try{let t=await R.save(a,r?{create:!0}:{id:e});location.hash=I(`agents`,`custom`,t.id)}catch(e){p(e.message),x(!1)}}},A=e?I(`agents`,`custom`,e):I(`agents`,`custom`,`new`);return(0,q.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,q.jsx)(Xe,{}),(0,q.jsxs)(`main`,{className:j(Ze,`settings-fields flex-auto gap-2`),children:[(0,q.jsxs)(`a`,{href:A,className:`mb-2 inline-flex items-center gap-1.5 self-start text-sm`,children:[(0,q.jsx)(w,{size:16,"aria-hidden":`true`}),e?`Back to the agent`:`Back to the builder`]}),(0,q.jsx)(`h1`,{className:`m-0 text-[26px] font-semibold tracking-[-0.01em]`,children:r?`New custom agent`:`Edit ${a?.name||e}`}),(0,q.jsx)(`p`,{className:`m-0 mb-2 max-w-[70ch] text-sm leading-relaxed text-ink-2`,children:r?c?`ForgeQE's ${c.title} template, filled from this project. Read every setting and change what does not fit: it is saved as a draft, and runs once a person has tried and approved it.`:`An agent for one job your team repeats. It uses ForgeQE's own agents, tools, skills and knowledge, and is held to the environments and actions you pick here, on every call. It runs once a person has tried and approved it.`:`Saving changes its manifest only. The approved version keeps running until this change is approved on its page.`}),f&&(0,q.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:f}),c&&u&&(0,q.jsxs)(`section`,{"aria-labelledby":`ca-template`,className:`mb-2 flex flex-col gap-2`,children:[(0,q.jsxs)(`h2`,{id:`ca-template`,className:`m-0 text-base font-semibold`,children:[`From the `,c.title,` template`]}),(0,q.jsxs)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:[c.systems.length>0&&(0,q.jsxs)(`li`,{className:`flex flex-col gap-0.5 rounded-[12px] bg-surface-muted px-4 py-3 text-sm`,children:[(0,q.jsxs)(`span`,{className:`font-medium text-ink`,children:[`It uses the tools of `,c.systems.map(e=>u?.systems.find(t=>t.name===e)?.label||e).join(`, `)]}),(0,q.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:`Through ForgeQE, which checks every call against what this agent may do. The editor has no field for them yet: they are kept as the template set them.`})]}),c.notes.map(e=>(0,q.jsx)(`li`,{className:`flex flex-col gap-0.5 rounded-[12px] bg-surface-muted px-4 py-3 text-sm`,children:(0,q.jsx)(`span`,{className:`font-medium text-ink`,children:e})},e))]})]}),r&&!t&&(0,q.jsx)(`p`,{className:`m-0 mb-2 text-sm`,children:(0,q.jsx)(`a`,{href:I(`agents`,`custom`,`new`),children:`Or say what it should do, and let ForgeQE build it with you`})}),!a||!u?!f&&(0,q.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(V,{first:!0,children:`What it is`}),(0,q.jsx)(H,{label:`Name`,help:`What it does, then “agent”: Checkout guard agent.`,htmlFor:`ca-name`,children:(0,q.jsx)(P,{id:`ca-name`,value:a.name,maxLength:60,onChange:e=>E({name:e.target.value,...r&&!S?{id:Tn(e.target.value)}:{}})})}),(0,q.jsx)(H,{label:`Id`,help:r?`Its file name and address: lower-case words and hyphens. It cannot change later.`:`It cannot change. Make a new agent for another id.`,htmlFor:`ca-id`,children:(0,q.jsx)(P,{id:`ca-id`,value:a.id,maxLength:40,disabled:!r,spellCheck:!1,onChange:e=>(C(!0),E({id:e.target.value.toLowerCase()}))})}),(0,q.jsx)(H,{label:`Version`,help:`Raise it for each change you approve: 1.0.0, then 1.1.0.`,htmlFor:`ca-version`,children:(0,q.jsx)(P,{id:`ca-version`,value:a.version,maxLength:14,onChange:e=>E({version:e.target.value})})}),(0,q.jsx)(H,{label:`Description`,help:`One line: what it is for. The Orchestrator reads it to know when to hand it work.`,htmlFor:`ca-desc`,stacked:!0,children:(0,q.jsx)(P,{id:`ca-desc`,value:a.description,maxLength:300,onChange:e=>E({description:e.target.value})})}),(0,q.jsx)(H,{label:`Icon`,help:`What it wears on the Agents page and its own page: one of ForgeQE's agent icons.`,htmlFor:`ca-icon`,stacked:!0,children:(0,q.jsx)(Wt,{id:`ca-icon`,value:a.icon,onChange:e=>E({icon:e})})}),(0,q.jsx)(H,{label:`Instructions`,help:`Its focus and how to work, in plain words. Guidance for the model: the limits below are what holds it.`,htmlFor:`ca-instr`,stacked:!0,children:(0,q.jsx)(ye,{id:`ca-instr`,rows:5,value:a.instructions,maxLength:8e3,onChange:e=>E({instructions:e.target.value})})}),(0,q.jsx)(V,{help:`Where its runs, tests and calls may go. In an environment named like production, reads go ahead, runs are asked unless you say otherwise, and every change is approved by a person.`,children:`Where it works`}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 py-3`,children:[u.environments.length===0&&(0,q.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`No environments in env.yaml yet. Add them in Settings, Environments.`}),u.environments.map(e=>(0,q.jsx)($,{checked:a.scope.environments.includes(e.name),onChange:t=>D({environments:Q(a.scope.environments,e.name,t)}),help:e.production?`Production: reads go ahead; a person approves every change there.`:void 0,children:e.name},e.name))]}),(0,q.jsx)(V,{help:`ForgeQE's capabilities it may use: their tools, and only theirs. Each says whether it is set up here.`,children:`What it can do`}),(0,q.jsx)(`div`,{className:`flex flex-col gap-4 py-3`,children:ee.map(([e,t])=>{let n=t.filter(e=>a.scope.capabilities.includes(e.id)).length;return(0,q.jsxs)(`details`,{open:n>0||void 0,className:`group rounded-[12px] card border px-3 py-2`,children:[(0,q.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 py-1 text-[14px] font-medium`,children:[(0,q.jsx)(o,{size:14,"aria-hidden":`true`,className:`flex-none text-muted transition-transform duration-200 group-open:rotate-90`}),(0,q.jsx)(`span`,{className:`flex-1`,children:e}),(0,q.jsx)(`span`,{className:`text-[12.5px] font-normal text-muted tabular-nums`,children:n?`${n} of ${t.length} picked`:`${t.length}`})]}),(0,q.jsx)(`div`,{className:`flex flex-col gap-2 pt-2 pb-1 pl-6`,children:t.map(e=>{let t=Dn[e.state];return(0,q.jsx)($,{checked:a.scope.capabilities.includes(e.id),onChange:t=>D({capabilities:Q(a.scope.capabilities,e.id,t)}),help:(0,q.jsxs)(`span`,{className:`flex items-start gap-1.5`,children:[(0,q.jsx)(L,{icon:t.icon,size:13,className:j(`mt-0.5 flex-none`,t.cls)}),(0,q.jsxs)(`span`,{children:[t.label,e.gaps.length?`: ${e.gaps.join(`; `)}`:``]})]}),children:(0,q.jsx)(`span`,{"data-tip":e.summary,children:e.title})},e.id)})})]},e)})}),(0,q.jsx)(V,{help:`ForgeQE's agents it may start: a capability that needs one (a browser run needs the Browser agent) is refused without it.`,children:`Agents it may use`}),(0,q.jsx)(`div`,{className:`flex flex-col gap-2 py-3`,children:u.agents.map(e=>(0,q.jsx)($,{checked:a.scope.agents.includes(e.name),onChange:t=>D({agents:Q(a.scope.agents,e.name,t)}),help:(0,q.jsx)(`span`,{className:`font-mono text-[11.5px]`,children:e.name}),children:e.title},e.name))}),(0,q.jsx)(V,{help:`Only these are loaded for it.`,children:`Skills and knowledge`}),(0,q.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 py-3 sm:grid-cols-2`,children:[(0,q.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0`,children:[(0,q.jsx)(`legend`,{className:`mb-1 p-0 text-[13px] font-semibold text-muted`,children:`Skills`}),u.skills.length===0&&(0,q.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`None in this project yet.`}),u.skills.map(e=>(0,q.jsx)($,{checked:a.scope.skills.includes(e.name),onChange:t=>D({skills:Q(a.scope.skills,e.name,t)}),help:e.about,children:e.name},e.name))]}),(0,q.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-2 border-0 p-0`,children:[(0,q.jsx)(`legend`,{className:`mb-1 p-0 text-[13px] font-semibold text-muted`,children:`Knowledge files`}),u.knowledge.length===0&&(0,q.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`None in .forgeqe/knowledge yet.`}),u.knowledge.map(e=>(0,q.jsx)($,{checked:a.scope.knowledge.includes(e.file),onChange:t=>D({knowledge:Q(a.scope.knowledge,e.file,t)}),help:e.title===e.file?void 0:e.title,children:e.file},e.file))]})]}),(0,q.jsx)(V,{help:`Enforced on every call. Ask first: a person approves each such call in the chat. In production, every call is asked.`,children:`What it may do`}),(0,q.jsx)(`div`,{className:`flex flex-col gap-2 py-3`,children:u.actions.map(e=>(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-6 gap-y-1`,children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-[1_1_320px]`,children:(0,q.jsx)($,{checked:a.permissions.actions.includes(e),onChange:t=>O({actions:Q(a.permissions.actions,e,t)}),help:En[e]?.help,children:En[e]?.label||e})}),(0,q.jsx)($,{checked:e===`external`?!(a.permissions.trust||[]).includes(`external`):a.permissions.approve.includes(e),disabled:!a.permissions.actions.includes(e),onChange:t=>O(e===`external`?{trust:Q(a.permissions.trust||[],`external`,!t)}:{approve:Q(a.permissions.approve,e,t)}),children:`Ask first`})]},e))}),(0,q.jsx)(H,{label:`Repository`,help:`Whether it may change files in the repository (with Change files).`,children:(0,q.jsx)(`div`,{role:`radiogroup`,"aria-label":`Repository`,className:`flex gap-1 rounded-[10px] bg-surface-strong p-1`,children:[[`read`,`Read only`],[`write`,`May change files`]].map(([e,t])=>(0,q.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":a.permissions.repository===e,onClick:()=>O({repository:e}),className:j(`min-h-8 cursor-pointer rounded-[7px] border-0 px-3.5 text-sm font-medium`,a.permissions.repository===e?`bg-bg text-ink shadow-sm`:`bg-transparent text-muted hover:text-ink`),children:t},e))})}),a.scope.environments.some(e=>u.environments.some(t=>t.name===e&&t.production))&&a.permissions.actions.includes(`run`)&&(0,q.jsx)(H,{label:`Production`,help:`Reads there go ahead without asking; every change there is approved by a person.`,children:(0,q.jsx)($,{checked:!(a.permissions.production||[]).includes(`run`),onChange:e=>O({production:e?[]:[`run`]}),children:`Ask before each run`})}),a.permissions.repository===`write`&&(()=>{let e=(u.coding||[]).filter(e=>u.capabilities.some(t=>a.scope.capabilities.includes(t.id)&&t.tools.includes(e)));if(!e.length)return null;let t=e.every(e=>(a.permissions.trust||[]).includes(e));return(0,q.jsx)(H,{label:`Coding agent`,help:`The tests it runs can reach any address. Without asking, ForgeQE first looks in the test project's config and env files, and asks when they name an address outside its environments.`,children:(0,q.jsx)($,{checked:!t,onChange:t=>O({trust:t?(a.permissions.trust||[]).filter(t=>!e.includes(t)):[...new Set([...a.permissions.trust||[],...e])]}),children:`Ask first`})})})(),(0,q.jsx)(H,{label:`Hands work on`,help:`How many levels deep it may give part of a task to a helper.`,htmlFor:`ca-depth`,children:(0,q.jsxs)(ge,{id:`ca-depth`,value:String(a.runtime.maxDelegationDepth),onChange:e=>E({runtime:{...a.runtime,maxDelegationDepth:Number(e.target.value)}}),className:`w-[200px]`,children:[(0,q.jsx)(`option`,{value:`0`,children:`Never`}),(0,q.jsx)(`option`,{value:`1`,children:`1 level`}),(0,q.jsx)(`option`,{value:`2`,children:`2 levels`}),(0,q.jsx)(`option`,{value:`3`,children:`3 levels`})]})}),(0,q.jsx)(H,{label:`Budget per run`,help:`The most model tokens one run may use; it stops there. Empty: no limit.`,htmlFor:`ca-budget`,children:(0,q.jsx)(P,{id:`ca-budget`,type:`number`,min:1e3,step:1e3,className:`w-[200px]`,value:a.runtime.maxTokens??``,placeholder:`No limit`,onChange:e=>E({runtime:{maxDelegationDepth:a.runtime.maxDelegationDepth,...e.target.value?{maxTokens:Math.max(0,Math.round(Number(e.target.value)))}:{}}})})}),(0,q.jsx)(V,{help:`One per line: what it should keep in mind. Guidance for the model, never a limit.`,children:`Guidance`}),(0,q.jsx)(ye,{"aria-label":`Guidance, one per line`,rows:3,value:a.policies.join(`
3
- `),onChange:e=>E({policies:e.target.value.split(`
4
- `).map(e=>e.slice(0,300))})}),(0,q.jsx)(V,{help:`Requests its page offers to start from (at most 6).`,children:`Starters`}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[a.starters.map((e,t)=>(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(P,{"aria-label":`Starter ${t+1} label`,className:`w-[200px]`,maxLength:40,value:e.label,placeholder:`Label`,onChange:e=>E({starters:a.starters.map((n,r)=>r===t?{...n,label:e.target.value}:n)})}),(0,q.jsx)(P,{"aria-label":`Starter ${t+1} request`,className:`min-w-0 flex-[1_1_280px]`,maxLength:500,value:e.text,placeholder:`The request`,onChange:e=>E({starters:a.starters.map((n,r)=>r===t?{...n,text:e.target.value}:n)})}),(0,q.jsx)(M,{variant:`icon`,size:`icon`,"aria-label":`Remove starter ${t+1}`,"data-tip":`Remove starter ${t+1}`,onClick:()=>E({starters:a.starters.filter((e,n)=>n!==t)}),children:(0,q.jsx)(ne,{"aria-hidden":`true`})})]},t)),a.starters.length<6&&(0,q.jsxs)(M,{size:`sm`,className:`self-start`,onClick:()=>E({starters:[...a.starters,{label:``,text:``}]}),"data-tip":`Add a starter`,children:[(0,q.jsx)(n,{"aria-hidden":`true`}),`Add`]})]}),g.length>0&&(0,q.jsxs)(`section`,{"aria-labelledby":`ca-advice`,className:`mt-6 flex flex-col gap-2`,children:[(0,q.jsx)(`h2`,{id:`ca-advice`,className:`m-0 text-base font-semibold`,children:`What it still needs`}),(0,q.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-2 p-0`,children:g.map((e,t)=>(0,q.jsxs)(`li`,{className:j(`flex flex-col gap-0.5 rounded-[12px] px-4 py-3 text-sm`,e.blocking?`bg-warn-soft`:`bg-surface-muted`),children:[(0,q.jsx)(`span`,{className:j(`font-medium`,e.blocking?`text-warn`:`text-ink`),children:e.about}),(0,q.jsx)(`span`,{className:`text-[13px] text-ink-2`,children:e.why}),(0,q.jsx)(`span`,{className:`text-[13px] text-muted`,children:e.fix})]},t))})]}),(0,q.jsxs)(`div`,{className:`sticky bottom-0 mt-4 flex flex-wrap items-center gap-3 border-t border-line-soft bg-bg py-3`,children:[(0,q.jsx)(`div`,{role:`status`,className:`min-w-0 flex-[1_1_320px] text-[13px]`,children:v?(0,q.jsx)(`span`,{className:`text-muted`,children:`Checking…`}):m.length?(0,q.jsxs)(`ul`,{className:`m-0 list-disc pl-5 text-fail [overflow-wrap:anywhere]`,children:[m.slice(0,4).map((e,t)=>(0,q.jsx)(`li`,{children:e},t)),m.length>4&&(0,q.jsxs)(`li`,{children:[`and `,m.length-4,` more`]})]}):(0,q.jsx)(`span`,{className:`text-pass`,children:`Ready to save. It can be tried once saved.`})}),(0,q.jsx)(`a`,{href:A,className:`text-sm`,children:`Cancel`}),(0,q.jsxs)(M,{variant:`primary`,disabled:b||!a.id||!a.name,onClick:()=>void k(),"data-tip":r?`Save the agent`:`Save changes`,children:[(0,q.jsx)(i,{"aria-hidden":`true`}),`Save`]})]})]})]})]})}var kn=232,An=34,jn=22,Mn=96,Nn=22,Pn=20,Fn=10;function In(e){let t=new Set(e.fks.flatMap(e=>e.columns)),n=n=>e.pk.includes(n.name)?0:t.has(n.name)?1:2;return{cols:[...e.columns].sort((e,t)=>n(e)-n(t)).slice(0,Fn),hidden:Math.max(0,e.columns.length-Fn)+(e.more_columns||0)}}function Ln(e){let t=new Set(e.map(e=>e.name)),n=new Map(e.map(e=>[e.name,0]));for(let r=0;r<e.length;r++){let r=!1;for(let i of e)for(let a of i.fks){if(!t.has(a.table)||a.table===i.name)continue;let o=(n.get(a.table)??0)+1;o>(n.get(i.name)??0)&&o<e.length&&(n.set(i.name,o),r=!0)}if(!r)break}return n}function Rn(e){let t=Ln(e),n=new Map;for(let r of e)n.set(t.get(r.name),[...n.get(t.get(r.name))||[],r]);let r=new Map,i=0;for(let[e,t]of[...n.entries()].sort((e,t)=>e[0]-t[0])){let n=Pn;for(let i of t.sort((e,t)=>e.name.localeCompare(t.name))){let{cols:t,hidden:a}=In(i),o=An+t.length*jn+(a?jn:0)+6;r.set(i.name,{t:i,x:Pn+e*328,y:n,h:o,cols:t,hidden:a}),n+=o+Nn}i=Math.max(i,n)}return{boxes:r,width:40+(Math.max(0,...n.keys())+1)*328-Mn,height:i+Pn-Nn}}function zn(e,t){let n=t?e.cols.findIndex(e=>e.name===t):-1;return e.y+(n<0?An/2:An+n*jn+jn/2)}function Bn({tables:e,selected:t,onSelect:n}){let{boxes:r,width:i,height:a}=(0,K.useMemo)(()=>Rn(e),[e]),o=(0,K.useMemo)(()=>{if(!t)return null;let n=new Set([t]);for(let r of e)for(let e of r.fks)(r.name===t||e.table===t)&&(n.add(r.name),n.add(e.table));return n},[e,t]),s=e.flatMap(e=>e.fks.filter(e=>r.has(e.table)).map((n,i)=>{let a=r.get(e.name),o=r.get(n.table),s=zn(a,n.columns[0]),c=zn(o,n.references[0]),l=a===o,u=l||a.x>o.x?a.x:a.x+kn,d=l?o.x:a.x>o.x?o.x+kn:o.x,f=l?-40:Math.max(40,Math.abs(u-d)/2),p=l?`M ${u} ${s} C ${u+f} ${s}, ${d+f} ${c-12}, ${d} ${c-12}`:`M ${u} ${s} C ${u-Math.sign(u-d)*f} ${s}, ${d+Math.sign(u-d)*f} ${c}, ${d} ${c}`,m=!!t&&(e.name===t||n.table===t);return{key:`${e.name}.${i}`,d:p,on:m,label:`${e.name}.${n.columns.join(`, `)} references ${n.table}.${n.references.join(`, `)}`}}));return(0,q.jsx)(`div`,{className:`overflow-auto rounded-[10px] border border-line-soft bg-surface-muted/40`,role:`group`,"aria-label":`Schema diagram: ${e.length} tables, ${s.length} relationships`,children:(0,q.jsxs)(`div`,{className:`relative`,style:{width:i,height:a},children:[(0,q.jsxs)(`svg`,{width:i,height:a,className:`absolute inset-0`,"aria-hidden":`true`,children:[(0,q.jsx)(`defs`,{children:(0,q.jsx)(`marker`,{id:`fk-end`,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,q.jsx)(`path`,{d:`M0 0 L8 4 L0 8 z`,fill:`currentColor`})})}),s.map(e=>(0,q.jsx)(`path`,{d:e.d,fill:`none`,markerEnd:`url(#fk-end)`,strokeWidth:e.on?2:1.25,className:j(e.on?`text-accent`:t?`text-line`:`text-muted`),stroke:`currentColor`,"data-tip":e.label},e.key))]}),[...r.values()].map(e=>{let r=new Set(e.t.fks.flatMap(e=>e.columns)),i=t===e.t.name,a=!!o&&!o.has(e.t.name);return(0,q.jsxs)(`button`,{type:`button`,"aria-pressed":i,onClick:()=>n(e.t.name),"data-tip":e.t.comment||e.t.name,className:j(`absolute flex cursor-pointer flex-col overflow-hidden rounded-[10px] border bg-bg p-0 text-left shadow-sm transition-opacity`,i?`border-accent ring-2 ring-accent/30`:`border-line hover:border-accent`,a&&`opacity-35`),style:{left:e.x,top:e.y,width:kn,height:e.h},children:[(0,q.jsxs)(`span`,{className:j(`flex h-[34px] w-full flex-none items-center gap-2 border-b border-line-soft px-3`,i?`bg-accent-soft`:`bg-surface-muted`),children:[(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[12.5px] font-semibold text-ink`,children:e.t.name}),e.t.kind===`view`&&(0,q.jsx)(`span`,{className:`text-[11px] text-muted`,children:`view`}),e.t.rows!==void 0&&(0,q.jsx)(`span`,{className:`text-[11px] text-muted tabular-nums`,children:e.t.rows.toLocaleString()})]}),e.cols.map(t=>(0,q.jsxs)(`span`,{className:`flex h-[22px] w-full flex-none items-center gap-1.5 px-3 text-[12px]`,children:[(0,q.jsx)(`span`,{className:`flex w-3.5 flex-none justify-center text-muted`,children:e.t.pk.includes(t.name)?(0,q.jsx)(S,{size:11,"aria-label":`key`,className:`text-warn`}):r.has(t.name)?(0,q.jsx)(y,{size:11,"aria-label":`foreign key`,className:`text-accent-fg`}):null}),(0,q.jsx)(`span`,{className:j(`min-w-0 flex-1 truncate font-mono`,e.t.pk.includes(t.name)?`font-semibold text-ink`:`text-ink-2`),children:t.name}),(0,q.jsx)(`span`,{className:`max-w-[90px] flex-none truncate font-mono text-[11px] text-muted lowercase`,children:t.type})]},t.name)),e.hidden>0&&(0,q.jsxs)(`span`,{className:`flex h-[22px] flex-none items-center px-3 pl-8 text-[11.5px] text-muted`,children:[`+`,e.hidden,` more`]})]},e.t.name)})]})})}var Vn=[`databases`,`schema`,`ask`,`requests`,`about`],Hn={test:`databases`,map:`schema`,ask:`ask`,checks:`ask`,request:`ask`,fetch:`requests`},Un=40;function Wn({view:e,job:t,busy:n,act:r,maps:i}){let a=t&&!t.running&&t.kind===`test`?t:null,o=a?a.lines.filter(e=>/^[✓✗]/.test(e.trim())).join(` `)||a.lines.filter(e=>!/^args |^token /.test(e)).slice(-1)[0]:``;return e.databases.length?(0,q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[a&&o&&(0,q.jsx)(`p`,{className:j(`m-0 rounded-[12px] px-3 py-2 text-sm [overflow-wrap:anywhere]`,a.exitCode===0?`bg-pass-soft text-pass`:`bg-fail-soft text-fail`),children:o.replace(/^[✓✗]\s*/,``)}),(0,q.jsx)(He,{label:`Connected databases`,minWidth:720,head:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`th`,{className:W,children:`Database`}),(0,q.jsx)(`th`,{className:W,children:`Engine`}),(0,q.jsx)(`th`,{className:W,children:`Where`}),(0,q.jsx)(`th`,{className:W,children:`Access`}),(0,q.jsx)(`th`,{className:We,children:`Tables`}),(0,q.jsx)(`th`,{className:W,children:(0,q.jsx)(`span`,{className:`sr-only`,children:`Actions`})})]}),children:e.databases.map(e=>{let t=i[e.name]?.map;return(0,q.jsxs)(`tr`,{className:Be,children:[(0,q.jsx)(`td`,{className:G,children:(0,q.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:e.name}),e.description&&(0,q.jsx)(`span`,{className:`text-[12px] text-muted`,children:e.description})]})}),(0,q.jsx)(`td`,{className:j(G,`whitespace-nowrap`),children:e.engine||`from its connection string`}),(0,q.jsx)(`td`,{className:j(G,`max-w-[240px] truncate font-mono text-[12px]`),"data-tip":e.where,children:e.where}),(0,q.jsx)(`td`,{className:j(G,`whitespace-nowrap`),children:(0,q.jsx)(F,{tone:e.writable?`warn`:`neutral`,icon:e.writable,children:e.writable?`Writable, after asking`:`Read only`})}),(0,q.jsx)(`td`,{className:Je,children:t?t.total:(0,q.jsx)(`span`,{className:`text-muted`,children:`—`})}),(0,q.jsx)(`td`,{className:j(G,`whitespace-nowrap text-right`),children:(0,q.jsxs)(`span`,{className:`inline-flex gap-1.5`,children:[(0,q.jsx)(M,{size:`icon`,variant:`icon`,disabled:n,onClick:()=>r(`test`,{db:e.name}),"aria-label":`Test the connection to ${e.name}`,"data-tip":`Test the connection to ${e.name}`,className:`size-8`,children:(0,q.jsx)(g,{"aria-hidden":`true`})}),(0,q.jsx)(`a`,{href:I(`agents`,`db`,`schema`,encodeURIComponent(e.name)),"aria-label":`Schema of ${e.name}`,"data-tip":`Schema of ${e.name}`,className:j(B({variant:`icon`,size:`icon`}),`size-8 no-underline`),children:(0,q.jsx)(ee,{"aria-hidden":`true`})}),(0,q.jsx)(`a`,{href:I(`data`,`databases/${encodeURIComponent(e.name)}`),"aria-label":`Query ${e.name}`,"data-tip":`Query ${e.name}`,className:j(B({variant:`icon`,size:`icon`}),`size-8 no-underline`),children:(0,q.jsx)(v,{"aria-hidden":`true`})})]})})]},e.name)})}),(0,q.jsx)(`a`,{href:I(`settings`,`databases`),className:`self-start text-[13px]`,children:`Add or change databases in Settings`})]}):(0,q.jsxs)(z,{className:`py-3`,children:[`The DB agent is not connected to a database yet. `,(0,q.jsx)(`a`,{href:I(`settings`,`databases`),children:`Add one in Settings`}),`: a connection string, or its host, user and password, kept in your credential store.`]})}function Gn({t:e,all:t,onSelect:n}){let r=new Map(e.fks.flatMap(e=>e.columns.map((t,n)=>[t,`${e.table}.${e.references[n]??e.references[0]??``}`]))),i=t.filter(t=>t.fks.some(t=>t.table===e.name));return(0,q.jsxs)(`section`,{"aria-labelledby":`table-h`,className:`flex flex-col gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,q.jsxs)(`h3`,{id:`table-h`,className:`m-0 flex items-center gap-2 font-mono text-base font-semibold`,children:[(0,q.jsx)(L,{icon:te,size:18,className:`text-accent-fg`}),e.name]}),(0,q.jsxs)(`span`,{className:`text-[13px] text-muted`,children:[e.kind===`view`?`view · `:``,N(e.columns.length+(e.more_columns||0),`column`),e.rows===void 0?``:` · about ${e.rows.toLocaleString()} rows`]})]}),e.comment&&(0,q.jsx)(`p`,{className:`m-0 text-sm text-ink-2`,children:e.comment}),(0,q.jsx)(He,{label:`Columns of ${e.name}`,resetKey:e.name,search:e.columns.length>12,head:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`th`,{className:W,children:`Column`}),(0,q.jsx)(`th`,{className:W,children:`Type`}),(0,q.jsx)(`th`,{className:W,children:`Null`}),(0,q.jsx)(`th`,{className:W,children:`Key`})]}),children:e.columns.map(t=>(0,q.jsxs)(`tr`,{className:Be,children:[(0,q.jsx)(`td`,{className:j(G,`font-mono text-[12.5px]`,e.pk.includes(t.name)&&`font-semibold`),children:t.name}),(0,q.jsx)(`td`,{className:j(G,`font-mono text-[12px] text-muted`),children:t.type}),(0,q.jsx)(`td`,{className:j(G,`text-muted`),children:t.nullable?`Allowed`:`Not null`}),(0,q.jsxs)(`td`,{className:G,children:[e.pk.includes(t.name)&&(0,q.jsx)(`span`,{className:`mr-2`,children:`Primary key`}),r.has(t.name)&&(0,q.jsxs)(`button`,{type:`button`,className:`cursor-pointer border-0 bg-transparent p-0 font-mono text-[12px] text-accent-fg underline-offset-2 hover:underline`,onClick:()=>n(r.get(t.name).split(`.`)[0]),children:[`→ `,r.get(t.name)]})]})]},t.name))}),i.length>0&&(0,q.jsxs)(`p`,{className:`m-0 flex flex-wrap items-center gap-2 text-[13px] text-muted`,children:[`Pointed at by`,i.map(e=>(0,q.jsx)(`button`,{type:`button`,onClick:()=>n(e.name),className:j(B({size:`sm`}),`font-mono text-[12px]`),children:e.name},e.name))]})]})}function Kn({view:e,job:t,busy:n,act:r,maps:i,dbName:a,setDb:o}){let[s,c]=(0,K.useState)(``),[l,u]=(0,K.useState)(``),[d,f]=(0,K.useState)(!1),m=i[a],g=m?.map?.tables??[],_=!!t?.running&&t.kind===`map`&&t.target===a,v=(0,K.useRef)(new Set);(0,K.useEffect)(()=>{!a||i[a]||n||v.current.has(a)||(v.current.add(a),r(`map`,{db:a}))},[a,n]),(0,K.useEffect)(()=>c(``),[a]);let y=g.length>Un,x=s||y&&[...g].sort((e,t)=>qn(g,t.name)-qn(g,e.name))[0]?.name||``,S=(0,K.useMemo)(()=>{if(!y||d)return g;let e=new Set([x]);for(let t of g)for(let n of t.fks)(t.name===x||n.table===x)&&(e.add(t.name),e.add(n.table));return g.filter(t=>e.has(t.name))},[g,y,d,x]),C=l.toLowerCase().split(/\s+/).filter(Boolean),w=C.length?g.filter(e=>C.every(t=>`${e.name} ${e.comment||``} ${e.columns.map(e=>e.name).join(` `)}`.toLowerCase().includes(t))):g,T=g.find(e=>e.name===s),E=g.reduce((e,t)=>e+t.fks.length,0);return e.databases.length?(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(ge,{"aria-label":`Database`,value:a,onChange:e=>o(e.target.value),className:`w-[220px]`,children:e.databases.map(e=>(0,q.jsx)(`option`,{children:e.name},e.name))}),(0,q.jsxs)(M,{disabled:n,onClick:()=>r(`map`,{db:a,refresh:!0}),"data-tip":`Read the schema again`,children:[(0,q.jsx)(p,{"aria-hidden":`true`}),`Refresh`]}),m?.map&&(0,q.jsxs)(`span`,{className:`text-sm text-muted tabular-nums`,children:[N(m.map.total,`table`),` · `,N(E,`relationship`),m.map.total>g.length?` · the first ${g.length} drawn`:``]})]}),_&&(0,q.jsxs)(`p`,{className:`m-0 text-sm text-muted`,children:[`Reading the schema of `,a,`…`]}),m&&!m.ok&&(0,q.jsx)(yt,{text:m.error||`Could not read the schema of ${a}.`}),m?.ok&&g.length===0&&(0,q.jsxs)(z,{className:`py-3`,children:[a,` has no tables the DB agent can see.`]}),g.length>0&&(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-6 gap-y-4`,children:[(0,q.jsxs)(`nav`,{"aria-label":`Tables`,className:`flex min-w-0 flex-[1_1_220px] flex-col gap-2 @3xl:max-w-[240px]`,children:[(0,q.jsx)(pe,{id:`schema-find`,label:`Find a table`,value:l,onChange:u,className:`max-w-none flex-none`}),(0,q.jsxs)(`ul`,{className:`m-0 flex max-h-[520px] list-none flex-col overflow-auto p-0`,children:[w.map(e=>(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,"aria-pressed":s===e.name,onClick:()=>c(s===e.name?``:e.name),className:j(`flex min-h-9 w-full cursor-pointer items-center gap-2 rounded-[8px] border-0 px-2.5 text-left text-[13px]`,s===e.name?`bg-surface-strong font-medium text-ink`:`bg-transparent text-ink-2 hover:bg-surface-muted`),children:[(0,q.jsx)(L,{icon:te,size:14,className:`flex-none text-muted`}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,"data-tip":e.name,children:e.name}),(0,q.jsx)(`span`,{className:`flex-none text-[11.5px] text-muted tabular-nums`,children:e.columns.length+(e.more_columns||0)})]})},e.name)),!w.length&&(0,q.jsx)(`li`,{className:`px-2.5 py-2 text-[13px] text-muted`,children:`No table matches.`})]})]}),(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-[999_1_560px] flex-col gap-4`,children:[y&&(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[13px] text-muted`,children:[(0,q.jsxs)(`span`,{className:`flex-1`,children:[d?`All ${g.length} tables`:`${x} and the tables it joins (${S.length} of ${g.length})`,`. Pick a table to draw it with its neighbours.`]}),(0,q.jsxs)(M,{size:`sm`,onClick:()=>f(!d),"data-tip":d?`Draw around one table`:`Draw every table`,children:[d?(0,q.jsx)(h,{"aria-hidden":`true`}):(0,q.jsx)(b,{"aria-hidden":`true`}),d?`Less`:`All (${g.length})`]})]}),(0,q.jsx)(Bn,{tables:S,selected:s||void 0,onSelect:e=>c(s===e?``:e)}),(0,q.jsx)(`p`,{className:`m-0 text-[12.5px] text-muted`,children:`Parents on the left; each line runs from a foreign key to the table it references. Pick a table to see its columns and what points at it.`}),T&&(0,q.jsx)(Gn,{t:T,all:g,onSelect:c})]})]})]}):(0,q.jsx)(Wn,{view:e,job:t,busy:n,act:r,maps:i})}var qn=(e,t)=>e.reduce((e,n)=>e+n.fks.filter(e=>e.table===t).length+(n.name===t?n.fks.length:0),0);function Jn({page:e,tab:t,sub:n}){let{view:r,error:i,busy:a,act:o,stop:s,job:c}=bt(),[l,u]=(0,K.useState)(null),[d,f]=(0,K.useState)({}),p=Vn.includes(t)?t:`databases`,m=Pe(e.agent),h=n?fe(n):``,[g,_]=(0,K.useState)(h);(0,K.useEffect)(()=>{h&&_(h)},[h]),(0,K.useEffect)(()=>{!g&&r?.databases[0]&&_(r.databases[0].name)},[r,g]);let y=c&&!c.running?c.endedAt:``;(0,K.useEffect)(()=>{c&&!c.running&&c.kind===`map`&&c.target&&f(e=>({...e,[c.target]:c.result??{ok:!1,error:c.lines.slice(-1)[0]}})),de.log().then(u,()=>u([]))},[y]);let b=(l||[]).filter(e=>!e.ok).length,x={databases:`Databases${r?` (${r.databases.length})`:``}`,schema:`Schema`,ask:`Ask`,requests:`Requests${l?` (${l.length})`:``}`,about:`Tools and runs`};return(0,q.jsxs)(`section`,{"aria-label":`${U(m.name,!0)}'s screens`,className:`@container flex w-full flex-col gap-4 text-left`,children:[r&&(0,q.jsxs)(`p`,{className:`m-0 flex flex-wrap items-center gap-x-1 text-sm text-ink-2 tabular-nums`,children:[(0,q.jsx)(L,{icon:v,size:14,className:`text-muted`}),N(r.databases.length,`database`),` connected · `,l?N(l.length,`request`):`…`,b?(0,q.jsxs)(q.Fragment,{children:[` · `,(0,q.jsxs)(`span`,{className:`text-fail`,children:[b,` failed`]})]}):null,` · ${r.requests.length} kept`]}),i&&(0,q.jsx)(`p`,{role:`alert`,className:`m-0 rounded-[12px] bg-fail-soft px-3 py-2 text-sm text-fail [overflow-wrap:anywhere]`,children:i}),!r&&!i&&(0,q.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted`,children:`Loading…`}),r&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(gt,{label:m.name,current:p,onPick:e=>location.hash=I(`agents`,`db`,e),tabs:Vn.map(e=>({id:e,label:x[e]}))}),c&&(c.running?Hn[c.kind]!==void 0:Hn[c.kind]===p)&&(0,q.jsx)(vt,{job:c,onStop:s}),(0,q.jsxs)(`div`,{role:`tabpanel`,id:`panel-${p}`,"aria-labelledby":`tab-${p}`,children:[p===`databases`&&(0,q.jsx)(Wn,{view:r,job:c,busy:a,act:o,maps:d}),p===`schema`&&(0,q.jsx)(Kn,{view:r,job:c,busy:a,act:o,maps:d,dbName:g,setDb:e=>location.hash=I(`agents`,`db`,`schema`,encodeURIComponent(e))}),p===`ask`&&(0,q.jsx)(_t,{view:r,job:c,busy:a,act:o,preset:h||void 0}),p===`requests`&&(0,q.jsx)(xt,{view:r,log:l,busy:a,act:o}),p===`about`&&(0,q.jsx)(Zn,{page:e})]})]})]})}var Yn=5;function Xn({id:e}){if(!e)return(0,q.jsx)(Ut,{});let[t,n,r,...i]=e.split(`/`);if(t===`custom`&&n===`new`&&r===`template`&&i.length===1&&/^[a-z][a-z0-9-]{0,39}$/.test(i[0]))return(0,q.jsx)(On,{template:i[0]},i[0]);if(t===`custom`&&!i.length){if(n===`new`&&r===void 0)return(0,q.jsx)(qt,{});if(n===`new`&&r===`form`)return(0,q.jsx)(On,{});if(n===`build`&&r&&/^[a-f0-9]{16}$/.test(r))return(0,q.jsx)(Yt,{sid:r},r);if(n&&$e.test(n)&&r===void 0)return(0,q.jsx)(sn,{id:n},n);if(n&&$e.test(n)&&r===`edit`)return(0,q.jsx)(On,{id:n},n)}let[a,o,...s]=(e||``).split(`/`),c=Fe(a);if(c?.id===`db`&&o!==`tools`)return(0,q.jsx)(ft,{agent:c,wide:(0,q.jsx)(Jn,{page:c,tab:o,sub:s.join(`/`)})},c.id);let l=a===`category`&&!s.length?Ce(o):void 0;return l?(0,q.jsx)(Ut,{only:l.id},l.id):c&&o===`tools`&&!s.length?(0,q.jsx)(nr,{page:c},c.id):!c||o!==void 0?(0,q.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,q.jsx)(Xe,{}),(0,q.jsxs)(`p`,{className:`m-0 px-6 py-10 text-sm text-muted`,children:[`There is no such agent. `,(0,q.jsx)(`a`,{href:I(`agents`),children:`See every agent`}),`, or `,(0,q.jsx)(`a`,{href:I(),children:`start a chat`}),` instead.`]})]}):(0,q.jsx)(ft,{agent:c,below:(0,q.jsx)(Zn,{page:c})},c.id)}function Zn({page:e}){let[t,n]=(0,K.useState)(null),[r,i]=(0,K.useState)([]),[a,o]=(0,K.useState)(null),[s,c]=(0,K.useState)(``),[l,u]=(0,K.useState)(null);(0,K.useEffect)(()=>{let t=!1;return se.directory().then(n=>!t&&u(n.agents[e.agent]??null),()=>{}),se.tools(e.agent).then(e=>!t&&o(e),e=>!t&&c(e.message)),me.list().then(r=>!t&&n(r.runs.filter(t=>t.agents.some(t=>e.runs.includes(t.name))).slice(0,Yn)),()=>!t&&n([])),_e.prompts().then(n=>!t&&i(n.agents.filter(t=>e.runs.includes(t.name))),()=>{}),()=>{t=!0}},[e]);let d=Pe(e.agent).name,f=[...new Set(r.map(e=>e.prompt))];return(0,q.jsxs)(`div`,{className:`flex w-full flex-col gap-6 pt-2`,children:[l&&l.status!==`ready`&&(0,q.jsx)($n,{card:l,name:d}),(0,q.jsxs)(`section`,{"aria-labelledby":`agent-tools`,className:`flex flex-col gap-2`,children:[(0,q.jsx)(`h2`,{id:`agent-tools`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Tools it can use`}),s?(0,q.jsx)(`p`,{className:`m-0 text-sm text-fail`,children:s}):a?(0,q.jsx)(rr,{view:a,limit:Yn,more:I(`agents`,e.id,`tools`)}):(0,q.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Reading its tools…`})]}),a&&a.connections.length>0&&(0,q.jsxs)(`section`,{"aria-labelledby":`agent-connected`,className:`flex flex-col gap-2`,children:[(0,q.jsx)(`h2`,{id:`agent-connected`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Connected to`}),(0,q.jsx)(tr,{list:a.connections,limit:4,more:I(`agents`,e.id,`tools`)})]}),e.prompt!==!1&&(0,q.jsxs)(`section`,{"aria-labelledby":`agent-prompt`,className:`flex flex-col gap-2`,children:[(0,q.jsx)(`h2`,{id:`agent-prompt`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Its instructions`}),(0,q.jsxs)(`a`,{href:I(`prompts`),className:`flex items-center gap-3 rounded-[12px] card border px-4 py-3 text-ink no-underline hover:bg-surface-muted hover:text-ink`,children:[(0,q.jsx)(L,{icon:D,size:18,className:`flex-none text-muted`}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,q.jsx)(`span`,{className:`text-[14px] font-medium`,children:f.length?f.map(e=>`${e}.md`).join(`, `):`The prompt it starts from`}),(0,q.jsxs)(`span`,{className:`text-[12.5px] text-muted`,children:[`What `,U(d),` starts with, and your team's additions: change them in Prompts.`]})]}),(0,q.jsx)(A,{size:16,"aria-hidden":`true`,className:`flex-none text-muted`})]})]}),(0,q.jsxs)(`section`,{"aria-labelledby":`agent-runs`,className:`flex flex-col gap-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,q.jsx)(`h2`,{id:`agent-runs`,className:`m-0 flex-1 text-[13px] font-semibold text-muted`,children:`Recent runs`}),(0,q.jsx)(`a`,{href:I(`runs`),className:`text-[13px]`,children:`All runs`})]}),t===null?(0,q.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Reading the runs…`}):t.length===0?(0,q.jsxs)(z,{className:`py-4`,children:[U(d,!0),` has not worked in this project yet.`]}):(0,q.jsx)(`ul`,{"aria-label":`${U(d,!0)}'s recent runs`,className:`m-0 flex list-none flex-col rounded-[12px] card border p-1.5`,children:t.map(e=>(0,q.jsx)(`li`,{children:(0,q.jsxs)(`a`,{href:I(`runs`,encodeURIComponent(e.name)),className:`flex min-h-11 items-center gap-3 rounded-[8px] px-3 py-1.5 text-ink no-underline hover:bg-surface-muted hover:text-ink`,children:[(0,q.jsx)(St,{status:e.status}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,q.jsx)(`span`,{className:`truncate text-[14px] font-medium`,"data-tip":e.title,children:e.title}),e.error&&(0,q.jsx)(`span`,{className:`truncate text-[12px] text-fail`,children:e.error})]}),(0,q.jsx)(`span`,{className:`flex-none text-[12.5px] text-muted tabular-nums`,children:pt(e.startedAt)})]})},e.name))})]})]})}var Qn={setup:{to:I(`settings`,`setup`),label:`Settings, Set up`},models:{to:I(`settings`,`models`),label:`Settings, Models`},tests:{to:I(`settings`,`tests`),label:`Settings, Code`},databases:{to:I(`settings`,`databases`),label:`Settings, Databases`},integrations:{to:I(`settings`,`integrations`),label:`Settings, Integrations`},features:{to:I(`settings`,`features`),label:`What's ready`}};function $n({card:e,name:n}){let r=Et[e.status],i=e.needs??[];return(0,q.jsxs)(`section`,{"aria-labelledby":`agent-needs`,className:`flex flex-col gap-2`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`h2`,{id:`agent-needs`,className:`m-0 text-[13px] font-semibold text-muted`,children:`What it needs`}),(0,q.jsx)(F,{tone:r.tone,children:r.label})]}),i.length===0?(0,q.jsx)(`p`,{className:`m-0 rounded-[12px] bg-surface-muted px-4 py-3 text-sm text-ink-2`,children:e.note}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`m-0 text-[12.5px] text-muted`,children:i.some(e=>e.blocks)?`${U(n,!0)} cannot work until the first ${i.filter(e=>e.blocks).length===1?`one is`:`ones are`} set up.`:`${U(n,!0)} works, without the parts below.`}),(0,q.jsx)(`ul`,{"aria-label":`What ${U(n)} needs`,className:`m-0 flex list-none flex-col rounded-[12px] card border p-0`,children:i.map((e,n)=>(0,q.jsxs)(`li`,{className:j(`flex items-center gap-3 px-3 py-2.5`,n>0&&`border-t border-line-soft`),children:[(0,q.jsx)(t,{size:16,"aria-label":e.blocks?`Needed`:`Optional`,className:j(`flex-none`,e.blocks?`text-fail`:`text-warn`)}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,q.jsx)(`span`,{className:`text-[14px] font-medium`,children:e.what}),(0,q.jsx)(`span`,{className:`text-[12.5px] text-muted [overflow-wrap:anywhere]`,children:e.why})]}),e.fix&&(0,q.jsxs)(`a`,{href:Qn[e.fix].to,className:`flex flex-none items-center gap-1 text-[13px]`,children:[Qn[e.fix].label,(0,q.jsx)(A,{size:14,"aria-hidden":`true`})]})]},`${e.what}:${n}`))})]})]})}var er={repository:`branch`,database:`container`,environment:`web`,system:`plug`};function tr({list:e,limit:t,more:n}){let r=t?e.slice(0,t):e;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-1 gap-2 p-0 sm:grid-cols-2`,children:r.map((e,t)=>(0,q.jsxs)(`li`,{className:j(`flex items-center gap-3 rounded-[12px] card border px-3 py-2.5`,!e.on&&`bg-surface-muted`),children:[(0,q.jsx)(ue,{name:er[e.kind],px:22,className:j(!e.on&&`opacity-50 grayscale`)}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,q.jsx)(`span`,{className:`truncate text-[14px] font-medium`,"data-tip":e.name,children:e.name}),(0,q.jsx)(`span`,{className:`truncate text-[12.5px] text-muted`,children:e.on?e.detail:`Not connected: ${e.why||`not set up`}`})]})]},`${e.kind}:${e.name}:${t}`))}),n&&r.length<e.length&&(0,q.jsxs)(`a`,{href:n,className:`self-start text-[13px]`,children:[`Show all `,e.length,` connections`]})]})}function nr({page:e}){let[t,n]=(0,K.useState)(null),[r,i]=(0,K.useState)(``);(0,K.useEffect)(()=>{let t=!1;return se.tools(e.agent).then(e=>!t&&n(e),e=>!t&&i(e.message)),()=>{t=!0}},[e]);let a=Pe(e.agent).name;return(0,q.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,q.jsx)(Xe,{}),(0,q.jsxs)(`main`,{className:Ze,children:[(0,q.jsxs)(`a`,{href:I(`agents`,e.id),className:`mb-4 inline-flex items-center gap-1.5 text-sm`,children:[(0,q.jsx)(w,{size:16,"aria-hidden":`true`}),a]}),(0,q.jsxs)(`div`,{className:`mb-1 flex items-center gap-3`,children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`theme-side inline-flex size-10 border border-line-soft flex-none items-center justify-center rounded-[10px]`,children:(0,q.jsx)(Ke,{agent:e.agent,px:24,decorative:!0})}),(0,q.jsxs)(`h1`,{className:`m-0 text-[26px] font-semibold tracking-[-0.01em]`,children:[`What `,U(a),` can use`]})]}),(0,q.jsxs)(`p`,{className:`mt-1 mb-6 max-w-[64ch] text-sm leading-relaxed text-ink-2`,children:[t?`${t.title.replace(/\.$/,``)}.`:e.about,` Every tool it has, in the groups its session is given, and what it reaches from this project.`]}),r?(0,q.jsx)(`p`,{className:`m-0 text-sm text-fail`,children:r}):t?(0,q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,q.jsxs)(`section`,{"aria-labelledby":`all-tools`,className:`flex flex-col gap-2`,children:[(0,q.jsx)(`h2`,{id:`all-tools`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Tools it can use`}),(0,q.jsx)(rr,{view:t,openAll:!0})]}),t.connections.length>0&&(0,q.jsxs)(`section`,{"aria-labelledby":`all-connected`,className:`flex flex-col gap-2`,children:[(0,q.jsx)(`h2`,{id:`all-connected`,className:`m-0 text-[13px] font-semibold text-muted`,children:`Connected to`}),(0,q.jsx)(tr,{list:t.connections})]})]}):(0,q.jsx)(`p`,{className:`m-0 text-sm text-muted`,children:`Reading its tools…`})]})]})}function rr({view:e,limit:t,more:n,openAll:r}){let[i,a]=(0,K.useState)(()=>r?e.groups.map(e=>e.id):[]),s=t?e.groups.slice(0,t):e.groups,c=e.groups.reduce((e,t)=>e+t.tools.length,0),l=e.groups.filter(e=>e.on).length;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,q.jsxs)(`p`,{className:`m-0 text-[12.5px] text-muted`,children:[l,` of `,e.groups.length,` `,e.groups.length===1?`group`:`groups`,` usable here.`]}),(0,q.jsx)(`ul`,{className:`m-0 flex list-none flex-col rounded-[12px] card border p-0`,children:s.map((e,n)=>{let r=i.includes(e.id);return(0,q.jsxs)(`li`,{className:j(n>0&&`border-t border-line-soft`),children:[(0,q.jsxs)(`button`,{type:`button`,"aria-expanded":r,"aria-controls":`tools-${n}`,disabled:!e.tools.length,onClick:()=>a(r?i.filter(t=>t!==e.id):[...i,e.id]),className:`flex w-full cursor-pointer items-center gap-3 border-0 bg-transparent px-3 py-2.5 text-left text-ink disabled:cursor-default`,children:[e.on?(0,q.jsx)(k,{size:16,"aria-label":`Usable`,className:`flex-none text-pass`}):(0,q.jsx)(u,{size:16,"aria-label":`Not usable here`,className:`flex-none text-muted`}),(0,q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,q.jsxs)(`span`,{className:`text-[14px] font-medium`,children:[e.label,e.tools.length>0&&(0,q.jsxs)(`span`,{className:`font-normal text-muted`,children:[` · `,e.tools.length]})]}),(0,q.jsx)(`span`,{className:j(`text-[12.5px] text-muted`,t&&`truncate`),children:e.on?[e.about,e.limited].filter(Boolean).join(` · `):`Not here: ${e.why||`not set up`}`})]}),e.tools.length>0&&(0,q.jsx)(o,{size:16,"aria-hidden":`true`,className:j(`flex-none text-muted transition-transform duration-200`,r&&`rotate-90`)})]}),(0,q.jsx)(we,{open:r,id:`tools-${n}`,children:(0,q.jsx)(`ul`,{className:`m-0 flex list-none flex-wrap gap-1.5 px-3 pb-3 pl-10`,children:e.tools.map(e=>(0,q.jsxs)(`li`,{"data-tip":e.what||void 0,className:`rounded-[6px] bg-surface-strong px-2 py-1 font-mono text-[12px] text-ink-2`,children:[e.name,e.what&&(0,q.jsx)(`span`,{className:`ml-1.5 font-sans text-muted`,children:e.what})]},e.name))})})]},e.id)})}),n&&(s.length<e.groups.length||c>0)&&(0,q.jsx)(`a`,{href:n,className:`self-start text-[13px]`,children:s.length<e.groups.length?`Show all ${e.groups.length} groups and ${c} tools`:`Show every tool (${c})`})]})}export{Xn as Agent,Zn as AgentDetails};