@contractspec/example.agent-console 3.7.5 → 3.7.7

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 (176) hide show
  1. package/.turbo/turbo-build.log +18 -18
  2. package/AGENTS.md +50 -31
  3. package/CHANGELOG.md +12 -0
  4. package/README.md +69 -77
  5. package/dist/agent/agent.event.js +1 -1
  6. package/dist/agent/agent.operation.js +1 -1
  7. package/dist/agent/index.d.ts +5 -5
  8. package/dist/agent/index.js +1 -1
  9. package/dist/browser/agent/agent.event.js +1 -1
  10. package/dist/browser/agent/agent.operation.js +1 -1
  11. package/dist/browser/agent/index.js +1 -1
  12. package/dist/browser/index.js +2145 -2145
  13. package/dist/browser/presentations/index.js +4 -4
  14. package/dist/browser/run/index.js +536 -536
  15. package/dist/browser/run/run.event.js +2 -2
  16. package/dist/browser/run/run.presentation.js +2 -2
  17. package/dist/browser/tool/index.js +260 -260
  18. package/dist/browser/tool/tool.event.js +1 -1
  19. package/dist/browser/tool/tool.presentation.js +2 -2
  20. package/dist/browser/ui/AgentDashboard.js +956 -956
  21. package/dist/browser/ui/AgentRunList.js +16 -16
  22. package/dist/browser/ui/AgentToolRegistry.js +9 -9
  23. package/dist/browser/ui/hooks/index.js +153 -153
  24. package/dist/browser/ui/hooks/useAgentList.js +1 -1
  25. package/dist/browser/ui/hooks/useAgentMutations.js +1 -1
  26. package/dist/browser/ui/hooks/useRunList.js +1 -1
  27. package/dist/browser/ui/hooks/useToolList.js +1 -1
  28. package/dist/browser/ui/index.js +1222 -1222
  29. package/dist/browser/ui/modals/AgentActionsModal.js +13 -13
  30. package/dist/browser/ui/modals/CreateAgentModal.js +15 -15
  31. package/dist/browser/ui/modals/index.js +297 -297
  32. package/dist/browser/ui/renderers/agent-list.renderer.js +7 -7
  33. package/dist/browser/ui/renderers/index.js +157 -157
  34. package/dist/browser/ui/views/AgentListView.js +7 -7
  35. package/dist/browser/ui/views/RunListView.js +16 -16
  36. package/dist/browser/ui/views/ToolRegistryView.js +9 -9
  37. package/dist/browser/ui/views/index.js +97 -97
  38. package/dist/handlers/index.d.ts +1 -1
  39. package/dist/index.d.ts +4 -4
  40. package/dist/index.js +2145 -2145
  41. package/dist/node/agent/agent.event.js +1 -1
  42. package/dist/node/agent/agent.operation.js +1 -1
  43. package/dist/node/agent/index.js +1 -1
  44. package/dist/node/index.js +2145 -2145
  45. package/dist/node/presentations/index.js +4 -4
  46. package/dist/node/run/index.js +536 -536
  47. package/dist/node/run/run.event.js +2 -2
  48. package/dist/node/run/run.presentation.js +2 -2
  49. package/dist/node/tool/index.js +260 -260
  50. package/dist/node/tool/tool.event.js +1 -1
  51. package/dist/node/tool/tool.presentation.js +2 -2
  52. package/dist/node/ui/AgentDashboard.js +956 -956
  53. package/dist/node/ui/AgentRunList.js +16 -16
  54. package/dist/node/ui/AgentToolRegistry.js +9 -9
  55. package/dist/node/ui/hooks/index.js +153 -153
  56. package/dist/node/ui/hooks/useAgentList.js +1 -1
  57. package/dist/node/ui/hooks/useAgentMutations.js +1 -1
  58. package/dist/node/ui/hooks/useRunList.js +1 -1
  59. package/dist/node/ui/hooks/useToolList.js +1 -1
  60. package/dist/node/ui/index.js +1222 -1222
  61. package/dist/node/ui/modals/AgentActionsModal.js +13 -13
  62. package/dist/node/ui/modals/CreateAgentModal.js +15 -15
  63. package/dist/node/ui/modals/index.js +297 -297
  64. package/dist/node/ui/renderers/agent-list.renderer.js +7 -7
  65. package/dist/node/ui/renderers/index.js +157 -157
  66. package/dist/node/ui/views/AgentListView.js +7 -7
  67. package/dist/node/ui/views/RunListView.js +16 -16
  68. package/dist/node/ui/views/ToolRegistryView.js +9 -9
  69. package/dist/node/ui/views/index.js +97 -97
  70. package/dist/presentations/index.d.ts +3 -5
  71. package/dist/presentations/index.js +4 -4
  72. package/dist/run/index.d.ts +7 -7
  73. package/dist/run/index.js +536 -536
  74. package/dist/run/run.event.js +2 -2
  75. package/dist/run/run.handler.d.ts +3 -0
  76. package/dist/run/run.presentation.js +2 -2
  77. package/dist/shared/index.d.ts +1 -1
  78. package/dist/tool/index.d.ts +7 -7
  79. package/dist/tool/index.js +260 -260
  80. package/dist/tool/tool.event.js +1 -1
  81. package/dist/tool/tool.handler.d.ts +1 -1
  82. package/dist/tool/tool.presentation.js +2 -2
  83. package/dist/ui/AgentDashboard.js +956 -956
  84. package/dist/ui/AgentRunList.js +16 -16
  85. package/dist/ui/AgentToolRegistry.js +9 -9
  86. package/dist/ui/hooks/index.d.ts +4 -4
  87. package/dist/ui/hooks/index.js +153 -153
  88. package/dist/ui/hooks/useAgentList.d.ts +5 -0
  89. package/dist/ui/hooks/useAgentList.js +1 -1
  90. package/dist/ui/hooks/useAgentMutations.d.ts +9 -2
  91. package/dist/ui/hooks/useAgentMutations.js +1 -1
  92. package/dist/ui/hooks/useRunList.d.ts +5 -0
  93. package/dist/ui/hooks/useRunList.js +1 -1
  94. package/dist/ui/hooks/useToolList.d.ts +5 -0
  95. package/dist/ui/hooks/useToolList.js +1 -1
  96. package/dist/ui/index.d.ts +3 -3
  97. package/dist/ui/index.js +1222 -1222
  98. package/dist/ui/modals/AgentActionsModal.js +13 -13
  99. package/dist/ui/modals/CreateAgentModal.js +15 -15
  100. package/dist/ui/modals/index.d.ts +1 -1
  101. package/dist/ui/modals/index.js +297 -297
  102. package/dist/ui/renderers/agent-list.markdown.d.ts +5 -0
  103. package/dist/ui/renderers/agent-list.renderer.js +7 -7
  104. package/dist/ui/renderers/dashboard.markdown.d.ts +5 -0
  105. package/dist/ui/renderers/index.d.ts +2 -2
  106. package/dist/ui/renderers/index.js +157 -157
  107. package/dist/ui/renderers/run-list.markdown.d.ts +5 -0
  108. package/dist/ui/renderers/tool-registry.markdown.d.ts +5 -0
  109. package/dist/ui/views/AgentListView.js +7 -7
  110. package/dist/ui/views/RunListView.js +16 -16
  111. package/dist/ui/views/ToolRegistryView.js +9 -9
  112. package/dist/ui/views/index.js +97 -97
  113. package/package.json +10 -10
  114. package/src/agent/agent.entity.ts +111 -111
  115. package/src/agent/agent.enum.ts +12 -12
  116. package/src/agent/agent.event.ts +91 -91
  117. package/src/agent/agent.handler.ts +123 -123
  118. package/src/agent/agent.operation.ts +400 -400
  119. package/src/agent/agent.presentation.ts +62 -62
  120. package/src/agent/agent.schema.ts +175 -175
  121. package/src/agent/agent.test-spec.ts +48 -48
  122. package/src/agent/index.ts +46 -51
  123. package/src/agent.capability.ts +11 -11
  124. package/src/agent.feature.ts +131 -131
  125. package/src/docs/agent-console.docblock.ts +42 -42
  126. package/src/example.ts +35 -35
  127. package/src/handlers/agent.handlers.ts +522 -521
  128. package/src/handlers/index.ts +12 -12
  129. package/src/index.ts +8 -9
  130. package/src/presentations/index.ts +11 -13
  131. package/src/run/index.ts +49 -54
  132. package/src/run/run.entity.ts +137 -137
  133. package/src/run/run.enum.ts +18 -18
  134. package/src/run/run.event.ts +174 -174
  135. package/src/run/run.handler.ts +92 -91
  136. package/src/run/run.operation.ts +474 -474
  137. package/src/run/run.presentation.ts +42 -42
  138. package/src/run/run.schema.ts +126 -126
  139. package/src/run/run.test-spec.ts +48 -48
  140. package/src/seeders/index.ts +21 -21
  141. package/src/shared/index.ts +1 -1
  142. package/src/shared/mock-agents.ts +76 -76
  143. package/src/shared/mock-runs.ts +102 -102
  144. package/src/shared/mock-tools.ts +140 -140
  145. package/src/shared/overlay-types.ts +23 -23
  146. package/src/tool/index.ts +39 -44
  147. package/src/tool/tool.entity.ts +73 -73
  148. package/src/tool/tool.enum.ts +13 -13
  149. package/src/tool/tool.event.ts +80 -80
  150. package/src/tool/tool.handler.ts +102 -102
  151. package/src/tool/tool.operation.ts +328 -328
  152. package/src/tool/tool.presentation.ts +43 -43
  153. package/src/tool/tool.schema.ts +106 -106
  154. package/src/tool/tool.test-spec.ts +48 -48
  155. package/src/ui/AgentDashboard.tsx +348 -348
  156. package/src/ui/hooks/index.ts +7 -7
  157. package/src/ui/hooks/useAgentList.ts +57 -56
  158. package/src/ui/hooks/useAgentMutations.ts +160 -159
  159. package/src/ui/hooks/useRunList.ts +58 -57
  160. package/src/ui/hooks/useToolList.ts +102 -101
  161. package/src/ui/index.ts +6 -9
  162. package/src/ui/modals/AgentActionsModal.tsx +262 -262
  163. package/src/ui/modals/CreateAgentModal.tsx +232 -232
  164. package/src/ui/modals/index.ts +1 -1
  165. package/src/ui/overlays/demo-overlays.ts +52 -52
  166. package/src/ui/renderers/agent-list.markdown.ts +61 -60
  167. package/src/ui/renderers/agent-list.renderer.tsx +14 -14
  168. package/src/ui/renderers/dashboard.markdown.ts +140 -139
  169. package/src/ui/renderers/index.ts +3 -4
  170. package/src/ui/renderers/run-list.markdown.ts +48 -47
  171. package/src/ui/renderers/tool-registry.markdown.ts +66 -65
  172. package/src/ui/views/AgentListView.tsx +90 -90
  173. package/src/ui/views/RunListView.tsx +141 -141
  174. package/src/ui/views/ToolRegistryView.tsx +113 -113
  175. package/tsconfig.json +7 -8
  176. package/tsdown.config.js +7 -3
