@contractspec/example.agent-console 3.7.6 → 3.8.2
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 +126 -105
- package/AGENTS.md +52 -31
- package/CHANGELOG.md +29 -0
- package/README.md +112 -83
- package/dist/agent/agent.event.js +1 -1
- package/dist/agent/agent.handler.d.ts +3 -0
- package/dist/agent/agent.handler.js +730 -1
- package/dist/agent/agent.operation.js +1 -1
- package/dist/agent/index.d.ts +5 -5
- package/dist/agent/index.js +74 -73
- package/dist/agent.feature.js +179 -0
- package/dist/browser/agent/agent.event.js +1 -1
- package/dist/browser/agent/agent.handler.js +730 -1
- package/dist/browser/agent/agent.operation.js +1 -1
- package/dist/browser/agent/index.js +74 -73
- package/dist/browser/agent.feature.js +179 -0
- package/dist/browser/docs/agent-console.docblock.js +11 -8
- package/dist/browser/docs/index.js +11 -8
- package/dist/browser/example.js +2 -3
- package/dist/browser/handlers/agent.handlers.js +1883 -2
- package/dist/browser/handlers/index.js +2142 -8
- package/dist/browser/index.js +4075 -3161
- package/dist/browser/presentations/index.js +51 -51
- package/dist/browser/run/index.js +380 -374
- package/dist/browser/run/run.event.js +2 -2
- package/dist/browser/run/run.handler.js +666 -1
- package/dist/browser/run/run.presentation.js +2 -2
- package/dist/browser/shared/index.js +293 -1
- package/dist/browser/shared/mock-runs.js +5 -0
- package/dist/browser/tool/index.js +161 -161
- package/dist/browser/tool/tool.event.js +1 -1
- package/dist/browser/tool/tool.handler.js +479 -3
- package/dist/browser/tool/tool.presentation.js +2 -2
- package/dist/browser/ui/AgentDashboard.js +1816 -931
- package/dist/browser/ui/AgentDashboard.visualizations.js +217 -0
- package/dist/browser/ui/AgentRunList.js +360 -128
- package/dist/browser/ui/AgentToolRegistry.js +9 -9
- package/dist/browser/ui/hooks/index.js +611 -161
- package/dist/browser/ui/hooks/useAgentList.js +1 -1
- package/dist/browser/ui/hooks/useAgentMutations.js +444 -9
- package/dist/browser/ui/hooks/useRunList.js +26 -11
- package/dist/browser/ui/hooks/useToolList.js +1 -1
- package/dist/browser/ui/index.js +2161 -1258
- package/dist/browser/ui/modals/AgentActionsModal.js +13 -13
- package/dist/browser/ui/modals/CreateAgentModal.js +15 -15
- package/dist/browser/ui/modals/index.js +297 -297
- package/dist/browser/ui/renderers/agent-list.markdown.js +14 -5
- package/dist/browser/ui/renderers/agent-list.renderer.js +7 -7
- package/dist/browser/ui/renderers/dashboard.markdown.js +207 -36
- package/dist/browser/ui/renderers/index.js +359 -163
- package/dist/browser/ui/renderers/run-list.markdown.js +9 -4
- package/dist/browser/ui/renderers/tool-registry.markdown.js +15 -4
- package/dist/browser/ui/views/AgentListView.js +7 -7
- package/dist/browser/ui/views/RunDataTable.js +326 -0
- package/dist/browser/ui/views/RunListView.js +360 -128
- package/dist/browser/ui/views/ToolRegistryView.js +9 -9
- package/dist/browser/ui/views/index.js +478 -246
- package/dist/browser/ui/views/run-data-table.columns.js +271 -0
- package/dist/browser/ui/views/run-list.shared.js +177 -0
- package/dist/browser/visualizations/catalog.js +134 -0
- package/dist/browser/visualizations/index.js +187 -0
- package/dist/browser/visualizations/selectors.js +181 -0
- package/dist/docs/agent-console.docblock.js +11 -8
- package/dist/docs/index.js +11 -8
- package/dist/example.js +2 -3
- package/dist/example.test.d.ts +1 -0
- package/dist/handlers/agent.handlers.d.ts +2 -0
- package/dist/handlers/agent.handlers.js +1883 -2
- package/dist/handlers/index.d.ts +2 -4
- package/dist/handlers/index.js +2142 -8
- package/dist/handlers/mock-handlers.test.d.ts +1 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.js +4075 -3161
- package/dist/node/agent/agent.event.js +1 -1
- package/dist/node/agent/agent.handler.js +730 -1
- package/dist/node/agent/agent.operation.js +1 -1
- package/dist/node/agent/index.js +74 -73
- package/dist/node/agent.feature.js +179 -0
- package/dist/node/docs/agent-console.docblock.js +11 -8
- package/dist/node/docs/index.js +11 -8
- package/dist/node/example.js +2 -3
- package/dist/node/handlers/agent.handlers.js +1883 -2
- package/dist/node/handlers/index.js +2142 -8
- package/dist/node/index.js +4075 -3161
- package/dist/node/presentations/index.js +51 -51
- package/dist/node/run/index.js +380 -374
- package/dist/node/run/run.event.js +2 -2
- package/dist/node/run/run.handler.js +666 -1
- package/dist/node/run/run.presentation.js +2 -2
- package/dist/node/shared/index.js +293 -1
- package/dist/node/shared/mock-runs.js +5 -0
- package/dist/node/tool/index.js +161 -161
- package/dist/node/tool/tool.event.js +1 -1
- package/dist/node/tool/tool.handler.js +479 -3
- package/dist/node/tool/tool.presentation.js +2 -2
- package/dist/node/ui/AgentDashboard.js +1816 -931
- package/dist/node/ui/AgentDashboard.visualizations.js +217 -0
- package/dist/node/ui/AgentRunList.js +360 -128
- package/dist/node/ui/AgentToolRegistry.js +9 -9
- package/dist/node/ui/hooks/index.js +611 -161
- package/dist/node/ui/hooks/useAgentList.js +1 -1
- package/dist/node/ui/hooks/useAgentMutations.js +444 -9
- package/dist/node/ui/hooks/useRunList.js +26 -11
- package/dist/node/ui/hooks/useToolList.js +1 -1
- package/dist/node/ui/index.js +2161 -1258
- package/dist/node/ui/modals/AgentActionsModal.js +13 -13
- package/dist/node/ui/modals/CreateAgentModal.js +15 -15
- package/dist/node/ui/modals/index.js +297 -297
- package/dist/node/ui/renderers/agent-list.markdown.js +14 -5
- package/dist/node/ui/renderers/agent-list.renderer.js +7 -7
- package/dist/node/ui/renderers/dashboard.markdown.js +207 -36
- package/dist/node/ui/renderers/index.js +359 -163
- package/dist/node/ui/renderers/run-list.markdown.js +9 -4
- package/dist/node/ui/renderers/tool-registry.markdown.js +15 -4
- package/dist/node/ui/views/AgentListView.js +7 -7
- package/dist/node/ui/views/RunDataTable.js +326 -0
- package/dist/node/ui/views/RunListView.js +360 -128
- package/dist/node/ui/views/ToolRegistryView.js +9 -9
- package/dist/node/ui/views/index.js +478 -246
- package/dist/node/ui/views/run-data-table.columns.js +271 -0
- package/dist/node/ui/views/run-list.shared.js +177 -0
- package/dist/node/visualizations/catalog.js +134 -0
- package/dist/node/visualizations/index.js +187 -0
- package/dist/node/visualizations/selectors.js +181 -0
- package/dist/presentations/index.d.ts +3 -5
- package/dist/presentations/index.js +51 -51
- package/dist/proof/index.d.ts +2 -0
- package/dist/proof/meetup-proof.d.ts +10 -0
- package/dist/proof/meetup-proof.runtime.d.ts +22 -0
- package/dist/proof/meetup-proof.scenario.d.ts +2 -0
- package/dist/proof/meetup-proof.suite.d.ts +1 -0
- package/dist/proof/meetup-proof.test.d.ts +1 -0
- package/dist/run/index.d.ts +7 -7
- package/dist/run/index.js +380 -374
- package/dist/run/run.event.js +2 -2
- package/dist/run/run.handler.d.ts +7 -0
- package/dist/run/run.handler.js +666 -1
- package/dist/run/run.presentation.js +2 -2
- package/dist/shared/demo-dashboard-data.d.ts +16 -0
- package/dist/shared/demo-runtime-seed.d.ts +17 -0
- package/dist/shared/demo-runtime.d.ts +8 -0
- package/dist/shared/demo-runtime.test.d.ts +1 -0
- package/dist/shared/index.d.ts +4 -1
- package/dist/shared/index.js +293 -1
- package/dist/shared/mock-runs.d.ts +4 -0
- package/dist/shared/mock-runs.js +5 -0
- package/dist/tool/index.d.ts +7 -7
- package/dist/tool/index.js +161 -161
- package/dist/tool/tool.event.js +1 -1
- package/dist/tool/tool.handler.d.ts +3 -0
- package/dist/tool/tool.handler.js +479 -3
- package/dist/tool/tool.presentation.js +2 -2
- package/dist/ui/AgentDashboard.js +1816 -931
- package/dist/ui/AgentDashboard.sandbox.test.d.ts +1 -0
- package/dist/ui/AgentDashboard.visualizations.d.ts +4 -0
- package/dist/ui/AgentDashboard.visualizations.js +218 -0
- package/dist/ui/AgentRunList.js +360 -128
- package/dist/ui/AgentToolRegistry.js +9 -9
- package/dist/ui/hooks/index.d.ts +4 -4
- package/dist/ui/hooks/index.js +611 -161
- package/dist/ui/hooks/useAgentList.d.ts +5 -0
- package/dist/ui/hooks/useAgentList.js +1 -1
- package/dist/ui/hooks/useAgentMutations.d.ts +9 -2
- package/dist/ui/hooks/useAgentMutations.js +444 -9
- package/dist/ui/hooks/useRunList.d.ts +13 -2
- package/dist/ui/hooks/useRunList.js +26 -11
- package/dist/ui/hooks/useToolList.d.ts +5 -0
- package/dist/ui/hooks/useToolList.js +1 -1
- package/dist/ui/index.d.ts +3 -3
- package/dist/ui/index.js +2161 -1258
- package/dist/ui/modals/AgentActionsModal.js +13 -13
- package/dist/ui/modals/CreateAgentModal.js +15 -15
- package/dist/ui/modals/index.d.ts +1 -1
- package/dist/ui/modals/index.js +297 -297
- package/dist/ui/renderers/agent-list.markdown.d.ts +5 -0
- package/dist/ui/renderers/agent-list.markdown.js +14 -5
- package/dist/ui/renderers/agent-list.renderer.js +7 -7
- package/dist/ui/renderers/dashboard.markdown.d.ts +5 -0
- package/dist/ui/renderers/dashboard.markdown.js +207 -36
- package/dist/ui/renderers/index.d.ts +2 -2
- package/dist/ui/renderers/index.js +359 -163
- package/dist/ui/renderers/run-list.markdown.d.ts +5 -0
- package/dist/ui/renderers/run-list.markdown.js +9 -4
- package/dist/ui/renderers/tool-registry.markdown.d.ts +6 -1
- package/dist/ui/renderers/tool-registry.markdown.js +15 -4
- package/dist/ui/views/AgentListView.js +7 -7
- package/dist/ui/views/RunDataTable.d.ts +18 -0
- package/dist/ui/views/RunDataTable.js +327 -0
- package/dist/ui/views/RunListView.js +360 -128
- package/dist/ui/views/ToolRegistryView.js +9 -9
- package/dist/ui/views/index.js +478 -246
- package/dist/ui/views/run-data-table.columns.d.ts +3 -0
- package/dist/ui/views/run-data-table.columns.js +272 -0
- package/dist/ui/views/run-list.shared.d.ts +14 -0
- package/dist/ui/views/run-list.shared.js +178 -0
- package/dist/visualizations/catalog.d.ts +10 -0
- package/dist/visualizations/catalog.js +135 -0
- package/dist/visualizations/index.d.ts +2 -0
- package/dist/visualizations/index.js +188 -0
- package/dist/visualizations/selectors.d.ts +3 -0
- package/dist/visualizations/selectors.js +182 -0
- package/dist/visualizations/selectors.test.d.ts +1 -0
- package/package.json +114 -12
- package/proofs/agent-console-meetup.replay.json +220 -0
- package/src/agent/agent.entity.ts +111 -111
- package/src/agent/agent.enum.ts +12 -12
- package/src/agent/agent.event.ts +91 -91
- package/src/agent/agent.handler.ts +144 -127
- package/src/agent/agent.operation.ts +400 -400
- package/src/agent/agent.presentation.ts +62 -62
- package/src/agent/agent.schema.ts +175 -175
- package/src/agent/agent.test-spec.ts +48 -48
- package/src/agent/index.ts +46 -51
- package/src/agent.capability.ts +11 -11
- package/src/agent.feature.ts +134 -131
- package/src/docs/agent-console.docblock.ts +52 -49
- package/src/example.test.ts +75 -0
- package/src/example.ts +34 -35
- package/src/handlers/agent.handlers.ts +576 -522
- package/src/handlers/index.ts +30 -14
- package/src/handlers/mock-handlers.test.ts +77 -0
- package/src/index.ts +10 -9
- package/src/presentations/index.ts +11 -13
- package/src/proof/index.ts +2 -0
- package/src/proof/meetup-proof.runtime.ts +196 -0
- package/src/proof/meetup-proof.scenario.ts +99 -0
- package/src/proof/meetup-proof.suite.ts +29 -0
- package/src/proof/meetup-proof.test.ts +28 -0
- package/src/proof/meetup-proof.ts +130 -0
- package/src/run/index.ts +49 -54
- package/src/run/run.entity.ts +137 -137
- package/src/run/run.enum.ts +18 -18
- package/src/run/run.event.ts +174 -174
- package/src/run/run.handler.ts +113 -96
- package/src/run/run.operation.ts +474 -474
- package/src/run/run.presentation.ts +42 -42
- package/src/run/run.schema.ts +126 -126
- package/src/run/run.test-spec.ts +48 -48
- package/src/seeders/index.ts +21 -21
- package/src/shared/demo-dashboard-data.ts +58 -0
- package/src/shared/demo-runtime-seed.ts +139 -0
- package/src/shared/demo-runtime.test.ts +169 -0
- package/src/shared/demo-runtime.ts +260 -0
- package/src/shared/index.ts +12 -1
- package/src/shared/mock-agents.ts +76 -76
- package/src/shared/mock-runs.ts +107 -102
- package/src/shared/mock-tools.ts +140 -140
- package/src/shared/overlay-types.ts +23 -23
- package/src/tool/index.ts +39 -44
- package/src/tool/tool.entity.ts +73 -73
- package/src/tool/tool.enum.ts +13 -13
- package/src/tool/tool.event.ts +80 -80
- package/src/tool/tool.handler.ts +124 -107
- package/src/tool/tool.operation.ts +328 -328
- package/src/tool/tool.presentation.ts +43 -43
- package/src/tool/tool.schema.ts +106 -106
- package/src/tool/tool.test-spec.ts +48 -48
- package/src/ui/AgentDashboard.sandbox.test.tsx +312 -0
- package/src/ui/AgentDashboard.tsx +351 -348
- package/src/ui/AgentDashboard.visualizations.tsx +35 -0
- package/src/ui/hooks/index.ts +7 -7
- package/src/ui/hooks/useAgentList.ts +57 -56
- package/src/ui/hooks/useAgentMutations.ts +168 -159
- package/src/ui/hooks/useRunList.ts +90 -57
- package/src/ui/hooks/useToolList.ts +102 -101
- package/src/ui/index.ts +6 -9
- package/src/ui/modals/AgentActionsModal.tsx +262 -262
- package/src/ui/modals/CreateAgentModal.tsx +232 -232
- package/src/ui/modals/index.ts +1 -1
- package/src/ui/overlays/demo-overlays.ts +52 -52
- package/src/ui/renderers/agent-list.markdown.ts +81 -61
- package/src/ui/renderers/agent-list.renderer.tsx +14 -14
- package/src/ui/renderers/dashboard.markdown.ts +135 -139
- package/src/ui/renderers/index.ts +3 -4
- package/src/ui/renderers/run-list.markdown.ts +56 -47
- package/src/ui/renderers/tool-registry.markdown.ts +79 -66
- package/src/ui/views/AgentListView.tsx +90 -90
- package/src/ui/views/RunDataTable.tsx +74 -0
- package/src/ui/views/RunListView.tsx +84 -158
- package/src/ui/views/ToolRegistryView.tsx +113 -113
- package/src/ui/views/run-data-table.columns.tsx +102 -0
- package/src/ui/views/run-list.shared.tsx +139 -0
- package/src/visualizations/catalog.ts +132 -0
- package/src/visualizations/index.ts +2 -0
- package/src/visualizations/selectors.test.ts +12 -0
- package/src/visualizations/selectors.ts +70 -0
- package/tsconfig.json +7 -8
- package/tsdown.config.js +24 -3
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { afterEach, beforeAll, describe, expect, it } from 'bun:test';
|
|
2
|
+
import {
|
|
3
|
+
type TemplateDefinition,
|
|
4
|
+
TemplateRuntimeContext,
|
|
5
|
+
type TemplateRuntimeContextValue,
|
|
6
|
+
} from '@contractspec/lib.example-shared-ui';
|
|
7
|
+
import Window from 'happy-dom/lib/window/Window.js';
|
|
8
|
+
import { act } from 'react';
|
|
9
|
+
import { createRoot, type Root } from 'react-dom/client';
|
|
10
|
+
import type { AgentHandlers } from '../handlers/agent.handlers';
|
|
11
|
+
import {
|
|
12
|
+
AGENT_CONSOLE_DEMO_ORGANIZATION_ID,
|
|
13
|
+
createAgentConsoleDemoHandlers,
|
|
14
|
+
} from '../shared';
|
|
15
|
+
import { AgentDashboard } from './AgentDashboard';
|
|
16
|
+
|
|
17
|
+
const PROJECT_ID = 'agent-console-sandbox-smoke';
|
|
18
|
+
const TEMPLATE: TemplateDefinition = {
|
|
19
|
+
id: 'agent-console',
|
|
20
|
+
name: 'Agent Console',
|
|
21
|
+
description: 'Deterministic sandbox smoke test template.',
|
|
22
|
+
category: 'ai',
|
|
23
|
+
complexity: 'intermediate',
|
|
24
|
+
icon: '🤖',
|
|
25
|
+
features: ['agents', 'runs', 'tools', 'metrics'],
|
|
26
|
+
tags: ['sandbox', 'smoke'],
|
|
27
|
+
schema: { models: ['Agent', 'Run', 'Tool'], contracts: [] },
|
|
28
|
+
components: {
|
|
29
|
+
list: 'AgentListView',
|
|
30
|
+
detail: 'RunListView',
|
|
31
|
+
form: 'CreateAgentModal',
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
beforeAll(() => {
|
|
36
|
+
const windowInstance = new Window({
|
|
37
|
+
url: 'https://sandbox.contractspec.local/sandbox',
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(windowInstance, 'SyntaxError', {
|
|
40
|
+
value: SyntaxError,
|
|
41
|
+
configurable: true,
|
|
42
|
+
});
|
|
43
|
+
Object.assign(globalThis, {
|
|
44
|
+
window: windowInstance,
|
|
45
|
+
document: windowInstance.document,
|
|
46
|
+
navigator: windowInstance.navigator,
|
|
47
|
+
HTMLElement: windowInstance.HTMLElement,
|
|
48
|
+
HTMLButtonElement: windowInstance.HTMLButtonElement,
|
|
49
|
+
HTMLInputElement: windowInstance.HTMLInputElement,
|
|
50
|
+
HTMLTextAreaElement: windowInstance.HTMLTextAreaElement,
|
|
51
|
+
Node: windowInstance.Node,
|
|
52
|
+
Event: windowInstance.Event,
|
|
53
|
+
MouseEvent: windowInstance.MouseEvent,
|
|
54
|
+
KeyboardEvent: windowInstance.KeyboardEvent,
|
|
55
|
+
MutationObserver: windowInstance.MutationObserver,
|
|
56
|
+
getComputedStyle: windowInstance.getComputedStyle.bind(windowInstance),
|
|
57
|
+
requestAnimationFrame: (callback: FrameRequestCallback) =>
|
|
58
|
+
setTimeout(() => callback(Date.now()), 0),
|
|
59
|
+
cancelAnimationFrame: (id: number) => clearTimeout(id),
|
|
60
|
+
IS_REACT_ACT_ENVIRONMENT: true,
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
afterEach(() => {
|
|
65
|
+
document.body.innerHTML = '';
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
function createContextValue(
|
|
69
|
+
handlers: AgentHandlers
|
|
70
|
+
): TemplateRuntimeContextValue<{ agent: AgentHandlers }> {
|
|
71
|
+
return {
|
|
72
|
+
template: TEMPLATE,
|
|
73
|
+
runtime: {},
|
|
74
|
+
installer: {
|
|
75
|
+
install: async () => {},
|
|
76
|
+
saveToStudio: async () => ({ projectId: PROJECT_ID, status: 'saved' }),
|
|
77
|
+
},
|
|
78
|
+
client: {} as never,
|
|
79
|
+
templateId: TEMPLATE.id,
|
|
80
|
+
projectId: PROJECT_ID,
|
|
81
|
+
engine: {} as never,
|
|
82
|
+
fetchData: async () => ({ data: null }),
|
|
83
|
+
handlers: { agent: handlers },
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async function renderDashboard() {
|
|
88
|
+
const container = document.createElement('div');
|
|
89
|
+
document.body.append(container);
|
|
90
|
+
const root: Root = createRoot(container);
|
|
91
|
+
const handlers = createAgentConsoleDemoHandlers({
|
|
92
|
+
projectId: PROJECT_ID,
|
|
93
|
+
organizationId: AGENT_CONSOLE_DEMO_ORGANIZATION_ID,
|
|
94
|
+
idFactory: (() => {
|
|
95
|
+
const counters = { agent: 0, run: 0 };
|
|
96
|
+
return (kind: 'agent' | 'run') => `${kind}-sandbox-${++counters[kind]}`;
|
|
97
|
+
})(),
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
await act(async () => {
|
|
101
|
+
root.render(
|
|
102
|
+
<TemplateRuntimeContext.Provider value={createContextValue(handlers)}>
|
|
103
|
+
<AgentDashboard />
|
|
104
|
+
</TemplateRuntimeContext.Provider>
|
|
105
|
+
);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
return { container, root };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function waitFor(assertion: () => boolean, timeoutMs = 3000) {
|
|
112
|
+
const startedAt = Date.now();
|
|
113
|
+
while (Date.now() - startedAt < timeoutMs) {
|
|
114
|
+
if (assertion()) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
await act(async () => {
|
|
118
|
+
await new Promise((resolve) => setTimeout(resolve, 25));
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
throw new Error('Timed out waiting for dashboard state.');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function findButton(container: HTMLElement, label: string) {
|
|
125
|
+
return [...container.getElementsByTagName('button')].find((element) =>
|
|
126
|
+
element.textContent?.includes(label)
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function findAgentCard(container: HTMLElement, name: string) {
|
|
131
|
+
return [...container.getElementsByTagName('*')].find(
|
|
132
|
+
(element) =>
|
|
133
|
+
element.getAttribute('role') === 'button' &&
|
|
134
|
+
element.textContent?.includes(name)
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function getReactProp<T>(element: Element, propName: string): T | undefined {
|
|
139
|
+
const record = element as unknown as Record<string, unknown>;
|
|
140
|
+
const reactPropsKey = Object.keys(record).find((key) =>
|
|
141
|
+
key.startsWith('__reactProps$')
|
|
142
|
+
);
|
|
143
|
+
if (!reactPropsKey) {
|
|
144
|
+
return undefined;
|
|
145
|
+
}
|
|
146
|
+
const props = record[reactPropsKey];
|
|
147
|
+
if (typeof props !== 'object' || props === null || !(propName in props)) {
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
150
|
+
const value = (props as Record<string, unknown>)[propName];
|
|
151
|
+
return value as T | undefined;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async function click(element: Element | null | undefined) {
|
|
155
|
+
if (!element) {
|
|
156
|
+
throw new Error('Expected clickable element.');
|
|
157
|
+
}
|
|
158
|
+
const onPress = getReactProp<(() => void) | undefined>(element, 'onPress');
|
|
159
|
+
const onClick = getReactProp<((event: MouseEvent) => void) | undefined>(
|
|
160
|
+
element,
|
|
161
|
+
'onClick'
|
|
162
|
+
);
|
|
163
|
+
await act(async () => {
|
|
164
|
+
if (typeof onPress === 'function') {
|
|
165
|
+
onPress();
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (typeof onClick === 'function') {
|
|
169
|
+
onClick(new MouseEvent('click', { bubbles: true }));
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if ('click' in element && typeof element.click === 'function') {
|
|
173
|
+
element.click();
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
element.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
async function fill(selector: string, value: string) {
|
|
181
|
+
const element = document.querySelector<
|
|
182
|
+
HTMLInputElement | HTMLTextAreaElement
|
|
183
|
+
>(selector);
|
|
184
|
+
if (!element) {
|
|
185
|
+
throw new Error(`Missing form field ${selector}.`);
|
|
186
|
+
}
|
|
187
|
+
const valueSetter = Object.getOwnPropertyDescriptor(
|
|
188
|
+
Object.getPrototypeOf(element),
|
|
189
|
+
'value'
|
|
190
|
+
)?.set;
|
|
191
|
+
if (!valueSetter) {
|
|
192
|
+
throw new Error(`Missing value setter for ${selector}.`);
|
|
193
|
+
}
|
|
194
|
+
const onChange = getReactProp<
|
|
195
|
+
(event: {
|
|
196
|
+
target: { value: string };
|
|
197
|
+
currentTarget: { value: string };
|
|
198
|
+
}) => void
|
|
199
|
+
>(element, 'onChange');
|
|
200
|
+
await act(async () => {
|
|
201
|
+
valueSetter.call(element, value);
|
|
202
|
+
onChange?.({
|
|
203
|
+
target: { value },
|
|
204
|
+
currentTarget: { value },
|
|
205
|
+
});
|
|
206
|
+
if (!onChange) {
|
|
207
|
+
element.dispatchEvent(new Event('input', { bubbles: true }));
|
|
208
|
+
element.dispatchEvent(new Event('change', { bubbles: true }));
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
describe('AgentDashboard sandbox smoke', () => {
|
|
214
|
+
it('loads seeded state, renders tabs, creates an agent, and executes a run', async () => {
|
|
215
|
+
const { container, root } = await renderDashboard();
|
|
216
|
+
await waitFor(
|
|
217
|
+
() => container.textContent?.includes('AI Agent Console') === true
|
|
218
|
+
);
|
|
219
|
+
await waitFor(
|
|
220
|
+
() =>
|
|
221
|
+
container.textContent?.includes(
|
|
222
|
+
'Affichage de 1 à 3 sur 5 résultats'
|
|
223
|
+
) === true
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
expect(container.textContent).toContain('Runs');
|
|
227
|
+
expect(container.textContent).toContain('Agents');
|
|
228
|
+
expect(container.textContent).toContain('Tools');
|
|
229
|
+
expect(container.textContent).toContain('Metrics');
|
|
230
|
+
expect(container.textContent).toContain('Run History');
|
|
231
|
+
|
|
232
|
+
await click(findButton(container, 'Tools'));
|
|
233
|
+
await waitFor(
|
|
234
|
+
() => container.textContent?.includes('Total Tools') === true
|
|
235
|
+
);
|
|
236
|
+
await click(findButton(container, 'Metrics'));
|
|
237
|
+
await waitFor(
|
|
238
|
+
() => container.textContent?.includes('Usage Analytics') === true
|
|
239
|
+
);
|
|
240
|
+
await click(findButton(container, 'Agents'));
|
|
241
|
+
await waitFor(() => container.textContent?.includes('Total: 4') === true);
|
|
242
|
+
|
|
243
|
+
await click(findButton(container, 'New Agent'));
|
|
244
|
+
await waitFor(
|
|
245
|
+
() => document.body.textContent?.includes('Create New Agent') === true
|
|
246
|
+
);
|
|
247
|
+
await fill('#agent-name', 'Paris Meetup UI Agent');
|
|
248
|
+
await fill(
|
|
249
|
+
'#agent-description',
|
|
250
|
+
'Smoke test agent for the sandbox walkthrough.'
|
|
251
|
+
);
|
|
252
|
+
await click(findButton(document.body, 'Create Agent'));
|
|
253
|
+
await click(findButton(container, 'Runs'));
|
|
254
|
+
await waitFor(
|
|
255
|
+
() =>
|
|
256
|
+
container.textContent?.includes(
|
|
257
|
+
'Affichage de 1 à 3 sur 5 résultats'
|
|
258
|
+
) === true
|
|
259
|
+
);
|
|
260
|
+
await click(findButton(container, 'Agents'));
|
|
261
|
+
await waitFor(
|
|
262
|
+
() => container.textContent?.includes('Paris Meetup UI Agent') === true
|
|
263
|
+
);
|
|
264
|
+
await waitFor(() => container.textContent?.includes('Total: 5') === true);
|
|
265
|
+
|
|
266
|
+
const agentCard = findAgentCard(container, 'Paris Meetup UI Agent');
|
|
267
|
+
await click(agentCard);
|
|
268
|
+
await waitFor(
|
|
269
|
+
() => document.body.textContent?.includes('Activate Agent') === true
|
|
270
|
+
);
|
|
271
|
+
await click(findButton(document.body, 'Activate Agent'));
|
|
272
|
+
await click(findButton(container, 'Runs'));
|
|
273
|
+
await waitFor(
|
|
274
|
+
() => container.textContent?.includes('Run History') === true
|
|
275
|
+
);
|
|
276
|
+
await click(findButton(container, 'Agents'));
|
|
277
|
+
await waitFor(
|
|
278
|
+
() =>
|
|
279
|
+
findAgentCard(
|
|
280
|
+
container,
|
|
281
|
+
'Paris Meetup UI Agent'
|
|
282
|
+
)?.textContent?.includes('ACTIVE') === true
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
const activeAgentCard = findAgentCard(container, 'Paris Meetup UI Agent');
|
|
286
|
+
await click(activeAgentCard);
|
|
287
|
+
await waitFor(
|
|
288
|
+
() => document.body.textContent?.includes('Execute Agent') === true
|
|
289
|
+
);
|
|
290
|
+
await click(findButton(document.body, 'Execute Agent'));
|
|
291
|
+
await waitFor(
|
|
292
|
+
() => document.body.textContent?.includes('Message *') === true
|
|
293
|
+
);
|
|
294
|
+
await fill('#execute-message', 'Summarize the meetup smoke test.');
|
|
295
|
+
await click(findButton(document.body, 'Execute'));
|
|
296
|
+
|
|
297
|
+
await click(findButton(container, 'Runs'));
|
|
298
|
+
await waitFor(
|
|
299
|
+
() =>
|
|
300
|
+
container.textContent?.includes(
|
|
301
|
+
'Affichage de 1 à 3 sur 6 résultats'
|
|
302
|
+
) === true
|
|
303
|
+
);
|
|
304
|
+
await waitFor(
|
|
305
|
+
() => container.textContent?.includes('Paris Meetup UI Agent') === true
|
|
306
|
+
);
|
|
307
|
+
|
|
308
|
+
await act(async () => {
|
|
309
|
+
root.unmount();
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
});
|