orc-ai 0.1.43 → 0.1.44

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 (111) hide show
  1. package/README.md +70 -11
  2. package/dist/checksums.txt +5 -0
  3. package/dist/index.js +565 -531
  4. package/dist/skills/orc-platform/SKILL.md +7 -0
  5. package/dist/skills/orc-platform/references/packages.md +22 -0
  6. package/dist/skills/orc-platform/references/setup.md +62 -0
  7. package/dist/skills/orc-platform/references/work.md +6 -0
  8. package/dist/web/assets/{Agents-OioCD6VE.js → Agents-DbB2cb_X.js} +3 -3
  9. package/dist/web/assets/Attention-C_BbdXun.js +2 -0
  10. package/dist/web/assets/Audit-Bbs3nk6j.js +1 -0
  11. package/dist/web/assets/Dashboard-Z5m-OPdt.js +1 -0
  12. package/dist/web/assets/{DocumentWorkspace-CE6Jydpq.js → DocumentWorkspace-D87XDN89.js} +1 -1
  13. package/dist/web/assets/{FileEditor-WTRFcaeP.js → FileEditor-N-6dtCZN.js} +1 -1
  14. package/dist/web/assets/{JobWebhooks-DfH2j2qa.js → JobWebhooks-DKFEEiP_.js} +1 -1
  15. package/dist/web/assets/{Jobs-CjVBkAR4.js → Jobs-DWrubRJm.js} +1 -1
  16. package/dist/web/assets/{Knowledge-BSqXfDrV.js → Knowledge-D1DMvczp.js} +3 -3
  17. package/dist/web/assets/PackageCatalog-pdPaTTJ9.js +18 -0
  18. package/dist/web/assets/{Pager-C5Mhu4cm.js → Pager-lPvhBe-l.js} +1 -1
  19. package/dist/web/assets/{Rules-Cduh89vN.js → Rules-DQXqE5XD.js} +14 -12
  20. package/dist/web/assets/{Sessions-DB4tEeup.js → Sessions-BkPWdesG.js} +3 -3
  21. package/dist/web/assets/{Settings-BS5sIo9b.js → Settings-DY7vTeUq.js} +7 -7
  22. package/dist/web/assets/Skills-Dzpq3YB8.js +16 -0
  23. package/dist/web/assets/{SourceEditor-CqLe3QBX.js → SourceEditor-CY9136HY.js} +3 -3
  24. package/dist/web/assets/{Tasks-QVB8AH8_.js → Tasks-BzqiSMLt.js} +5 -5
  25. package/dist/web/assets/Terminals-D5fxL91x.js +115 -0
  26. package/dist/web/assets/{Webhooks-CgqxLH4w.js → Webhooks-DyJRnKj5.js} +1 -1
  27. package/dist/web/assets/{abnfDiagram-VCTEODGH-BwilySuK.js → abnfDiagram-VCTEODGH-b_KmB8jf.js} +1 -1
  28. package/dist/web/assets/{arc-Cux6JiSb.js → arc-BnujRvIo.js} +1 -1
  29. package/dist/web/assets/{architectureDiagram-5GKGNRK7-D-ByBPbm.js → architectureDiagram-5GKGNRK7-WEtLjnZb.js} +2 -2
  30. package/dist/web/assets/{blockDiagram-I7D4REHJ-Din_Tp56.js → blockDiagram-I7D4REHJ-DloFWHRl.js} +1 -1
  31. package/dist/web/assets/{c4Diagram-7LVT6UL2-DYyAYcyC.js → c4Diagram-7LVT6UL2-CLLVNxSf.js} +1 -1
  32. package/dist/web/assets/channel-KN91hj_u.js +1 -0
  33. package/dist/web/assets/{chunk-2Q5K7J3B-CPJA6Yfg.js → chunk-2Q5K7J3B-CT9K7oGS.js} +1 -1
  34. package/dist/web/assets/{chunk-5VM5RSS4-C3SDCrL8.js → chunk-5VM5RSS4-C5czpKJa.js} +1 -1
  35. package/dist/web/assets/{chunk-F27PBJKO-Bpn3qXzM.js → chunk-F27PBJKO-CB0aeQW0.js} +1 -1
  36. package/dist/web/assets/{chunk-IMKFNOWR-CwbskBX_.js → chunk-IMKFNOWR-BFooJFqm.js} +1 -1
  37. package/dist/web/assets/{chunk-JWPE2WC7-B_tFUgaz.js → chunk-JWPE2WC7-Vevj2CsH.js} +1 -1
  38. package/dist/web/assets/{chunk-POPQ4Y6H-BHiZIox4.js → chunk-POPQ4Y6H-Cn90j9Nm.js} +1 -1
  39. package/dist/web/assets/{chunk-SVP7TREG-RIsRYMql.js → chunk-SVP7TREG-Ca06hcLp.js} +1 -1
  40. package/dist/web/assets/{chunk-TICWLB2K-C4WnjQ-g.js → chunk-TICWLB2K-o_xm22jZ.js} +1 -1
  41. package/dist/web/assets/{chunk-XXDRQBXY-B1f8rh55.js → chunk-XXDRQBXY-CQ_7ZUjC.js} +1 -1
  42. package/dist/web/assets/classDiagram-ZZMXUADV-wNP-H4GI.js +1 -0
  43. package/dist/web/assets/classDiagram-v2-VYDZK3BY-wNP-H4GI.js +1 -0
  44. package/dist/web/assets/{cose-bilkent-JH36ORCC-BWSBuZCN.js → cose-bilkent-JH36ORCC-CalIaEeA.js} +1 -1
  45. package/dist/web/assets/{cynefin-OW5HDTMX-DS8_-RUQ.js → cynefin-OW5HDTMX-FAdMojjm.js} +1 -1
  46. package/dist/web/assets/{cynefinDiagram-5FMLGOSQ-BXhPW2ra.js → cynefinDiagram-5FMLGOSQ-VLbq1KAt.js} +1 -1
  47. package/dist/web/assets/{dagre-GXQ25YYZ-BFJpmRsY.js → dagre-GXQ25YYZ-Dre5wMdT.js} +1 -1
  48. package/dist/web/assets/{diagram-S7CK7UJ4-CtnZg8I7.js → diagram-S7CK7UJ4-DkTuWBYn.js} +1 -1
  49. package/dist/web/assets/{diagram-UQ7AKVKN-DlWc0Wil.js → diagram-UQ7AKVKN-BK5Ltr9k.js} +1 -1
  50. package/dist/web/assets/{diagram-VSXAHHWV-CjcupCxx.js → diagram-VSXAHHWV-LG1f8W6V.js} +1 -1
  51. package/dist/web/assets/{diagram-VX7I27RA-Cm2GC6SD.js → diagram-VX7I27RA-BVwt3jpo.js} +1 -1
  52. package/dist/web/assets/{diagram-Z3DM3KII-CsEvtuQd.js → diagram-Z3DM3KII-19sqs0Y_.js} +1 -1
  53. package/dist/web/assets/{download-BS_0-AxS.js → download-BGem9h6x.js} +1 -1
  54. package/dist/web/assets/{ebnfDiagram-PWID7BFC-COzCi41m.js → ebnfDiagram-PWID7BFC-BQrUKmgc.js} +1 -1
  55. package/dist/web/assets/{erDiagram-RLTQ6QDP-IMxBO8ty.js → erDiagram-RLTQ6QDP-BH7BQClj.js} +1 -1
  56. package/dist/web/assets/{flowDiagram-HODETNUW-vds1bUdG.js → flowDiagram-HODETNUW-B5-km_ak.js} +1 -1
  57. package/dist/web/assets/{folder-open-Bj_73g-Y.js → folder-open-ChN5iZ3w.js} +1 -1
  58. package/dist/web/assets/{ganttDiagram-EL5Y4UJY-ClOaYIks.js → ganttDiagram-EL5Y4UJY-CFjl9COc.js} +4 -4
  59. package/dist/web/assets/{gitGraphDiagram-WWUBYQGX-BJP34EWq.js → gitGraphDiagram-WWUBYQGX-CaC1myzp.js} +1 -1
  60. package/dist/web/assets/{highlighted-body-KPVGNVTW-D1qiXPpq.js → highlighted-body-KPVGNVTW-DDIlpHEF.js} +1 -1
  61. package/dist/web/assets/index-BJl2bI67.js +466 -0
  62. package/dist/web/assets/index-By-yk0a_.css +1 -0
  63. package/dist/web/assets/{infoDiagram-27XIBGKW-Dy7DB3pC.js → infoDiagram-27XIBGKW-C5OHrTYA.js} +1 -1
  64. package/dist/web/assets/{ishikawaDiagram-5VMMS53U-B4sINDZb.js → ishikawaDiagram-5VMMS53U-CSbRW4Jo.js} +1 -1
  65. package/dist/web/assets/{journeyDiagram-3NMN7TZE-BnSJ3YV3.js → journeyDiagram-3NMN7TZE-DFSnebbO.js} +1 -1
  66. package/dist/web/assets/{kanban-definition-UXKFOSKX-eQTOsBlg.js → kanban-definition-UXKFOSKX-BDaSkcPI.js} +1 -1
  67. package/dist/web/assets/{layout-CUd5e3nS.js → layout-BCFlcCVi.js} +1 -1
  68. package/dist/web/assets/{linear-0ca0-hn8.js → linear-BTUXXmnO.js} +1 -1
  69. package/dist/web/assets/{list-TY5QvST4.js → list-CCv6cv61.js} +1 -1
  70. package/dist/web/assets/{mermaid-HWGCJPDP-uMQRi2iO.js → mermaid-HWGCJPDP-BybXV5X9.js} +65 -65
  71. package/dist/web/assets/{mindmap-definition-YA3MSWOX-DVzVYHJb.js → mindmap-definition-YA3MSWOX-gosxcHRf.js} +1 -1
  72. package/dist/web/assets/{pegDiagram-XKGWAZYB-BJ7UWr8A.js → pegDiagram-XKGWAZYB-CqABPNFC.js} +1 -1
  73. package/dist/web/assets/{pencil-tq07PJIK.js → pencil-D3Nj_J6I.js} +1 -1
  74. package/dist/web/assets/{pieDiagram-E7YTZNPT-jMPBCwJE.js → pieDiagram-E7YTZNPT-CULuRgHi.js} +1 -1
  75. package/dist/web/assets/{quadrantDiagram-AXDQQJYC-CaI8P14G.js → quadrantDiagram-AXDQQJYC-BOLJCnM7.js} +1 -1
  76. package/dist/web/assets/{railroadDiagram-O6MQD6OU-Vr6XNTAL.js → railroadDiagram-O6MQD6OU-Cm-gmAJP.js} +1 -1
  77. package/dist/web/assets/{refresh-cw-CSpRwkJ1.js → refresh-cw-Dt1BasKC.js} +1 -1
  78. package/dist/web/assets/{requirementDiagram-BXWQKSXE-Ct8-bR5z.js → requirementDiagram-BXWQKSXE-BJ9PIX2G.js} +1 -1
  79. package/dist/web/assets/{sankeyDiagram-P5KCCOFB-CCooWN1o.js → sankeyDiagram-P5KCCOFB-OtNbBp5F.js} +1 -1
  80. package/dist/web/assets/{save-wtDP4EBM.js → save-D-k08Gwx.js} +1 -1
  81. package/dist/web/assets/{scroll-area-C0__dq9d.js → scroll-area-DyJaZyLF.js} +1 -1
  82. package/dist/web/assets/{sequenceDiagram-WJ2MYXX4-CJG0tpsp.js → sequenceDiagram-WJ2MYXX4-CO79aRbm.js} +1 -1
  83. package/dist/web/assets/{sizeCapture-INFHLROL-CYAGWmyp.js → sizeCapture-INFHLROL-DEFrP0Kz.js} +1 -1
  84. package/dist/web/assets/{stateDiagram-D77RDMKH-B6tbtiF5.js → stateDiagram-D77RDMKH-d4dMkT_v.js} +1 -1
  85. package/dist/web/assets/stateDiagram-v2-MP3YSRHH-BGw3THh3.js +1 -0
  86. package/dist/web/assets/{swimlanes-42K2YHIH-B5YmlV2W.js → swimlanes-42K2YHIH-B7-9UuUR.js} +1 -1
  87. package/dist/web/assets/swimlanesDiagram-VR7AAH4N-CDTgKDWG.js +8 -0
  88. package/dist/web/assets/{timeline-definition-24CTP7MA-C70UVk0W.js → timeline-definition-24CTP7MA-BOCBVF6I.js} +1 -1
  89. package/dist/web/assets/{upload-Bbjonx95.js → upload-Dc5-aQpw.js} +1 -1
  90. package/dist/web/assets/{useJobs-B65iRrUv.js → useJobs-BQp9uwz-.js} +1 -1
  91. package/dist/web/assets/{useKnowledge-BwBd_xnP.js → useKnowledge-B7daBTjp.js} +1 -1
  92. package/dist/web/assets/{useMemories-CA58mmx2.js → useMemories-MoQflRW_.js} +1 -1
  93. package/dist/web/assets/useProjectScope-BthZtFg0.js +1 -0
  94. package/dist/web/assets/{vennDiagram-4TSXK5OY-DlQ_KIfV.js → vennDiagram-4TSXK5OY-BjUoKfC-.js} +1 -1
  95. package/dist/web/assets/{wardleyDiagram-VM6X3IG4-B8kVmvQk.js → wardleyDiagram-VM6X3IG4-CBdh0MEJ.js} +1 -1
  96. package/dist/web/assets/{xychartDiagram-S5SC5T6Z-CmW5-A2L.js → xychartDiagram-S5SC5T6Z-CAodTcXa.js} +1 -1
  97. package/dist/web/index.html +2 -2
  98. package/package.json +1 -1
  99. package/dist/web/assets/Audit-DYXfN8Z-.js +0 -1
  100. package/dist/web/assets/Dashboard-DZipdmRC.js +0 -1
  101. package/dist/web/assets/PackageCatalog-NCTkGfB2.js +0 -18
  102. package/dist/web/assets/Skills-BoPSePtc.js +0 -16
  103. package/dist/web/assets/Terminals-DtujdvuM.js +0 -115
  104. package/dist/web/assets/channel-e1u5XNEX.js +0 -1
  105. package/dist/web/assets/classDiagram-ZZMXUADV-lJertNRH.js +0 -1
  106. package/dist/web/assets/classDiagram-v2-VYDZK3BY-lJertNRH.js +0 -1
  107. package/dist/web/assets/index-DqE2dG9P.js +0 -461
  108. package/dist/web/assets/index-sd04m1Ya.css +0 -1
  109. package/dist/web/assets/stateDiagram-v2-MP3YSRHH-DkG2Bl6V.js +0 -1
  110. package/dist/web/assets/swimlanesDiagram-VR7AAH4N-D5nGg3Kj.js +0 -8
  111. package/dist/web/assets/useProjectScope-6JtX8j4R.js +0 -1
@@ -15,6 +15,13 @@ Call `context` first. Use current tool schemas and installed CLI help as the ope
15
15
  contract. Report missing capabilities rather than inventing calls or changing the
16
16
  installation as a side effect.
17
17
 