@@ -1,6 +1,6 @@
1
1
  // src/ui/hooks/useAgentList.ts
2
- import { useCallback, useEffect, useMemo, useState } from "react";
3
2
  import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
3
+ import { useCallback, useEffect, useMemo, useState } from "react";
4
4
  function useAgentList(options = {}) {
5
5
  const { handlers, projectId } = useTemplateRuntime();
6
6
  const { agent } = handlers;
@@ -54,13 +54,13 @@ function useAgentList(options = {}) {
54
54
  // src/ui/views/AgentListView.tsx
55
55
  import {
56
56
  Button,
57
- StatCard,
58
- StatCardGroup,
57
+ EmptyState,
59
58
  EntityCard,
60
- StatusChip,
61
- LoaderBlock,
62
59
  ErrorState,
63
- EmptyState
60
+ LoaderBlock,
61
+ StatCard,
62
+ StatCardGroup,
63
+ StatusChip
64
64
  } from "@contractspec/lib.design-system";
65
65
  import { jsxDEV } from "react/jsx-dev-runtime";
66
66
  "use client";
@@ -125,7 +125,7 @@ function AgentListView() {
125
125
  className: "flex items-center justify-between",
126
126
  children: [
127
127
  /* @__PURE__ */ jsxDEV("h3", {
128
- className: "text-lg font-semibold",
128
+ className: "font-semibold text-lg",
129
129
  children: "Agents"
130
130
  }, undefined, false, undefined, this),
131
131
  /* @__PURE__ */ jsxDEV(Button, {
@@ -1,6 +1,6 @@
1
1
  // src/ui/hooks/useAgentList.ts
2
- import { useCallback, useEffect, useMemo, useState } from "react";
3
2
  import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
3
+ import { useCallback, useEffect, useMemo, useState } from "react";
4
4
  function useAgentList(options = {}) {
5
5
  const { handlers, projectId } = useTemplateRuntime();
6
6
  const { agent } = handlers;
@@ -51,16 +51,69 @@ function useAgentList(options = {}) {
51
51
  };
52
52
  }
53
53
 
54
+ // src/ui/renderers/agent-list.markdown.ts
55
+ import {
56
+ mockListAgentsHandler
57
+ } from "@contractspec/example.agent-console/handlers";
58
+ var agentListMarkdownRenderer = {
59
+ target: "markdown",
60
+ render: async (desc) => {
61
+ if (desc.source.type !== "component" || desc.source.componentKey !== "AgentListView") {
62
+ throw new Error("agentListMarkdownRenderer: not AgentListView");
63
+ }
64
+ const data = await mockListAgentsHandler({
65
+ organizationId: "demo-org",
66
+ limit: 50,
67
+ offset: 0
68
+ });
69
+ const lines = [
70
+ `# ${desc.meta.description ?? "Agent List"}`,
71
+ "",
72
+ `> ${desc.meta.key} v${desc.meta.version}`,
73
+ "",
74
+ `**Total Agents:** ${data.total}`,
75
+ "",
76
+ "## Agents",
77
+ ""
78
+ ];
79
+ const byStatus = {};
80
+ for (const agent of data.items) {
81
+ const status = agent.status;
82
+ if (byStatus[status]) {
83
+ byStatus[status].push(agent);
84
+ } else {
85
+ byStatus[status] = [agent];
86
+ }
87
+ }
88
+ for (const [status, agents] of Object.entries(byStatus)) {
89
+ lines.push(`### ${status} (${agents.length})`);
90
+ lines.push("");
91
+ for (const agent of agents) {
92
+ lines.push(`- **${agent.name}** (${agent.modelProvider}/${agent.modelName})`);
93
+ if (agent.description) {
94
+ lines.push(` > ${agent.description}`);
95
+ }
96
+ }
97
+ lines.push("");
98
+ }
99
+ return {
100
+ mimeType: "text/markdown",
101
+ body: lines.join(`
102
+ `)
103
+ };
104
+ }
105
+ };
106
+
54
107
  // src/ui/views/AgentListView.tsx
55
108
  import {
56
109
  Button,
57
- StatCard,
58
- StatCardGroup,
110
+ EmptyState,
59
111
  EntityCard,
60
- StatusChip,
61
- LoaderBlock,
62
112
  ErrorState,
63
- EmptyState
113
+ LoaderBlock,
114
+ StatCard,
115
+ StatCardGroup,
116
+ StatusChip
64
117
  } from "@contractspec/lib.design-system";
65
118
  import { jsxDEV } from "react/jsx-dev-runtime";
66
119
  "use client";
@@ -125,7 +178,7 @@ function AgentListView() {
125
178
  className: "flex items-center justify-between",
126
179
  children: [
127
180
  /* @__PURE__ */ jsxDEV("h3", {
128
- className: "text-lg font-semibold",
181
+ className: "font-semibold text-lg",
129
182
  children: "Agents"
130
183
  }, undefined, false, undefined, this),
131
184
  /* @__PURE__ */ jsxDEV(Button, {
@@ -176,50 +229,112 @@ var agentListReactRenderer = {
176
229
  }
177
230
  };
178
231
 
179
- // src/ui/renderers/agent-list.markdown.ts
232
+ // src/ui/renderers/dashboard.markdown.ts
180
233
  import {
181
- mockListAgentsHandler
234
+ mockListAgentsHandler as mockListAgentsHandler2,
235
+ mockListRunsHandler,
236
+ mockListToolsHandler
182
237
  } from "@contractspec/example.agent-console/handlers";
183
- var agentListMarkdownRenderer = {
238
+ function formatDuration(ms) {
239
+ if (ms < 1000)
240
+ return `${ms}ms`;
241
+ if (ms < 60000)
242
+ return `${(ms / 1000).toFixed(1)}s`;
243
+ return `${(ms / 60000).toFixed(1)}m`;
244
+ }
245
+ var agentDashboardMarkdownRenderer = {
184
246
  target: "markdown",
185
247
  render: async (desc) => {
186
- if (desc.source.type !== "component" || desc.source.componentKey !== "AgentListView") {
187
- throw new Error("agentListMarkdownRenderer: not AgentListView");
248
+ if (desc.source.type !== "component" || desc.source.componentKey !== "AgentConsoleDashboard") {
249
+ throw new Error("agentDashboardMarkdownRenderer: not AgentConsoleDashboard");
188
250
  }
189
- const data = await mockListAgentsHandler({
190
- organizationId: "demo-org",
191
- limit: 50,
192
- offset: 0
193
- });
251
+ const [agentsData, runsData, toolsData] = await Promise.all([
252
+ mockListAgentsHandler2({
253
+ organizationId: "demo-org",
254
+ limit: 100
255
+ }),
256
+ mockListRunsHandler({
257
+ limit: 100
258
+ }),
259
+ mockListToolsHandler({
260
+ organizationId: "demo-org",
261
+ limit: 100
262
+ })
263
+ ]);
264
+ const activeAgents = agentsData.items.filter((a) => a.status === "ACTIVE").length;
265
+ const completedRuns = runsData.items.filter((r) => r.status === "COMPLETED").length;
266
+ const failedRuns = runsData.items.filter((r) => r.status === "FAILED").length;
267
+ const totalTokens = runsData.items.reduce((sum, r) => sum + (r.totalTokens ?? 0), 0);
268
+ const totalCost = runsData.items.reduce((sum, r) => sum + (r.estimatedCostUsd ?? 0), 0);
269
+ const activeTools = toolsData.items.filter((t) => t.status === "ACTIVE").length;
194
270
  const lines = [
195
- `# ${desc.meta.description ?? "Agent List"}`,
271
+ "# Agent Console Dashboard",
196
272
  "",
197
- `> ${desc.meta.key} v${desc.meta.version}`,
273
+ "> AI agent operations overview",
198
274
  "",
199
- `**Total Agents:** ${data.total}`,
275
+ "## Summary",
276
+ "",
277
+ "| Metric | Value |",
278
+ "|--------|-------|",
279
+ `| Total Agents | ${agentsData.total} |`,
280
+ `| Active Agents | ${activeAgents} |`,
281
+ `| Total Runs | ${runsData.total} |`,
282
+ `| Completed Runs | ${completedRuns} |`,
283
+ `| Failed Runs | ${failedRuns} |`,
284
+ `| Total Tokens | ${totalTokens.toLocaleString()} |`,
285
+ `| Total Cost | $${totalCost.toFixed(4)} |`,
286
+ `| Total Tools | ${toolsData.total} |`,
287
+ `| Active Tools | ${activeTools} |`,
200
288
  "",
201
289
  "## Agents",
202
290
  ""
203
291
  ];
204
- const byStatus = {};
205
- for (const agent of data.items) {
206
- const status = agent.status;
207
- if (byStatus[status]) {
208
- byStatus[status].push(agent);
209
- } else {
210
- byStatus[status] = [agent];
292
+ if (agentsData.items.length === 0) {
293
+ lines.push("_No agents configured._");
294
+ } else {
295
+ lines.push("| Agent | Model | Status | Description |");
296
+ lines.push("|-------|-------|--------|-------------|");
297
+ for (const agent of agentsData.items.slice(0, 5)) {
298
+ lines.push(`| ${agent.name} | ${agent.modelProvider}/${agent.modelName} | ${agent.status} | ${agent.description ?? "-"} |`);
299
+ }
300
+ if (agentsData.items.length > 5) {
301
+ lines.push(`| ... | ... | ... | _${agentsData.total - 5} more_ |`);
211
302
  }
212
303
  }
213
- for (const [status, agents] of Object.entries(byStatus)) {
214
- lines.push(`### ${status} (${agents.length})`);
215
- lines.push("");
216
- for (const agent of agents) {
217
- lines.push(`- **${agent.name}** (${agent.modelProvider}/${agent.modelName})`);
218
- if (agent.description) {
219
- lines.push(` > ${agent.description}`);
220
- }
304
+ lines.push("");
305
+ lines.push("## Recent Runs");
306
+ lines.push("");
307
+ if (runsData.items.length === 0) {
308
+ lines.push("_No runs yet._");
309
+ } else {
310
+ lines.push("| Run ID | Agent | Status | Duration | Tokens | Cost |");
311
+ lines.push("|--------|-------|--------|----------|--------|------|");
312
+ for (const run of runsData.items.slice(0, 5)) {
313
+ lines.push(`| ${run.id.slice(-8)} | ${run.agentName} | ${run.status} | ${run.durationMs ? formatDuration(run.durationMs) : "-"} | ${run.totalTokens ?? 0} | $${(run.estimatedCostUsd ?? 0).toFixed(4)} |`);
314
+ }
315
+ if (runsData.items.length > 5) {
316
+ lines.push(`| ... | ... | ... | ... | ... | _${runsData.total - 5} more_ |`);
317
+ }
318
+ }
319
+ lines.push("");
320
+ lines.push("## Tools");
321
+ lines.push("");
322
+ const toolsByCategory = {};
323
+ for (const tool of toolsData.items) {
324
+ const cat = tool.category;
325
+ if (!toolsByCategory[cat])
326
+ toolsByCategory[cat] = [];
327
+ toolsByCategory[cat].push(tool);
328
+ }
329
+ if (Object.keys(toolsByCategory).length === 0) {
330
+ lines.push("_No tools registered._");
331
+ } else {
332
+ lines.push("| Category | Tools | Active |");
333
+ lines.push("|----------|-------|--------|");
334
+ for (const [category, tools] of Object.entries(toolsByCategory).sort()) {
335
+ const active = tools.filter((t) => t.status === "ACTIVE").length;
336
+ lines.push(`| ${category} | ${tools.length} | ${active} |`);
221
337
  }
222
- lines.push("");
223
338
  }
224
339
  return {
225
340
  mimeType: "text/markdown",
@@ -230,8 +345,8 @@ var agentListMarkdownRenderer = {
230
345
  };
231
346
 
232
347
  // src/ui/renderers/run-list.markdown.ts
233
- import { mockListRunsHandler } from "@contractspec/example.agent-console/handlers";
234
- function formatDuration(ms) {
348
+ import { mockListRunsHandler as mockListRunsHandler2 } from "@contractspec/example.agent-console/handlers";
349
+ function formatDuration2(ms) {
235
350
  if (ms < 1000)
236
351
  return `${ms}ms`;
237
352
  if (ms < 60000)
@@ -244,7 +359,7 @@ var runListMarkdownRenderer = {
244
359
  if (desc.source.type !== "component" || desc.source.componentKey !== "RunListView") {
245
360
  throw new Error("runListMarkdownRenderer: not RunListView");
246
361
  }
247
- const data = await mockListRunsHandler({
362
+ const data = await mockListRunsHandler2({
248
363
  organizationId: "demo-org",
249
364
  limit: 20,
250
365
  offset: 0
@@ -262,7 +377,7 @@ var runListMarkdownRenderer = {
262
377
  "| --- | --- | --- | --- | --- | --- |"
263
378
  ];
264
379
  for (const run of data.items.slice(0, 10)) {
265
- lines.push(`| ${run.id.slice(-8)} | ${run.agentName} | ${run.status} | ${run.durationMs ? formatDuration(run.durationMs) : "-"} | ${run.totalTokens} | $${run.estimatedCostUsd?.toFixed(4) ?? "-"} |`);
380
+ lines.push(`| ${run.id.slice(-8)} | ${run.agentName} | ${run.status} | ${run.durationMs ? formatDuration2(run.durationMs) : "-"} | ${run.totalTokens} | $${run.estimatedCostUsd?.toFixed(4) ?? "-"} |`);
266
381
  }
267
382
  return {
268
383
  mimeType: "text/markdown",
@@ -273,14 +388,14 @@ var runListMarkdownRenderer = {
273
388
  };
274
389
 
275
390
  // src/ui/renderers/tool-registry.markdown.ts
276
- import { mockListToolsHandler } from "@contractspec/example.agent-console/handlers";
391
+ import { mockListToolsHandler as mockListToolsHandler2 } from "@contractspec/example.agent-console/handlers";
277
392
  var toolRegistryMarkdownRenderer = {
278
393
  target: "markdown",
279
394
  render: async (desc) => {
280
395
  if (desc.source.type !== "component" || desc.source.componentKey !== "ToolRegistryView") {
281
396
  throw new Error("toolRegistryMarkdownRenderer: not ToolRegistryView");
282
397
  }
283
- const data = await mockListToolsHandler({
398
+ const data = await mockListToolsHandler2({
284
399
  organizationId: "demo-org",
285
400
  limit: 50,
286
401
  offset: 0
@@ -322,121 +437,6 @@ var toolRegistryMarkdownRenderer = {
322
437
  };
323
438
  }
324
439
  };
325
-
326
- // src/ui/renderers/dashboard.markdown.ts
327
- import {
328
- mockListAgentsHandler as mockListAgentsHandler2,
329
- mockListRunsHandler as mockListRunsHandler2,
330
- mockListToolsHandler as mockListToolsHandler2
331
- } from "@contractspec/example.agent-console/handlers";
332
- function formatDuration2(ms) {
333
- if (ms < 1000)
334
- return `${ms}ms`;
335
- if (ms < 60000)
336
- return `${(ms / 1000).toFixed(1)}s`;
337
- return `${(ms / 60000).toFixed(1)}m`;
338
- }
339
- var agentDashboardMarkdownRenderer = {
340
- target: "markdown",
341
- render: async (desc) => {
342
- if (desc.source.type !== "component" || desc.source.componentKey !== "AgentConsoleDashboard") {
343
- throw new Error("agentDashboardMarkdownRenderer: not AgentConsoleDashboard");
344
- }
345
- const [agentsData, runsData, toolsData] = await Promise.all([
346
- mockListAgentsHandler2({
347
- organizationId: "demo-org",
348
- limit: 100
349
- }),
350
- mockListRunsHandler2({
351
- limit: 100
352
- }),
353
- mockListToolsHandler2({
354
- organizationId: "demo-org",
355
- limit: 100
356
- })
357
- ]);
358
- const activeAgents = agentsData.items.filter((a) => a.status === "ACTIVE").length;
359
- const completedRuns = runsData.items.filter((r) => r.status === "COMPLETED").length;
360
- const failedRuns = runsData.items.filter((r) => r.status === "FAILED").length;
361
- const totalTokens = runsData.items.reduce((sum, r) => sum + (r.totalTokens ?? 0), 0);
362
- const totalCost = runsData.items.reduce((sum, r) => sum + (r.estimatedCostUsd ?? 0), 0);
363
- const activeTools = toolsData.items.filter((t) => t.status === "ACTIVE").length;
364
- const lines = [
365
- "# Agent Console Dashboard",
366
- "",
367
- "> AI agent operations overview",
368
- "",
369
- "## Summary",
370
- "",
371
- "| Metric | Value |",
372
- "|--------|-------|",
373
- `| Total Agents | ${agentsData.total} |`,
374
- `| Active Agents | ${activeAgents} |`,
375
- `| Total Runs | ${runsData.total} |`,
376
- `| Completed Runs | ${completedRuns} |`,
377
- `| Failed Runs | ${failedRuns} |`,
378
- `| Total Tokens | ${totalTokens.toLocaleString()} |`,
379
- `| Total Cost | $${totalCost.toFixed(4)} |`,
380
- `| Total Tools | ${toolsData.total} |`,
381
- `| Active Tools | ${activeTools} |`,
382
- "",
383
- "## Agents",
384
- ""
385
- ];
386
- if (agentsData.items.length === 0) {
387
- lines.push("_No agents configured._");
388
- } else {
389
- lines.push("| Agent | Model | Status | Description |");
390
- lines.push("|-------|-------|--------|-------------|");
391
- for (const agent of agentsData.items.slice(0, 5)) {
392
- lines.push(`| ${agent.name} | ${agent.modelProvider}/${agent.modelName} | ${agent.status} | ${agent.description ?? "-"} |`);
393
- }
394
- if (agentsData.items.length > 5) {
395
- lines.push(`| ... | ... | ... | _${agentsData.total - 5} more_ |`);
396
- }
397
- }
398
- lines.push("");
399
- lines.push("## Recent Runs");
400
- lines.push("");
401
- if (runsData.items.length === 0) {
402
- lines.push("_No runs yet._");
403
- } else {
404
- lines.push("| Run ID | Agent | Status | Duration | Tokens | Cost |");
405
- lines.push("|--------|-------|--------|----------|--------|------|");
406
- for (const run of runsData.items.slice(0, 5)) {
407
- lines.push(`| ${run.id.slice(-8)} | ${run.agentName} | ${run.status} | ${run.durationMs ? formatDuration2(run.durationMs) : "-"} | ${run.totalTokens ?? 0} | $${(run.estimatedCostUsd ?? 0).toFixed(4)} |`);
408
- }
409
- if (runsData.items.length > 5) {
410
- lines.push(`| ... | ... | ... | ... | ... | _${runsData.total - 5} more_ |`);
411
- }
412
- }
413
- lines.push("");
414
- lines.push("## Tools");
415
- lines.push("");
416
- const toolsByCategory = {};
417
- for (const tool of toolsData.items) {
418
- const cat = tool.category;
419
- if (!toolsByCategory[cat])
420
- toolsByCategory[cat] = [];
421
- toolsByCategory[cat].push(tool);
422
- }
423
- if (Object.keys(toolsByCategory).length === 0) {
424
- lines.push("_No tools registered._");
425
- } else {
426
- lines.push("| Category | Tools | Active |");
427
- lines.push("|----------|-------|--------|");
428
- for (const [category, tools] of Object.entries(toolsByCategory).sort()) {
429
- const active = tools.filter((t) => t.status === "ACTIVE").length;
430
- lines.push(`| ${category} | ${tools.length} | ${active} |`);
431
- }
432
- }
433
- return {
434
- mimeType: "text/markdown",
435
- body: lines.join(`
436
- `)
437
- };
438
- }
439
- };
440
440
  export {
441
441
  toolRegistryMarkdownRenderer,
442
442
  runListMarkdownRenderer,
@@ -1,6 +1,6 @@
1
1
  // src/ui/hooks/useAgentList.ts
2
- import { useCallback, useEffect, useMemo, useState } from "react";
3
2
  import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
3
+ import { useCallback, useEffect, useMemo, useState } from "react";
4
4
  function useAgentList(options = {}) {
5
5
  const { handlers, projectId } = useTemplateRuntime();
6
6
  const { agent } = handlers;
@@ -54,13 +54,13 @@ function useAgentList(options = {}) {
54
54
  // src/ui/views/AgentListView.tsx
55
55
  import {
56
56
  Button,
57
- StatCard,
58
- StatCardGroup,
57
+ EmptyState,
59
58
  EntityCard,
60
- StatusChip,
61
- LoaderBlock,
62
59
  ErrorState,
63
- EmptyState
60
+ LoaderBlock,
61
+ StatCard,
62
+ StatCardGroup,
63
+ StatusChip
64
64
  } from "@contractspec/lib.design-system";
65
65
  import { jsxDEV } from "react/jsx-dev-runtime";
66
66
  "use client";
@@ -125,7 +125,7 @@ function AgentListView() {
125
125
  className: "flex items-center justify-between",
126
126
  children: [
127
127
  /* @__PURE__ */ jsxDEV("h3", {
128
- className: "text-lg font-semibold",
128
+ className: "font-semibold text-lg",
129
129
  children: "Agents"
130
130
  }, undefined, false, undefined, this),
131
131
  /* @__PURE__ */ jsxDEV(Button, {
@@ -1,6 +1,6 @@
1
1
  // src/ui/hooks/useRunList.ts
2
- import { useCallback, useEffect, useState } from "react";
3
2
  import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
3
+ import { useCallback, useEffect, useState } from "react";
4
4
  function useRunList(options = {}) {
5
5
  const { handlers, projectId } = useTemplateRuntime();
6
6
  const { agent } = handlers;
@@ -53,12 +53,12 @@ function useRunList(options = {}) {
53
53
 
54
54
  // src/ui/views/RunListView.tsx
55
55
  import {
56
- StatCard,
57
- StatCardGroup,
58
- StatusChip,
59
56
  EmptyState,
57
+ ErrorState,
60
58
  LoaderBlock,
61
- ErrorState
59
+ StatCard,
60
+ StatCardGroup,
61
+ StatusChip
62
62
  } from "@contractspec/lib.design-system";
63
63
  import { jsxDEV } from "react/jsx-dev-runtime";
64
64
  "use client";
@@ -143,45 +143,45 @@ function RunListView({ agentId, onRunClick }) {
143
143
  ]
144
144
  }, undefined, true, undefined, this),
145
145
  /* @__PURE__ */ jsxDEV("div", {
146
- className: "border-border rounded-lg border",
146
+ className: "rounded-lg border border-border",
147
147
  children: /* @__PURE__ */ jsxDEV("table", {
148
148
  className: "w-full",
149
149
  children: [
150
150
  /* @__PURE__ */ jsxDEV("thead", {
151
- className: "border-border bg-muted/30 border-b",
151
+ className: "border-border border-b bg-muted/30",
152
152
  children: /* @__PURE__ */ jsxDEV("tr", {
153
153
  children: [
154
154
  /* @__PURE__ */ jsxDEV("th", {
155
- className: "text-muted-foreground px-4 py-3 text-left text-sm font-medium",
155
+ className: "px-4 py-3 text-left font-medium text-muted-foreground text-sm",
156
156
  children: "Run"
157
157
  }, undefined, false, undefined, this),
158
158
  /* @__PURE__ */ jsxDEV("th", {
159
- className: "text-muted-foreground px-4 py-3 text-left text-sm font-medium",
159
+ className: "px-4 py-3 text-left font-medium text-muted-foreground text-sm",
160
160
  children: "Agent"
161
161
  }, undefined, false, undefined, this),
162
162
  /* @__PURE__ */ jsxDEV("th", {
163
- className: "text-muted-foreground px-4 py-3 text-left text-sm font-medium",
163
+ className: "px-4 py-3 text-left font-medium text-muted-foreground text-sm",
164
164
  children: "Status"
165
165
  }, undefined, false, undefined, this),
166
166
  /* @__PURE__ */ jsxDEV("th", {
167
- className: "text-muted-foreground px-4 py-3 text-right text-sm font-medium",
167
+ className: "px-4 py-3 text-right font-medium text-muted-foreground text-sm",
168
168
  children: "Tokens"
169
169
  }, undefined, false, undefined, this),
170
170
  /* @__PURE__ */ jsxDEV("th", {
171
- className: "text-muted-foreground px-4 py-3 text-right text-sm font-medium",
171
+ className: "px-4 py-3 text-right font-medium text-muted-foreground text-sm",
172
172
  children: "Duration"
173
173
  }, undefined, false, undefined, this),
174
174
  /* @__PURE__ */ jsxDEV("th", {
175
- className: "text-muted-foreground px-4 py-3 text-right text-sm font-medium",
175
+ className: "px-4 py-3 text-right font-medium text-muted-foreground text-sm",
176
176
  children: "Cost"
177
177
  }, undefined, false, undefined, this)
178
178
  ]
179
179
  }, undefined, true, undefined, this)
180
180
  }, undefined, false, undefined, this),
181
181
  /* @__PURE__ */ jsxDEV("tbody", {
182
- className: "divide-border divide-y",
182
+ className: "divide-y divide-border",
183
183
  children: data.items.map((run) => /* @__PURE__ */ jsxDEV("tr", {
184
- className: "hover:bg-muted/50 cursor-pointer transition-colors",
184
+ className: "cursor-pointer transition-colors hover:bg-muted/50",
185
185
  onClick: () => onRunClick?.(run.id),
186
186
  children: [
187
187
  /* @__PURE__ */ jsxDEV("td", {
@@ -230,7 +230,7 @@ function RunListView({ agentId, onRunClick }) {
230
230
  }, undefined, true, undefined, this)
231
231
  }, undefined, false, undefined, this),
232
232
  /* @__PURE__ */ jsxDEV("div", {
233
- className: "text-muted-foreground text-center text-sm",
233
+ className: "text-center text-muted-foreground text-sm",
234
234
  children: [
235
235
  "Showing ",
236
236
  data.items.length,
@@ -1,6 +1,6 @@
1
1
  // src/ui/hooks/useToolList.ts
2
- import { useCallback, useEffect, useMemo, useState } from "react";
3
2
  import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
3
+ import { useCallback, useEffect, useMemo, useState } from "react";
4
4
  function useToolList(options = {}) {
5
5
  const { handlers, projectId } = useTemplateRuntime();
6
6
  const { agent } = handlers;
@@ -83,14 +83,14 @@ function useToolList(options = {}) {
83
83
 
84
84
  // src/ui/views/ToolRegistryView.tsx
85
85
  import {
86
- StatCard,
87
- StatCardGroup,
88
- StatusChip,
89
- EntityCard,
86
+ Button,
90
87
  EmptyState,
91
- LoaderBlock,
88
+ EntityCard,
92
89
  ErrorState,
93
- Button
90
+ LoaderBlock,
91
+ StatCard,
92
+ StatCardGroup,
93
+ StatusChip
94
94
  } from "@contractspec/lib.design-system";
95
95
  import { jsxDEV } from "react/jsx-dev-runtime";
96
96
  "use client";
@@ -170,11 +170,11 @@ function ToolRegistryView({
170
170
  children: categoryIcons[category]
171
171
  }, undefined, false, undefined, this),
172
172
  /* @__PURE__ */ jsxDEV("h3", {
173
- className: "text-lg font-semibold",
173
+ className: "font-semibold text-lg",
174
174
  children: category
175
175
  }, undefined, false, undefined, this),
176
176
  /* @__PURE__ */ jsxDEV("span", {
177
- className: "bg-muted text-muted-foreground rounded-full px-2 py-0.5 text-xs",
177
+ className: "rounded-full bg-muted px-2 py-0.5 text-muted-foreground text-xs",
178
178
  children: tools.length
179
179
  }, undefined, false, undefined, this)
180
180
  ]