@contractspec/example.agent-console 3.8.9 → 3.8.11

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 (228) hide show
  1. package/.turbo/turbo-build.log +225 -222
  2. package/CHANGELOG.md +30 -0
  3. package/dist/agent/agent.entity.js +1 -127
  4. package/dist/agent/agent.enum.js +1 -25
  5. package/dist/agent/agent.event.js +1 -116
  6. package/dist/agent/agent.handler.js +1 -1030
  7. package/dist/agent/agent.operation.js +1 -735
  8. package/dist/agent/agent.presentation.js +1 -282
  9. package/dist/agent/agent.schema.js +1 -215
  10. package/dist/agent/agent.test-spec.js +1 -58
  11. package/dist/agent/index.js +1 -1248
  12. package/dist/agent.capability.js +1 -19
  13. package/dist/agent.feature.js +1 -305
  14. package/dist/browser/agent/agent.entity.js +1 -127
  15. package/dist/browser/agent/agent.enum.js +1 -25
  16. package/dist/browser/agent/agent.event.js +1 -116
  17. package/dist/browser/agent/agent.handler.js +1 -1030
  18. package/dist/browser/agent/agent.operation.js +1 -735
  19. package/dist/browser/agent/agent.presentation.js +1 -282
  20. package/dist/browser/agent/agent.schema.js +1 -215
  21. package/dist/browser/agent/agent.test-spec.js +1 -58
  22. package/dist/browser/agent/index.js +1 -1248
  23. package/dist/browser/agent.capability.js +1 -19
  24. package/dist/browser/agent.feature.js +1 -305
  25. package/dist/browser/docs/agent-console.docblock.js +5 -49
  26. package/dist/browser/docs/index.js +5 -49
  27. package/dist/browser/example.js +1 -41
  28. package/dist/browser/handlers/agent.handlers.js +6 -2143
  29. package/dist/browser/handlers/index.js +6 -2943
  30. package/dist/browser/index.js +14 -6828
  31. package/dist/browser/presentations/index.js +1 -693
  32. package/dist/browser/run/index.js +1 -1363
  33. package/dist/browser/run/run.entity.js +1 -160
  34. package/dist/browser/run/run.enum.js +1 -34
  35. package/dist/browser/run/run.event.js +1 -217
  36. package/dist/browser/run/run.handler.js +1 -919
  37. package/dist/browser/run/run.operation.js +1 -667
  38. package/dist/browser/run/run.presentation.js +1 -223
  39. package/dist/browser/run/run.schema.js +1 -179
  40. package/dist/browser/run/run.test-spec.js +1 -58
  41. package/dist/browser/seeders/index.js +2 -21
  42. package/dist/browser/shared/index.js +1 -626
  43. package/dist/browser/shared/mock-agents.js +1 -82
  44. package/dist/browser/shared/mock-runs.js +1 -113
  45. package/dist/browser/shared/mock-tools.js +1 -146
  46. package/dist/browser/tool/index.js +1 -949
  47. package/dist/browser/tool/tool.entity.js +1 -90
  48. package/dist/browser/tool/tool.enum.js +1 -26
  49. package/dist/browser/tool/tool.event.js +1 -99
  50. package/dist/browser/tool/tool.handler.js +1 -699
  51. package/dist/browser/tool/tool.operation.js +1 -482
  52. package/dist/browser/tool/tool.presentation.js +1 -188
  53. package/dist/browser/tool/tool.schema.js +1 -141
  54. package/dist/browser/tool/tool.test-spec.js +1 -58
  55. package/dist/browser/ui/AgentDashboard.js +1 -2527
  56. package/dist/browser/ui/AgentDashboard.visualizations.js +1 -217
  57. package/dist/browser/ui/AgentRunList.js +1 -482
  58. package/dist/browser/ui/AgentToolRegistry.js +1 -212
  59. package/dist/browser/ui/ExecutionConsoleHost.js +1 -0
  60. package/dist/browser/ui/hooks/index.js +1 -740
  61. package/dist/browser/ui/hooks/useAgentList.js +1 -55
  62. package/dist/browser/ui/hooks/useAgentMutations.js +1 -530
  63. package/dist/browser/ui/hooks/useRunList.js +1 -70
  64. package/dist/browser/ui/hooks/useToolList.js +1 -85
  65. package/dist/browser/ui/index.js +5 -3018
  66. package/dist/browser/ui/modals/AgentActionsModal.js +1 -304
  67. package/dist/browser/ui/modals/CreateAgentModal.js +1 -243
  68. package/dist/browser/ui/modals/index.js +1 -546
  69. package/dist/browser/ui/overlays/demo-overlays.js +1 -64
  70. package/dist/browser/ui/overlays/index.js +1 -64
  71. package/dist/browser/ui/renderers/agent-list.markdown.js +2 -64
  72. package/dist/browser/ui/renderers/agent-list.renderer.js +1 -180
  73. package/dist/browser/ui/renderers/dashboard.markdown.js +2 -288
  74. package/dist/browser/ui/renderers/index.js +5 -642
  75. package/dist/browser/ui/renderers/run-list.markdown.js +2 -50
  76. package/dist/browser/ui/renderers/tool-registry.markdown.js +2 -64
  77. package/dist/browser/ui/views/AgentListView.js +1 -165
  78. package/dist/browser/ui/views/RunDataTable.js +1 -326
  79. package/dist/browser/ui/views/RunListView.js +1 -479
  80. package/dist/browser/ui/views/ToolRegistryView.js +1 -209
  81. package/dist/browser/ui/views/index.js +1 -851
  82. package/dist/browser/ui/views/run-data-table.columns.js +1 -271
  83. package/dist/browser/ui/views/run-list.shared.js +1 -177
  84. package/dist/browser/visualizations/catalog.js +1 -134
  85. package/dist/browser/visualizations/index.js +1 -187
  86. package/dist/browser/visualizations/selectors.js +1 -181
  87. package/dist/docs/agent-console.docblock.js +5 -49
  88. package/dist/docs/index.js +5 -49
  89. package/dist/example.js +1 -41
  90. package/dist/handlers/agent.handlers.js +6 -2143
  91. package/dist/handlers/index.js +6 -2943
  92. package/dist/index.js +14 -6828
  93. package/dist/node/agent/agent.entity.js +1 -127
  94. package/dist/node/agent/agent.enum.js +1 -25
  95. package/dist/node/agent/agent.event.js +1 -116
  96. package/dist/node/agent/agent.handler.js +1 -1030
  97. package/dist/node/agent/agent.operation.js +1 -735
  98. package/dist/node/agent/agent.presentation.js +1 -282
  99. package/dist/node/agent/agent.schema.js +1 -215
  100. package/dist/node/agent/agent.test-spec.js +1 -58
  101. package/dist/node/agent/index.js +1 -1248
  102. package/dist/node/agent.capability.js +1 -19
  103. package/dist/node/agent.feature.js +1 -305
  104. package/dist/node/docs/agent-console.docblock.js +5 -49
  105. package/dist/node/docs/index.js +5 -49
  106. package/dist/node/example.js +1 -41
  107. package/dist/node/handlers/agent.handlers.js +6 -2143
  108. package/dist/node/handlers/index.js +6 -2943
  109. package/dist/node/index.js +14 -6828
  110. package/dist/node/presentations/index.js +1 -693
  111. package/dist/node/run/index.js +1 -1363
  112. package/dist/node/run/run.entity.js +1 -160
  113. package/dist/node/run/run.enum.js +1 -34
  114. package/dist/node/run/run.event.js +1 -217
  115. package/dist/node/run/run.handler.js +1 -919
  116. package/dist/node/run/run.operation.js +1 -667
  117. package/dist/node/run/run.presentation.js +1 -223
  118. package/dist/node/run/run.schema.js +1 -179
  119. package/dist/node/run/run.test-spec.js +1 -58
  120. package/dist/node/seeders/index.js +2 -21
  121. package/dist/node/shared/index.js +1 -626
  122. package/dist/node/shared/mock-agents.js +1 -82
  123. package/dist/node/shared/mock-runs.js +1 -113
  124. package/dist/node/shared/mock-tools.js +1 -146
  125. package/dist/node/tool/index.js +1 -949
  126. package/dist/node/tool/tool.entity.js +1 -90
  127. package/dist/node/tool/tool.enum.js +1 -26
  128. package/dist/node/tool/tool.event.js +1 -99
  129. package/dist/node/tool/tool.handler.js +1 -699
  130. package/dist/node/tool/tool.operation.js +1 -482
  131. package/dist/node/tool/tool.presentation.js +1 -188
  132. package/dist/node/tool/tool.schema.js +1 -141
  133. package/dist/node/tool/tool.test-spec.js +1 -58
  134. package/dist/node/ui/AgentDashboard.js +1 -2527
  135. package/dist/node/ui/AgentDashboard.visualizations.js +1 -217
  136. package/dist/node/ui/AgentRunList.js +1 -482
  137. package/dist/node/ui/AgentToolRegistry.js +1 -212
  138. package/dist/node/ui/ExecutionConsoleHost.js +1 -0
  139. package/dist/node/ui/hooks/index.js +1 -740
  140. package/dist/node/ui/hooks/useAgentList.js +1 -55
  141. package/dist/node/ui/hooks/useAgentMutations.js +1 -530
  142. package/dist/node/ui/hooks/useRunList.js +1 -70
  143. package/dist/node/ui/hooks/useToolList.js +1 -85
  144. package/dist/node/ui/index.js +5 -3018
  145. package/dist/node/ui/modals/AgentActionsModal.js +1 -304
  146. package/dist/node/ui/modals/CreateAgentModal.js +1 -243
  147. package/dist/node/ui/modals/index.js +1 -546
  148. package/dist/node/ui/overlays/demo-overlays.js +1 -64
  149. package/dist/node/ui/overlays/index.js +1 -64
  150. package/dist/node/ui/renderers/agent-list.markdown.js +2 -64
  151. package/dist/node/ui/renderers/agent-list.renderer.js +1 -180
  152. package/dist/node/ui/renderers/dashboard.markdown.js +2 -288
  153. package/dist/node/ui/renderers/index.js +5 -642
  154. package/dist/node/ui/renderers/run-list.markdown.js +2 -50
  155. package/dist/node/ui/renderers/tool-registry.markdown.js +2 -64
  156. package/dist/node/ui/views/AgentListView.js +1 -165
  157. package/dist/node/ui/views/RunDataTable.js +1 -326
  158. package/dist/node/ui/views/RunListView.js +1 -479
  159. package/dist/node/ui/views/ToolRegistryView.js +1 -209
  160. package/dist/node/ui/views/index.js +1 -851
  161. package/dist/node/ui/views/run-data-table.columns.js +1 -271
  162. package/dist/node/ui/views/run-list.shared.js +1 -177
  163. package/dist/node/visualizations/catalog.js +1 -134
  164. package/dist/node/visualizations/index.js +1 -187
  165. package/dist/node/visualizations/selectors.js +1 -181
  166. package/dist/presentations/index.js +1 -693
  167. package/dist/run/index.js +1 -1363
  168. package/dist/run/run.entity.js +1 -160
  169. package/dist/run/run.enum.js +1 -34
  170. package/dist/run/run.event.js +1 -217
  171. package/dist/run/run.handler.js +1 -919
  172. package/dist/run/run.operation.js +1 -667
  173. package/dist/run/run.presentation.js +1 -223
  174. package/dist/run/run.schema.js +1 -179
  175. package/dist/run/run.test-spec.js +1 -58
  176. package/dist/seeders/index.js +2 -21
  177. package/dist/shared/index.js +1 -626
  178. package/dist/shared/mock-agents.js +1 -82
  179. package/dist/shared/mock-runs.js +1 -113
  180. package/dist/shared/mock-tools.js +1 -146
  181. package/dist/tool/index.js +1 -949
  182. package/dist/tool/tool.entity.js +1 -90
  183. package/dist/tool/tool.enum.js +1 -26
  184. package/dist/tool/tool.event.js +1 -99
  185. package/dist/tool/tool.handler.js +1 -699
  186. package/dist/tool/tool.operation.js +1 -482
  187. package/dist/tool/tool.presentation.js +1 -188
  188. package/dist/tool/tool.schema.js +1 -141
  189. package/dist/tool/tool.test-spec.js +1 -58
  190. package/dist/ui/AgentDashboard.js +1 -2527
  191. package/dist/ui/AgentDashboard.visualizations.js +1 -217
  192. package/dist/ui/AgentRunList.js +1 -482
  193. package/dist/ui/AgentToolRegistry.js +1 -212
  194. package/dist/ui/ExecutionConsoleHost.d.ts +1 -0
  195. package/dist/ui/ExecutionConsoleHost.js +2 -0
  196. package/dist/ui/ExecutionConsoleHost.test.d.ts +1 -0
  197. package/dist/ui/hooks/index.js +1 -740
  198. package/dist/ui/hooks/useAgentList.js +1 -55
  199. package/dist/ui/hooks/useAgentMutations.js +1 -530
  200. package/dist/ui/hooks/useRunList.js +1 -70
  201. package/dist/ui/hooks/useToolList.js +1 -85
  202. package/dist/ui/index.d.ts +1 -0
  203. package/dist/ui/index.js +5 -3018
  204. package/dist/ui/modals/AgentActionsModal.js +1 -304
  205. package/dist/ui/modals/CreateAgentModal.js +1 -243
  206. package/dist/ui/modals/index.js +1 -546
  207. package/dist/ui/overlays/demo-overlays.js +1 -64
  208. package/dist/ui/overlays/index.js +1 -64
  209. package/dist/ui/renderers/agent-list.markdown.js +2 -64
  210. package/dist/ui/renderers/agent-list.renderer.js +1 -180
  211. package/dist/ui/renderers/dashboard.markdown.js +2 -288
  212. package/dist/ui/renderers/index.js +5 -642
  213. package/dist/ui/renderers/run-list.markdown.js +2 -50
  214. package/dist/ui/renderers/tool-registry.markdown.js +2 -64
  215. package/dist/ui/views/AgentListView.js +1 -165
  216. package/dist/ui/views/RunDataTable.js +1 -326
  217. package/dist/ui/views/RunListView.js +1 -479
  218. package/dist/ui/views/ToolRegistryView.js +1 -209
  219. package/dist/ui/views/index.js +1 -851
  220. package/dist/ui/views/run-data-table.columns.js +1 -271
  221. package/dist/ui/views/run-list.shared.js +1 -177
  222. package/dist/visualizations/catalog.js +1 -134
  223. package/dist/visualizations/index.js +1 -187
  224. package/dist/visualizations/selectors.js +1 -181
  225. package/package.json +26 -10
  226. package/src/ui/ExecutionConsoleHost.test.tsx +110 -0
  227. package/src/ui/ExecutionConsoleHost.tsx +14 -0
  228. package/src/ui/index.ts +1 -1