18
+ Customize HTTP MCP with `mode=full|meta` and either `project=<name>` or
19
+ `projects=<name1>,<name2>`. Project selection sets defaults across project-aware
20
+ tools, including tasks, memories, jobs, knowledge and skills. Multiple projects
21
+ combine discovery results; their order controls skill instruction priority and
22
+ the default project for new resources. See [MCP query parameters](references/setup.md#customize-the-http-mcp-connection)
23
+ for defaults, examples, validation and tool-level overrides.
24
+
18
25
  Read only the reference matching the request. Related operations share a file so
19
26
  one recipe does not require a chain of tiny reads.
20
27
 
@@ -12,6 +12,28 @@ effective entry instructions and file inventory. Load a supporting file with
12
12
  filenames are supported; paths resolve from the skill root, never the repo cwd.
13
13
  Reads do not execute scripts. Binary content uses explicit base64 encoding.
14
14
 
15
+ Skills can belong to multiple projects; unassigned skills are global. Use
16
+ `/mcp?project=<readable-name>` or `/mcp?projects=orc,project2` to bind the connection
17
+ to selected projects' skills plus global ones. Shared skills appear once, before
18
+ pagination; project instruction overrides follow URL order, then global fallback.
19
+ Pass an explicit tool `project` to select one of the URL's projects. These defaults
20
+ also apply to project-aware context/tasks/jobs/memories/knowledge/session searches;
21
+ new resources use the first project by default. See [MCP query parameters](setup.md#customize-the-http-mcp-connection)
22
+ for `mode=full|meta`, selection limits and connection examples.
23
+ Other projects' skills are unavailable through list, search,
24
+ named/reference reads and downloads. Without a bound URL, pass `project` to select
25
+ scope. Scoped instruction edits do not assign skills to projects.
26
+ Manage assignments with `orc skill projects <name> --set <project-id> ...`, or
27
+ `--global`; authenticated API callers use GET/PUT `/api/skills/{name}/projects`.
28
+
29
+ `skill_list` lists and searches in pages: `limit` defaults to 30 (maximum 500),
30
+ `offset` defaults to 0, and the response includes `total` and `next_offset`.
31
+ Pass `q` for combined BM25/prefix/stem/phrase/substring/typo search on names and
32
+ descriptions. Search scores sort descending; all query terms must match. Fetch
33
+ the next page using `next_offset`; null means there are no more results.
34
+ MCP skill creation inherits the connection/argument project; with no selected
35
+ project, creation is global. Existing skills remain global until assigned.
36
+
15
37
  To use an original script/asset outside the ORC host, request
16
38
  `skill_read({name, ref: "scripts/check.py", download: true, project})`.
17
39
  Fetch the returned `download_url` into the intended local file and verify its
@@ -104,6 +104,68 @@ Reach `context` and other named tools through `tool_invoke` in meta mode.
104
104
  Connectors, loaded skills and installed hooks do not establish equal enforcement
105
105
  across agent clients. Disclose when MCP is unavailable; never claim a context read ran.
106
106
 
107
+ ### Customize the HTTP MCP connection
108
+
109
+ These query parameters customize `<origin>/mcp`; they also work together in meta
110
+ mode. Keep API authentication in the configured Authorization header.
111
+
112
+ | Parameter | Supported values | Default and effect |
113
+ | --- | --- | --- |
114
+ | `mode` | `full`, `meta` | `full`: lists domain tools directly. `meta`: lists `tool_search`, `tool_describe`, `tool_invoke`; domain operations keep the same validation and scope. |
115
+ | `project` | One readable project name, such as `orc` | Unset: existing tool/config defaults apply. When set, project-aware tools inherit this project. |
116
+ | `projects` | Comma-separated readable names, such as `orc,project2` | Selects multiple projects in priority order. Use instead of `project`. |
117
+
118
+ Examples, relative to the selected ORC origin:
119
+
120
+ ```text
121
+ /mcp # full tools, existing tool/config defaults
122
+ /mcp?mode=meta # meta tools, existing tool/config defaults
123
+ /mcp?project=orc # full tools, ORC project defaults
124
+ /mcp?projects=orc,project2 # full tools, both projects
125
+ /mcp?projects=orc,project2&mode=meta # both projects through meta tools
126
+ ```
127
+
128
+ Use readable names, not project IDs, in the URL; URL-encode spaces and reserved
129
+ characters. Names are trimmed and deduplicated case-insensitively, preserving the
130
+ first occurrence. Select at most 50 projects, with names of 1-200 characters.
131
+ Pass each project parameter once and never pass both `project` and `projects`.
132
+ Malformed selections or an unsupported mode return HTTP 400; any unknown project
133
+ returns 404, rather than silently falling back to another project.
134
+
135
+ Project selection is connection-wide, rather than a skill-only filter:
136
+
137
+ - `context`, task/job/memory lists, project discovery, audit and searches combine
138
+ selected projects before limits or pagination. Archived-session search uses
139
+ the same selection. Memories remain project-only; same-named memories in
140
+ different projects remain separate items.
141
+ - Skill discovery includes selected projects' skills plus unassigned global
142
+ skills, with shared skills appearing once. Reads prefer the first applicable
143
+ project instruction override in URL order, then global instructions.
144
+ - Knowledge discovery/search/evidence includes selected projects' KBs plus
145
+ global KBs. On a bound connection, KB `scope: "all"` stays within this selection.
146
+ - New resources default to the first URL project. An explicit tool `project`
147
+ (or `project_id` when its schema supports it) can choose another selected
148
+ project. For example, `task_list({})` combines the connection's projects;
149
+ `task_list({project: "project2"})` narrows to that project. Overrides outside
150
+ the URL selection are rejected. ID-targeted operations retain the resource's
151
+ existing owner.
152
+ - Global-only reads remain available where the tool supports `scope: "global"`.
153
+ Resources without project scoping retain their existing behavior. Without a
154
+ project query parameter, existing activeProject/tool defaults still apply.
155
+
156
+ This selection does not grant access or replace API authentication or tenant
157
+ authorization. Do not put secrets in the URL. Pagination/search settings such as
158
+ `limit`, `offset` and `q` belong in tool arguments, not the MCP connection query:
159
+ `skill_list({q: "code review", limit: 25, offset: 0})`. Skills default to 30 per
160
+ page (maximum 500); follow `next_offset` until it is null. Other tools retain
161
+ their own schemas and limits.
162
+
163
+ For a bridge connection using both parameters:
164
+
165
+ ```sh
166
+ spec call --mcp-http "<orc-base-url>/mcp?projects=orc,project2&mode=meta" tool_invoke --data '{"name":"context","arguments":{}}'
167
+ ```
168
+
107
169
  ## Diagnose before changing anything
108
170
 
109
171
  - Connection refused: verify origin, port, service ownership and process logs.
@@ -9,6 +9,12 @@ Sources: [Task flows](https://github.com/niradler/orc/blob/master/docs/task-flow
9
9
  Discover the project with `project_list` or `orc project list`; inspect its folder
10
10
  scope and execution host. MCP `project` arguments take readable names. CLI defaults
11
11
  to the configured active project; use its explicit project option when appropriate.
12
+ For HTTP MCP, `?project=orc` sets connection-wide defaults, while
13
+ `?projects=orc,project2` combines selected projects' lists/searches and defaults
14
+ new work to the first project. A tool's explicit project can select another
15
+ project from that URL. See [MCP query parameters](setup.md#customize-the-http-mcp-connection)
16
+ for `mode`, validation and examples; connection selection does not change the
17
+ configured active project or relocate existing resources.
12
18
  Inspect `task_list`/`task_get` before creating work. Record outcome, acceptance
13
19
  criteria, constraints and expected artifacts in the task; keep progress in comments.
14
20
  Use dependency-linked batches only for useful separate work units.
@@ -1,4 +1,4 @@
1
- import{r as b,j as e,U as J,W as X,X as Z,Y as M,Z as B,B as k,k as I,_ as ee,$ as K,a as te,u as U,a0 as ae,b as T,E as G,V as ne,L as se,a1 as re,a2 as ie,a3 as oe,a4 as de,a5 as le,a6 as ce,a7 as ue,a8 as W,d as D}from"./index-DqE2dG9P.js";import{p as ge,i as q}from"./public-api-BvD4z7ja.js";const _={specialist:`---
1
+ import{r as b,j as e,X as J,Y as X,Z,_ as M,$ as B,B as k,l as I,a0 as ee,a1 as K,a as te,u as U,a2 as ae,b as T,E as G,V as ne,L as se,a3 as re,a4 as ie,a5 as oe,a6 as de,a7 as le,a8 as ce,a9 as ue,aa as _,d as D}from"./index-BJl2bI67.js";import{p as ge,i as q}from"./public-api-BvD4z7ja.js";const z={specialist:`---
2
2
  name: Specialist
3
3
  description: Describe when to use this specialist
4
4
  ---
@@ -28,7 +28,7 @@ Implement the requested change, preserve unrelated work, and run relevant checks
28
28
  `};function me(r){const a=ge(r,{stringKeys:!0});if(a.errors.length)throw new Error(a.errors[0].message);if(a.warnings.length)throw new Error(a.warnings[0].message);if(!q(a.contents))throw new Error("YAML configuration must be a mapping.");const n=a.toJS({maxAliasCount:100});if(!n||typeof n!="object"||Array.isArray(n))throw new Error("YAML configuration must be a mapping.");return JSON.stringify(n),{document:a,fields:n}}function L(r){const a=r.replace(/^\uFEFF/,"").match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n([\s\S]*))?$/);if(!a)throw new Error("Add YAML configuration between --- lines, followed by instructions.");return{...me(a[1]),body:a[2]??"",newline:r.includes(`\r
29
29
  `)?`\r
30
30
  `:`
31
- `,bom:r.startsWith("\uFEFF")?"\uFEFF":""}}function z(r,a,n){const o=L(r);n===void 0?o.document.delete(a):o.document.set(a,n);const u=o.document.toString().trimEnd().replace(/\n/g,o.newline);return`${o.bom}---${o.newline}${u}${o.newline}---${o.newline}${o.body}`}function he(r,a){var o;const n=(o=r.match(/^((?:\uFEFF)?---\r?\n[\s\S]*?\r?\n---)(?:\r?\n[\s\S]*)?$/))==null?void 0:o[1];if(!n)throw new Error("Missing YAML configuration.");return`${n}${r.includes(`\r
31
+ `,bom:r.startsWith("\uFEFF")?"\uFEFF":""}}function H(r,a,n){const o=L(r);n===void 0?o.document.delete(a):o.document.set(a,n);const u=o.document.toString().trimEnd().replace(/\n/g,o.newline);return`${o.bom}---${o.newline}${u}${o.newline}---${o.newline}${o.body}`}function he(r,a){var o;const n=(o=r.match(/^((?:\uFEFF)?---\r?\n[\s\S]*?\r?\n---)(?:\r?\n[\s\S]*)?$/))==null?void 0:o[1];if(!n)throw new Error("Missing YAML configuration.");return`${n}${r.includes(`\r
32
32
  `)?`\r
33
33
  `:`
34
- `}${a}`}function V(r){const a=r.tools;if(a===void 0)return[];if(typeof a=="string")return a.split(/[\s,]+/).filter(Boolean).map(n=>({name:n,allowed:!0}));if(Array.isArray(a)&&a.every(n=>typeof n=="string"))return a.map(n=>({name:n,allowed:!0}));if(a&&typeof a=="object"&&!Array.isArray(a))return Object.entries(a).map(([n,o])=>{if(typeof o!="boolean")throw new Error(`Tool "${n}" must be true or false.`);return{name:n,allowed:o}});throw new Error("Tools must be a mapping of names to true/false, a list, or a string.")}function pe(r,a){const n=L(r);q(n.document.get("tools",!0))||n.document.set("tools",{});const o=n.document.get("tools",!0);if(q(o))for(const{name:u}of V(n.fields))a.some(C=>C.name===u)||n.document.deleteIn(["tools",u]);for(const u of a)n.document.setIn(["tools",u.name],u.allowed);return`${n.bom}---${n.newline}${n.document.toString().trimEnd().replace(/\n/g,n.newline)}${n.newline}---${n.newline}${n.body}`}function P(r){return V(r).map(a=>({...a,key:crypto.randomUUID()}))}function H({agent:r,pending:a,error:n,onSave:o}){var v,S;const[u,C]=b.useState((r==null?void 0:r.id)??""),[g,l]=b.useState((r==null?void 0:r.raw)??_.specialist),[d,p]=b.useState("fields"),[f,E]=b.useState(()=>r?P(r.fields):[]),[c,A]=b.useState(),x=b.useMemo(()=>{try{return{value:L(g),error:void 0}}catch(t){return{value:void 0,error:t.message}}},[g]),m=(v=x.value)==null?void 0:v.fields;let h;f.some(t=>!t.name.trim())?h="Enter a name for every tool.":new Set(f.map(t=>t.name.trim())).size!==f.length&&(h="Tool names must be unique.");const R=r?"Save changes":"Create agent";function w(t){E(t),t.every(i=>i.name.trim())&&new Set(t.map(i=>i.name.trim())).size===t.length&&l(pe(g,t.map(i=>({...i,name:i.name.trim()}))))}function N(){if(A(void 0),d==="fields"){if(h)return;p("source");return}try{const t=L(g);for(const i of["name","description","model","color"])if(t.fields[i]!==void 0&&typeof t.fields[i]!="string")throw new Error(`${i} must be a string to edit it in the form.`);E(P(t.fields)),p("fields")}catch(t){A(t.message)}}return e.jsxs(J,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(X,{children:e.jsx(Z,{children:r?`Edit ${r.name}`:"New shared agent"})}),e.jsxs("form",{className:"space-y-4",onSubmit:t=>{t.preventDefault(),o(u,g)},children:[e.jsxs("fieldset",{disabled:a,className:"space-y-4",children:[!r&&e.jsxs(e.Fragment,{children:[e.jsx(M,{htmlFor:"agent-template",children:"Starting template"}),e.jsxs("select",{id:"agent-template","data-testid":"agent-template",className:"w-full border rounded-sm p-2 bg-surface",defaultValue:"specialist",onChange:t=>{const i=_[t.target.value];l(i),E(P(L(i).fields)),A(void 0)},children:[e.jsx("option",{value:"specialist",children:"General specialist"}),e.jsx("option",{value:"reviewer",children:"Reviewer"}),e.jsx("option",{value:"builder",children:"Builder"})]})]}),e.jsx(M,{htmlFor:"agent-id",children:"Agent ID"}),e.jsx(B,{id:"agent-id","data-testid":"agent-id-input",value:u,disabled:!!r,onChange:t=>C(t.target.value),placeholder:"security-review"}),e.jsx(k,{type:"button",variant:"outline","data-testid":"agent-editor-mode",onClick:N,disabled:d==="fields"&&!!h,children:d==="fields"?"Edit YAML + Markdown":"Edit fields"}),d==="source"?e.jsxs(e.Fragment,{children:[e.jsx(M,{htmlFor:"agent-definition",children:"YAML configuration + Markdown instructions"}),e.jsx(I,{id:"agent-definition",testId:"agent-content-input",path:"agent.agent.md",readOnly:a,height:400,value:g,onChange:t=>{l(t),A(void 0)}})]}):m&&e.jsxs(e.Fragment,{children:[[["name","Name"],["description","Description"],["model","Model (optional)"],["color","Color (optional)"]].map(([t,i])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(M,{htmlFor:`agent-${t}`,children:i}),e.jsx(B,{id:`agent-${t}`,"data-testid":`agent-${t}-input`,value:typeof m[t]=="string"?m[t]:"",onChange:y=>l(z(g,t,y.target.value||(t==="description"?"":void 0)))})]},t)),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx("input",{"data-testid":"agent-custom-tools",type:"checkbox",checked:m.tools!==void 0,onChange:t=>{E([]),l(z(g,"tools",t.target.checked?{}:void 0))}})," ","Customize tool access"]}),e.jsx("p",{className:"text-xs text-outline",children:"Use the tool names supported by your chosen backend. With customization off, the backend's default tools apply. An empty custom list allows no tools."}),m.tools!==void 0&&e.jsxs(e.Fragment,{children:[f.map((t,i)=>e.jsxs("div",{"data-testid":"agent-tool-row",className:"flex items-center gap-2",children:[e.jsx(B,{"data-testid":"agent-tool-name","aria-label":`Tool ${i+1} name`,value:t.name,list:"agent-tool-suggestions",onChange:y=>w(f.map((j,$)=>$===i?{...j,name:y.target.value}:j))}),e.jsxs("label",{className:"flex items-center gap-1 text-sm",children:[e.jsx("input",{"data-testid":"agent-tool-allowed",type:"checkbox",checked:t.allowed,onChange:y=>w(f.map((j,$)=>$===i?{...j,allowed:y.target.checked}:j))})," ","Allowed"]}),e.jsx(k,{"data-testid":"agent-tool-remove",type:"button",variant:"outline",onClick:()=>w(f.filter((y,j)=>j!==i)),children:"Remove"})]},t.key)),e.jsx("datalist",{id:"agent-tool-suggestions",children:["Read","Grep","Glob","Edit","Write","Bash"].map(t=>e.jsx("option",{value:t},t))}),e.jsx(k,{"data-testid":"agent-tool-add",type:"button",variant:"outline",onClick:()=>w([...f,{key:crypto.randomUUID(),name:"",allowed:!0}]),children:"Add tool"})]})]}),e.jsx(M,{htmlFor:"agent-instructions",children:"Instructions"}),e.jsx(I,{id:"agent-instructions",testId:"agent-instructions-input",path:"instructions.md",readOnly:a,height:240,value:((S=x.value)==null?void 0:S.body)??"",onChange:t=>l(he(g,t))}),e.jsx("p",{className:"text-xs text-outline",children:"Use YAML + Markdown to edit handoffs and additional configuration. Custom fields are preserved."})]})]}),(n||x.error||c||d==="fields"&&h)&&e.jsx("p",{"data-testid":"agent-editor-error",role:"alert",className:"text-destructive",children:n||x.error||c||h}),e.jsx(k,{"data-testid":"agent-submit",type:"submit",disabled:a||!u.trim()||!g.trim()||!!x.error||d==="fields"&&!!h,children:a?"Saving...":R})]})]})}function ve({embedded:r=!1}){var i,y,j,$,O,Q,Y;const a=ee(),n=new URLSearchParams(a.search).get("project")??"all",[o,u]=K("editorMode","read",["read","edit","split"]),[C,g]=K("agentQuery",""),l=te(),d=U({queryKey:["agents"],queryFn:()=>D.agents.list()}),{selectedId:p,openDetail:f,closeDetail:E}=ae(r?"/packages/agents":"/agents","agentId"),c=U({queryKey:["agent",p],queryFn:()=>D.agents.get(p),enabled:!!p}),[A,x]=b.useState(!1),[m,h]=b.useState(),[R,w]=b.useState(!1),N=T({mutationFn:D.agents.create,onSuccess:()=>{l.invalidateQueries({queryKey:["agents"]}),x(!1)}}),v=T({mutationFn:D.agents.delete,onSuccess:()=>{w(!1),E(),l.invalidateQueries({queryKey:["agents"]}),l.invalidateQueries({queryKey:["agent-packages"]}),l.invalidateQueries({queryKey:["agent"]})}}),S=T({mutationFn:({profile:s,content:F})=>D.agents.update(s.id,{content:F,expectedRaw:s.raw,expectedPath:s.path}),onSuccess:s=>{l.setQueryData(["agent",s.id],s),l.invalidateQueries({queryKey:["agents"]}),l.invalidateQueries({queryKey:["agent-packages"]}),h(void 0)}});if(d.error)return e.jsx(G,{message:d.error.message,onRetry:()=>void d.refetch()});const t=(((i=d.data)==null?void 0:i.agents)??[]).filter(s=>`${s.name} ${s.id} ${s.description}`.toLowerCase().includes(C.toLowerCase()));return e.jsxs("div",{className:"space-y-5",children:[r?e.jsxs("div",{className:"flex flex-wrap justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-medium",children:"Agent definitions"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage specialist instructions, models and tools. Add them to APM packages for reuse."})]}),e.jsx(k,{"data-testid":"new-agent-button",onClick:()=>{N.reset(),x(!0)},children:"New agent"})]}):e.jsx(ne,{title:"Agents",meta:`${((y=d.data)==null?void 0:y.agents.length)??0} shared profiles`,action:e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsx(k,{"data-testid":"new-agent-button",onClick:()=>{N.reset(),x(!0)},children:"New agent"})})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Shared specialist definitions for every connected coding agent."," ",e.jsx("a",{className:"text-primary underline",href:"https://microsoft.github.io/apm/producer/author-primitives/instructions-and-agents/",target:"_blank",rel:"noreferrer",children:"APM agent format"})]}),!r&&e.jsx(se,{to:re("/packages",n,a.search),"data-testid":"agents-packages-link",className:"text-primary underline",children:"Manage packages and reusable launch setups"}),(((j=d.data)==null?void 0:j.broken)??[]).map(s=>e.jsxs("p",{role:"alert",className:"text-destructive",children:[s.path,": ",s.error]},s.path)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(B,{className:"min-w-[180px] max-w-lg flex-1","aria-label":"Find an agent",placeholder:"Find an agent by name or purpose…",value:C,onChange:s=>g(s.target.value,{replace:!0})}),C&&e.jsx(k,{variant:"ghost",onClick:()=>g(""),children:"Clear"})]}),e.jsxs("div",{className:"space-y-2",children:[d.isLoading&&e.jsx("p",{role:"status","data-testid":"page-loading",children:"Loading agents…"}),t.map(s=>e.jsxs("button",{type:"button","data-testid":"agent-row","data-agent-id":s.id,onClick:()=>f(s.id),className:"w-full text-left border-b border-outline-variant p-4 hover:bg-surface-low",children:[e.jsx("span",{className:"block break-words text-base font-medium",children:s.name}),e.jsxs("span",{className:"mt-1 block break-all text-xs text-muted-foreground",children:[s.id," · ",s.source]}),e.jsx("p",{className:"mt-2 break-words text-sm leading-relaxed text-muted-foreground",children:s.description})]},s.id)),!d.isLoading&&!t.length&&e.jsx("p",{"data-testid":"page-empty",className:"text-sm text-muted-foreground",children:C?"No agents match this search. Try another name or clear the filter.":"Create an agent or import specialists from Packages."})]}),e.jsx(ie,{open:!!p,onOpenChange:s=>!s&&E(),children:e.jsxs(oe,{children:[e.jsx(de,{children:e.jsx(le,{children:(($=c.data)==null?void 0:$.name)??"Agent profile"})}),e.jsx(ce,{children:c.error?e.jsx(G,{message:c.error.message,onRetry:()=>void c.refetch()}):c.data?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm",children:c.data.description}),e.jsx(k,{"data-testid":"agent-edit",variant:"outline",onClick:async()=>{S.reset();const s=await c.refetch();s.data&&h(s.data)},children:"Edit agent"}),e.jsx(k,{"data-testid":"agent-delete",variant:"destructive",onClick:()=>{v.reset(),w(!0)},disabled:v.isPending,children:"Delete agent"}),v.error&&e.jsx("p",{"data-testid":"agent-delete-error",role:"alert",className:"text-destructive",children:v.error.message}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use this profile in a flow agent node with ",e.jsxs("code",{children:['"agent": "',c.data.id,'"']})," ","and choose the coding backend independently."]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Model and tool restrictions depend on backend support. ORC refuses to launch when it cannot honor a declared restriction. Handoffs remain declarations; flow edges choose execution."}),e.jsx(I,{path:"metadata.json",value:JSON.stringify(c.data.fields,null,2),readOnly:!0,height:180,testId:"agent-fields"}),e.jsx(I,{path:"agent.agent.md",mode:o,onModeChange:u,value:c.data.raw,readOnly:!0,height:400,testId:"agent-content"})]}):e.jsx("p",{children:"Loading..."})})]})}),e.jsx(ue,{open:R,title:`Delete ${((O=c.data)==null?void 0:O.name)??"agent"}?`,description:`This permanently deletes the agent definition "${p}". Other agents and package resources are kept. Flows referencing this agent will need another profile.`,isPending:v.isPending,onCancel:()=>!v.isPending&&w(!1),onConfirm:()=>{p&&v.mutate(p,{onError:()=>w(!1)})}}),e.jsx(W,{open:A,onOpenChange:s=>!N.isPending&&x(s),children:A&&e.jsx(H,{pending:N.isPending,error:(Q=N.error)==null?void 0:Q.message,onSave:(s,F)=>N.mutate({id:s,content:F})})}),e.jsx(W,{open:!!m,onOpenChange:s=>!s&&!S.isPending&&h(void 0),children:m&&e.jsx(H,{agent:m,pending:S.isPending,error:(Y=S.error)==null?void 0:Y.message,onSave:(s,F)=>S.mutate({profile:m,content:F})},m.id)})]})}export{ve as default};
34
+ `}${a}`}function W(r){const a=r.tools;if(a===void 0)return[];if(typeof a=="string")return a.split(/[\s,]+/).filter(Boolean).map(n=>({name:n,allowed:!0}));if(Array.isArray(a)&&a.every(n=>typeof n=="string"))return a.map(n=>({name:n,allowed:!0}));if(a&&typeof a=="object"&&!Array.isArray(a))return Object.entries(a).map(([n,o])=>{if(typeof o!="boolean")throw new Error(`Tool "${n}" must be true or false.`);return{name:n,allowed:o}});throw new Error("Tools must be a mapping of names to true/false, a list, or a string.")}function pe(r,a){const n=L(r);q(n.document.get("tools",!0))||n.document.set("tools",{});const o=n.document.get("tools",!0);if(q(o))for(const{name:u}of W(n.fields))a.some(C=>C.name===u)||n.document.deleteIn(["tools",u]);for(const u of a)n.document.setIn(["tools",u.name],u.allowed);return`${n.bom}---${n.newline}${n.document.toString().trimEnd().replace(/\n/g,n.newline)}${n.newline}---${n.newline}${n.body}`}function P(r){return W(r).map(a=>({...a,key:crypto.randomUUID()}))}function V({agent:r,pending:a,error:n,onSave:o}){var v,S;const[u,C]=b.useState((r==null?void 0:r.id)??""),[g,l]=b.useState((r==null?void 0:r.raw)??z.specialist),[d,p]=b.useState("fields"),[f,E]=b.useState(()=>r?P(r.fields):[]),[c,A]=b.useState(),x=b.useMemo(()=>{try{return{value:L(g),error:void 0}}catch(t){return{value:void 0,error:t.message}}},[g]),m=(v=x.value)==null?void 0:v.fields;let h;f.some(t=>!t.name.trim())?h="Enter a name for every tool.":new Set(f.map(t=>t.name.trim())).size!==f.length&&(h="Tool names must be unique.");const R=r?"Save changes":"Create agent";function w(t){E(t),t.every(i=>i.name.trim())&&new Set(t.map(i=>i.name.trim())).size===t.length&&l(pe(g,t.map(i=>({...i,name:i.name.trim()}))))}function N(){if(A(void 0),d==="fields"){if(h)return;p("source");return}try{const t=L(g);for(const i of["name","description","model","color"])if(t.fields[i]!==void 0&&typeof t.fields[i]!="string")throw new Error(`${i} must be a string to edit it in the form.`);E(P(t.fields)),p("fields")}catch(t){A(t.message)}}return e.jsxs(J,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(X,{children:e.jsx(Z,{children:r?`Edit ${r.name}`:"New shared agent"})}),e.jsxs("form",{className:"space-y-4",onSubmit:t=>{t.preventDefault(),o(u,g)},children:[e.jsxs("fieldset",{disabled:a,className:"space-y-4",children:[!r&&e.jsxs(e.Fragment,{children:[e.jsx(M,{htmlFor:"agent-template",children:"Starting template"}),e.jsxs("select",{id:"agent-template","data-testid":"agent-template",className:"w-full border rounded-sm p-2 bg-surface",defaultValue:"specialist",onChange:t=>{const i=z[t.target.value];l(i),E(P(L(i).fields)),A(void 0)},children:[e.jsx("option",{value:"specialist",children:"General specialist"}),e.jsx("option",{value:"reviewer",children:"Reviewer"}),e.jsx("option",{value:"builder",children:"Builder"})]})]}),e.jsx(M,{htmlFor:"agent-id",children:"Agent ID"}),e.jsx(B,{id:"agent-id","data-testid":"agent-id-input",value:u,disabled:!!r,onChange:t=>C(t.target.value),placeholder:"security-review"}),e.jsx(k,{type:"button",variant:"outline","data-testid":"agent-editor-mode",onClick:N,disabled:d==="fields"&&!!h,children:d==="fields"?"Edit YAML + Markdown":"Edit fields"}),d==="source"?e.jsxs(e.Fragment,{children:[e.jsx(M,{htmlFor:"agent-definition",children:"YAML configuration + Markdown instructions"}),e.jsx(I,{id:"agent-definition",testId:"agent-content-input",path:"agent.agent.md",readOnly:a,height:400,value:g,onChange:t=>{l(t),A(void 0)}})]}):m&&e.jsxs(e.Fragment,{children:[[["name","Name"],["description","Description"],["model","Model (optional)"],["color","Color (optional)"]].map(([t,i])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(M,{htmlFor:`agent-${t}`,children:i}),e.jsx(B,{id:`agent-${t}`,"data-testid":`agent-${t}-input`,value:typeof m[t]=="string"?m[t]:"",onChange:y=>l(H(g,t,y.target.value||(t==="description"?"":void 0)))})]},t)),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx("input",{"data-testid":"agent-custom-tools",type:"checkbox",checked:m.tools!==void 0,onChange:t=>{E([]),l(H(g,"tools",t.target.checked?{}:void 0))}})," ","Customize tool access"]}),e.jsx("p",{className:"text-xs text-outline",children:"Use the tool names supported by your chosen backend. With customization off, the backend's default tools apply. An empty custom list allows no tools."}),m.tools!==void 0&&e.jsxs(e.Fragment,{children:[f.map((t,i)=>e.jsxs("div",{"data-testid":"agent-tool-row",className:"flex items-center gap-2",children:[e.jsx(B,{"data-testid":"agent-tool-name","aria-label":`Tool ${i+1} name`,value:t.name,list:"agent-tool-suggestions",onChange:y=>w(f.map((j,$)=>$===i?{...j,name:y.target.value}:j))}),e.jsxs("label",{className:"flex items-center gap-1 text-sm",children:[e.jsx("input",{"data-testid":"agent-tool-allowed",type:"checkbox",checked:t.allowed,onChange:y=>w(f.map((j,$)=>$===i?{...j,allowed:y.target.checked}:j))})," ","Allowed"]}),e.jsx(k,{"data-testid":"agent-tool-remove",type:"button",variant:"outline",onClick:()=>w(f.filter((y,j)=>j!==i)),children:"Remove"})]},t.key)),e.jsx("datalist",{id:"agent-tool-suggestions",children:["Read","Grep","Glob","Edit","Write","Bash"].map(t=>e.jsx("option",{value:t},t))}),e.jsx(k,{"data-testid":"agent-tool-add",type:"button",variant:"outline",onClick:()=>w([...f,{key:crypto.randomUUID(),name:"",allowed:!0}]),children:"Add tool"})]})]}),e.jsx(M,{htmlFor:"agent-instructions",children:"Instructions"}),e.jsx(I,{id:"agent-instructions",testId:"agent-instructions-input",path:"instructions.md",readOnly:a,height:240,value:((S=x.value)==null?void 0:S.body)??"",onChange:t=>l(he(g,t))}),e.jsx("p",{className:"text-xs text-outline",children:"Use YAML + Markdown to edit handoffs and additional configuration. Custom fields are preserved."})]})]}),(n||x.error||c||d==="fields"&&h)&&e.jsx("p",{"data-testid":"agent-editor-error",role:"alert",className:"text-destructive",children:n||x.error||c||h}),e.jsx(k,{"data-testid":"agent-submit",type:"submit",disabled:a||!u.trim()||!g.trim()||!!x.error||d==="fields"&&!!h,children:a?"Saving...":R})]})]})}function ve({embedded:r=!1}){var i,y,j,$,O,Q,Y;const a=ee(),n=new URLSearchParams(a.search).get("project")??"all",[o,u]=K("editorMode","read",["read","edit","split"]),[C,g]=K("agentQuery",""),l=te(),d=U({queryKey:["agents"],queryFn:()=>D.agents.list()}),{selectedId:p,openDetail:f,closeDetail:E}=ae(r?"/packages/agents":"/agents","agentId"),c=U({queryKey:["agent",p],queryFn:()=>D.agents.get(p),enabled:!!p}),[A,x]=b.useState(!1),[m,h]=b.useState(),[R,w]=b.useState(!1),N=T({mutationFn:D.agents.create,onSuccess:()=>{l.invalidateQueries({queryKey:["agents"]}),x(!1)}}),v=T({mutationFn:D.agents.delete,onSuccess:()=>{w(!1),E(),l.invalidateQueries({queryKey:["agents"]}),l.invalidateQueries({queryKey:["agent-packages"]}),l.invalidateQueries({queryKey:["agent"]})}}),S=T({mutationFn:({profile:s,content:F})=>D.agents.update(s.id,{content:F,expectedRaw:s.raw,expectedPath:s.path}),onSuccess:s=>{l.setQueryData(["agent",s.id],s),l.invalidateQueries({queryKey:["agents"]}),l.invalidateQueries({queryKey:["agent-packages"]}),h(void 0)}});if(d.error)return e.jsx(G,{message:d.error.message,onRetry:()=>void d.refetch()});const t=(((i=d.data)==null?void 0:i.agents)??[]).filter(s=>`${s.name} ${s.id} ${s.description}`.toLowerCase().includes(C.toLowerCase()));return e.jsxs("div",{className:"space-y-5",children:[r?e.jsxs("div",{className:"flex flex-wrap justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-medium",children:"Agent definitions"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage specialist instructions, models and tools. Add them to APM packages for reuse."})]}),e.jsx(k,{"data-testid":"new-agent-button",onClick:()=>{N.reset(),x(!0)},children:"New agent"})]}):e.jsx(ne,{title:"Agents",meta:`${((y=d.data)==null?void 0:y.agents.length)??0} shared profiles`,action:e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsx(k,{"data-testid":"new-agent-button",onClick:()=>{N.reset(),x(!0)},children:"New agent"})})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Shared specialist definitions for every connected coding agent."," ",e.jsx("a",{className:"text-primary underline",href:"https://microsoft.github.io/apm/producer/author-primitives/instructions-and-agents/",target:"_blank",rel:"noreferrer",children:"APM agent format"})]}),!r&&e.jsx(se,{to:re("/packages",n,a.search),"data-testid":"agents-packages-link",className:"text-primary underline",children:"Manage packages and reusable launch setups"}),(((j=d.data)==null?void 0:j.broken)??[]).map(s=>e.jsxs("p",{role:"alert",className:"text-destructive",children:[s.path,": ",s.error]},s.path)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(B,{className:"min-w-[180px] max-w-lg flex-1","aria-label":"Find an agent",placeholder:"Find an agent by name or purpose…",value:C,onChange:s=>g(s.target.value,{replace:!0})}),C&&e.jsx(k,{variant:"ghost",onClick:()=>g(""),children:"Clear"})]}),e.jsxs("div",{className:"space-y-2",children:[d.isLoading&&e.jsx("p",{role:"status","data-testid":"page-loading",children:"Loading agents…"}),t.map(s=>e.jsxs("button",{type:"button","data-testid":"agent-row","data-agent-id":s.id,onClick:()=>f(s.id),className:"w-full text-left border-b border-outline-variant p-4 hover:bg-surface-low",children:[e.jsx("span",{className:"block break-words text-base font-medium",children:s.name}),e.jsxs("span",{className:"mt-1 block break-all text-xs text-muted-foreground",children:[s.id," · ",s.source]}),e.jsx("p",{className:"mt-2 break-words text-sm leading-relaxed text-muted-foreground",children:s.description})]},s.id)),!d.isLoading&&!t.length&&e.jsx("p",{"data-testid":"page-empty",className:"text-sm text-muted-foreground",children:C?"No agents match this search. Try another name or clear the filter.":"Create an agent or import specialists from Packages."})]}),e.jsx(ie,{open:!!p,onOpenChange:s=>!s&&E(),children:e.jsxs(oe,{children:[e.jsx(de,{children:e.jsx(le,{children:(($=c.data)==null?void 0:$.name)??"Agent profile"})}),e.jsx(ce,{children:c.error?e.jsx(G,{message:c.error.message,onRetry:()=>void c.refetch()}):c.data?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm",children:c.data.description}),e.jsx(k,{"data-testid":"agent-edit",variant:"outline",onClick:async()=>{S.reset();const s=await c.refetch();s.data&&h(s.data)},children:"Edit agent"}),e.jsx(k,{"data-testid":"agent-delete",variant:"destructive",onClick:()=>{v.reset(),w(!0)},disabled:v.isPending,children:"Delete agent"}),v.error&&e.jsx("p",{"data-testid":"agent-delete-error",role:"alert",className:"text-destructive",children:v.error.message}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use this profile in a flow agent node with ",e.jsxs("code",{children:['"agent": "',c.data.id,'"']})," ","and choose the coding backend independently."]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Model and tool restrictions depend on backend support. ORC refuses to launch when it cannot honor a declared restriction. Handoffs remain declarations; flow edges choose execution."}),e.jsx(I,{path:"metadata.json",value:JSON.stringify(c.data.fields,null,2),readOnly:!0,height:180,testId:"agent-fields"}),e.jsx(I,{path:"agent.agent.md",mode:o,onModeChange:u,value:c.data.raw,readOnly:!0,height:400,testId:"agent-content"})]}):e.jsx("p",{children:"Loading..."})})]})}),e.jsx(ue,{open:R,title:`Delete ${((O=c.data)==null?void 0:O.name)??"agent"}?`,description:`This permanently deletes the agent definition "${p}". Other agents and package resources are kept. Flows referencing this agent will need another profile.`,isPending:v.isPending,onCancel:()=>!v.isPending&&w(!1),onConfirm:()=>{p&&v.mutate(p,{onError:()=>w(!1)})}}),e.jsx(_,{open:A,onOpenChange:s=>!N.isPending&&x(s),children:A&&e.jsx(V,{pending:N.isPending,error:(Q=N.error)==null?void 0:Q.message,onSave:(s,F)=>N.mutate({id:s,content:F})})}),e.jsx(_,{open:!!m,onOpenChange:s=>!s&&!S.isPending&&h(void 0),children:m&&e.jsx(V,{agent:m,pending:S.isPending,error:(Y=S.error)==null?void 0:Y.message,onSave:(s,F)=>S.mutate({profile:m,content:F})},m.id)})]})}export{ve as default};
@@ -0,0 +1,2 @@
1
+ import{g as y,j as t,V as N,r as v,a as k,b,d as f,B as c,T as S}from"./index-BJl2bI67.js";function A({request:e}){var g;const[r,d]=v.useState(""),[i,l]=v.useState([]),u=k(),n=b({mutationFn:s=>f.humanRequests.respond(e.id,e.version,s),onSettled:()=>u.invalidateQueries({queryKey:["human-requests"]})}),p=b({mutationFn:()=>f.humanRequests.cancel(e.id,e.version),onSettled:()=>u.invalidateQueries({queryKey:["human-requests"]})}),o=e.status==="pending",a=(g=e.input.action)==null?void 0:g.input,m=a!=null&&a.item&&typeof a.item=="object"?a.item:void 0,h=typeof(a==null?void 0:a.threadId)=="string",x=h?{...Object.fromEntries(Object.entries(a??{}).filter(([s])=>!["threadId","turnId","itemId","startedAtMs","item","availableDecisions","proposedExecpolicyAmendment","commandActions","kind"].includes(s))),...m!=null&&m.changes?{changes:m.changes}:{}}:a;return t.jsxs("article",{"data-testid":`attention-request-${e.id}`,className:"rounded-lg border border-border bg-surface p-5 space-y-4",children:[t.jsxs("div",{className:"flex flex-wrap justify-between gap-2 text-xs text-outline",children:[t.jsxs("span",{children:[e.input.kind==="question"?"Question":"Approval"," ·"," ",e.input.origin.backend]}),t.jsx("span",{children:o?"Waiting for you":e.status==="unavailable"?"Agent unavailable":"Answered · waiting for agent delivery"})]}),t.jsx("h2",{className:"text-base font-medium whitespace-pre-wrap",children:e.input.prompt}),t.jsxs("p",{className:"text-xs text-outline break-all",children:["Session ",e.input.origin.session_id]}),e.input.action&&t.jsxs("div",{className:"space-y-2 text-sm",children:[t.jsxs("p",{children:["Host: ",t.jsx("strong",{children:e.input.action.host})," · Folder: ",e.input.action.cwd]}),t.jsxs("pre",{"data-testid":"attention-action",className:"whitespace-pre-wrap break-all rounded-md bg-background p-3 text-xs",children:[e.input.action.tool,`
2
+ `,JSON.stringify(x&&Object.keys(x).length?x:a,null,2)]}),h&&t.jsxs("details",{className:"text-xs text-outline",children:[t.jsx("summary",{className:"cursor-pointer",children:"Full request details"}),t.jsx("pre",{className:"whitespace-pre-wrap break-all mt-2",children:JSON.stringify(a,null,2)})]}),t.jsx("p",{className:"text-outline",children:"Your approval lets this agent continue with its existing permissions."})]}),o&&e.input.kind==="question"&&t.jsxs("form",{className:"space-y-3",onSubmit:s=>{s.preventDefault(),n.mutate({kind:"question",answer:r,...i.length?{selected_choices:i}:{}})},children:[t.jsx("div",{className:"flex flex-wrap gap-2",children:e.input.choices.map(s=>t.jsxs(c,{variant:(e.input.multi_select?i.includes(s):r===s)?"default":"outline",type:"button",className:"h-auto min-h-9 flex-col items-start whitespace-normal text-left",disabled:n.isPending,"data-testid":`attention-choice-${s}`,onClick:()=>{if(e.input.multi_select){const j=i.includes(s)?i.filter(w=>w!==s):[...i,s];l(j),d(j.join(", "))}else d(s)},children:[t.jsx("span",{children:s}),Object.keys(e.input.choice_descriptions).includes(s)&&e.input.choice_descriptions[s]&&t.jsx("span",{className:"text-xs font-normal opacity-75 max-w-sm",children:e.input.choice_descriptions[s]})]},s))}),t.jsxs("label",{htmlFor:`answer-${e.id}`,className:"block text-sm space-y-2",children:[t.jsx("span",{children:"Your answer"}),t.jsx(S,{id:`answer-${e.id}`,"data-testid":"attention-answer",value:r,onChange:s=>{d(s.target.value),l([])},maxLength:16e3,disabled:n.isPending})]}),t.jsx(c,{"data-testid":"attention-send",type:"submit",disabled:!r.trim()||n.isPending,children:n.isPending?"Sending…":"Send answer"})]}),o&&e.input.kind==="approval"&&t.jsxs("div",{className:"flex gap-3",children:[t.jsx(c,{"data-testid":"attention-approve",disabled:n.isPending,onClick:()=>n.mutate({kind:"approval",approved:!0}),children:"Approve"}),t.jsx(c,{"data-testid":"attention-deny",variant:"outline",disabled:n.isPending,onClick:()=>n.mutate({kind:"approval",approved:!1}),children:"Deny"})]}),e.response&&t.jsx("p",{"data-testid":"attention-response",className:"text-sm whitespace-pre-wrap",children:e.response.kind==="question"?e.response.answer:e.response.approved?"Approved":"Denied"}),e.delivery_error&&t.jsx("p",{role:"status",className:"text-sm text-error",children:e.delivery_error}),(o||e.status==="unavailable")&&t.jsx(c,{"data-testid":"attention-cancel",variant:"ghost",disabled:n.isPending||p.isPending,onClick:()=>p.mutate(),children:o?"Cancel request":"Dismiss"}),p.error&&t.jsx("p",{role:"alert",children:p.error.message}),n.error&&t.jsx("p",{role:"alert","data-testid":"attention-error",className:"text-sm text-destructive",children:n.error.message})]})}function C(){var r,d,i;const e=y();return t.jsxs("div",{"data-testid":"attention-view",className:"max-w-4xl",children:[t.jsx(N,{title:"Attention needed",meta:"Questions and approvals from your agents"}),e.isLoading&&t.jsx("p",{role:"status",children:"Loading requests…"}),e.error&&t.jsx("p",{role:"alert",children:e.error.message}),((r=e.data)==null?void 0:r.length)===0&&t.jsx("p",{"data-testid":"attention-empty",className:"text-outline",children:"Nothing needs your attention."}),((d=e.data)==null?void 0:d.length)===100&&t.jsx("p",{className:"text-sm text-outline mb-4",children:"Showing the first 100 requests, with pending requests first. Resolving or dismissing entries reveals more."}),t.jsx("div",{className:"space-y-4",children:(i=e.data)==null?void 0:i.map(l=>t.jsx(A,{request:l},l.id))})]})}export{C as default};
@@ -0,0 +1 @@
1
+ import{ac as T,j as e,a4 as L,a5 as P,a6 as R,a7 as $,a8 as O,E as w,S,ad as A,ae as h,r as k,af as I,f as V,m as z,a1 as H,a2 as B,ag as U,ah as F,t as J,v as G,w as v,x as c,y as M,z as x,V as Y}from"./index-BJl2bI67.js";import{P as Z}from"./Pager-lPvhBe-l.js";import{S as y}from"./scroll-area-DyJaZyLF.js";import{u as q}from"./useProjectScope-BthZtFg0.js";const K={file:"text-outline",task:"text-outline",decision:"text-outline",error:"text-error",git:"text-outline",rule:"text-outline",plan:"text-outline"},Q="text-outline";function W(n){return K[n]??Q}function X({sessionId:n,open:a,onClose:r}){const{data:t,isLoading:u,error:p,refetch:j}=T(n??"");return e.jsx(L,{open:a,onOpenChange:o=>!o&&r(),children:e.jsxs(P,{side:"right",className:"w-[540px] max-w-[90vw]",children:[e.jsx(R,{children:e.jsx($,{children:u?"Loading...":t?`${t.agent??"Session"} ${t.agent_version?`v${t.agent_version}`:""}`:"Session Detail"})}),e.jsxs(O,{children:[e.jsx("p",{className:"mb-4 text-sm text-outline",children:"This audit record contains summaries and events. Open Sessions to read native agent conversations or resume them."}),p?e.jsx(w,{message:p.message,onRetry:()=>j()}):u?e.jsx("div",{className:"space-y-4",children:[...Array(4)].map((o,i)=>e.jsx(S,{className:"h-8 w-full bg-surface-highest"},i))}):t?e.jsxs("div",{className:"space-y-6",children:[t.summary&&e.jsx("div",{className:"font-body text-xs text-on-surface leading-relaxed",children:e.jsx(A,{children:t.summary})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(h,{label:"ID",children:e.jsx("span",{className:"font-mono text-xs break-all",children:t.id})}),e.jsx(h,{label:"Project ID",children:t.project_id??"—"}),e.jsx(h,{label:"Job Run ID",children:t.job_run_id??"—"}),e.jsx(h,{label:"Tokens Used",children:t.tokens_used!=null?t.tokens_used.toLocaleString():"—"}),e.jsx(h,{label:"Created",children:new Date(t.created_at).toLocaleString()})]}),t.events.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"font-label text-xs font-medium text-outline mb-3",children:["Events (",t.events.length,")"]}),e.jsx(y,{className:"h-[300px]",children:e.jsx("div",{className:"space-y-1",children:[...t.events].sort((o,i)=>new Date(o.created_at).getTime()-new Date(i.created_at).getTime()).map(o=>e.jsx(ee,{event:o},o.id))})})]}),t.snapshot&&e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-xs font-medium text-outline mb-3",children:"Snapshot"}),e.jsx(y,{className:"h-[200px]",children:e.jsx("pre",{className:"font-mono text-xs text-on-surface-variant whitespace-pre-wrap break-words bg-background border-l border-border p-3",children:t.snapshot})})]})]}):e.jsx("div",{className:"font-body text-xs text-outline py-8 text-center",children:"Session not found"})]})]})})}function ee({event:n}){const[a,r]=k.useState(!1),t=n.data!=null;return e.jsxs("div",{className:"border-b border-border/65",children:[e.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-surface-high transition-colors",onClick:()=>t&&r(!a),"aria-expanded":t?a:void 0,children:[t?a?e.jsx(I,{size:10,className:"text-outline flex-shrink-0"}):e.jsx(V,{size:10,className:"text-outline flex-shrink-0"}):e.jsx("span",{className:"w-[10px] flex-shrink-0"}),e.jsx("span",{className:`inline-flex items-center px-1.5 py-0.5 text-[10px] font-label font-medium ${W(n.type)}`,children:n.type}),e.jsx("span",{className:"flex-1 font-body text-xs text-outline truncate",children:se(n.data)}),e.jsx("span",{className:"font-label text-[10px] text-outline flex-shrink-0",children:new Date(n.created_at).toLocaleTimeString()})]}),a&&t&&e.jsx("div",{className:"px-3 pb-2",children:e.jsx("pre",{className:"font-mono text-xs text-on-surface-variant whitespace-pre-wrap break-words bg-background border-l border-border/65 p-2 max-h-48 overflow-auto",children:JSON.stringify(n.data,null,2)})})]})}function se(n){if(n==null)return"";if(typeof n=="string")return n;if(typeof n=="object"){const a=n;if(typeof a.path=="string")return a.path;if(typeof a.content=="string")return a.content.length>80?`${a.content.slice(0,80)}...`:a.content;if(typeof a.message=="string")return a.message;if(typeof a.summary=="string")return a.summary;const r=Object.keys(a);return r.length<=3?r.join(", "):`${r.length} fields`}return String(n)}const b=25,m="font-label text-xs font-medium text-outline";function te({projectId:n}){const a=z("sm"),[r,t]=H("order","desc",["asc","desc"]),[u,p]=k.useState({order:r,page:0}),j=u.order===r?u.page:0,o=s=>p({order:r,page:s}),{selectedId:i,openDetail:g,closeDetail:_}=B("/audit","sessionId"),{data:l,isLoading:D,error:N,refetch:E}=U({...n==="all"?{}:{project_id:n},limit:b,offset:j*b,order:r});if(N)return e.jsx(w,{message:N.message,onRetry:()=>E()});const f=(l==null?void 0:l.sessions)??[],C=(l==null?void 0:l.total)??0;return e.jsxs("section",{"data-testid":"logged-sessions",children:[e.jsx("div",{className:"mb-4 flex justify-end",children:e.jsxs("select",{"aria-label":"Sort audit by date","data-testid":"audit-date-sort",value:r,onChange:s=>{o(0),t(s.target.value)},className:"min-h-11 rounded-md border border-control-border bg-background px-3 text-sm text-on-surface",children:[e.jsx("option",{value:"desc",children:"Created: newest first"}),e.jsx("option",{value:"asc",children:"Created: oldest first"})]})}),D?e.jsx("div",{className:"space-y-2",children:[...Array(5)].map((s,d)=>e.jsx(S,{className:"h-10 w-full bg-surface-highest"},d))}):f.length===0?e.jsx(F,{message:"No audit records"}):e.jsxs("div",{className:"min-w-0 overflow-hidden",children:[a?e.jsxs(J,{children:[e.jsx(G,{children:e.jsxs(v,{className:"border-b border-border hover:bg-transparent",children:[e.jsx(c,{className:m,children:"Agent"}),e.jsx(c,{className:`${m} w-24`,children:"Version"}),e.jsx(c,{className:m,children:"Summary"}),e.jsx(c,{className:`${m} w-24`,children:"Project"}),e.jsx(c,{className:`${m} w-28`,children:"Tokens Used"}),e.jsx(c,{className:`${m} w-36`,children:"Created"})]})}),e.jsx(M,{children:f.map(s=>e.jsxs(v,{"data-testid":"session-row","data-session-id":s.id,className:"border-b border-border/65 hover:bg-surface-high cursor-pointer",onClick:()=>g(s.id),children:[e.jsx(x,{className:"font-label text-xs text-primary",children:e.jsx("button",{type:"button",className:"text-left font-medium hover:underline",onClick:d=>{d.stopPropagation(),g(s.id)},children:s.agent??"Session"})}),e.jsx(x,{className:"font-label text-xs text-outline",children:s.agent_version??"—"}),e.jsx(x,{className:"font-body text-xs text-on-surface-variant max-w-sm truncate",children:s.summary??"—"}),e.jsx(x,{className:"font-label text-xs text-outline",children:s.project_id?s.project_id.slice(-6):"—"}),e.jsx(x,{className:"font-label text-xs text-outline text-right",children:s.tokens_used!=null?s.tokens_used.toLocaleString():"—"}),e.jsx(x,{className:"font-label text-xs text-outline",children:new Date(s.created_at).toLocaleString()})]},s.id))})]}):e.jsx("div",{className:"divide-y divide-border",children:f.map(s=>{var d;return e.jsxs("article",{"data-testid":"session-row","data-session-id":s.id,className:"py-4 space-y-3",children:[e.jsx("button",{type:"button",className:"min-h-11 text-sm text-left font-medium text-primary break-words",onClick:()=>g(s.id),children:s.agent??"Session"}),e.jsx("p",{className:"text-sm leading-relaxed text-on-surface break-words",children:s.summary??"No summary recorded"}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-2 text-xs text-outline",children:[e.jsxs("span",{children:["Version ",s.agent_version??"—"]}),e.jsxs("span",{children:[((d=s.tokens_used)==null?void 0:d.toLocaleString())??"—"," tokens"]}),e.jsx("span",{children:s.project_id?`Project ${s.project_id.slice(-6)}`:"Unassigned"}),e.jsx("span",{children:new Date(s.created_at).toLocaleString()})]})]},s.id)})}),e.jsx(Z,{page:j,pageSize:b,total:C,onPage:o})]}),e.jsx(X,{sessionId:i,open:!!i,onClose:_})]})}function ie({projectId:n}){const a=q(n);return e.jsxs("div",{children:[e.jsx(Y,{title:"Audit"}),e.jsx("p",{className:"mb-4 text-sm text-outline",children:"Recorded summaries and events. Open Sessions to read conversations or resume a coding agent."}),e.jsx(te,{projectId:a},a)]})}export{ie as default};
@@ -0,0 +1 @@
1
+ import{i as E,m as U,n as V,o as q,p as I,q as J,j as t,E as Q,S as H,s as T,P as S,t as z,v as W,w as L,x as m,y as O,z as v,A as F,D,R as G}from"./index-BJl2bI67.js";import{u as K}from"./useJobs-BQp9uwz-.js";import{u as X}from"./useMemories-MoQflRW_.js";import{u as Y}from"./useProjectScope-BthZtFg0.js";function l(o,p){return o.isLoading?"…":o.error?"—":p}function es({projectId:o}){var f,_;const p=E(),a=Y(o),$=U("sm"),i=s=>{const e=new URL(s,window.location.origin);e.searchParams.set("project",a),p({pathname:e.pathname,search:e.search,hash:e.hash})},d=a==="all"||a==="unassigned"?void 0:{project_id:a},c=V(d),{data:b,isLoading:A}=c,u=K(d),{data:N}=u,h=X({project_id:d==null?void 0:d.project_id,limit:1},{enabled:a!=="unassigned"}),P=a==="unassigned"?0:((f=h.data)==null?void 0:f.total)??0,{data:n}=q(),j=I(!0),g=(j.data??[]).filter(s=>a==="all"||(a==="unassigned"?s.project_id===null:s.project_id===a)),w=a==="unassigned"?(N??[]).filter(s=>s.project_id===null):N??[],k=a==="unassigned"?(b??[]).filter(s=>s.project_id===null):b??[],r=k.reduce((s,e)=>(s[e.status]=(s[e.status]??0)+1,s),{}),y=[...k].sort((s,e)=>new Date(e.updated_at).getTime()-new Date(s.updated_at).getTime()).slice(0,8),x=w.filter(s=>s.enabled),R=a==="all"?"All Projects":a==="unassigned"?"Unassigned":((_=n==null?void 0:n.find(s=>s.id===a))==null?void 0:_.name)??"",M=[{label:"Doing",value:l(c,r.doing??0),sub:"in progress",path:"/tasks?view=table&status=doing"},{label:"Review",value:l(c,r.review??0),sub:"awaiting review",path:"/tasks?view=table&status=review"},{label:"Blocked",value:l(c,r.blocked??0),sub:"needs attention",path:"/tasks?view=table&status=blocked"},{label:"Todo",value:l(c,(r.todo??0)+(r.queued??0)),sub:"pending",path:"/tasks?view=board"},{label:"Done",value:l(c,r.done??0),sub:"completed",path:"/tasks?view=table&status=done"}],B=[{label:"Active jobs",value:l(u,x.length),sub:`of ${w.length} total`,path:"/jobs"},{label:"Memories",value:l(h,P),sub:"in this scope",path:J},{label:"Projects",value:(n??[]).filter(s=>s.status==="active").length,sub:"active across workspace",path:"/projects"}];return t.jsxs("div",{"data-activity-preview":!0,"data-testid":"activity-preview",className:"activity-preview",children:[t.jsxs("div",{className:"activity-heading",children:[t.jsxs("div",{children:[t.jsx("h1",{"data-testid":"view-title",children:"Activity"}),t.jsx("p",{"data-testid":"view-meta",children:R||"All projects"})]}),t.jsx("button",{type:"button",className:"activity-primary",onClick:()=>i("/tasks"),children:"View tasks"})]}),[c,u,h,j].some(s=>s.isLoading)&&t.jsx("p",{role:"status",className:"activity-muted mb-4",children:"Loading activity…"}),[{name:"Tasks",query:c},{name:"Jobs",query:u},{name:"Memories",query:h},{name:"Sessions",query:j}].filter(({query:s})=>s.error).map(({name:s,query:e})=>{var C;return t.jsx(Q,{message:`${s}: ${((C=e.error)==null?void 0:C.message)??"Could not load activity"}`,onRetry:()=>e.refetch()},s)}),t.jsx("section",{className:"activity-metrics","aria-label":"Task summary",children:M.map(s=>t.jsxs("button",{type:"button","data-testid":"stat-card","data-stat-label":s.label,className:"activity-metric",onClick:()=>i(s.path),children:[t.jsx("span",{className:"activity-metric-label",children:s.label}),t.jsx("span",{"data-testid":"stat-card-value",className:"activity-metric-value",children:s.value}),t.jsx("span",{className:"activity-metric-sub",children:s.sub})]},s.label))}),t.jsx("section",{className:"activity-resources","aria-label":"Workspace summary",children:B.map(s=>t.jsxs("button",{type:"button","data-testid":"stat-card","data-stat-label":s.label,onClick:()=>i(s.path),children:[t.jsx("span",{children:s.label}),t.jsx("span",{"data-testid":"stat-card-value",className:"activity-resource-value",children:s.value}),t.jsx("span",{className:"activity-resource-sub",children:s.sub})]},s.label))}),t.jsxs("section",{className:"activity-section",children:[t.jsxs("div",{className:"activity-section-heading",children:[t.jsx("h2",{children:"Recent tasks"}),t.jsx("button",{type:"button",className:"activity-text-action",onClick:()=>i("/tasks"),children:"View all"})]}),A?t.jsx("div",{className:"space-y-2",children:[0,1,2,3].map(s=>t.jsx(H,{className:"h-10 w-full"},s))}):y.length===0?t.jsx("p",{className:"activity-empty",children:"No tasks"}):$?t.jsxs(z,{className:"activity-task-table",children:[t.jsx(W,{children:t.jsxs(L,{children:[t.jsx(m,{children:"Task"}),t.jsx(m,{className:"w-36",children:"Status"}),t.jsx(m,{className:"w-28",children:"Priority"}),t.jsx(m,{className:"w-28",children:"Updated"})]})}),t.jsx(O,{children:y.map(s=>t.jsxs(L,{onClick:()=>i(`/tasks/${s.id}`),children:[t.jsx(v,{children:t.jsx("button",{type:"button",className:"activity-task-title",onClick:e=>{e.stopPropagation(),i(`/tasks/${s.id}`)},children:s.title})}),t.jsx(v,{children:t.jsx("span",{className:"activity-status","data-status":s.status,children:t.jsx(T,{status:s.status})})}),t.jsx(v,{children:t.jsx("span",{className:"activity-priority",children:t.jsx(S,{priority:s.priority})})}),t.jsx(v,{className:"activity-muted",children:new Date(s.updated_at).toLocaleDateString()})]},s.id))})]}):t.jsx("div",{className:"activity-task-list",children:y.map(s=>t.jsxs("article",{className:"activity-task-mobile",children:[t.jsx("button",{type:"button",className:"activity-task-title",onClick:()=>i(`/tasks/${s.id}`),children:s.title}),t.jsxs("div",{className:"activity-task-meta",children:[t.jsx("span",{className:"activity-status","data-status":s.status,children:t.jsx(T,{status:s.status})}),t.jsx("span",{className:"activity-priority",children:t.jsx(S,{priority:s.priority})}),t.jsx("span",{children:new Date(s.updated_at).toLocaleDateString()})]})]},s.id))})]}),t.jsxs("div",{className:"activity-secondary",children:[x.length>0&&t.jsxs("section",{className:"activity-section",children:[t.jsxs("div",{className:"activity-section-heading",children:[t.jsx("h2",{children:"Active jobs"}),t.jsx("button",{type:"button",className:"activity-text-action",onClick:()=>i("/jobs"),children:"View all"})]}),t.jsx("div",{className:"activity-row-list",children:x.slice(0,5).map(s=>t.jsxs("button",{type:"button",className:"activity-row",onClick:()=>i(`/jobs/${s.id}`),children:[t.jsxs("span",{className:"activity-row-heading",children:[t.jsx("span",{children:s.name}),t.jsx("span",{className:"activity-muted",children:s.trigger_type})]}),s.last_run_at&&t.jsxs("span",{className:"activity-row-description",children:["Last run ",new Date(s.last_run_at).toLocaleString()]})]},s.id))})]}),g.length>0&&t.jsxs("section",{className:"activity-section",children:[t.jsxs("div",{className:"activity-section-heading",children:[t.jsx("h2",{children:"Agent sessions"}),t.jsx("button",{type:"button",className:"activity-text-action",onClick:()=>i("/sessions"),children:"View all"})]}),t.jsx("div",{className:"activity-row-list",children:g.slice(0,5).map(s=>t.jsxs("div",{className:"activity-row",children:[t.jsxs("button",{type:"button",className:"w-full text-left","data-testid":"activity-session-link","data-session-id":s.id,onClick:()=>i(`/sessions?session=${encodeURIComponent(s.id)}`),children:[t.jsxs("span",{className:"activity-row-heading",children:[t.jsx("span",{children:s.name??s.agent}),t.jsx("span",{className:"activity-muted",children:F(s.last_activity_at)})]}),t.jsxs("span",{className:"activity-row-description inline-flex items-center gap-2",children:[t.jsx("span",{className:`size-1.5 rounded-full ${D[s.status].dot}`}),s.agent," · ",D[s.status].label,s.task?` · ${s.task.title}`:""]})]}),t.jsx(G,{session:s})]},s.id))})]})]}),a==="all"&&(n??[]).length>0&&t.jsxs("section",{className:"activity-section",children:[t.jsxs("div",{className:"activity-section-heading",children:[t.jsx("h2",{children:"Projects"}),t.jsx("button",{type:"button",className:"activity-text-action",onClick:()=>i("/projects"),children:"View all"})]}),t.jsx("div",{className:"activity-projects",children:(n??[]).filter(s=>s.status==="active").slice(0,6).map(s=>t.jsxs("button",{type:"button",className:"activity-row",onClick:()=>i(`/projects/${s.id}`),children:[t.jsx("span",{className:"activity-row-heading",children:s.name}),s.description&&t.jsx("span",{className:"activity-row-description",children:s.description})]},s.id))})]})]})}export{es as default};
@@ -1 +1 @@
1
- import{g as A,h as G,r as o,j as e,M as Y,B as m}from"./index-DqE2dG9P.js";const i=new Map,M=new Set;typeof window<"u"&&window.addEventListener("beforeunload",t=>{i.size&&(t.preventDefault(),t.returnValue="")});function H(t){return M.has(t)?!1:i.has(t)?window.confirm("Discard unsaved changes to this document?")?(i.delete(t),!0):!1:!0}function K({documentId:t,content:s,path:D,onSave:d,testId:N,wikiLinks:C,navigation:k,expanded:R,onExpandedChange:E,layout:F,pageTitle:q,hideFrontmatter:T}){const[V]=A(),W=G(),v=V.get("editorMode"),x=v==="edit"||v==="split"?v:"read",p=o.useRef(i.get(t)??{original:s,content:s}),[w,f]=o.useState(p.current.content),[u,j]=o.useState(p.current.original),[r,z]=o.useState(!1),[y,b]=o.useState(null),S=o.useRef(!1),l=o.useRef(p.current.content),c=w!==u;o.useEffect(()=>{i.has(t)||(f(s),l.current=s,j(s))},[s,t]);function O(a){l.current=a,f(a),a===u?i.delete(t):i.set(t,{original:u,content:a})}async function h(){if(!d||!c||S.current)return;S.current=!0,M.add(t),z(!0),b(null);const a=l.current;try{const n=await d(a,u),g=typeof n=="string"?n:a;j(g),l.current===a?(i.delete(t),l.current=g,f(g)):i.set(t,{original:g,content:l.current})}catch(n){b(n instanceof Error?n.message:"Could not save document")}finally{S.current=!1,M.delete(t),z(!1)}}function P(a){const n=new URLSearchParams(window.location.search);n.set("editorMode",a),n.toString()!==new URLSearchParams(window.location.search).toString()&&W({search:n.toString(),hash:window.location.hash})}function U(){H(t)&&(f(s),j(s),l.current=s,b(null))}const B=d?r?"Saving…":c?"Unsaved changes":"Saved":"Read-only",L=e.jsxs(e.Fragment,{children:[y&&e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:[y," Your draft has been kept."]}),c&&s!==u&&e.jsx("p",{role:"status",className:"text-sm text-outline",children:"The document changed elsewhere. Your draft is preserved; saving will check for conflicts."})]});return F==="page"?e.jsx("div",{className:"min-w-0","data-testid":"document-workspace",children:e.jsx(Y,{path:D,value:w,onChange:O,onSave:()=>void h(),readOnly:!d||r,testId:N,wikiLinks:C,initialMode:"read",mode:x,onModeChange:P,expanded:R,onExpandedChange:E,layout:"page",pageTitle:q,hideFrontmatter:T,notice:y||c&&s!==u?L:void 0,actions:(x!=="read"||c||r)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-testid":"document-save-status",role:"status",className:"text-xs text-outline",children:B}),d&&(c||r)&&e.jsxs(e.Fragment,{children:[e.jsx(m,{type:"button",size:"sm",variant:"ghost","data-testid":"document-discard",disabled:r,onClick:U,children:"Discard"}),e.jsx(m,{type:"button",size:"sm","data-testid":"document-save",disabled:r,onClick:()=>void h(),children:"Save"})]})]})})}):e.jsx("div",{className:"min-w-0 space-y-3","data-testid":"document-workspace",children:e.jsx(Y,{path:D,value:w,onChange:O,onSave:()=>void h(),readOnly:!d||r,testId:N,wikiLinks:C,initialMode:"read",mode:x,onModeChange:P,expanded:R,onExpandedChange:E,layout:F,header:e.jsxs("div",{className:"space-y-2",children:[k&&e.jsx("div",{className:"mb-3 min-w-0",children:k}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{"data-testid":"document-save-status",role:"status",className:"min-w-0 flex-1 text-sm text-outline",children:B}),d&&e.jsxs(e.Fragment,{children:[e.jsx(m,{type:"button",variant:"ghost","data-testid":"document-discard",disabled:!c||r,onClick:U,children:"Discard changes"}),e.jsx(m,{type:"button","data-testid":"document-save",disabled:!c||r,onClick:()=>void h(),children:"Save changes"})]})]}),L]})})})}export{K as D,H as c};
1
+ import{h as A,i as G,r as o,j as e,M as Y,B as g}from"./index-BJl2bI67.js";const i=new Map,M=new Set;typeof window<"u"&&window.addEventListener("beforeunload",t=>{i.size&&(t.preventDefault(),t.returnValue="")});function H(t){return M.has(t)?!1:i.has(t)?window.confirm("Discard unsaved changes to this document?")?(i.delete(t),!0):!1:!0}function K({documentId:t,content:s,path:D,onSave:d,testId:N,wikiLinks:C,navigation:k,expanded:R,onExpandedChange:E,layout:F,pageTitle:q,hideFrontmatter:T}){const[V]=A(),W=G(),v=V.get("editorMode"),x=v==="edit"||v==="split"?v:"read",p=o.useRef(i.get(t)??{original:s,content:s}),[w,f]=o.useState(p.current.content),[u,j]=o.useState(p.current.original),[r,z]=o.useState(!1),[y,b]=o.useState(null),S=o.useRef(!1),l=o.useRef(p.current.content),c=w!==u;o.useEffect(()=>{i.has(t)||(f(s),l.current=s,j(s))},[s,t]);function O(a){l.current=a,f(a),a===u?i.delete(t):i.set(t,{original:u,content:a})}async function h(){if(!d||!c||S.current)return;S.current=!0,M.add(t),z(!0),b(null);const a=l.current;try{const n=await d(a,u),m=typeof n=="string"?n:a;j(m),l.current===a?(i.delete(t),l.current=m,f(m)):i.set(t,{original:m,content:l.current})}catch(n){b(n instanceof Error?n.message:"Could not save document")}finally{S.current=!1,M.delete(t),z(!1)}}function P(a){const n=new URLSearchParams(window.location.search);n.set("editorMode",a),n.toString()!==new URLSearchParams(window.location.search).toString()&&W({search:n.toString(),hash:window.location.hash})}function U(){H(t)&&(f(s),j(s),l.current=s,b(null))}const B=d?r?"Saving…":c?"Unsaved changes":"Saved":"Read-only",L=e.jsxs(e.Fragment,{children:[y&&e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:[y," Your draft has been kept."]}),c&&s!==u&&e.jsx("p",{role:"status",className:"text-sm text-outline",children:"The document changed elsewhere. Your draft is preserved; saving will check for conflicts."})]});return F==="page"?e.jsx("div",{className:"min-w-0","data-testid":"document-workspace",children:e.jsx(Y,{path:D,value:w,onChange:O,onSave:()=>void h(),readOnly:!d||r,testId:N,wikiLinks:C,initialMode:"read",mode:x,onModeChange:P,expanded:R,onExpandedChange:E,layout:"page",pageTitle:q,hideFrontmatter:T,notice:y||c&&s!==u?L:void 0,actions:(x!=="read"||c||r)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-testid":"document-save-status",role:"status",className:"text-xs text-outline",children:B}),d&&(c||r)&&e.jsxs(e.Fragment,{children:[e.jsx(g,{type:"button",size:"sm",variant:"ghost","data-testid":"document-discard",disabled:r,onClick:U,children:"Discard"}),e.jsx(g,{type:"button",size:"sm","data-testid":"document-save",disabled:r,onClick:()=>void h(),children:"Save"})]})]})})}):e.jsx("div",{className:"min-w-0 space-y-3","data-testid":"document-workspace",children:e.jsx(Y,{path:D,value:w,onChange:O,onSave:()=>void h(),readOnly:!d||r,testId:N,wikiLinks:C,initialMode:"read",mode:x,onModeChange:P,expanded:R,onExpandedChange:E,layout:F,header:e.jsxs("div",{className:"space-y-2",children:[k&&e.jsx("div",{className:"mb-3 min-w-0",children:k}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{"data-testid":"document-save-status",role:"status",className:"min-w-0 flex-1 text-sm text-outline",children:B}),d&&e.jsxs(e.Fragment,{children:[e.jsx(g,{type:"button",variant:"ghost","data-testid":"document-discard",disabled:!c||r,onClick:U,children:"Discard changes"}),e.jsx(g,{type:"button","data-testid":"document-save",disabled:!c||r,onClick:()=>void h(),children:"Save changes"})]})]}),L]})})})}export{K as D,H as c};
@@ -1 +1 @@
1
- import{g as U,r as t,a as $,j as n,i as K,M as A,k as T,d as P}from"./index-DqE2dG9P.js";import{S as V}from"./save-wtDP4EBM.js";const c=new Map;typeof window<"u"&&window.addEventListener("beforeunload",s=>{c.size!==0&&(s.preventDefault(),s.returnValue="")});function H({terminalId:s,path:i,content:u,readOnly:v,onDirty:w}){const[Q,z]=U(),p=Q.get("editorMode"),D=p==="read"||p==="split"?p:"edit",a=`${s}:${i}`,d=t.useRef(c.get(a)??{original:u,content:u}),o=t.useRef(d.current.original),l=t.useRef(d.current.content),[S,g]=t.useState(d.current.content!==d.current.original),[C,j]=t.useState(!1),[E,x]=t.useState(null),[k,b]=t.useState(d.current.content),R=$(),y=t.useRef(()=>{}),h=t.useRef(!1),m=t.useRef(!1),f=t.useRef(w);f.current=w;async function M(){if(h.current||v||l.current===o.current)return;h.current=!0,j(!0),x(null);const e=l.current;try{await P.git.saveFile(s,i,e,o.current),o.current=e;const r=l.current!==e;g(r),m.current&&f.current(r),r?c.set(a,{original:e,content:l.current}):c.delete(a),R.invalidateQueries({queryKey:["checkout-files",s,i]}),R.invalidateQueries({queryKey:["git",s]})}catch(r){x(r instanceof Error?r.message:"Could not save file")}finally{h.current=!1,j(!1)}}y.current=()=>void M(),t.useEffect(()=>(m.current=!0,f.current(d.current.content!==d.current.original),()=>{m.current=!1}),[]),t.useEffect(()=>{h.current||c.has(a)||u===o.current||(o.current=u,l.current=u,b(u),g(!1),m.current&&f.current(!1))},[u,a]);function N(e){l.current=e,b(e);const r=e!==o.current;g(r),f.current(r),r?c.set(a,{original:o.current,content:e}):c.delete(a)}function L(){window.confirm("Discard your edits and reload the file from disk?")&&P.git.files(s,i).then(e=>{if(e.content===null||e.binary||e.truncated)throw new Error("File is no longer editable");o.current=e.content,l.current=e.content,c.delete(a),b(e.content),g(!1),f.current(!1),x(null)}).catch(e=>x(e instanceof Error?e.message:"Could not reload file"))}const F=n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-surface-highest px-2 py-1",children:[n.jsxs("button",{type:"button","data-testid":"file-save",disabled:!S||C||v,onClick:()=>void M(),className:"flex min-h-11 items-center gap-1 rounded px-2 py-1 text-sm text-primary hover:bg-surface-highest disabled:opacity-40",title:"Save (Ctrl/Cmd+S)",children:[n.jsx(V,{size:14}),C?"Saving…":"Save"]}),n.jsx("span",{"data-testid":"file-save-status",className:"min-w-0 flex-1 truncate text-sm text-on-surface-variant",children:v?"Read-only preview":S?"Unsaved changes":"Saved"})]}),E&&n.jsxs("div",{role:"alert",className:"shrink-0 border-b border-error/30 p-2 text-xs text-error",children:[E,n.jsx("button",{type:"button","data-testid":"file-reload",onClick:L,className:"ml-2 underline",children:"Reload from disk"})]})]});return n.jsxs("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"file-editor",children:[!K(i)&&F,n.jsx("div",{"data-testid":"file-preview",className:"min-h-0 flex-1 overflow-hidden",children:K(i)?n.jsx(A,{path:i,value:k,onChange:N,onSave:()=>y.current(),readOnly:v,height:"100%",testId:"file-editor-input",header:F,mode:D,onModeChange:e=>z(r=>{const q=new URLSearchParams(r);return q.set("editorMode",e),q})}):n.jsx(T,{path:i,value:k,onChange:N,onSave:()=>y.current(),readOnly:v,height:"100%",testId:"file-editor-input"})})]})}export{H as FileEditor};
1
+ import{h as U,r as t,a as $,j as n,k as K,M as A,l as T,d as P}from"./index-BJl2bI67.js";import{S as V}from"./save-D-k08Gwx.js";const c=new Map;typeof window<"u"&&window.addEventListener("beforeunload",s=>{c.size!==0&&(s.preventDefault(),s.returnValue="")});function H({terminalId:s,path:i,content:u,readOnly:v,onDirty:w}){const[Q,z]=U(),p=Q.get("editorMode"),D=p==="read"||p==="split"?p:"edit",a=`${s}:${i}`,d=t.useRef(c.get(a)??{original:u,content:u}),o=t.useRef(d.current.original),l=t.useRef(d.current.content),[S,g]=t.useState(d.current.content!==d.current.original),[C,j]=t.useState(!1),[E,h]=t.useState(null),[k,b]=t.useState(d.current.content),R=$(),y=t.useRef(()=>{}),x=t.useRef(!1),m=t.useRef(!1),f=t.useRef(w);f.current=w;async function M(){if(x.current||v||l.current===o.current)return;x.current=!0,j(!0),h(null);const e=l.current;try{await P.git.saveFile(s,i,e,o.current),o.current=e;const r=l.current!==e;g(r),m.current&&f.current(r),r?c.set(a,{original:e,content:l.current}):c.delete(a),R.invalidateQueries({queryKey:["checkout-files",s,i]}),R.invalidateQueries({queryKey:["git",s]})}catch(r){h(r instanceof Error?r.message:"Could not save file")}finally{x.current=!1,j(!1)}}y.current=()=>void M(),t.useEffect(()=>(m.current=!0,f.current(d.current.content!==d.current.original),()=>{m.current=!1}),[]),t.useEffect(()=>{x.current||c.has(a)||u===o.current||(o.current=u,l.current=u,b(u),g(!1),m.current&&f.current(!1))},[u,a]);function N(e){l.current=e,b(e);const r=e!==o.current;g(r),f.current(r),r?c.set(a,{original:o.current,content:e}):c.delete(a)}function L(){window.confirm("Discard your edits and reload the file from disk?")&&P.git.files(s,i).then(e=>{if(e.content===null||e.binary||e.truncated)throw new Error("File is no longer editable");o.current=e.content,l.current=e.content,c.delete(a),b(e.content),g(!1),f.current(!1),h(null)}).catch(e=>h(e instanceof Error?e.message:"Could not reload file"))}const F=n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-surface-highest px-2 py-1",children:[n.jsxs("button",{type:"button","data-testid":"file-save",disabled:!S||C||v,onClick:()=>void M(),className:"flex min-h-11 items-center gap-1 rounded px-2 py-1 text-sm text-primary hover:bg-surface-highest disabled:opacity-40",title:"Save (Ctrl/Cmd+S)",children:[n.jsx(V,{size:14}),C?"Saving…":"Save"]}),n.jsx("span",{"data-testid":"file-save-status",className:"min-w-0 flex-1 truncate text-sm text-on-surface-variant",children:v?"Read-only preview":S?"Unsaved changes":"Saved"})]}),E&&n.jsxs("div",{role:"alert",className:"shrink-0 border-b border-error/30 p-2 text-xs text-error",children:[E,n.jsx("button",{type:"button","data-testid":"file-reload",onClick:L,className:"ml-2 underline",children:"Reload from disk"})]})]});return n.jsxs("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"file-editor",children:[!K(i)&&F,n.jsx("div",{"data-testid":"file-preview",className:"min-h-0 flex-1 overflow-hidden",children:K(i)?n.jsx(A,{path:i,value:k,onChange:N,onSave:()=>y.current(),readOnly:v,height:"100%",testId:"file-editor-input",header:F,mode:D,onModeChange:e=>z(r=>{const q=new URLSearchParams(r);return q.set("editorMode",e),q})}):n.jsx(T,{path:i,value:k,onChange:N,onSave:()=>y.current(),readOnly:v,height:"100%",testId:"file-editor-input"})})]})}export{H as FileEditor};
@@ -1 +1 @@
1
- import{u as S,a as f,b as v,d as j,r as h,j as e,B as b,Y as w,Z as _,L as k,E as R,a9 as F}from"./index-DqE2dG9P.js";import{a as $}from"./useJobs-B65iRrUv.js";function L(t){return S({queryKey:["webhooks",t],queryFn:()=>j.webhooks.list(t),select:s=>s.webhooks})}function D(t){return S({queryKey:["webhook-deliveries",t],queryFn:()=>j.webhooks.deliveries(t),select:s=>s.deliveries,enabled:!!t,refetchInterval:3e3})}function U(){const t=f();return v({mutationFn:s=>j.webhooks.create(s),onSuccess:()=>t.invalidateQueries({queryKey:["webhooks"]})})}function E(){const t=f();return v({mutationFn:({id:s,...a})=>j.webhooks.update(s,a),onSuccess:()=>t.invalidateQueries({queryKey:["webhooks"]})})}function G(){const t=f();return v({mutationFn:s=>j.webhooks.delete(s),onSuccess:()=>t.invalidateQueries({queryKey:["webhooks"]})})}function P(){return v({mutationFn:t=>j.webhooks.rotate(t)})}function q(t){return[...new Set(t.split(",").map(s=>s.trim()).filter(Boolean))]}function I(t,s,a){return new URL(`/webhooks/${encodeURIComponent(t)}`,new URL(s,a)).href}function z(t){return["localhost","127.0.0.1","[::1]"].includes(new URL(t).hostname)}function N({id:t,testId:s,value:a,onChange:i,placeholder:d}){const[n,r]=h.useState(a.join(", "));return e.jsx(_,{id:t,"data-testid":s,value:n,placeholder:d,onChange:l=>{r(l.target.value),i(l.target.value)}})}function J({projectId:t,onCreated:s}){const a=U(),[i,d]=h.useState(""),[n,r]=h.useState("github"),[l,m]=h.useState(null),u=h.useId();return l?e.jsxs("div",{"data-testid":"webhook-created",className:"space-y-3",children:[e.jsx(W,{hook:l,secret:l.secret}),e.jsx(b,{type:"button",variant:"outline","data-testid":"webhook-setup-done",onClick:()=>{s==null||s(l),m(null),d("")},children:"I've copied the setup details"})]}):e.jsxs("div",{className:"space-y-3","data-testid":"webhook-create-form",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(w,{htmlFor:`${u}-name`,children:"Webhook name"}),e.jsx(_,{id:`${u}-name`,"data-testid":"webhook-name",value:i,onChange:c=>d(c.target.value),maxLength:100,placeholder:"GitHub repository events"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(w,{htmlFor:`${u}-provider`,children:"Provider"}),e.jsxs("select",{id:`${u}-provider`,"data-testid":"webhook-provider",className:"w-full min-h-11 rounded-md border border-control-border bg-background px-3 text-sm",value:n,onChange:c=>r(c.target.value),children:[e.jsx("option",{value:"github",children:"GitHub"}),e.jsx("option",{value:"generic",children:"Other service (HMAC)"})]})]}),e.jsx("p",{className:"text-xs text-outline",children:"Create the event source here. Connect jobs and choose their event filters in Jobs. No job is required to create a webhook."}),a.error&&e.jsx("p",{role:"alert",className:"text-sm text-error",children:a.error.message}),e.jsx(b,{type:"button","data-testid":"webhook-create",disabled:!i.trim()||a.isPending,onClick:()=>a.mutate({name:i.trim(),provider:n,project_id:t??null},{onSuccess:m}),children:a.isPending?"Creating...":"Create webhook"})]})}function A({value:t,onChange:s,projectId:a}){const{data:i,error:d,isLoading:n,refetch:r}=L(a),l=i==null?void 0:i.filter(o=>o.project_id===null||o.project_id===a),[m,u]=h.useState(!1);function c(o){t.some(p=>p.webhook_id===o)||s([...t,{webhook_id:o,events:[],actions:[]}])}function y(o,p,x){s(t.map(g=>g.webhook_id===o?{...g,[p]:q(x)}:g))}return e.jsxs("section",{className:"space-y-3 border-y border-border py-4","data-testid":"job-webhook-picker",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Which webhook should trigger this job?"}),d?e.jsx(R,{message:d.message,onRetry:()=>r()}):e.jsxs(e.Fragment,{children:[e.jsx(w,{htmlFor:"job-webhook-source",children:"Configured webhooks"}),e.jsxs("select",{id:"job-webhook-source","data-testid":"job-webhook-select",className:"w-full min-h-11 rounded-md border border-control-border bg-background px-3 text-sm",value:"",disabled:n,onChange:o=>{o.target.value&&c(o.target.value)},children:[e.jsx("option",{value:"",children:n?"Loading webhooks...":"Select an existing webhook"}),(l??[]).filter(o=>!t.some(p=>p.webhook_id===o.id)).map(o=>e.jsxs("option",{value:o.id,children:[o.name,o.enabled?"":" (disabled)"]},o.id))]}),!n&&!(l!=null&&l.length)&&e.jsx("p",{className:"text-xs text-outline",children:"No webhooks configured for this project yet. Create one below or on the Webhooks page."})]}),t.map(o=>{var p;return e.jsxs("div",{className:"space-y-2 border-t border-border pt-3","data-testid":"job-webhook-binding","data-webhook-id":o.webhook_id,children:[e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:((p=l==null?void 0:l.find(x=>x.id===o.webhook_id))==null?void 0:p.name)??o.webhook_id}),e.jsx(b,{type:"button",variant:"ghost",size:"sm","data-testid":"job-webhook-remove",onClick:()=>s(t.filter(x=>x.webhook_id!==o.webhook_id)),children:"Disconnect"})]}),e.jsx(w,{htmlFor:`events-${o.webhook_id}`,children:"Events for this job"}),e.jsx(N,{id:`events-${o.webhook_id}`,testId:"webhook-events",value:o.events,onChange:x=>y(o.webhook_id,"events",x),placeholder:"pull_request, push (blank accepts all)"}),e.jsx(w,{htmlFor:`actions-${o.webhook_id}`,children:"Actions for this job (optional)"}),e.jsx(N,{id:`actions-${o.webhook_id}`,testId:"webhook-actions",value:o.actions,onChange:x=>y(o.webhook_id,"actions",x),placeholder:"opened, synchronize (blank accepts all)"})]},o.webhook_id)}),e.jsx(b,{type:"button",size:"sm",variant:"outline","data-testid":"webhook-add",onClick:()=>u(!m),children:m?"Close new webhook":"Create a webhook"}),m&&e.jsx(J,{projectId:a,onCreated:o=>{c(o.id),u(!1)}})]})}function K({job:t}){const s=$(),[a,i]=h.useState(t.webhooks??[]);return e.jsxs("section",{className:"space-y-3","data-testid":"job-webhooks",children:[!t.enabled&&e.jsx("p",{className:"text-sm text-outline",children:"Job disabled. Configure connections now and enable it from Jobs when ready."}),e.jsx(A,{value:a,onChange:i,projectId:t.project_id??void 0}),s.error&&e.jsx("p",{role:"alert",className:"text-sm text-error",children:s.error.message}),e.jsx(b,{type:"button",size:"sm","data-testid":"job-webhooks-save",disabled:s.isPending,onClick:()=>s.mutate({id:t.id,webhooks:a,trigger_type:"webhook"}),children:"Save connections"}),s.isSuccess&&e.jsx("p",{role:"status",className:"text-xs text-outline",children:"Connections saved."}),e.jsx(k,{className:"inline-block text-sm underline",to:`/webhooks?project=${encodeURIComponent(t.project_id??"all")}`,children:"Manage configured webhooks and deliveries"})]})}function C({label:t,value:s,secret:a=!1}){const[i,d]=h.useState(!1),[n,r]=h.useState(!1);return e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-outline",children:t}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("code",{className:"min-w-0 flex-1 break-all text-xs","data-testid":a?"webhook-secret":"webhook-url",children:s}),e.jsx(b,{type:"button",size:"sm",variant:"outline","aria-label":`Copy ${t}`,onClick:async()=>{try{await navigator.clipboard.writeText(s),d(!0),r(!1)}catch{r(!0)}},children:i?"Copied":"Copy"})]}),n&&e.jsx("p",{role:"alert",className:"text-xs text-error",children:"Select and copy the value above; clipboard access is unavailable."})]})}function W({hook:t,secret:s}){const a=I(t.token,F(),window.location.origin);return e.jsxs("div",{className:"space-y-3","data-testid":"webhook-setup",children:[e.jsx(C,{label:"Payload URL",value:a}),z(a)&&e.jsx("p",{className:"text-sm text-warning",children:"This address is local. For external providers, use your publicly reachable ORC address with the same /webhooks/ path."}),s?e.jsxs(e.Fragment,{children:[e.jsx(C,{label:"Signing secret",value:s,secret:!0}),e.jsx("p",{className:"text-xs text-outline",children:"Copy the signing secret before leaving. It is shown once."})]}):e.jsx("p",{className:"text-xs text-outline",children:"The signing secret is hidden. Generate a replacement only if you need to reconnect the sender."}),t.provider==="github"?e.jsxs("ol",{className:"list-decimal space-y-1 pl-5 text-sm text-outline",children:[e.jsx("li",{children:"In your repository, open GitHub Settings - Webhooks - Add webhook."}),e.jsx("li",{children:"Paste the Payload URL, select application/json, and enter the signing secret."}),e.jsx("li",{children:"Select the events needed by your connected jobs. Each job has its own filters."}),e.jsx("li",{children:"Send an event and inspect Recent deliveries below."})]}):e.jsx("p",{className:"text-sm text-outline",children:"Send JSON, signed with HMAC-SHA256 of the raw body. Set X-Orc-Signature-256 to sha256=<hex signature>, X-Orc-Event to the event name and X-Orc-Delivery to a unique delivery ID."})]})}function Q({hook:t}){var u;const s=E(),a=P(),[i,d]=h.useState(!1),[n,r]=h.useState(!1),[l,m]=h.useState();return e.jsxs("article",{className:"space-y-3 border-b border-border pb-5","data-testid":"webhook-endpoint","data-webhook-id":t.id,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:t.name}),e.jsxs("span",{className:"text-xs text-outline",children:[t.provider," - ",t.enabled?"Enabled":"Disabled"]}),e.jsx(b,{type:"button",variant:"outline",size:"sm",disabled:s.isPending,onClick:()=>s.mutate({id:t.id,enabled:!t.enabled}),children:t.enabled?"Disable":"Enable"})]}),e.jsxs("div",{className:"space-y-1","data-testid":"webhook-connected-jobs",children:[e.jsxs("p",{className:"text-xs text-outline",children:["Connected jobs (",t.subscriptions.length,")"]}),t.subscriptions.length?t.subscriptions.map(c=>e.jsxs("div",{className:"text-sm",children:[e.jsx(k,{className:"underline","data-testid":"webhook-job-link",to:`/jobs/${c.job_id}?project=all`,children:c.name}),e.jsxs("span",{className:"text-xs text-outline",children:[" ","- ",c.enabled?"Enabled":"Disabled","; events:"," ",c.events.join(", ")||"all","; actions: ",c.actions.join(", ")||"all"]})]},c.job_id)):e.jsx("p",{className:"text-sm text-outline",children:"No connected jobs. Select this webhook when creating or editing a job."})]}),e.jsx(W,{hook:t,secret:l}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(b,{type:"button",variant:"outline",size:"sm","data-testid":"webhook-deliveries-toggle",onClick:()=>d(!i),children:i?"Hide deliveries":"Recent deliveries"}),e.jsx(b,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(!n),children:"New signing secret"})]}),n&&e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsx("p",{children:"The sender's existing secret will stop working. Update it after generating the replacement."}),e.jsx(b,{type:"button",variant:"outline",size:"sm",disabled:a.isPending,onClick:()=>a.mutate(t.id,{onSuccess:c=>{m(c.secret),r(!1)}}),children:"Generate replacement secret"})]}),(s.error||a.error)&&e.jsx("p",{role:"alert",className:"text-sm text-error",children:(u=s.error??a.error)==null?void 0:u.message}),i&&e.jsx(H,{id:t.id})]})}function H({id:t}){const{data:s,isLoading:a,error:i,refetch:d}=D(t);return e.jsxs("section",{className:"space-y-2","data-testid":"webhook-deliveries",children:[e.jsx("h4",{className:"text-sm font-medium",children:"Recent deliveries"}),i?e.jsx(R,{message:i.message,onRetry:()=>d()}):a?e.jsx("p",{role:"status",children:"Loading deliveries..."}):s!=null&&s.length?s.map(n=>e.jsxs("div",{className:"space-y-1 border-t border-border py-2 text-xs","data-testid":"webhook-delivery",children:[e.jsxs("div",{className:"flex flex-wrap justify-between gap-2",children:[e.jsxs("span",{children:[n.event,n.action?` / ${n.action}`:""]}),e.jsx("span",{children:n.status})]}),e.jsxs("p",{className:"text-outline",children:[n.repository," ",new Date(n.created_at).toLocaleString()]}),n.status==="ignored"&&e.jsx("p",{className:"text-outline",children:"No enabled connected job matched this event."}),n.error&&e.jsx("p",{className:"text-error",children:n.error}),n.runs.map(r=>e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs(k,{className:"underline",to:`/jobs/${r.job_id}?project=all`,children:["Job run: ",r.status]}),r.task_id&&e.jsx(k,{className:"underline",to:`/tasks/${r.task_id}?project=all`,children:"Created task"}),r.session_id&&e.jsx(k,{className:"underline",to:`/audit/${r.session_id}?project=all`,children:"Agent session"})]},r.job_run_id))]},n.id)):e.jsx("p",{className:"text-sm text-outline",children:"No events received yet. Register the endpoint with your provider, then send an event."})]})}export{K as J,J as W,G as a,Q as b,A as c,L as u};
1
+ import{u as S,a as f,b as v,d as j,r as h,j as e,B as b,_ as w,$ as _,L as k,E as R,ab as $}from"./index-BJl2bI67.js";import{a as F}from"./useJobs-BQp9uwz-.js";function L(t){return S({queryKey:["webhooks",t],queryFn:()=>j.webhooks.list(t),select:s=>s.webhooks})}function D(t){return S({queryKey:["webhook-deliveries",t],queryFn:()=>j.webhooks.deliveries(t),select:s=>s.deliveries,enabled:!!t,refetchInterval:3e3})}function U(){const t=f();return v({mutationFn:s=>j.webhooks.create(s),onSuccess:()=>t.invalidateQueries({queryKey:["webhooks"]})})}function E(){const t=f();return v({mutationFn:({id:s,...a})=>j.webhooks.update(s,a),onSuccess:()=>t.invalidateQueries({queryKey:["webhooks"]})})}function G(){const t=f();return v({mutationFn:s=>j.webhooks.delete(s),onSuccess:()=>t.invalidateQueries({queryKey:["webhooks"]})})}function P(){return v({mutationFn:t=>j.webhooks.rotate(t)})}function q(t){return[...new Set(t.split(",").map(s=>s.trim()).filter(Boolean))]}function I(t,s,a){return new URL(`/webhooks/${encodeURIComponent(t)}`,new URL(s,a)).href}function z(t){return["localhost","127.0.0.1","[::1]"].includes(new URL(t).hostname)}function N({id:t,testId:s,value:a,onChange:i,placeholder:d}){const[n,r]=h.useState(a.join(", "));return e.jsx(_,{id:t,"data-testid":s,value:n,placeholder:d,onChange:l=>{r(l.target.value),i(l.target.value)}})}function J({projectId:t,onCreated:s}){const a=U(),[i,d]=h.useState(""),[n,r]=h.useState("github"),[l,m]=h.useState(null),u=h.useId();return l?e.jsxs("div",{"data-testid":"webhook-created",className:"space-y-3",children:[e.jsx(W,{hook:l,secret:l.secret}),e.jsx(b,{type:"button",variant:"outline","data-testid":"webhook-setup-done",onClick:()=>{s==null||s(l),m(null),d("")},children:"I've copied the setup details"})]}):e.jsxs("div",{className:"space-y-3","data-testid":"webhook-create-form",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(w,{htmlFor:`${u}-name`,children:"Webhook name"}),e.jsx(_,{id:`${u}-name`,"data-testid":"webhook-name",value:i,onChange:c=>d(c.target.value),maxLength:100,placeholder:"GitHub repository events"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(w,{htmlFor:`${u}-provider`,children:"Provider"}),e.jsxs("select",{id:`${u}-provider`,"data-testid":"webhook-provider",className:"w-full min-h-11 rounded-md border border-control-border bg-background px-3 text-sm",value:n,onChange:c=>r(c.target.value),children:[e.jsx("option",{value:"github",children:"GitHub"}),e.jsx("option",{value:"generic",children:"Other service (HMAC)"})]})]}),e.jsx("p",{className:"text-xs text-outline",children:"Create the event source here. Connect jobs and choose their event filters in Jobs. No job is required to create a webhook."}),a.error&&e.jsx("p",{role:"alert",className:"text-sm text-error",children:a.error.message}),e.jsx(b,{type:"button","data-testid":"webhook-create",disabled:!i.trim()||a.isPending,onClick:()=>a.mutate({name:i.trim(),provider:n,project_id:t??null},{onSuccess:m}),children:a.isPending?"Creating...":"Create webhook"})]})}function A({value:t,onChange:s,projectId:a}){const{data:i,error:d,isLoading:n,refetch:r}=L(a),l=i==null?void 0:i.filter(o=>o.project_id===null||o.project_id===a),[m,u]=h.useState(!1);function c(o){t.some(p=>p.webhook_id===o)||s([...t,{webhook_id:o,events:[],actions:[]}])}function y(o,p,x){s(t.map(g=>g.webhook_id===o?{...g,[p]:q(x)}:g))}return e.jsxs("section",{className:"space-y-3 border-y border-border py-4","data-testid":"job-webhook-picker",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Which webhook should trigger this job?"}),d?e.jsx(R,{message:d.message,onRetry:()=>r()}):e.jsxs(e.Fragment,{children:[e.jsx(w,{htmlFor:"job-webhook-source",children:"Configured webhooks"}),e.jsxs("select",{id:"job-webhook-source","data-testid":"job-webhook-select",className:"w-full min-h-11 rounded-md border border-control-border bg-background px-3 text-sm",value:"",disabled:n,onChange:o=>{o.target.value&&c(o.target.value)},children:[e.jsx("option",{value:"",children:n?"Loading webhooks...":"Select an existing webhook"}),(l??[]).filter(o=>!t.some(p=>p.webhook_id===o.id)).map(o=>e.jsxs("option",{value:o.id,children:[o.name,o.enabled?"":" (disabled)"]},o.id))]}),!n&&!(l!=null&&l.length)&&e.jsx("p",{className:"text-xs text-outline",children:"No webhooks configured for this project yet. Create one below or on the Webhooks page."})]}),t.map(o=>{var p;return e.jsxs("div",{className:"space-y-2 border-t border-border pt-3","data-testid":"job-webhook-binding","data-webhook-id":o.webhook_id,children:[e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:((p=l==null?void 0:l.find(x=>x.id===o.webhook_id))==null?void 0:p.name)??o.webhook_id}),e.jsx(b,{type:"button",variant:"ghost",size:"sm","data-testid":"job-webhook-remove",onClick:()=>s(t.filter(x=>x.webhook_id!==o.webhook_id)),children:"Disconnect"})]}),e.jsx(w,{htmlFor:`events-${o.webhook_id}`,children:"Events for this job"}),e.jsx(N,{id:`events-${o.webhook_id}`,testId:"webhook-events",value:o.events,onChange:x=>y(o.webhook_id,"events",x),placeholder:"pull_request, push (blank accepts all)"}),e.jsx(w,{htmlFor:`actions-${o.webhook_id}`,children:"Actions for this job (optional)"}),e.jsx(N,{id:`actions-${o.webhook_id}`,testId:"webhook-actions",value:o.actions,onChange:x=>y(o.webhook_id,"actions",x),placeholder:"opened, synchronize (blank accepts all)"})]},o.webhook_id)}),e.jsx(b,{type:"button",size:"sm",variant:"outline","data-testid":"webhook-add",onClick:()=>u(!m),children:m?"Close new webhook":"Create a webhook"}),m&&e.jsx(J,{projectId:a,onCreated:o=>{c(o.id),u(!1)}})]})}function K({job:t}){const s=F(),[a,i]=h.useState(t.webhooks??[]);return e.jsxs("section",{className:"space-y-3","data-testid":"job-webhooks",children:[!t.enabled&&e.jsx("p",{className:"text-sm text-outline",children:"Job disabled. Configure connections now and enable it from Jobs when ready."}),e.jsx(A,{value:a,onChange:i,projectId:t.project_id??void 0}),s.error&&e.jsx("p",{role:"alert",className:"text-sm text-error",children:s.error.message}),e.jsx(b,{type:"button",size:"sm","data-testid":"job-webhooks-save",disabled:s.isPending,onClick:()=>s.mutate({id:t.id,webhooks:a,trigger_type:"webhook"}),children:"Save connections"}),s.isSuccess&&e.jsx("p",{role:"status",className:"text-xs text-outline",children:"Connections saved."}),e.jsx(k,{className:"inline-block text-sm underline",to:`/webhooks?project=${encodeURIComponent(t.project_id??"all")}`,children:"Manage configured webhooks and deliveries"})]})}function C({label:t,value:s,secret:a=!1}){const[i,d]=h.useState(!1),[n,r]=h.useState(!1);return e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-outline",children:t}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("code",{className:"min-w-0 flex-1 break-all text-xs","data-testid":a?"webhook-secret":"webhook-url",children:s}),e.jsx(b,{type:"button",size:"sm",variant:"outline","aria-label":`Copy ${t}`,onClick:async()=>{try{await navigator.clipboard.writeText(s),d(!0),r(!1)}catch{r(!0)}},children:i?"Copied":"Copy"})]}),n&&e.jsx("p",{role:"alert",className:"text-xs text-error",children:"Select and copy the value above; clipboard access is unavailable."})]})}function W({hook:t,secret:s}){const a=I(t.token,$(),window.location.origin);return e.jsxs("div",{className:"space-y-3","data-testid":"webhook-setup",children:[e.jsx(C,{label:"Payload URL",value:a}),z(a)&&e.jsx("p",{className:"text-sm text-warning",children:"This address is local. For external providers, use your publicly reachable ORC address with the same /webhooks/ path."}),s?e.jsxs(e.Fragment,{children:[e.jsx(C,{label:"Signing secret",value:s,secret:!0}),e.jsx("p",{className:"text-xs text-outline",children:"Copy the signing secret before leaving. It is shown once."})]}):e.jsx("p",{className:"text-xs text-outline",children:"The signing secret is hidden. Generate a replacement only if you need to reconnect the sender."}),t.provider==="github"?e.jsxs("ol",{className:"list-decimal space-y-1 pl-5 text-sm text-outline",children:[e.jsx("li",{children:"In your repository, open GitHub Settings - Webhooks - Add webhook."}),e.jsx("li",{children:"Paste the Payload URL, select application/json, and enter the signing secret."}),e.jsx("li",{children:"Select the events needed by your connected jobs. Each job has its own filters."}),e.jsx("li",{children:"Send an event and inspect Recent deliveries below."})]}):e.jsx("p",{className:"text-sm text-outline",children:"Send JSON, signed with HMAC-SHA256 of the raw body. Set X-Orc-Signature-256 to sha256=<hex signature>, X-Orc-Event to the event name and X-Orc-Delivery to a unique delivery ID."})]})}function Q({hook:t}){var u;const s=E(),a=P(),[i,d]=h.useState(!1),[n,r]=h.useState(!1),[l,m]=h.useState();return e.jsxs("article",{className:"space-y-3 border-b border-border pb-5","data-testid":"webhook-endpoint","data-webhook-id":t.id,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:t.name}),e.jsxs("span",{className:"text-xs text-outline",children:[t.provider," - ",t.enabled?"Enabled":"Disabled"]}),e.jsx(b,{type:"button",variant:"outline",size:"sm",disabled:s.isPending,onClick:()=>s.mutate({id:t.id,enabled:!t.enabled}),children:t.enabled?"Disable":"Enable"})]}),e.jsxs("div",{className:"space-y-1","data-testid":"webhook-connected-jobs",children:[e.jsxs("p",{className:"text-xs text-outline",children:["Connected jobs (",t.subscriptions.length,")"]}),t.subscriptions.length?t.subscriptions.map(c=>e.jsxs("div",{className:"text-sm",children:[e.jsx(k,{className:"underline","data-testid":"webhook-job-link",to:`/jobs/${c.job_id}?project=all`,children:c.name}),e.jsxs("span",{className:"text-xs text-outline",children:[" ","- ",c.enabled?"Enabled":"Disabled","; events:"," ",c.events.join(", ")||"all","; actions: ",c.actions.join(", ")||"all"]})]},c.job_id)):e.jsx("p",{className:"text-sm text-outline",children:"No connected jobs. Select this webhook when creating or editing a job."})]}),e.jsx(W,{hook:t,secret:l}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(b,{type:"button",variant:"outline",size:"sm","data-testid":"webhook-deliveries-toggle",onClick:()=>d(!i),children:i?"Hide deliveries":"Recent deliveries"}),e.jsx(b,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(!n),children:"New signing secret"})]}),n&&e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsx("p",{children:"The sender's existing secret will stop working. Update it after generating the replacement."}),e.jsx(b,{type:"button",variant:"outline",size:"sm",disabled:a.isPending,onClick:()=>a.mutate(t.id,{onSuccess:c=>{m(c.secret),r(!1)}}),children:"Generate replacement secret"})]}),(s.error||a.error)&&e.jsx("p",{role:"alert",className:"text-sm text-error",children:(u=s.error??a.error)==null?void 0:u.message}),i&&e.jsx(H,{id:t.id})]})}function H({id:t}){const{data:s,isLoading:a,error:i,refetch:d}=D(t);return e.jsxs("section",{className:"space-y-2","data-testid":"webhook-deliveries",children:[e.jsx("h4",{className:"text-sm font-medium",children:"Recent deliveries"}),i?e.jsx(R,{message:i.message,onRetry:()=>d()}):a?e.jsx("p",{role:"status",children:"Loading deliveries..."}):s!=null&&s.length?s.map(n=>e.jsxs("div",{className:"space-y-1 border-t border-border py-2 text-xs","data-testid":"webhook-delivery",children:[e.jsxs("div",{className:"flex flex-wrap justify-between gap-2",children:[e.jsxs("span",{children:[n.event,n.action?` / ${n.action}`:""]}),e.jsx("span",{children:n.status})]}),e.jsxs("p",{className:"text-outline",children:[n.repository," ",new Date(n.created_at).toLocaleString()]}),n.status==="ignored"&&e.jsx("p",{className:"text-outline",children:"No enabled connected job matched this event."}),n.error&&e.jsx("p",{className:"text-error",children:n.error}),n.runs.map(r=>e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs(k,{className:"underline",to:`/jobs/${r.job_id}?project=all`,children:["Job run: ",r.status]}),r.task_id&&e.jsx(k,{className:"underline",to:`/tasks/${r.task_id}?project=all`,children:"Created task"}),r.session_id&&e.jsx(k,{className:"underline",to:`/audit/${r.session_id}?project=all`,children:"Agent session"})]},r.job_run_id))]},n.id)):e.jsx("p",{className:"text-sm text-outline",children:"No events received yet. Register the endpoint with your provider, then send an event."})]})}export{K as J,J as W,G as a,Q as b,A as c,L as u};
@@ -1,4 +1,4 @@
1
- import{c as ae,r as o,ag as ge,j as e,Y as d,ah as G,Z as f,a2 as pe,a3 as je,a4 as fe,a5 as Ne,a6 as ye,E as H,S as U,ac as P,ai as ve,B as g,ad as ke,f as _e,q as we,L as Q,l as Se,aj as Ce,a0 as De,V as ee,ak as Te,al as $e,af as Pe,am as te,T as Ee,s as Re,t as se,v as L,w as Je,x as O,a7 as ze,n as Ie,a8 as ne,U as re,W as le,X as ie,an as V,ao as q,ap as M,aq as W,ar as B,as as oe}from"./index-DqE2dG9P.js";import{J as Le,c as de}from"./JobWebhooks-DfH2j2qa.js";import{S as Oe}from"./scroll-area-C0__dq9d.js";import{b as Ae,c as Fe,d as ce,a as K,e as Be,u as Ve,f as qe,g as Me,h as We}from"./useJobs-B65iRrUv.js";import{P as X}from"./pencil-tq07PJIK.js";import{u as He}from"./useProjectScope-6JtX8j4R.js";/**
1
+ import{c as ae,r as o,ai as ge,j as e,_ as d,T as G,$ as f,a4 as pe,a5 as je,a6 as fe,a7 as Ne,a8 as ye,E as H,S as U,ae as P,aj as ve,B as g,af as ke,f as _e,s as we,L as Q,m as Se,ak as Ce,a2 as De,V as ee,al as Te,am as $e,ah as Pe,an as te,t as Ee,v as Re,w as se,x as L,y as Je,z as O,a9 as ze,o as Ie,aa as ne,X as re,Y as le,Z as ie,ao as V,ap as q,aq as M,ar as W,as as B,at as oe}from"./index-BJl2bI67.js";import{J as Le,c as de}from"./JobWebhooks-DKFEEiP_.js";import{S as Oe}from"./scroll-area-DyJaZyLF.js";import{b as Ae,c as Fe,d as ce,a as K,e as Be,u as Ve,f as qe,g as Me,h as We}from"./useJobs-BQp9uwz-.js";import{P as X}from"./pencil-D3Nj_J6I.js";import{u as He}from"./useProjectScope-BthZtFg0.js";/**
2
2
  * @license lucide-react v1.27.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.