@contractspec/example.agent-console 1.57.0 → 1.59.0
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.
- package/.turbo/turbo-build.log +210 -278
- package/.turbo/turbo-prebuild.log +1 -0
- package/CHANGELOG.md +31 -0
- package/dist/agent/agent.entity.d.ts +35 -40
- package/dist/agent/agent.entity.d.ts.map +1 -1
- package/dist/agent/agent.entity.js +124 -132
- package/dist/agent/agent.enum.d.ts +3 -8
- package/dist/agent/agent.enum.d.ts.map +1 -1
- package/dist/agent/agent.enum.js +22 -30
- package/dist/agent/agent.event.d.ts +105 -111
- package/dist/agent/agent.event.d.ts.map +1 -1
- package/dist/agent/agent.event.js +107 -200
- package/dist/agent/agent.handler.d.ts +74 -77
- package/dist/agent/agent.handler.d.ts.map +1 -1
- package/dist/agent/agent.handler.js +293 -75
- package/dist/agent/agent.operation.d.ts +424 -430
- package/dist/agent/agent.operation.d.ts.map +1 -1
- package/dist/agent/agent.operation.js +728 -478
- package/dist/agent/agent.presentation.d.ts +3 -8
- package/dist/agent/agent.presentation.d.ts.map +1 -1
- package/dist/agent/agent.presentation.js +275 -84
- package/dist/agent/agent.schema.d.ts +371 -376
- package/dist/agent/agent.schema.d.ts.map +1 -1
- package/dist/agent/agent.schema.js +209 -399
- package/dist/agent/agent.test-spec.d.ts +2 -7
- package/dist/agent/agent.test-spec.d.ts.map +1 -1
- package/dist/agent/agent.test-spec.js +56 -62
- package/dist/agent/index.d.ts +11 -8
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +1245 -9
- package/dist/agent.capability.d.ts +1 -6
- package/dist/agent.capability.d.ts.map +1 -1
- package/dist/agent.capability.js +17 -20
- package/dist/agent.feature.d.ts +7 -6
- package/dist/agent.feature.d.ts.map +1 -1
- package/dist/agent.feature.js +117 -303
- package/dist/browser/agent/agent.entity.js +127 -0
- package/dist/browser/agent/agent.enum.js +25 -0
- package/dist/browser/agent/agent.event.js +116 -0
- package/dist/browser/agent/agent.handler.js +301 -0
- package/dist/browser/agent/agent.operation.js +735 -0
- package/dist/browser/agent/agent.presentation.js +279 -0
- package/dist/browser/agent/agent.schema.js +215 -0
- package/dist/browser/agent/agent.test-spec.js +58 -0
- package/dist/browser/agent/index.js +1244 -0
- package/dist/browser/agent.capability.js +16 -0
- package/dist/browser/agent.feature.js +118 -0
- package/dist/browser/docs/agent-console.docblock.js +93 -0
- package/dist/browser/docs/index.js +93 -0
- package/dist/browser/example.js +42 -0
- package/dist/browser/handlers/agent.handlers.js +252 -0
- package/dist/browser/handlers/index.js +799 -0
- package/dist/browser/index.js +5895 -0
- package/dist/browser/presentations/index.js +684 -0
- package/dist/browser/run/index.js +1350 -0
- package/dist/browser/run/run.entity.js +160 -0
- package/dist/browser/run/run.enum.js +34 -0
- package/dist/browser/run/run.event.js +213 -0
- package/dist/browser/run/run.handler.js +254 -0
- package/dist/browser/run/run.operation.js +667 -0
- package/dist/browser/run/run.presentation.js +220 -0
- package/dist/browser/run/run.schema.js +179 -0
- package/dist/browser/run/run.test-spec.js +58 -0
- package/dist/browser/seeders/index.js +21 -0
- package/dist/browser/shared/index.js +334 -0
- package/dist/browser/shared/mock-agents.js +82 -0
- package/dist/browser/shared/mock-runs.js +108 -0
- package/dist/browser/shared/mock-tools.js +146 -0
- package/dist/browser/shared/overlay-types.js +0 -0
- package/dist/browser/tool/index.js +946 -0
- package/dist/browser/tool/tool.entity.js +90 -0
- package/dist/browser/tool/tool.enum.js +26 -0
- package/dist/browser/tool/tool.event.js +99 -0
- package/dist/browser/tool/tool.handler.js +223 -0
- package/dist/browser/tool/tool.operation.js +482 -0
- package/dist/browser/tool/tool.presentation.js +185 -0
- package/dist/browser/tool/tool.schema.js +141 -0
- package/dist/browser/tool/tool.test-spec.js +58 -0
- package/dist/browser/ui/AgentDashboard.js +1607 -0
- package/dist/browser/ui/AgentRunList.js +250 -0
- package/dist/browser/ui/AgentToolRegistry.js +212 -0
- package/dist/browser/ui/hooks/index.js +271 -0
- package/dist/browser/ui/hooks/useAgentList.js +55 -0
- package/dist/browser/ui/hooks/useAgentMutations.js +76 -0
- package/dist/browser/ui/hooks/useRunList.js +55 -0
- package/dist/browser/ui/hooks/useToolList.js +85 -0
- package/dist/browser/ui/index.js +2080 -0
- package/dist/browser/ui/modals/AgentActionsModal.js +304 -0
- package/dist/browser/ui/modals/CreateAgentModal.js +229 -0
- package/dist/browser/ui/modals/index.js +532 -0
- package/dist/browser/ui/overlays/demo-overlays.js +64 -0
- package/dist/browser/ui/overlays/index.js +64 -0
- package/dist/browser/ui/renderers/agent-list.markdown.js +55 -0
- package/dist/browser/ui/renderers/agent-list.renderer.js +180 -0
- package/dist/browser/ui/renderers/dashboard.markdown.js +117 -0
- package/dist/browser/ui/renderers/index.js +446 -0
- package/dist/browser/ui/renderers/run-list.markdown.js +45 -0
- package/dist/browser/ui/renderers/tool-registry.markdown.js +53 -0
- package/dist/browser/ui/views/AgentListView.js +165 -0
- package/dist/browser/ui/views/RunListView.js +247 -0
- package/dist/browser/ui/views/ToolRegistryView.js +209 -0
- package/dist/browser/ui/views/index.js +619 -0
- package/dist/docs/agent-console.docblock.d.ts +2 -1
- package/dist/docs/agent-console.docblock.d.ts.map +1 -0
- package/dist/docs/agent-console.docblock.js +45 -64
- package/dist/docs/index.d.ts +2 -1
- package/dist/docs/index.d.ts.map +1 -0
- package/dist/docs/index.js +94 -1
- package/dist/example.d.ts +2 -6
- package/dist/example.d.ts.map +1 -1
- package/dist/example.js +41 -55
- package/dist/handlers/agent.handlers.d.ts +121 -120
- package/dist/handlers/agent.handlers.d.ts.map +1 -1
- package/dist/handlers/agent.handlers.js +235 -245
- package/dist/handlers/index.d.ts +8 -5
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/handlers/index.js +799 -5
- package/dist/index.d.ts +26 -48
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5896 -50
- package/dist/node/agent/agent.entity.js +127 -0
- package/dist/node/agent/agent.enum.js +25 -0
- package/dist/node/agent/agent.event.js +116 -0
- package/dist/node/agent/agent.handler.js +301 -0
- package/dist/node/agent/agent.operation.js +735 -0
- package/dist/node/agent/agent.presentation.js +279 -0
- package/dist/node/agent/agent.schema.js +215 -0
- package/dist/node/agent/agent.test-spec.js +58 -0
- package/dist/node/agent/index.js +1244 -0
- package/dist/node/agent.capability.js +16 -0
- package/dist/node/agent.feature.js +118 -0
- package/dist/node/docs/agent-console.docblock.js +93 -0
- package/dist/node/docs/index.js +93 -0
- package/dist/node/example.js +42 -0
- package/dist/node/handlers/agent.handlers.js +252 -0
- package/dist/node/handlers/index.js +799 -0
- package/dist/node/index.js +5895 -0
- package/dist/node/presentations/index.js +684 -0
- package/dist/node/run/index.js +1350 -0
- package/dist/node/run/run.entity.js +160 -0
- package/dist/node/run/run.enum.js +34 -0
- package/dist/node/run/run.event.js +213 -0
- package/dist/node/run/run.handler.js +254 -0
- package/dist/node/run/run.operation.js +667 -0
- package/dist/node/run/run.presentation.js +220 -0
- package/dist/node/run/run.schema.js +179 -0
- package/dist/node/run/run.test-spec.js +58 -0
- package/dist/node/seeders/index.js +21 -0
- package/dist/node/shared/index.js +334 -0
- package/dist/node/shared/mock-agents.js +82 -0
- package/dist/node/shared/mock-runs.js +108 -0
- package/dist/node/shared/mock-tools.js +146 -0
- package/dist/node/shared/overlay-types.js +0 -0
- package/dist/node/tool/index.js +946 -0
- package/dist/node/tool/tool.entity.js +90 -0
- package/dist/node/tool/tool.enum.js +26 -0
- package/dist/node/tool/tool.event.js +99 -0
- package/dist/node/tool/tool.handler.js +223 -0
- package/dist/node/tool/tool.operation.js +482 -0
- package/dist/node/tool/tool.presentation.js +185 -0
- package/dist/node/tool/tool.schema.js +141 -0
- package/dist/node/tool/tool.test-spec.js +58 -0
- package/dist/node/ui/AgentDashboard.js +1607 -0
- package/dist/node/ui/AgentRunList.js +250 -0
- package/dist/node/ui/AgentToolRegistry.js +212 -0
- package/dist/node/ui/hooks/index.js +271 -0
- package/dist/node/ui/hooks/useAgentList.js +55 -0
- package/dist/node/ui/hooks/useAgentMutations.js +76 -0
- package/dist/node/ui/hooks/useRunList.js +55 -0
- package/dist/node/ui/hooks/useToolList.js +85 -0
- package/dist/node/ui/index.js +2080 -0
- package/dist/node/ui/modals/AgentActionsModal.js +304 -0
- package/dist/node/ui/modals/CreateAgentModal.js +229 -0
- package/dist/node/ui/modals/index.js +532 -0
- package/dist/node/ui/overlays/demo-overlays.js +64 -0
- package/dist/node/ui/overlays/index.js +64 -0
- package/dist/node/ui/renderers/agent-list.markdown.js +55 -0
- package/dist/node/ui/renderers/agent-list.renderer.js +180 -0
- package/dist/node/ui/renderers/dashboard.markdown.js +117 -0
- package/dist/node/ui/renderers/index.js +446 -0
- package/dist/node/ui/renderers/run-list.markdown.js +45 -0
- package/dist/node/ui/renderers/tool-registry.markdown.js +53 -0
- package/dist/node/ui/views/AgentListView.js +165 -0
- package/dist/node/ui/views/RunListView.js +247 -0
- package/dist/node/ui/views/ToolRegistryView.js +209 -0
- package/dist/node/ui/views/index.js +619 -0
- package/dist/presentations/index.d.ts +9 -4
- package/dist/presentations/index.d.ts.map +1 -0
- package/dist/presentations/index.js +684 -4
- package/dist/run/index.d.ts +11 -8
- package/dist/run/index.d.ts.map +1 -0
- package/dist/run/index.js +1351 -9
- package/dist/run/run.entity.d.ts +55 -60
- package/dist/run/run.entity.d.ts.map +1 -1
- package/dist/run/run.entity.js +155 -199
- package/dist/run/run.enum.d.ts +4 -9
- package/dist/run/run.enum.d.ts.map +1 -1
- package/dist/run/run.enum.js +30 -40
- package/dist/run/run.event.d.ts +255 -261
- package/dist/run/run.event.d.ts.map +1 -1
- package/dist/run/run.event.js +198 -418
- package/dist/run/run.handler.d.ts +169 -172
- package/dist/run/run.handler.d.ts.map +1 -1
- package/dist/run/run.handler.js +246 -74
- package/dist/run/run.operation.d.ts +658 -664
- package/dist/run/run.operation.d.ts.map +1 -1
- package/dist/run/run.operation.js +659 -617
- package/dist/run/run.presentation.d.ts +2 -7
- package/dist/run/run.presentation.d.ts.map +1 -1
- package/dist/run/run.presentation.js +217 -61
- package/dist/run/run.schema.d.ts +367 -372
- package/dist/run/run.schema.d.ts.map +1 -1
- package/dist/run/run.schema.js +172 -330
- package/dist/run/run.test-spec.d.ts +2 -7
- package/dist/run/run.test-spec.d.ts.map +1 -1
- package/dist/run/run.test-spec.js +56 -62
- package/dist/seeders/index.d.ts +4 -8
- package/dist/seeders/index.d.ts.map +1 -1
- package/dist/seeders/index.js +19 -17
- package/dist/shared/index.d.ts +7 -4
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +334 -4
- package/dist/shared/mock-agents.d.ts +77 -80
- package/dist/shared/mock-agents.d.ts.map +1 -1
- package/dist/shared/mock-agents.js +82 -93
- package/dist/shared/mock-runs.d.ts +107 -110
- package/dist/shared/mock-runs.d.ts.map +1 -1
- package/dist/shared/mock-runs.js +108 -117
- package/dist/shared/mock-tools.d.ts +217 -220
- package/dist/shared/mock-tools.d.ts.map +1 -1
- package/dist/shared/mock-tools.js +146 -180
- package/dist/shared/overlay-types.d.ts +25 -28
- package/dist/shared/overlay-types.d.ts.map +1 -1
- package/dist/shared/overlay-types.js +1 -0
- package/dist/tool/index.d.ts +11 -8
- package/dist/tool/index.d.ts.map +1 -0
- package/dist/tool/index.js +947 -9
- package/dist/tool/tool.entity.d.ts +23 -28
- package/dist/tool/tool.entity.d.ts.map +1 -1
- package/dist/tool/tool.entity.js +87 -101
- package/dist/tool/tool.enum.d.ts +3 -8
- package/dist/tool/tool.enum.d.ts.map +1 -1
- package/dist/tool/tool.enum.js +23 -31
- package/dist/tool/tool.event.d.ts +84 -90
- package/dist/tool/tool.event.d.ts.map +1 -1
- package/dist/tool/tool.event.js +92 -151
- package/dist/tool/tool.handler.d.ts +266 -269
- package/dist/tool/tool.handler.d.ts.map +1 -1
- package/dist/tool/tool.handler.js +213 -76
- package/dist/tool/tool.operation.d.ts +359 -365
- package/dist/tool/tool.operation.d.ts.map +1 -1
- package/dist/tool/tool.operation.js +477 -400
- package/dist/tool/tool.presentation.d.ts +2 -7
- package/dist/tool/tool.presentation.d.ts.map +1 -1
- package/dist/tool/tool.presentation.js +182 -61
- package/dist/tool/tool.schema.d.ts +196 -201
- package/dist/tool/tool.schema.d.ts.map +1 -1
- package/dist/tool/tool.schema.js +137 -231
- package/dist/tool/tool.test-spec.d.ts +2 -7
- package/dist/tool/tool.test-spec.d.ts.map +1 -1
- package/dist/tool/tool.test-spec.js +56 -62
- package/dist/ui/AgentDashboard.d.ts +1 -6
- package/dist/ui/AgentDashboard.d.ts.map +1 -1
- package/dist/ui/AgentDashboard.js +1598 -410
- package/dist/ui/AgentRunList.d.ts +7 -2
- package/dist/ui/AgentRunList.d.ts.map +1 -0
- package/dist/ui/AgentRunList.js +249 -3
- package/dist/ui/AgentToolRegistry.d.ts +7 -2
- package/dist/ui/AgentToolRegistry.d.ts.map +1 -0
- package/dist/ui/AgentToolRegistry.js +211 -3
- package/dist/ui/hooks/index.d.ts +8 -6
- package/dist/ui/hooks/index.d.ts.map +1 -0
- package/dist/ui/hooks/index.js +270 -6
- package/dist/ui/hooks/useAgentList.d.ts +21 -25
- package/dist/ui/hooks/useAgentList.d.ts.map +1 -1
- package/dist/ui/hooks/useAgentList.js +52 -62
- package/dist/ui/hooks/useAgentMutations.d.ts +22 -25
- package/dist/ui/hooks/useAgentMutations.d.ts.map +1 -1
- package/dist/ui/hooks/useAgentMutations.js +73 -120
- package/dist/ui/hooks/useRunList.d.ts +17 -21
- package/dist/ui/hooks/useRunList.d.ts.map +1 -1
- package/dist/ui/hooks/useRunList.js +52 -62
- package/dist/ui/hooks/useToolList.d.ts +32 -36
- package/dist/ui/hooks/useToolList.d.ts.map +1 -1
- package/dist/ui/hooks/useToolList.js +82 -92
- package/dist/ui/index.d.ts +9 -24
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +2081 -24
- package/dist/ui/modals/AgentActionsModal.d.ts +11 -24
- package/dist/ui/modals/AgentActionsModal.d.ts.map +1 -1
- package/dist/ui/modals/AgentActionsModal.js +300 -257
- package/dist/ui/modals/CreateAgentModal.d.ts +12 -21
- package/dist/ui/modals/CreateAgentModal.d.ts.map +1 -1
- package/dist/ui/modals/CreateAgentModal.js +226 -210
- package/dist/ui/modals/index.d.ts +3 -3
- package/dist/ui/modals/index.d.ts.map +1 -0
- package/dist/ui/modals/index.js +532 -3
- package/dist/ui/overlays/demo-overlays.d.ts +10 -8
- package/dist/ui/overlays/demo-overlays.d.ts.map +1 -1
- package/dist/ui/overlays/demo-overlays.js +63 -71
- package/dist/ui/overlays/index.d.ts +2 -2
- package/dist/ui/overlays/index.d.ts.map +1 -0
- package/dist/ui/overlays/index.js +65 -3
- package/dist/ui/renderers/agent-list.markdown.d.ts +9 -8
- package/dist/ui/renderers/agent-list.markdown.d.ts.map +1 -1
- package/dist/ui/renderers/agent-list.markdown.js +55 -50
- package/dist/ui/renderers/agent-list.renderer.d.ts +5 -6
- package/dist/ui/renderers/agent-list.renderer.d.ts.map +1 -1
- package/dist/ui/renderers/agent-list.renderer.js +179 -17
- package/dist/ui/renderers/dashboard.markdown.d.ts +9 -8
- package/dist/ui/renderers/dashboard.markdown.d.ts.map +1 -1
- package/dist/ui/renderers/dashboard.markdown.js +115 -97
- package/dist/ui/renderers/index.d.ts +9 -6
- package/dist/ui/renderers/index.d.ts.map +1 -0
- package/dist/ui/renderers/index.js +446 -6
- package/dist/ui/renderers/run-list.markdown.d.ts +9 -8
- package/dist/ui/renderers/run-list.markdown.d.ts.map +1 -1
- package/dist/ui/renderers/run-list.markdown.js +42 -40
- package/dist/ui/renderers/tool-registry.markdown.d.ts +9 -8
- package/dist/ui/renderers/tool-registry.markdown.d.ts.map +1 -1
- package/dist/ui/renderers/tool-registry.markdown.js +52 -53
- package/dist/ui/views/AgentListView.d.ts +1 -6
- package/dist/ui/views/AgentListView.d.ts.map +1 -1
- package/dist/ui/views/AgentListView.js +161 -88
- package/dist/ui/views/RunListView.d.ts +4 -11
- package/dist/ui/views/RunListView.d.ts.map +1 -1
- package/dist/ui/views/RunListView.js +237 -154
- package/dist/ui/views/ToolRegistryView.d.ts +4 -11
- package/dist/ui/views/ToolRegistryView.d.ts.map +1 -1
- package/dist/ui/views/ToolRegistryView.js +205 -92
- package/dist/ui/views/index.d.ts +7 -4
- package/dist/ui/views/index.d.ts.map +1 -0
- package/dist/ui/views/index.js +619 -4
- package/package.json +656 -118
- package/tsdown.config.js +1 -2
- package/.turbo/turbo-build$colon$bundle.log +0 -285
- package/dist/agent/agent.entity.js.map +0 -1
- package/dist/agent/agent.enum.js.map +0 -1
- package/dist/agent/agent.event.js.map +0 -1
- package/dist/agent/agent.handler.js.map +0 -1
- package/dist/agent/agent.operation.js.map +0 -1
- package/dist/agent/agent.presentation.js.map +0 -1
- package/dist/agent/agent.schema.js.map +0 -1
- package/dist/agent/agent.test-spec.js.map +0 -1
- package/dist/agent.capability.js.map +0 -1
- package/dist/agent.feature.js.map +0 -1
- package/dist/docs/agent-console.docblock.js.map +0 -1
- package/dist/example.js.map +0 -1
- package/dist/handlers/agent.handlers.js.map +0 -1
- package/dist/run/run.entity.js.map +0 -1
- package/dist/run/run.enum.js.map +0 -1
- package/dist/run/run.event.js.map +0 -1
- package/dist/run/run.handler.js.map +0 -1
- package/dist/run/run.operation.js.map +0 -1
- package/dist/run/run.presentation.js.map +0 -1
- package/dist/run/run.schema.js.map +0 -1
- package/dist/run/run.test-spec.js.map +0 -1
- package/dist/seeders/index.js.map +0 -1
- package/dist/shared/mock-agents.js.map +0 -1
- package/dist/shared/mock-runs.js.map +0 -1
- package/dist/shared/mock-tools.js.map +0 -1
- package/dist/tool/tool.entity.js.map +0 -1
- package/dist/tool/tool.enum.js.map +0 -1
- package/dist/tool/tool.event.js.map +0 -1
- package/dist/tool/tool.handler.js.map +0 -1
- package/dist/tool/tool.operation.js.map +0 -1
- package/dist/tool/tool.presentation.js.map +0 -1
- package/dist/tool/tool.schema.js.map +0 -1
- package/dist/tool/tool.test-spec.js.map +0 -1
- package/dist/ui/AgentDashboard.js.map +0 -1
- package/dist/ui/hooks/useAgentList.js.map +0 -1
- package/dist/ui/hooks/useAgentMutations.js.map +0 -1
- package/dist/ui/hooks/useRunList.js.map +0 -1
- package/dist/ui/hooks/useToolList.js.map +0 -1
- package/dist/ui/modals/AgentActionsModal.js.map +0 -1
- package/dist/ui/modals/CreateAgentModal.js.map +0 -1
- package/dist/ui/overlays/demo-overlays.js.map +0 -1
- package/dist/ui/renderers/agent-list.markdown.js.map +0 -1
- package/dist/ui/renderers/agent-list.renderer.js.map +0 -1
- package/dist/ui/renderers/dashboard.markdown.js.map +0 -1
- package/dist/ui/renderers/run-list.markdown.js.map +0 -1
- package/dist/ui/renderers/tool-registry.markdown.js.map +0 -1
- package/dist/ui/views/AgentListView.js.map +0 -1
- package/dist/ui/views/RunListView.js.map +0 -1
- package/dist/ui/views/ToolRegistryView.js.map +0 -1
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,124 +1,77 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/ui/hooks/useAgentMutations.ts
|
|
1
3
|
import { useCallback, useState } from "react";
|
|
2
4
|
import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
|
|
3
|
-
|
|
4
|
-
//#region src/ui/hooks/useAgentMutations.ts
|
|
5
|
-
/**
|
|
6
|
-
* Hook for Agent Console mutations (commands)
|
|
7
|
-
*
|
|
8
|
-
* Uses runtime-local database-backed handlers for:
|
|
9
|
-
* - CreateAgentCommand
|
|
10
|
-
* - UpdateAgentCommand
|
|
11
|
-
*/
|
|
12
5
|
function useAgentMutations(options = {}) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
setUpdateState({
|
|
82
|
-
loading: false,
|
|
83
|
-
error,
|
|
84
|
-
data: null
|
|
85
|
-
});
|
|
86
|
-
options.onError?.(error);
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
}, [agent, options]);
|
|
90
|
-
return {
|
|
91
|
-
createAgent,
|
|
92
|
-
updateAgent,
|
|
93
|
-
activateAgent: useCallback(async (agentId) => {
|
|
94
|
-
return updateAgent({
|
|
95
|
-
id: agentId,
|
|
96
|
-
status: "ACTIVE"
|
|
97
|
-
});
|
|
98
|
-
}, [updateAgent]),
|
|
99
|
-
pauseAgent: useCallback(async (agentId) => {
|
|
100
|
-
return updateAgent({
|
|
101
|
-
id: agentId,
|
|
102
|
-
status: "PAUSED"
|
|
103
|
-
});
|
|
104
|
-
}, [updateAgent]),
|
|
105
|
-
archiveAgent: useCallback(async (agentId) => {
|
|
106
|
-
return updateAgent({
|
|
107
|
-
id: agentId,
|
|
108
|
-
status: "ARCHIVED"
|
|
109
|
-
});
|
|
110
|
-
}, [updateAgent]),
|
|
111
|
-
executeAgent: useCallback(async (input) => {
|
|
112
|
-
console.log("Execute agent:", input);
|
|
113
|
-
options.onSuccess?.();
|
|
114
|
-
return null;
|
|
115
|
-
}, [options]),
|
|
116
|
-
createState,
|
|
117
|
-
updateState,
|
|
118
|
-
isLoading: createState.loading || updateState.loading
|
|
119
|
-
};
|
|
6
|
+
const { handlers, projectId } = useTemplateRuntime();
|
|
7
|
+
const { agent } = handlers;
|
|
8
|
+
const [createState, setCreateState] = useState({
|
|
9
|
+
loading: false,
|
|
10
|
+
error: null,
|
|
11
|
+
data: null
|
|
12
|
+
});
|
|
13
|
+
const [updateState, setUpdateState] = useState({
|
|
14
|
+
loading: false,
|
|
15
|
+
error: null,
|
|
16
|
+
data: null
|
|
17
|
+
});
|
|
18
|
+
const createAgent = useCallback(async (input) => {
|
|
19
|
+
setCreateState({ loading: true, error: null, data: null });
|
|
20
|
+
try {
|
|
21
|
+
const result = await agent.createAgent(input, {
|
|
22
|
+
projectId,
|
|
23
|
+
organizationId: "demo-org"
|
|
24
|
+
});
|
|
25
|
+
setCreateState({ loading: false, error: null, data: result });
|
|
26
|
+
options.onSuccess?.();
|
|
27
|
+
return result;
|
|
28
|
+
} catch (err) {
|
|
29
|
+
const error = err instanceof Error ? err : new Error("Failed to create agent");
|
|
30
|
+
setCreateState({ loading: false, error, data: null });
|
|
31
|
+
options.onError?.(error);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}, [agent, projectId, options]);
|
|
35
|
+
const updateAgent = useCallback(async (input) => {
|
|
36
|
+
setUpdateState({ loading: true, error: null, data: null });
|
|
37
|
+
try {
|
|
38
|
+
const result = await agent.updateAgent(input);
|
|
39
|
+
setUpdateState({ loading: false, error: null, data: result });
|
|
40
|
+
options.onSuccess?.();
|
|
41
|
+
return result;
|
|
42
|
+
} catch (err) {
|
|
43
|
+
const error = err instanceof Error ? err : new Error("Failed to update agent");
|
|
44
|
+
setUpdateState({ loading: false, error, data: null });
|
|
45
|
+
options.onError?.(error);
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}, [agent, options]);
|
|
49
|
+
const activateAgent = useCallback(async (agentId) => {
|
|
50
|
+
return updateAgent({ id: agentId, status: "ACTIVE" });
|
|
51
|
+
}, [updateAgent]);
|
|
52
|
+
const pauseAgent = useCallback(async (agentId) => {
|
|
53
|
+
return updateAgent({ id: agentId, status: "PAUSED" });
|
|
54
|
+
}, [updateAgent]);
|
|
55
|
+
const archiveAgent = useCallback(async (agentId) => {
|
|
56
|
+
return updateAgent({ id: agentId, status: "ARCHIVED" });
|
|
57
|
+
}, [updateAgent]);
|
|
58
|
+
const executeAgent = useCallback(async (input) => {
|
|
59
|
+
console.log("Execute agent:", input);
|
|
60
|
+
options.onSuccess?.();
|
|
61
|
+
return null;
|
|
62
|
+
}, [options]);
|
|
63
|
+
return {
|
|
64
|
+
createAgent,
|
|
65
|
+
updateAgent,
|
|
66
|
+
activateAgent,
|
|
67
|
+
pauseAgent,
|
|
68
|
+
archiveAgent,
|
|
69
|
+
executeAgent,
|
|
70
|
+
createState,
|
|
71
|
+
updateState,
|
|
72
|
+
isLoading: createState.loading || updateState.loading
|
|
73
|
+
};
|
|
120
74
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
//# sourceMappingURL=useAgentMutations.js.map
|
|
75
|
+
export {
|
|
76
|
+
useAgentMutations
|
|
77
|
+
};
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
import { ListRunsOutput as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
status?: Run['status'] | 'all';
|
|
10
|
-
limit?: number;
|
|
1
|
+
import type { ListRunsOutput as RuntimeListRunsOutput, Run as RuntimeRun, RunMetrics as RuntimeRunMetrics } from '../../handlers/agent.handlers';
|
|
2
|
+
export type Run = RuntimeRun;
|
|
3
|
+
export type ListRunsOutput = RuntimeListRunsOutput;
|
|
4
|
+
export type RunMetrics = RuntimeRunMetrics;
|
|
5
|
+
export interface UseRunListOptions {
|
|
6
|
+
agentId?: string;
|
|
7
|
+
status?: Run['status'] | 'all';
|
|
8
|
+
limit?: number;
|
|
11
9
|
}
|
|
12
|
-
declare function useRunList(options?: UseRunListOptions): {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
export declare function useRunList(options?: UseRunListOptions): {
|
|
11
|
+
data: RuntimeListRunsOutput | null;
|
|
12
|
+
metrics: RuntimeRunMetrics | null;
|
|
13
|
+
loading: boolean;
|
|
14
|
+
error: Error | null;
|
|
15
|
+
page: number;
|
|
16
|
+
refetch: () => Promise<void>;
|
|
17
|
+
nextPage: () => void;
|
|
18
|
+
prevPage: () => false | void;
|
|
21
19
|
};
|
|
22
|
-
//#endregion
|
|
23
|
-
export { ListRunsOutput, Run, RunMetrics, UseRunListOptions, useRunList };
|
|
24
20
|
//# sourceMappingURL=useRunList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRunList.d.ts","
|
|
1
|
+
{"version":3,"file":"useRunList.d.ts","sourceRoot":"","sources":["../../../src/ui/hooks/useRunList.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,cAAc,IAAI,qBAAqB,EACvC,GAAG,IAAI,UAAU,EACjB,UAAU,IAAI,iBAAiB,EAEhC,MAAM,+BAA+B,CAAC;AAGvC,MAAM,MAAM,GAAG,GAAG,UAAU,CAAC;AAC7B,MAAM,MAAM,cAAc,GAAG,qBAAqB,CAAC;AACnD,MAAM,MAAM,UAAU,GAAG,iBAAiB,CAAC;AAE3C,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,GAAG,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB;;;;;;;;;EAuDzD"}
|
|
@@ -1,66 +1,56 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/ui/hooks/useRunList.ts
|
|
1
3
|
import { useCallback, useEffect, useState } from "react";
|
|
2
4
|
import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
|
|
3
|
-
|
|
4
|
-
//#region src/ui/hooks/useRunList.ts
|
|
5
|
-
/**
|
|
6
|
-
* Hook for fetching and managing run list data
|
|
7
|
-
*
|
|
8
|
-
* Uses runtime-local database-backed handlers.
|
|
9
|
-
*/
|
|
10
5
|
function useRunList(options = {}) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
refetch: fetchData,
|
|
59
|
-
nextPage: () => setPage((p) => p + 1),
|
|
60
|
-
prevPage: () => page > 1 && setPage((p) => p - 1)
|
|
61
|
-
};
|
|
6
|
+
const { handlers, projectId } = useTemplateRuntime();
|
|
7
|
+
const { agent } = handlers;
|
|
8
|
+
const [data, setData] = useState(null);
|
|
9
|
+
const [metrics, setMetrics] = useState(null);
|
|
10
|
+
const [loading, setLoading] = useState(true);
|
|
11
|
+
const [error, setError] = useState(null);
|
|
12
|
+
const [page, setPage] = useState(1);
|
|
13
|
+
const fetchData = useCallback(async () => {
|
|
14
|
+
setLoading(true);
|
|
15
|
+
setError(null);
|
|
16
|
+
try {
|
|
17
|
+
const [runsResult, metricsResult] = await Promise.all([
|
|
18
|
+
agent.listRuns({
|
|
19
|
+
projectId,
|
|
20
|
+
agentId: options.agentId,
|
|
21
|
+
status: options.status === "all" ? undefined : options.status,
|
|
22
|
+
limit: options.limit ?? 20,
|
|
23
|
+
offset: (page - 1) * (options.limit ?? 20)
|
|
24
|
+
}),
|
|
25
|
+
agent.getRunMetrics({
|
|
26
|
+
projectId,
|
|
27
|
+
agentId: options.agentId,
|
|
28
|
+
startDate: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000),
|
|
29
|
+
endDate: new Date
|
|
30
|
+
})
|
|
31
|
+
]);
|
|
32
|
+
setData(runsResult);
|
|
33
|
+
setMetrics(metricsResult);
|
|
34
|
+
} catch (err) {
|
|
35
|
+
setError(err instanceof Error ? err : new Error("Unknown error"));
|
|
36
|
+
} finally {
|
|
37
|
+
setLoading(false);
|
|
38
|
+
}
|
|
39
|
+
}, [agent, projectId, options.agentId, options.status, options.limit, page]);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
fetchData();
|
|
42
|
+
}, [fetchData]);
|
|
43
|
+
return {
|
|
44
|
+
data,
|
|
45
|
+
metrics,
|
|
46
|
+
loading,
|
|
47
|
+
error,
|
|
48
|
+
page,
|
|
49
|
+
refetch: fetchData,
|
|
50
|
+
nextPage: () => setPage((p) => p + 1),
|
|
51
|
+
prevPage: () => page > 1 && setPage((p) => p - 1)
|
|
52
|
+
};
|
|
62
53
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
//# sourceMappingURL=useRunList.js.map
|
|
54
|
+
export {
|
|
55
|
+
useRunList
|
|
56
|
+
};
|
|
@@ -1,40 +1,36 @@
|
|
|
1
|
-
import { ListToolsOutput as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type
|
|
5
|
-
type
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
status?: ToolStatus | 'all';
|
|
12
|
-
limit?: number;
|
|
1
|
+
import type { ListToolsOutput as RuntimeListToolsOutput, Tool as RuntimeTool } from '../../handlers/agent.handlers';
|
|
2
|
+
export type Tool = RuntimeTool;
|
|
3
|
+
export type ListToolsOutput = RuntimeListToolsOutput;
|
|
4
|
+
export type ToolCategory = Tool['category'];
|
|
5
|
+
export type ToolStatus = Tool['status'];
|
|
6
|
+
export interface UseToolListOptions {
|
|
7
|
+
search?: string;
|
|
8
|
+
category?: ToolCategory;
|
|
9
|
+
status?: ToolStatus | 'all';
|
|
10
|
+
limit?: number;
|
|
13
11
|
}
|
|
14
|
-
declare function useToolList(options?: UseToolListOptions): {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
12
|
+
export declare function useToolList(options?: UseToolListOptions): {
|
|
13
|
+
data: RuntimeListToolsOutput | null;
|
|
14
|
+
loading: boolean;
|
|
15
|
+
error: Error | null;
|
|
16
|
+
stats: {
|
|
17
|
+
total: number;
|
|
18
|
+
active: number;
|
|
19
|
+
deprecated: number;
|
|
20
|
+
disabled: number;
|
|
21
|
+
topCategories: {
|
|
22
|
+
category: string;
|
|
23
|
+
count: number;
|
|
24
|
+
}[];
|
|
25
|
+
} | null;
|
|
26
|
+
groupedByCategory: Record<string, RuntimeTool[]> | {};
|
|
27
|
+
categoryStats: never[] | {
|
|
28
|
+
category: string;
|
|
29
|
+
count: number;
|
|
26
30
|
}[];
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
count: number;
|
|
32
|
-
}[];
|
|
33
|
-
page: number;
|
|
34
|
-
refetch: () => Promise<void>;
|
|
35
|
-
nextPage: () => void;
|
|
36
|
-
prevPage: () => false | void;
|
|
31
|
+
page: number;
|
|
32
|
+
refetch: () => Promise<void>;
|
|
33
|
+
nextPage: () => void;
|
|
34
|
+
prevPage: () => false | void;
|
|
37
35
|
};
|
|
38
|
-
//#endregion
|
|
39
|
-
export { ListToolsOutput, Tool, ToolCategory, ToolStatus, UseToolListOptions, useToolList };
|
|
40
36
|
//# sourceMappingURL=useToolList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useToolList.d.ts","
|
|
1
|
+
{"version":3,"file":"useToolList.d.ts","sourceRoot":"","sources":["../../../src/ui/hooks/useToolList.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,eAAe,IAAI,sBAAsB,EACzC,IAAI,IAAI,WAAW,EAEpB,MAAM,+BAA+B,CAAC;AAGvC,MAAM,MAAM,IAAI,GAAG,WAAW,CAAC;AAC/B,MAAM,MAAM,eAAe,GAAG,sBAAsB,CAAC;AAErD,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;AAC5C,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;AAExC,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,MAAM,CAAC,EAAE,UAAU,GAAG,KAAK,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB;;;;;;;;;;;;;;;;;;;;;;;EA8F3D"}
|
|
@@ -1,96 +1,86 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/ui/hooks/useToolList.ts
|
|
1
3
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
4
|
import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
|
|
3
|
-
|
|
4
|
-
//#region src/ui/hooks/useToolList.ts
|
|
5
|
-
/**
|
|
6
|
-
* Hook for fetching and managing tool list data
|
|
7
|
-
*
|
|
8
|
-
* Uses runtime-local database-backed handlers.
|
|
9
|
-
*/
|
|
10
5
|
function useToolList(options = {}) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
refetch: fetchData,
|
|
89
|
-
nextPage: () => setPage((p) => p + 1),
|
|
90
|
-
prevPage: () => page > 1 && setPage((p) => p - 1)
|
|
91
|
-
};
|
|
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
|
+
};
|
|
92
83
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
//# sourceMappingURL=useToolList.js.map
|
|
84
|
+
export {
|
|
85
|
+
useToolList
|
|
86
|
+
};
|