@@ -1,213 +1,2 @@
1
1
  // @bun
2
- // src/ui/hooks/useToolList.ts
3
- import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
4
- import { useCallback, useEffect, useMemo, useState } from "react";
5
- function useToolList(options = {}) {
6
- const { handlers, projectId } = useTemplateRuntime();
7
- const { agent } = handlers;
8
- const [data, setData] = useState(null);
9
- const [loading, setLoading] = useState(true);
10
- const [error, setError] = useState(null);
11
- const [page, setPage] = useState(1);
12
- const fetchData = useCallback(async () => {
13
- setLoading(true);
14
- setError(null);
15
- try {
16
- const result = await agent.listTools({
17
- projectId,
18
- search: options.search,
19
- category: options.category,
20
- status: options.status === "all" ? undefined : options.status,
21
- limit: options.limit ?? 50,
22
- offset: (page - 1) * (options.limit ?? 50)
23
- });
24
- setData(result);
25
- } catch (err) {
26
- setError(err instanceof Error ? err : new Error("Unknown error"));
27
- } finally {
28
- setLoading(false);
29
- }
30
- }, [
31
- agent,
32
- projectId,
33
- options.search,
34
- options.category,
35
- options.status,
36
- options.limit,
37
- page
38
- ]);
39
- useEffect(() => {
40
- fetchData();
41
- }, [fetchData]);
42
- const { stats, groupedByCategory, categoryStats } = useMemo(() => {
43
- if (!data)
44
- return { stats: null, groupedByCategory: {}, categoryStats: [] };
45
- const items = data.items;
46
- const active = items.filter((t) => t.status === "ACTIVE").length;
47
- const deprecated = items.filter((t) => t.status === "DEPRECATED").length;
48
- const disabled = items.filter((t) => t.status === "DISABLED").length;
49
- const grouped = {};
50
- const byCategory = {};
51
- items.forEach((t) => {
52
- const cat = t.category;
53
- if (!grouped[cat])
54
- grouped[cat] = [];
55
- grouped[cat].push(t);
56
- byCategory[cat] = (byCategory[cat] || 0) + 1;
57
- });
58
- const catStats = Object.entries(byCategory).map(([category, count]) => ({ category, count })).sort((a, b) => b.count - a.count);
59
- return {
60
- stats: {
61
- total: data.total,
62
- active,
63
- deprecated,
64
- disabled,
65
- topCategories: catStats.slice(0, 5)
66
- },
67
- groupedByCategory: grouped,
68
- categoryStats: catStats
69
- };
70
- }, [data]);
71
- return {
72
- data,
73
- loading,
74
- error,
75
- stats,
76
- groupedByCategory,
77
- categoryStats,
78
- page,
79
- refetch: fetchData,
80
- nextPage: () => setPage((p) => p + 1),
81
- prevPage: () => page > 1 && setPage((p) => p - 1)
82
- };
83
- }
84
-
85
- // src/ui/views/ToolRegistryView.tsx
86
- import {
87
- Button,
88
- EmptyState,
89
- EntityCard,
90
- ErrorState,
91
- LoaderBlock,
92
- StatCard,
93
- StatCardGroup,
94
- StatusChip
95
- } from "@contractspec/lib.design-system";
96
- import { jsxDEV } from "react/jsx-dev-runtime";
97
- "use client";
98
- var categoryIcons = {
99
- RETRIEVAL: "\uD83D\uDD0D",
100
- COMPUTATION: "\uD83E\uDDEE",
101
- COMMUNICATION: "\uD83D\uDCE7",
102
- INTEGRATION: "\uD83D\uDD17",
103
- UTILITY: "\uD83D\uDEE0\uFE0F",
104
- CUSTOM: "\u2699\uFE0F"
105
- };
106
- function getStatusTone(status) {
107
- switch (status) {
108
- case "ACTIVE":
109
- return "success";
110
- case "DRAFT":
111
- return "neutral";
112
- case "DEPRECATED":
113
- return "warning";
114
- case "DISABLED":
115
- return "danger";
116
- default:
117
- return "neutral";
118
- }
119
- }
120
- function ToolRegistryView({
121
- onToolClick,
122
- onCreateTool
123
- }) {
124
- const { data, loading, error, groupedByCategory, categoryStats, refetch } = useToolList();
125
- if (loading && !data) {
126
- return /* @__PURE__ */ jsxDEV(LoaderBlock, {
127
- label: "Loading tools..."
128
- }, undefined, false, undefined, this);
129
- }
130
- if (error) {
131
- return /* @__PURE__ */ jsxDEV(ErrorState, {
132
- title: "Failed to load tools",
133
- description: error.message,
134
- onRetry: refetch,
135
- retryLabel: "Retry"
136
- }, undefined, false, undefined, this);
137
- }
138
- if (!data?.items.length) {
139
- return /* @__PURE__ */ jsxDEV(EmptyState, {
140
- title: "No tools registered",
141
- description: "Create your first tool to extend agent capabilities.",
142
- primaryAction: onCreateTool ? /* @__PURE__ */ jsxDEV(Button, {
143
- onPress: onCreateTool,
144
- children: "Create Tool"
145
- }, undefined, false, undefined, this) : undefined
146
- }, undefined, false, undefined, this);
147
- }
148
- return /* @__PURE__ */ jsxDEV("div", {
149
- className: "space-y-8",
150
- children: [
151
- /* @__PURE__ */ jsxDEV(StatCardGroup, {
152
- children: [
153
- /* @__PURE__ */ jsxDEV(StatCard, {
154
- label: "Total Tools",
155
- value: data.total
156
- }, undefined, false, undefined, this),
157
- categoryStats.slice(0, 3).map(({ category, count }) => /* @__PURE__ */ jsxDEV(StatCard, {
158
- label: `${categoryIcons[category] ?? ""} ${category}`,
159
- value: count
160
- }, category, false, undefined, this))
161
- ]
162
- }, undefined, true, undefined, this),
163
- Object.entries(groupedByCategory).map(([category, tools]) => /* @__PURE__ */ jsxDEV("section", {
164
- className: "space-y-4",
165
- children: [
166
- /* @__PURE__ */ jsxDEV("div", {
167
- className: "flex items-center gap-2",
168
- children: [
169
- /* @__PURE__ */ jsxDEV("span", {
170
- className: "text-2xl",
171
- children: categoryIcons[category]
172
- }, undefined, false, undefined, this),
173
- /* @__PURE__ */ jsxDEV("h3", {
174
- className: "font-semibold text-lg",
175
- children: category
176
- }, undefined, false, undefined, this),
177
- /* @__PURE__ */ jsxDEV("span", {
178
- className: "rounded-full bg-muted px-2 py-0.5 text-muted-foreground text-xs",
179
- children: tools.length
180
- }, undefined, false, undefined, this)
181
- ]
182
- }, undefined, true, undefined, this),
183
- /* @__PURE__ */ jsxDEV("div", {
184
- className: "grid gap-4 md:grid-cols-2 lg:grid-cols-3",
185
- children: tools.map((tool) => /* @__PURE__ */ jsxDEV(EntityCard, {
186
- cardTitle: tool.name,
187
- cardSubtitle: `v${tool.version}`,
188
- meta: /* @__PURE__ */ jsxDEV("p", {
189
- className: "text-muted-foreground text-sm",
190
- children: tool.description
191
- }, undefined, false, undefined, this),
192
- chips: /* @__PURE__ */ jsxDEV(StatusChip, {
193
- tone: getStatusTone(tool.status),
194
- label: tool.status
195
- }, undefined, false, undefined, this),
196
- footer: /* @__PURE__ */ jsxDEV("code", {
197
- className: "text-muted-foreground text-xs",
198
- children: tool.name
199
- }, undefined, false, undefined, this),
200
- onClick: onToolClick ? () => onToolClick(tool.id) : undefined
201
- }, tool.id, false, undefined, this))
202
- }, undefined, false, undefined, this)
203
- ]
204
- }, category, true, undefined, this))
205
- ]
206
- }, undefined, true, undefined, this);
207
- }
208
-
209
- // src/ui/AgentToolRegistry.tsx
210
- "use client";
211
- export {
212
- ToolRegistryView as AgentToolRegistry
213
- };
2
+ import{useTemplateRuntime as h}from"@contractspec/lib.example-shared-ui";import{useCallback as b,useEffect as m,useMemo as T,useState as $}from"react";function B(q={}){let{handlers:X,projectId:W}=h(),{agent:Y}=X,[Q,A]=$(null),[G,Z]=$(!0),[N,U]=$(null),[H,v]=$(1),M=b(async()=>{Z(!0),U(null);try{let J=await Y.listTools({projectId:W,search:q.search,category:q.category,status:q.status==="all"?void 0:q.status,limit:q.limit??50,offset:(H-1)*(q.limit??50)});A(J)}catch(J){U(J instanceof Error?J:Error("Unknown error"))}finally{Z(!1)}},[Y,W,q.search,q.category,q.status,q.limit,H]);m(()=>{M()},[M]);let{stats:L,groupedByCategory:w,categoryStats:E}=T(()=>{if(!Q)return{stats:null,groupedByCategory:{},categoryStats:[]};let J=Q.items,R=J.filter((K)=>K.status==="ACTIVE").length,f=J.filter((K)=>K.status==="DEPRECATED").length,k=J.filter((K)=>K.status==="DISABLED").length,_={},P={};J.forEach((K)=>{let O=K.category;if(!_[O])_[O]=[];_[O].push(K),P[O]=(P[O]||0)+1});let V=Object.entries(P).map(([K,O])=>({category:K,count:O})).sort((K,O)=>O.count-K.count);return{stats:{total:Q.total,active:R,deprecated:f,disabled:k,topCategories:V.slice(0,5)},groupedByCategory:_,categoryStats:V}},[Q]);return{data:Q,loading:G,error:N,stats:L,groupedByCategory:w,categoryStats:E,page:H,refetch:M,nextPage:()=>v((J)=>J+1),prevPage:()=>H>1&&v((J)=>J-1)}}import{Button as S,EmptyState as j,EntityCard as x,ErrorState as C,LoaderBlock as u,StatCard as D,StatCardGroup as d,StatusChip as y}from"@contractspec/lib.design-system";import{jsx as F,jsxs as z}from"react/jsx-runtime";var I={RETRIEVAL:"\uD83D\uDD0D",COMPUTATION:"\uD83E\uDDEE",COMMUNICATION:"\uD83D\uDCE7",INTEGRATION:"\uD83D\uDD17",UTILITY:"\uD83D\uDEE0\uFE0F",CUSTOM:"\u2699\uFE0F"};function p(q){switch(q){case"ACTIVE":return"success";case"DRAFT":return"neutral";case"DEPRECATED":return"warning";case"DISABLED":return"danger";default:return"neutral"}}function g({onToolClick:q,onCreateTool:X}){let{data:W,loading:Y,error:Q,groupedByCategory:A,categoryStats:G,refetch:Z}=B();if(Y&&!W)return F(u,{label:"Loading tools..."});if(Q)return F(C,{title:"Failed to load tools",description:Q.message,onRetry:Z,retryLabel:"Retry"});if(!W?.items.length)return F(j,{title:"No tools registered",description:"Create your first tool to extend agent capabilities.",primaryAction:X?F(S,{onPress:X,children:"Create Tool"}):void 0});return z("div",{className:"space-y-8",children:[z(d,{children:[F(D,{label:"Total Tools",value:W.total}),G.slice(0,3).map(({category:N,count:U})=>F(D,{label:`${I[N]??""} ${N}`,value:U},N))]}),Object.entries(A).map(([N,U])=>z("section",{className:"space-y-4",children:[z("div",{className:"flex items-center gap-2",children:[F("span",{className:"text-2xl",children:I[N]}),F("h3",{className:"font-semibold text-lg",children:N}),F("span",{className:"rounded-full bg-muted px-2 py-0.5 text-muted-foreground text-xs",children:U.length})]}),F("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:U.map((H)=>F(x,{cardTitle:H.name,cardSubtitle:`v${H.version}`,meta:F("p",{className:"text-muted-foreground text-sm",children:H.description}),chips:F(y,{tone:p(H.status),label:H.status}),footer:F("code",{className:"text-muted-foreground text-xs",children:H.name}),onClick:q?()=>q(H.id):void 0},H.id))})]},N))]})}export{g as AgentToolRegistry};
@@ -0,0 +1 @@
1
+ export declare function ExecutionConsoleHost(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{defineVisualization as j,VisualizationRegistry as l0}from"@contractspec/lib.contracts-spec/visualizations";var x={key:"agent.run.list",version:"1.0.0"},s={version:"1.0.0",domain:"ai-ops",stability:"experimental",owners:["@example.agent-console"],tags:["agent-console","visualization","operations"]},m0=j({meta:{...s,key:"agent-console.visualization.run-status",title:"Run Status Breakdown",description:"Distribution of run outcomes across the current sample.",goal:"Make operational success and failure mix visible at a glance.",context:"Agent operations overview."},source:{primary:x,resultPath:"data"},visualization:{kind:"pie",nameDimension:"status",valueMeasure:"runs",dimensions:[{key:"status",label:"Status",dataPath:"status",type:"category"}],measures:[{key:"runs",label:"Runs",dataPath:"runs",format:"number"}],table:{caption:"Run counts by status."}}}),d0=j({meta:{...s,key:"agent-console.visualization.run-activity",title:"Recent Run Activity",description:"Daily run volume across the current sample.",goal:"Show whether agent activity is rising or slowing down.",context:"Operations trend monitoring."},source:{primary:x,resultPath:"data"},visualization:{kind:"cartesian",variant:"line",xDimension:"day",yMeasures:["runs"],dimensions:[{key:"day",label:"Day",dataPath:"day",type:"time"}],measures:[{key:"runs",label:"Runs",dataPath:"runs",format:"number",color:"#0f766e"}],table:{caption:"Daily run counts."}}}),p0=j({meta:{...s,key:"agent-console.visualization.run-efficiency",title:"Duration vs Tokens",description:"Scatter chart comparing token consumption and runtime.",goal:"Reveal outlier runs that are slow relative to their token usage.",context:"Operational performance diagnostics."},source:{primary:x,resultPath:"data"},visualization:{kind:"cartesian",variant:"scatter",xDimension:"totalTokens",yMeasures:["durationMs"],dimensions:[{key:"totalTokens",label:"Total Tokens",dataPath:"totalTokens",type:"number"}],measures:[{key:"durationMs",label:"Duration",dataPath:"durationMs",format:"duration",color:"#7c3aed"},{key:"estimatedCostUsd",label:"Cost",dataPath:"estimatedCostUsd",format:"currency"}],series:[{key:"runs",label:"Runs",measure:"durationMs",type:"scatter",color:"#7c3aed"}],table:{caption:"Run duration versus token usage."}}}),z0=[m0,d0,p0],i2=new l0([...z0]),C2=z0.map((m)=>({key:m.meta.key,version:m.meta.version}));function G0(m){if(!m)return"unknown";return m.toISOString().slice(0,10)}function U0(m){let p=new Map,y=new Map;for(let T of m)p.set(T.status,(p.get(T.status)??0)+1),y.set(G0(T.startedAt??T.queuedAt),(y.get(G0(T.startedAt??T.queuedAt))??0)+1);return[{key:"run-status",spec:m0,data:{data:Array.from(p.entries()).map(([T,f])=>({status:T,runs:f}))},title:"Run Status Breakdown",description:"Completed, failed, running, and cancelled runs in the sample.",height:260},{key:"run-activity",spec:d0,data:{data:Array.from(y.entries()).sort(([T],[f])=>T.localeCompare(f)).map(([T,f])=>({day:T,runs:f}))},title:"Recent Run Activity",description:"Daily run volume derived from run start times."},{key:"run-efficiency",spec:p0,data:{data:m.filter((T)=>typeof T.durationMs==="number").map((T)=>({totalTokens:T.totalTokens,durationMs:T.durationMs??0,estimatedCostUsd:T.estimatedCostUsd}))},title:"Duration vs Tokens",description:"Operational scatter plot for spotting inefficient runs."}]}var Q0=[{id:"agent-1",organizationId:"demo-org",name:"Customer Support Bot",slug:"customer-support-bot",description:"Handles tier-1 customer inquiries and routes complex issues.",status:"ACTIVE",modelProvider:"OPENAI",modelName:"gpt-4o-mini",modelConfig:{temperature:0.7},systemPrompt:"You are a helpful customer support assistant.",toolChoice:"auto",maxIterations:10,timeoutMs:120000,version:"1.0.0",tags:["support","tier-1"],createdAt:new Date("2024-01-15T10:00:00Z"),updatedAt:new Date("2024-03-20T14:30:00Z")},{id:"agent-2",organizationId:"demo-org",name:"Code Review Assistant",slug:"code-review-assistant",description:"Reviews pull requests and provides actionable feedback.",status:"ACTIVE",modelProvider:"ANTHROPIC",modelName:"claude-sonnet-4-20250514",modelConfig:{temperature:0.3},systemPrompt:"You are a code review expert.",toolChoice:"auto",maxIterations:15,timeoutMs:180000,version:"2.1.0",tags:["code","review","dev"],createdAt:new Date("2024-02-10T09:00:00Z"),updatedAt:new Date("2024-04-05T11:15:00Z")},{id:"agent-3",organizationId:"demo-org",name:"Data Analyst",slug:"data-analyst",description:"Queries databases and generates insights from data.",status:"PAUSED",modelProvider:"OPENAI",modelName:"gpt-4o",modelConfig:{temperature:0.5},systemPrompt:"You are a data analyst expert in SQL and analytics.",toolChoice:"required",maxIterations:20,timeoutMs:300000,version:"1.2.0",tags:["data","analytics","sql"],createdAt:new Date("2024-03-01T08:00:00Z"),updatedAt:new Date("2024-04-10T16:45:00Z")},{id:"agent-4",organizationId:"demo-org",name:"Meeting Scheduler",slug:"meeting-scheduler",description:"Schedules meetings and manages calendar conflicts.",status:"DRAFT",modelProvider:"GOOGLE",modelName:"gemini-2.0-flash",modelConfig:{temperature:0.2},systemPrompt:"You help schedule and organize meetings efficiently.",toolChoice:"auto",maxIterations:5,timeoutMs:60000,version:"0.1.0",tags:["calendar","scheduling"],createdAt:new Date("2024-04-01T12:00:00Z"),updatedAt:new Date("2024-04-01T12:00:00Z")}];var R0=[{id:"tool-1",organizationId:"demo-org",name:"Web Search",slug:"web-search",description:"Search the web for real-time information using Brave API.",category:"RETRIEVAL",status:"ACTIVE",parametersSchema:{type:"object",properties:{query:{type:"string",description:"Search query"},numResults:{type:"number",default:10}},required:["query"]},outputSchema:{type:"array",items:{type:"object"}},implementationType:"http",implementationConfig:{url:"https://api.brave.com/search",method:"GET"},maxInvocationsPerMinute:60,timeoutMs:30000,version:"1.0.0",tags:["search","web"],createdAt:new Date("2024-01-01T00:00:00Z"),updatedAt:new Date("2024-02-15T10:00:00Z")},{id:"tool-2",organizationId:"demo-org",name:"SQL Query",slug:"sql-query",description:"Execute read-only SQL queries against the data warehouse.",category:"RETRIEVAL",status:"ACTIVE",parametersSchema:{type:"object",properties:{query:{type:"string",description:"SQL query"},maxRows:{type:"number",default:100}},required:["query"]},outputSchema:{type:"object"},implementationType:"function",implementationConfig:{handler:"executeSqlQuery"},maxInvocationsPerMinute:30,timeoutMs:60000,version:"1.1.0",tags:["sql","database"],createdAt:new Date("2024-01-05T00:00:00Z"),updatedAt:new Date("2024-03-10T14:00:00Z")},{id:"tool-3",organizationId:"demo-org",name:"Email Sender",slug:"email-sender",description:"Send emails via SMTP or API.",category:"COMMUNICATION",status:"ACTIVE",parametersSchema:{type:"object",properties:{to:{type:"string"},subject:{type:"string"},body:{type:"string"}},required:["to","subject","body"]},implementationType:"http",implementationConfig:{url:"/api/send-email",method:"POST"},maxInvocationsPerMinute:10,timeoutMs:30000,version:"1.0.0",tags:["email","communication"],createdAt:new Date("2024-02-01T00:00:00Z"),updatedAt:new Date("2024-02-01T00:00:00Z")},{id:"tool-4",organizationId:"demo-org",name:"GitHub Integration",slug:"github-integration",description:"Interact with GitHub repositories, PRs, and issues.",category:"INTEGRATION",status:"ACTIVE",parametersSchema:{type:"object",properties:{action:{type:"string",enum:["list_prs","get_pr","create_comment"]},repo:{type:"string"},params:{type:"object"}},required:["action","repo"]},implementationType:"http",implementationConfig:{url:"https://api.github.com",auth:"token"},maxInvocationsPerMinute:100,timeoutMs:15000,version:"2.0.0",tags:["github","integration","code"],createdAt:new Date("2024-02-20T00:00:00Z"),updatedAt:new Date("2024-04-01T09:00:00Z")},{id:"tool-5",organizationId:"demo-org",name:"Calculator",slug:"calculator",description:"Perform mathematical calculations.",category:"COMPUTATION",status:"ACTIVE",parametersSchema:{type:"object",properties:{expression:{type:"string",description:"Math expression to evaluate"}},required:["expression"]},outputSchema:{type:"object",properties:{result:{type:"number"}}},implementationType:"function",implementationConfig:{handler:"evaluateMath"},timeoutMs:5000,version:"1.0.0",tags:["math","utility"],createdAt:new Date("2024-01-10T00:00:00Z"),updatedAt:new Date("2024-01-10T00:00:00Z")}];var K0=[{id:"run-1",organizationId:"demo-org",projectId:"demo-project",agentId:"agent-1",agentName:"Customer Support Bot",userId:"user-1",sessionId:"session-1",input:{message:"How do I reset my password?",context:{}},output:{response:"You can reset your password by clicking..."},status:"COMPLETED",totalTokens:1250,promptTokens:800,completionTokens:450,totalIterations:3,durationMs:4500,estimatedCostUsd:0.0025,queuedAt:new Date("2024-04-15T10:00:00Z"),startedAt:new Date("2024-04-15T10:00:01Z"),completedAt:new Date("2024-04-15T10:00:05Z"),steps:[],logs:[]},{id:"run-2",organizationId:"demo-org",projectId:"demo-project",agentId:"agent-2",agentName:"Code Review Assistant",userId:"user-2",input:{message:"Review PR #123",context:{prNumber:123}},status:"IN_PROGRESS",totalTokens:3500,promptTokens:3000,completionTokens:500,totalIterations:5,queuedAt:new Date("2024-04-15T10:30:00Z"),startedAt:new Date("2024-04-15T10:30:02Z"),steps:[],logs:[]},{id:"run-3",organizationId:"demo-org",projectId:"demo-project",agentId:"agent-1",agentName:"Customer Support Bot",userId:"user-1",input:{message:"What are your business hours?"},output:{response:"Our business hours are 9 AM to 5 PM EST..."},status:"COMPLETED",totalTokens:800,promptTokens:500,completionTokens:300,totalIterations:2,durationMs:2100,estimatedCostUsd:0.0012,queuedAt:new Date("2024-04-15T09:00:00Z"),startedAt:new Date("2024-04-15T09:00:01Z"),completedAt:new Date("2024-04-15T09:00:03Z"),steps:[],logs:[]},{id:"run-4",organizationId:"demo-org",projectId:"demo-project",agentId:"agent-3",agentName:"Data Analyst",userId:"user-3",input:{message:"Generate sales report for Q1"},status:"FAILED",errorMessage:"Database connection timeout",errorCode:"DB_TIMEOUT",totalTokens:2000,promptTokens:1500,completionTokens:500,totalIterations:8,durationMs:45000,queuedAt:new Date("2024-04-14T15:00:00Z"),startedAt:new Date("2024-04-14T15:00:05Z"),completedAt:new Date("2024-04-14T15:00:50Z"),steps:[],logs:[]},{id:"run-5",organizationId:"demo-org",projectId:"demo-project",agentId:"agent-2",agentName:"Code Review Assistant",userId:"user-2",input:{message:"Review PR #120"},output:{response:"Code review complete. 3 suggestions..."},status:"COMPLETED",totalTokens:5200,promptTokens:4000,completionTokens:1200,totalIterations:7,durationMs:15000,estimatedCostUsd:0.0156,queuedAt:new Date("2024-04-14T11:00:00Z"),startedAt:new Date("2024-04-14T11:00:03Z"),completedAt:new Date("2024-04-14T11:00:18Z"),steps:[],logs:[]}];import{VisualizationCard as e0,VisualizationGrid as n0}from"@contractspec/lib.design-system";import{jsx as L,jsxs as P0}from"react/jsx-runtime";function Y0({runs:m}){let p=U0(m);return P0("section",{className:"space-y-3",children:[P0("div",{children:[L("h3",{className:"font-semibold text-lg",children:"Operational Visualizations"}),L("p",{className:"text-muted-foreground text-sm",children:"Contract-backed charts derived from recent run activity."})]}),L(n0,{children:p.map((y)=>L(e0,{data:y.data,description:y.description,height:y.height,spec:y.spec,title:y.title},y.key))})]})}import{useTemplateRuntime as o0}from"@contractspec/lib.example-shared-ui";import{useCallback as g0,useEffect as a0,useMemo as t0,useState as S}from"react";function T0(m={}){let{handlers:p,projectId:y}=o0(),{agent:T}=p,[f,I]=S(null),[d,O]=S(!0),[U,G]=S(null),[z,A]=S(1),Y=g0(async()=>{O(!0),G(null);try{let N=await T.listAgents({projectId:y,search:m.search,status:m.status==="all"?void 0:m.status,limit:m.limit??20,offset:(z-1)*(m.limit??20)});I(N)}catch(N){G(N instanceof Error?N:Error("Unknown error"))}finally{O(!1)}},[T,y,m.search,m.status,m.limit,z]);a0(()=>{Y()},[Y]);let H=t0(()=>{if(!f)return null;return{total:f.total,active:f.items.filter((N)=>N.status==="ACTIVE").length,paused:f.items.filter((N)=>N.status==="PAUSED").length,draft:f.items.filter((N)=>N.status==="DRAFT").length}},[f]);return{data:f,loading:d,error:U,stats:H,page:z,refetch:Y,nextPage:()=>A((N)=>N+1),prevPage:()=>z>1&&A((N)=>N-1)}}import{useTemplateRuntime as s0}from"@contractspec/lib.example-shared-ui";import{useCallback as b,useState as y0}from"react";var f0="demo-org",y1="agent-console-demo";function w1(m){return m.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Z1(m){return{...m}}function A1(m){return{...m}}function N1(m){return{...m}}function q1(){let m=0,p=Date.parse("2026-03-20T09:00:00.000Z");return()=>new Date(p+m++*60000)}function j0(m){return m.toLowerCase()}function x0(m){return m==="IN_PROGRESS"?"RUNNING":m}function D1(m,p){let y=Q0.map((d)=>({id:d.id,projectId:m,organizationId:p,name:d.name,slug:d.slug,description:d.description,modelProvider:j0(d.modelProvider),modelName:d.modelName,systemPrompt:d.systemPrompt,temperature:typeof d.modelConfig?.temperature==="number"?d.modelConfig.temperature:0.4,maxTokens:8192,status:d.status,createdAt:d.createdAt,updatedAt:d.updatedAt})),T=R0.map((d)=>({id:d.id,projectId:m,organizationId:p,name:d.name,description:d.description,version:d.version,category:d.category,status:d.status,inputSchema:JSON.stringify(d.parametersSchema),outputSchema:d.outputSchema?JSON.stringify(d.outputSchema):void 0,endpoint:typeof d.implementationConfig?.url==="string"?d.implementationConfig.url:void 0,createdAt:d.createdAt,updatedAt:d.updatedAt})),f=new Map(y.map((d)=>[d.id,d.name])),I=K0.map((d)=>({id:d.id,projectId:m,agentId:d.agentId,agentName:f.get(d.agentId)??d.agentName??"Unknown agent",status:x0(d.status),input:JSON.stringify(d.input),output:d.output?JSON.stringify(d.output):void 0,totalTokens:d.totalTokens,promptTokens:d.promptTokens,completionTokens:d.completionTokens,estimatedCostUsd:d.estimatedCostUsd??0,durationMs:d.durationMs,errorMessage:d.errorMessage,queuedAt:d.queuedAt,startedAt:d.startedAt,completedAt:d.completedAt}));return{agents:y,tools:T,runs:I}}function I1(m){let p=m.length,y=m.filter((f)=>f.status==="COMPLETED").length,T=m.map((f)=>f.durationMs).filter((f)=>typeof f==="number");return{totalRuns:p,successRate:p===0?0:y/p,averageDurationMs:T.length===0?0:Math.round(T.reduce((f,I)=>f+I,0)/T.length),totalTokens:m.reduce((f,I)=>f+I.totalTokens,0),totalCostUsd:m.reduce((f,I)=>f+I.estimatedCostUsd,0)}}function w0(m,p){return m instanceof Error?m:Error(p)}function _0(m={}){let{handlers:p,projectId:y}=s0(),{agent:T}=p,[f,I]=y0({loading:!1,error:null,data:null}),[d,O]=y0({loading:!1,error:null,data:null}),[U,G]=y0({loading:!1,error:null,data:null}),z=b(async(M)=>{I({loading:!0,error:null,data:null});try{let Q=await T.createAgent(M,{projectId:y,organizationId:f0});return I({loading:!1,error:null,data:Q}),m.onSuccess?.(),Q}catch(Q){let Z=w0(Q,"Failed to create agent");throw I({loading:!1,error:Z,data:null}),m.onError?.(Z),Z}},[T,y,m]),A=b(async(M)=>{O({loading:!0,error:null,data:null});try{let Q=await T.updateAgent(M);return O({loading:!1,error:null,data:Q}),m.onSuccess?.(),Q}catch(Q){let Z=w0(Q,"Failed to update agent");throw O({loading:!1,error:Z,data:null}),m.onError?.(Z),Z}},[T,m]),Y=b(async(M)=>{return A({id:M,status:"ACTIVE"})},[A]),H=b(async(M)=>{return A({id:M,status:"PAUSED"})},[A]),N=b(async(M)=>{return A({id:M,status:"ARCHIVED"})},[A]),P=b(async(M)=>{G({loading:!0,error:null,data:null});try{let Q=await T.executeAgent({agentId:M.agentId,message:M.message,context:{projectId:y,organizationId:f0}});return G({loading:!1,error:null,data:Q}),m.onSuccess?.(),Q}catch(Q){let Z=w0(Q,"Failed to execute agent");throw G({loading:!1,error:Z,data:null}),m.onError?.(Z),Z}},[T,y,m]);return{createAgent:z,updateAgent:A,activateAgent:Y,pauseAgent:H,archiveAgent:N,executeAgent:P,createState:f,updateState:d,executeState:U,isLoading:f.loading||d.loading||U.loading}}import{useTemplateRuntime as m2}from"@contractspec/lib.example-shared-ui";import{useCallback as d2,useEffect as p2,useState as C}from"react";function r(m={}){let{handlers:p,projectId:y}=m2(),{agent:T}=p,[f,I]=C(null),[d,O]=C(null),[U,G]=C(!0),[z,A]=C(null),[Y,H]=C(0),N=m.pageSize??m.limit??20,P=m.pageIndex??Y,[M]=m.sorting??[],Q=d2(async()=>{G(!0),A(null);try{let[w,R]=await Promise.all([T.listRuns({projectId:y,agentId:m.agentId,status:m.status==="all"?void 0:m.status,sortBy:M?.id,sortDirection:M?M.desc?"desc":"asc":void 0,limit:N,offset:P*N}),T.getRunMetrics({projectId:y,agentId:m.agentId})]);I(w),O(R)}catch(w){A(w instanceof Error?w:Error("Unknown error"))}finally{G(!1)}},[T,P,N,y,m.agentId,m.status,M?.desc,M?.id]);p2(()=>{Q()},[Q]);let Z=m.pageIndex!==void 0;return{data:f,metrics:d,loading:U,error:z,page:P+1,pageIndex:P,pageSize:N,refetch:Q,nextPage:Z?void 0:()=>H((w)=>w+1),prevPage:Z?void 0:()=>H((w)=>Math.max(0,w-1))}}import{Button as u}from"@contractspec/lib.design-system";import{useState as l}from"react";import{jsx as K,jsxs as J}from"react/jsx-runtime";function T2(m){switch(m){case"ACTIVE":return"text-green-600 bg-green-100 dark:text-green-400 dark:bg-green-900/30";case"DRAFT":return"text-blue-600 bg-blue-100 dark:text-blue-400 dark:bg-blue-900/30";case"PAUSED":return"text-yellow-600 bg-yellow-100 dark:text-yellow-400 dark:bg-yellow-900/30";case"ARCHIVED":return"text-gray-600 bg-gray-100 dark:text-gray-400 dark:bg-gray-700";default:return"text-gray-600 bg-gray-100"}}function J0({isOpen:m,agent:p,onClose:y,onActivate:T,onPause:f,onArchive:I,onExecute:d,isLoading:O=!1}){let[U,G]=l("menu"),[z,A]=l(""),[Y,H]=l(null),[N,P]=l(null),M=()=>{G("menu"),A(""),H(null),P(null)},Q=()=>{M(),y()},Z=async()=>{if(!p)return;if(P(null),!z.trim()){P("Please enter a message");return}try{await d(p.id,z.trim()),Q()}catch(R){P(R instanceof Error?R.message:"Failed to execute agent")}},w=async(R)=>{if(!p)return;P(null);try{switch(R){case"activate":await T(p.id);break;case"pause":await f(p.id);break;case"archive":await I(p.id);break}Q()}catch(k){P(k instanceof Error?k.message:`Failed to ${R} agent`)}};if(!m||!p)return null;return J("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[K("div",{className:"absolute inset-0 bg-background/80 backdrop-blur-sm",onClick:Q,role:"button",tabIndex:0,onKeyDown:(R)=>{if(R.key==="Enter"||R.key===" ")Q()},"aria-label":"Close modal"}),J("div",{className:"relative z-10 w-full max-w-md rounded-xl border border-border bg-card p-6 shadow-xl",children:[J("div",{className:"mb-4 border-border border-b pb-4",children:[K("h2",{className:"font-semibold text-xl",children:p.name}),J("div",{className:"mt-1 flex items-center gap-2",children:[J("span",{className:"text-muted-foreground text-sm",children:[p.modelProvider," / ",p.modelName]}),K("span",{className:`rounded-full px-2 py-0.5 font-medium text-xs ${T2(p.status)}`,children:p.status})]}),p.description&&K("p",{className:"mt-2 text-muted-foreground text-sm",children:p.description})]}),U==="menu"&&J("div",{className:"space-y-3",children:[p.status==="ACTIVE"&&J(u,{className:"w-full justify-start",variant:"ghost",onPress:()=>G("execute"),children:[K("span",{className:"mr-2",children:"\u25B6\uFE0F"})," Execute Agent"]}),(p.status==="DRAFT"||p.status==="PAUSED")&&J(u,{className:"w-full justify-start",variant:"ghost",onPress:()=>w("activate"),disabled:O,children:[K("span",{className:"mr-2",children:"\uD83D\uDFE2"})," Activate Agent"]}),p.status==="ACTIVE"&&J(u,{className:"w-full justify-start",variant:"ghost",onPress:()=>w("pause"),disabled:O,children:[K("span",{className:"mr-2",children:"\u23F8\uFE0F"})," Pause Agent"]}),p.status!=="ARCHIVED"&&J(u,{className:"w-full justify-start text-yellow-600 hover:text-yellow-700",variant:"ghost",onPress:()=>{H("archive"),G("confirm")},children:[K("span",{className:"mr-2",children:"\uD83D\uDCE6"})," Archive Agent"]}),p.status==="ARCHIVED"&&J(u,{className:"w-full justify-start",variant:"ghost",onPress:()=>w("activate"),disabled:O,children:[K("span",{className:"mr-2",children:"\uD83D\uDD04"})," Restore Agent"]}),N&&K("div",{className:"rounded-md bg-destructive/10 p-3 text-destructive text-sm",children:N}),K("div",{className:"border-border border-t pt-3",children:K(u,{className:"w-full",variant:"outline",onPress:Q,children:"Close"})})]}),U==="execute"&&J("div",{className:"space-y-4",children:[J("div",{children:[K("label",{htmlFor:"execute-message",className:"mb-1 block font-medium text-muted-foreground text-sm",children:"Message *"}),K("textarea",{id:"execute-message",value:z,onChange:(R)=>A(R.target.value),placeholder:"Enter your message to the agent...",rows:4,disabled:O,className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring disabled:opacity-50"})]}),N&&K("div",{className:"rounded-md bg-destructive/10 p-3 text-destructive text-sm",children:N}),J("div",{className:"flex justify-end gap-3 pt-2",children:[K(u,{variant:"ghost",onPress:()=>G("menu"),disabled:O,children:"Back"}),K(u,{onPress:Z,disabled:O,children:O?"Executing...":"\u25B6\uFE0F Execute"})]})]}),U==="confirm"&&Y==="archive"&&J("div",{className:"space-y-4",children:[J("p",{className:"text-muted-foreground",children:["Are you sure you want to archive"," ",K("span",{className:"font-medium text-foreground",children:p.name}),"?"]}),K("p",{className:"text-muted-foreground text-sm",children:"Archived agents cannot be executed but can be restored later."}),N&&K("div",{className:"rounded-md bg-destructive/10 p-3 text-destructive text-sm",children:N}),J("div",{className:"flex justify-end gap-3 pt-2",children:[K(u,{variant:"ghost",onPress:()=>G("menu"),disabled:O,children:"Cancel"}),K(u,{onPress:()=>w("archive"),disabled:O,children:O?"Archiving...":"\uD83D\uDCE6 Archive"})]})]})]})]})}import{Button as H0,Input as f2}from"@contractspec/lib.design-system";import{useState as B}from"react";import{jsx as _,jsxs as X}from"react/jsx-runtime";var Z0=[{value:"openai",label:"OpenAI",models:["gpt-5.4","gpt-5-mini","gpt-4o","gpt-4-turbo","gpt-3.5-turbo"]},{value:"anthropic",label:"Anthropic",models:["claude-sonnet-4-6","claude-opus-4-6","claude-haiku-4-5"]},{value:"google",label:"Google",models:["gemini-2.5-flash","gemini-2.5-pro","gemini-pro","gemini-ultra"]},{value:"mistral",label:"Mistral",models:["mistral-large-2512","mistral-large-latest","mistral-medium-latest","mistral-small-latest"]}];function h0({isOpen:m,onClose:p,onSubmit:y,isLoading:T=!1}){let[f,I]=B(""),[d,O]=B(""),[U,G]=B("openai"),[z,A]=B("gpt-5.4"),[Y,H]=B(""),[N,P]=B(null),M=Z0.find((w)=>w.value===U),Q=async(w)=>{if(w.preventDefault(),P(null),!f.trim()){P("Agent name is required");return}try{await y({name:f.trim(),description:d.trim()||void 0,modelProvider:U,modelName:z,systemPrompt:Y.trim()||void 0}),I(""),O(""),G("openai"),A("gpt-5.4"),H(""),p()}catch(R){P(R instanceof Error?R.message:"Failed to create agent")}},Z=(w)=>{G(w);let R=Z0.find((k)=>k.value===w);if(R)A(R.models[0])};if(!m)return null;return X("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[_("div",{className:"absolute inset-0 bg-background/80 backdrop-blur-sm",onClick:p,role:"button",tabIndex:0,onKeyDown:(w)=>{if(w.key==="Enter"||w.key===" ")p()},"aria-label":"Close modal"}),X("div",{className:"relative z-10 max-h-[90vh] w-full max-w-lg overflow-y-auto rounded-xl border border-border bg-card p-6 shadow-xl",children:[_("h2",{className:"mb-4 font-semibold text-xl",children:"Create New Agent"}),X("form",{onSubmit:Q,className:"space-y-4",children:[X("div",{children:[_("label",{htmlFor:"agent-name",className:"mb-1 block font-medium text-muted-foreground text-sm",children:"Agent Name *"}),_(f2,{id:"agent-name",value:f,onChange:(w)=>I(w.target.value),placeholder:"e.g., Customer Support Bot",disabled:T})]}),X("div",{children:[_("label",{htmlFor:"agent-description",className:"mb-1 block font-medium text-muted-foreground text-sm",children:"Description"}),_("textarea",{id:"agent-description",value:d,onChange:(w)=>O(w.target.value),placeholder:"Describe what this agent does...",rows:2,disabled:T,className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring disabled:opacity-50"})]}),X("div",{className:"flex gap-3",children:[X("div",{className:"flex-1",children:[_("label",{htmlFor:"model-provider",className:"mb-1 block font-medium text-muted-foreground text-sm",children:"Provider *"}),_("select",{id:"model-provider",value:U,onChange:(w)=>Z(w.target.value),disabled:T,className:"h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring disabled:opacity-50",children:Z0.map((w)=>_("option",{value:w.value,children:w.label},w.value))})]}),X("div",{className:"flex-1",children:[_("label",{htmlFor:"model-name",className:"mb-1 block font-medium text-muted-foreground text-sm",children:"Model *"}),_("select",{id:"model-name",value:z,onChange:(w)=>A(w.target.value),disabled:T,className:"h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring disabled:opacity-50",children:M?.models.map((w)=>_("option",{value:w,children:w},w))})]})]}),X("div",{children:[_("label",{htmlFor:"system-prompt",className:"mb-1 block font-medium text-muted-foreground text-sm",children:"System Prompt"}),_("textarea",{id:"system-prompt",value:Y,onChange:(w)=>H(w.target.value),placeholder:"You are a helpful assistant that...",rows:4,disabled:T,className:"w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-sm focus:outline-none focus:ring-2 focus:ring-ring disabled:opacity-50"}),_("p",{className:"mt-1 text-muted-foreground text-xs",children:"Instructions that define the agent's behavior"})]}),N&&_("div",{className:"rounded-md bg-destructive/10 p-3 text-destructive text-sm",children:N}),X("div",{className:"flex justify-end gap-3 pt-2",children:[_(H0,{type:"button",variant:"ghost",onPress:p,disabled:T,children:"Cancel"}),_(H0,{type:"submit",disabled:T,children:T?"Creating...":"Create Agent"})]})]})]})]})}import{Button as e,StatusChip as y2}from"@contractspec/lib.design-system";import{HStack as N0,VStack as A0}from"@contractspec/lib.ui-kit-web/ui/stack";import{Text as v}from"@contractspec/lib.ui-kit-web/ui/text";import{jsx as V,jsxs as $}from"react/jsx-runtime";function q0(m){switch(m){case"COMPLETED":return"success";case"RUNNING":return"warning";case"QUEUED":return"neutral";case"FAILED":case"CANCELLED":return"danger";default:return"neutral"}}function D0(m){if(!m)return"-";if(m<1000)return`${m}ms`;if(m<60000)return`${(m/1000).toFixed(1)}s`;return`${(m/60000).toFixed(1)}m`}function i(m){if(m<1000)return m.toString();if(m<1e6)return`${(m/1000).toFixed(1)}K`;return`${(m/1e6).toFixed(2)}M`}function $0(m){if(!m)return"-";return`$${m.toFixed(4)}`}function W0(m){return JSON.stringify(m??null,null,2)}function u0({run:m}){return $(A0,{gap:"sm",className:"py-2",children:[$(N0,{justify:"between",className:"flex-wrap",children:[V(y2,{tone:q0(m.status),label:m.status}),$(v,{className:"text-muted-foreground text-sm",children:["Queued ",m.queuedAt.toLocaleString()]})]}),$(N0,{gap:"lg",className:"flex-wrap",children:[$(v,{className:"text-muted-foreground text-sm",children:["Prompt ",i(m.promptTokens)]}),$(v,{className:"text-muted-foreground text-sm",children:["Completion ",i(m.completionTokens)]}),$(v,{className:"text-muted-foreground text-sm",children:["Duration ",D0(m.durationMs)]})]}),$(A0,{gap:"xs",children:[V(v,{className:"font-medium text-sm",children:"Input"}),V("pre",{className:"overflow-auto rounded-md bg-muted/40 p-3 text-xs",children:W0(m.input)})]}),$(A0,{gap:"xs",children:[V(v,{className:"font-medium text-sm",children:"Output"}),V("pre",{className:"overflow-auto rounded-md bg-muted/40 p-3 text-xs",children:W0(m.output??m.errorMessage??"Pending")})]})]})}function X0({controller:m,totalRuns:p}){let y=m.rows[0],T=m.columns.find((d)=>d.id==="queuedAt"),f=m.columns.find((d)=>d.id==="durationMs"),I=m.columns.find((d)=>d.id==="estimatedCostUsd");return $(N0,{gap:"sm",className:"flex-wrap",children:[$(v,{className:"text-muted-foreground text-sm",children:[p," runs"]}),V(e,{variant:"outline",size:"sm",onPress:()=>y?.toggleExpanded?.(!y?.isExpanded),children:"Expand Latest Run"}),V(e,{variant:"outline",size:"sm",onPress:()=>T?.toggleVisibility?.(!T?.visible),children:T?.visible?"Hide Time":"Show Time"}),V(e,{variant:"outline",size:"sm",onPress:()=>f?.toggleVisibility?.(!f?.visible),children:f?.visible?"Hide Duration":"Show Duration"}),V(e,{variant:"outline",size:"sm",onPress:()=>I?.toggleVisibility?.(!I?.visible),children:I?.visible?"Hide Cost":"Show Cost"})]})}import{StatusChip as w2}from"@contractspec/lib.design-system";import{VStack as Z2}from"@contractspec/lib.ui-kit-web/ui/stack";import{Text as I0}from"@contractspec/lib.ui-kit-web/ui/text";import{jsx as n,jsxs as A2}from"react/jsx-runtime";function F0(){return[{id:"queuedAt",header:"Run",label:"Run",accessor:(m)=>m.queuedAt.getTime(),cell:({item:m})=>A2(Z2,{gap:"xs",children:[n(I0,{className:"font-mono text-sm",children:m.id.slice(-8)}),n(I0,{className:"text-muted-foreground text-xs",children:m.queuedAt.toLocaleString()})]}),size:220,minSize:180,canSort:!0,canHide:!0,canResize:!0},{id:"agentName",header:"Agent",label:"Agent",accessor:(m)=>m.agentName??"Unknown Agent",cell:({value:m})=>n(I0,{className:"font-medium",children:typeof m==="string"?m:"Unknown Agent"}),size:220,canSort:!0,canResize:!0},{id:"status",header:"Status",label:"Status",accessorKey:"status",cell:({value:m})=>{let p=typeof m==="string"?m:"QUEUED";return n(w2,{tone:q0(p),label:p})},size:150,canSort:!0,canResize:!0},{id:"totalTokens",header:"Tokens",label:"Tokens",accessorKey:"totalTokens",cell:({value:m})=>i(Number(m??0)),align:"right",size:140,canSort:!0,canResize:!0},{id:"durationMs",header:"Duration",label:"Duration",accessorKey:"durationMs",cell:({value:m})=>D0(typeof m==="number"?m:void 0),align:"right",size:140,canSort:!0,canHide:!0,canResize:!0},{id:"estimatedCostUsd",header:"Cost",label:"Cost",accessorKey:"estimatedCostUsd",cell:({value:m})=>$0(typeof m==="number"?m:void 0),align:"right",size:140,canSort:!0,canHide:!0,canResize:!0}]}import{DataTable as N2}from"@contractspec/lib.design-system";import{useContractTable as q2}from"@contractspec/lib.presentation-runtime-react";import*as V0 from"react";import{jsx as o}from"react/jsx-runtime";function k0({runs:m,totalItems:p,pageIndex:y,pageSize:T,sorting:f,loading:I,onSortingChange:d,onPaginationChange:O,onRunClick:U}){let G=V0.useMemo(()=>F0(),[]),z=q2({data:m,columns:G,executionMode:"server",totalItems:p,state:{sorting:f,pagination:{pageIndex:y,pageSize:T}},onSortingChange:d,onPaginationChange:O,initialState:{columnVisibility:{estimatedCostUsd:!1}},getRowId:(A)=>A.id,renderExpandedContent:(A)=>o(u0,{run:A}),getCanExpand:()=>!0});return o(N2,{controller:z,title:"Run History",description:"Server-mode ContractSpec table with shared pagination, sorting, visibility, and expansion.",loading:I,onRowPress:(A)=>U?.(A.id),toolbar:o(X0,{controller:z,totalRuns:p}),emptyState:o("div",{className:"rounded-md border border-dashed p-8 text-center text-muted-foreground text-sm",children:"No runs yet"})})}import{EmptyState as D2,ErrorState as I2,LoaderBlock as O2,StatCard as g,StatCardGroup as M2}from"@contractspec/lib.design-system";import{useState as E0}from"react";import{jsx as E,jsxs as v0}from"react/jsx-runtime";function b0({agentId:m,onRunClick:p}){let[y,T]=E0([{id:"queuedAt",desc:!0}]),[f,I]=E0({pageIndex:0,pageSize:3}),{data:d,metrics:O,loading:U,error:G,refetch:z}=r({agentId:m,pageIndex:f.pageIndex,pageSize:f.pageSize,sorting:y});if(U&&!d)return E(O2,{label:"Loading runs..."});if(G)return E(I2,{title:"Failed to load runs",description:G.message,onRetry:z,retryLabel:"Retry"});if(!d?.items.length)return E(D2,{title:"No runs yet",description:"Execute an agent to see run history here."});return v0("div",{className:"space-y-6",children:[O?v0(M2,{children:[E(g,{label:"Total Runs",value:O.totalRuns}),E(g,{label:"Success Rate",value:`${(O.successRate*100).toFixed(1)}%`}),E(g,{label:"Total Tokens",value:i(O.totalTokens)}),E(g,{label:"Total Cost",value:`$${O.totalCostUsd.toFixed(2)}`})]}):null,E(k0,{runs:d.items,totalItems:d.total,pageIndex:f.pageIndex,pageSize:f.pageSize,sorting:y,loading:U,onSortingChange:(A)=>{T(A),I((Y)=>({...Y,pageIndex:0}))},onPaginationChange:I,onRunClick:p})]})}import{useTemplateRuntime as z2}from"@contractspec/lib.example-shared-ui";import{useCallback as G2,useEffect as U2,useMemo as Q2,useState as a}from"react";function B0(m={}){let{handlers:p,projectId:y}=z2(),{agent:T}=p,[f,I]=a(null),[d,O]=a(!0),[U,G]=a(null),[z,A]=a(1),Y=G2(async()=>{O(!0),G(null);try{let M=await T.listTools({projectId:y,search:m.search,category:m.category,status:m.status==="all"?void 0:m.status,limit:m.limit??50,offset:(z-1)*(m.limit??50)});I(M)}catch(M){G(M instanceof Error?M:Error("Unknown error"))}finally{O(!1)}},[T,y,m.search,m.category,m.status,m.limit,z]);U2(()=>{Y()},[Y]);let{stats:H,groupedByCategory:N,categoryStats:P}=Q2(()=>{if(!f)return{stats:null,groupedByCategory:{},categoryStats:[]};let M=f.items,Q=M.filter((W)=>W.status==="ACTIVE").length,Z=M.filter((W)=>W.status==="DEPRECATED").length,w=M.filter((W)=>W.status==="DISABLED").length,R={},k={};M.forEach((W)=>{let F=W.category;if(!R[F])R[F]=[];R[F].push(W),k[F]=(k[F]||0)+1});let M0=Object.entries(k).map(([W,F])=>({category:W,count:F})).sort((W,F)=>F.count-W.count);return{stats:{total:f.total,active:Q,deprecated:Z,disabled:w,topCategories:M0.slice(0,5)},groupedByCategory:R,categoryStats:M0}},[f]);return{data:f,loading:d,error:U,stats:H,groupedByCategory:N,categoryStats:P,page:z,refetch:Y,nextPage:()=>A((M)=>M+1),prevPage:()=>z>1&&A((M)=>M-1)}}import{Button as R2,EmptyState as K2,EntityCard as P2,ErrorState as Y2,LoaderBlock as _2,StatCard as i0,StatCardGroup as J2,StatusChip as H2}from"@contractspec/lib.design-system";import{jsx as h,jsxs as t}from"react/jsx-runtime";var C0={RETRIEVAL:"\uD83D\uDD0D",COMPUTATION:"\uD83E\uDDEE",COMMUNICATION:"\uD83D\uDCE7",INTEGRATION:"\uD83D\uDD17",UTILITY:"\uD83D\uDEE0\uFE0F",CUSTOM:"\u2699\uFE0F"};function h2(m){switch(m){case"ACTIVE":return"success";case"DRAFT":return"neutral";case"DEPRECATED":return"warning";case"DISABLED":return"danger";default:return"neutral"}}function c0({onToolClick:m,onCreateTool:p}){let{data:y,loading:T,error:f,groupedByCategory:I,categoryStats:d,refetch:O}=B0();if(T&&!y)return h(_2,{label:"Loading tools..."});if(f)return h(Y2,{title:"Failed to load tools",description:f.message,onRetry:O,retryLabel:"Retry"});if(!y?.items.length)return h(K2,{title:"No tools registered",description:"Create your first tool to extend agent capabilities.",primaryAction:p?h(R2,{onPress:p,children:"Create Tool"}):void 0});return t("div",{className:"space-y-8",children:[t(J2,{children:[h(i0,{label:"Total Tools",value:y.total}),d.slice(0,3).map(({category:U,count:G})=>h(i0,{label:`${C0[U]??""} ${U}`,value:G},U))]}),Object.entries(I).map(([U,G])=>t("section",{className:"space-y-4",children:[t("div",{className:"flex items-center gap-2",children:[h("span",{className:"text-2xl",children:C0[U]}),h("h3",{className:"font-semibold text-lg",children:U}),h("span",{className:"rounded-full bg-muted px-2 py-0.5 text-muted-foreground text-xs",children:G.length})]}),h("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:G.map((z)=>h(P2,{cardTitle:z.name,cardSubtitle:`v${z.version}`,meta:h("p",{className:"text-muted-foreground text-sm",children:z.description}),chips:h(H2,{tone:h2(z.status),label:z.status}),footer:h("code",{className:"text-muted-foreground text-xs",children:z.name}),onClick:m?()=>m(z.id):void 0},z.id))})]},U))]})}import{Button as O0,StatCard as W2,StatCardGroup as $2}from"@contractspec/lib.design-system";import{useCallback as u2,useMemo as X2,useState as c}from"react";import{jsx as q,jsxs as D}from"react/jsx-runtime";function S0(){let[m,p]=c("runs"),[y,T]=c(!1),[f,I]=c(null),[d,O]=c(!1),[U,G]=c(0),{data:z,metrics:A,refetch:Y}=r(),{refetch:H}=T0(),N=_0({onSuccess:()=>{H(),Y(),G((Z)=>Z+1)}}),P=u2((Z)=>{I(Z),O(!0)},[]),M=[{id:"runs",label:"Runs",icon:"\u25B6"},{id:"agents",label:"Agents",icon:"\uD83E\uDD16"},{id:"tools",label:"Tools",icon:"\uD83D\uDD27"},{id:"metrics",label:"Metrics",icon:"\uD83D\uDCCA"}],Q=X2(()=>{if(!A)return[{label:"Total Runs",value:"-",hint:"Loading..."},{label:"Success Rate",value:"-",hint:""},{label:"Total Tokens",value:"-",hint:""},{label:"Total Cost",value:"-",hint:""}];return[{label:"Total Runs",value:A.totalRuns.toLocaleString(),hint:`${(A.successRate*100).toFixed(0)}% success`},{label:"Success Rate",value:`${(A.successRate*100).toFixed(0)}%`,hint:"of all runs"},{label:"Total Tokens",value:A.totalTokens>=1e6?`${(A.totalTokens/1e6).toFixed(1)}M`:`${(A.totalTokens/1000).toFixed(0)}K`,hint:"This period"},{label:"Total Cost",value:`$${A.totalCostUsd.toFixed(2)}`,hint:"This period"}]},[A]);return D("div",{className:"space-y-6",children:[D("div",{className:"flex items-center justify-between",children:[q("h2",{className:"font-bold text-2xl",children:"AI Agent Console"}),D(O0,{onPress:()=>T(!0),children:[q("span",{className:"mr-2",children:"+"})," New Agent"]})]}),q($2,{children:Q.map((Z,w)=>q(W2,{label:Z.label,value:Z.value,hint:Z.hint},w))}),q(Y0,{runs:z?.items??[]}),q("nav",{className:"flex gap-1 rounded-lg bg-muted p-1",role:"tablist",children:M.map((Z)=>D("button",{type:"button",role:"tab","aria-selected":m===Z.id,onClick:()=>p(Z.id),className:`flex flex-1 items-center justify-center gap-2 rounded-md px-4 py-2 font-medium text-sm transition-colors ${m===Z.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[q("span",{children:Z.icon}),Z.label]},Z.id))}),D("div",{className:"min-h-[400px]",role:"tabpanel",children:[m==="runs"&&q(b0,{},U),m==="agents"&&q(F2,{onAgentClick:P},U),m==="tools"&&q(c0,{}),m==="metrics"&&q(k2,{metrics:A})]}),q(h0,{isOpen:y,onClose:()=>T(!1),onSubmit:async(Z)=>{await N.createAgent(Z)},isLoading:N.createState.loading}),q(J0,{isOpen:d,agent:f,onClose:()=>{O(!1),I(null)},onActivate:async(Z)=>{await N.activateAgent(Z)},onPause:async(Z)=>{await N.pauseAgent(Z)},onArchive:async(Z)=>{await N.archiveAgent(Z)},onExecute:async(Z,w)=>{await N.executeAgent({agentId:Z,message:w})},isLoading:N.isLoading})]})}function F2({onAgentClick:m}){let{data:p,loading:y,error:T,stats:f,refetch:I}=T0();if(y&&!p)return q("div",{className:"flex h-64 items-center justify-center text-muted-foreground",children:"Loading agents..."});if(T)return D("div",{className:"flex h-64 flex-col items-center justify-center text-destructive",children:[D("p",{children:["Failed to load agents: ",T.message]}),q(O0,{variant:"outline",onPress:I,className:"mt-2",children:"Retry"})]});if(!p?.items.length)return D("div",{className:"flex h-64 flex-col items-center justify-center text-muted-foreground",children:[q("p",{className:"font-medium text-lg",children:"No agents yet"}),q("p",{className:"text-sm",children:"Create your first AI agent to get started."})]});return D("div",{className:"space-y-4",children:[f&&D("div",{className:"flex gap-4 text-sm",children:[D("span",{children:["Total: ",f.total]}),D("span",{className:"text-green-600",children:["Active: ",f.active]}),D("span",{className:"text-yellow-600",children:["Paused: ",f.paused]}),D("span",{className:"text-blue-600",children:["Draft: ",f.draft]})]}),q("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:p.items.map((d)=>q(V2,{agent:d,onClick:()=>m(d)},d.id))})]})}function V2({agent:m,onClick:p}){let y={ACTIVE:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",DRAFT:"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",PAUSED:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400",ARCHIVED:"bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-400"};return D("div",{onClick:p,className:"cursor-pointer rounded-xl border border-border bg-card p-4 transition-all hover:shadow-md",role:"button",tabIndex:0,onKeyDown:(T)=>{if(T.key==="Enter"||T.key===" ")p()},children:[D("div",{className:"flex items-start justify-between",children:[D("div",{className:"min-w-0 flex-1",children:[q("h3",{className:"truncate font-semibold",children:m.name}),D("p",{className:"text-muted-foreground text-sm",children:[m.modelProvider," / ",m.modelName]})]}),q("span",{className:`rounded-full px-2 py-0.5 font-medium text-xs ${y[m.status]}`,children:m.status})]}),m.description&&q("p",{className:"mt-2 line-clamp-2 text-muted-foreground text-sm",children:m.description}),D("div",{className:"mt-3 flex items-center justify-between",children:[q("span",{className:"text-muted-foreground text-xs",children:m.modelName}),q(O0,{variant:"ghost",size:"sm",onPress:p,children:"Actions"})]})]})}function k2({metrics:m}){if(!m)return q("div",{className:"flex h-64 items-center justify-center text-muted-foreground",children:"Loading metrics..."});let p=Math.round(m.totalRuns*m.successRate),y=m.totalRuns-p;return D("div",{className:"space-y-6",children:[q("h3",{className:"font-semibold text-lg",children:"Usage Analytics"}),D("div",{className:"grid gap-6 md:grid-cols-2",children:[D("div",{className:"rounded-xl border border-border bg-card p-4",children:[q("h4",{className:"font-medium",children:"Run Outcomes"}),D("div",{className:"mt-4 space-y-3",children:[q(L0,{label:"Completed",value:p,total:m.totalRuns,color:"bg-green-500"}),q(L0,{label:"Failed",value:y,total:m.totalRuns,color:"bg-red-500"})]})]}),D("div",{className:"rounded-xl border border-border bg-card p-4",children:[q("h4",{className:"font-medium",children:"Performance"}),D("dl",{className:"mt-4 grid grid-cols-2 gap-4",children:[D("div",{children:[q("dt",{className:"text-muted-foreground text-sm",children:"Avg Duration"}),D("dd",{className:"font-semibold text-xl",children:[(m.averageDurationMs/1000).toFixed(1),"s"]})]}),D("div",{children:[q("dt",{className:"text-muted-foreground text-sm",children:"Success Rate"}),D("dd",{className:"font-semibold text-xl",children:[(m.successRate*100).toFixed(0),"%"]})]})]})]})]}),D("div",{className:"rounded-xl border border-border bg-card p-4",children:[q("h4",{className:"font-medium",children:"Key Metrics"}),D("dl",{className:"mt-4 grid gap-4 sm:grid-cols-3",children:[D("div",{children:[q("dt",{className:"text-muted-foreground text-sm",children:"Total Runs"}),q("dd",{className:"font-semibold text-2xl",children:m.totalRuns.toLocaleString()})]}),D("div",{children:[q("dt",{className:"text-muted-foreground text-sm",children:"Total Tokens"}),D("dd",{className:"font-semibold text-2xl",children:[(m.totalTokens/1000).toFixed(0),"K"]})]}),D("div",{children:[q("dt",{className:"text-muted-foreground text-sm",children:"Cost per Run"}),D("dd",{className:"font-semibold text-2xl",children:["$",m.totalRuns>0?(m.totalCostUsd/m.totalRuns).toFixed(4):"0"]})]})]})]})]})}function L0({label:m,value:p,total:y,color:T}){let f=y>0?p/y*100:0;return D("div",{children:[D("div",{className:"flex justify-between text-sm",children:[q("span",{children:m}),D("span",{className:"text-muted-foreground",children:[p," (",f.toFixed(0),"%)"]})]}),q("div",{className:"mt-1 h-2 overflow-hidden rounded-full bg-muted",children:q("div",{className:`h-full ${T}`,style:{width:`${f}%`}})})]})}import{VStack as E2}from"@contractspec/lib.ui-kit-web/ui/stack";import{ExecutionLaneConsoleDemo as v2}from"@contractspec/module.execution-console";import{jsx as r0,jsxs as b2}from"react/jsx-runtime";function Pm(){return b2(E2,{gap:"xl",align:"stretch",children:[r0(S0,{}),r0(v2,{})]})}export{Pm as ExecutionConsoleHost};
@@ -0,0 +1 @@
1
+ export {};