agent-relay 2.3.2 → 2.3.5
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/README.md +1 -1
- package/dist/index.cjs +1 -1
- package/dist/src/cli/index.js +124 -7
- package/dist/src/cli/index.js.map +1 -1
- package/package.json +20 -26
- package/packages/acp-bridge/package.json +2 -2
- package/packages/bridge/package.json +7 -7
- package/packages/config/dist/cloud-config.d.ts +1 -1
- package/packages/config/dist/cloud-config.d.ts.map +1 -1
- package/packages/config/dist/cloud-config.js.map +1 -1
- package/packages/config/dist/schemas.d.ts +5 -5
- package/packages/config/dist/schemas.js +1 -1
- package/packages/config/dist/schemas.js.map +1 -1
- package/packages/config/package.json +2 -2
- package/packages/config/src/cloud-config.ts +2 -2
- package/packages/config/src/schemas.test.ts +48 -0
- package/packages/config/src/schemas.ts +1 -1
- package/packages/continuity/package.json +2 -2
- package/packages/daemon/package.json +12 -12
- package/packages/hooks/package.json +4 -4
- package/packages/mcp/package.json +5 -5
- package/packages/memory/package.json +2 -2
- package/packages/policy/package.json +2 -2
- package/packages/protocol/package.json +1 -1
- package/packages/resiliency/package.json +1 -1
- package/packages/sdk/dist/index.d.ts +1 -29
- package/packages/sdk/dist/index.d.ts.map +1 -1
- package/packages/sdk/dist/index.js +1 -38
- package/packages/sdk/dist/index.js.map +1 -1
- package/packages/sdk/package.json +4 -25
- package/packages/sdk/src/index.ts +1 -69
- package/packages/sdk-py/README.md +56 -0
- package/packages/sdk-py/pyproject.toml +23 -0
- package/packages/sdk-py/src/agent_relay/__init__.py +27 -0
- package/packages/sdk-py/src/agent_relay/builder.py +367 -0
- package/packages/sdk-py/src/agent_relay/types.py +92 -0
- package/packages/sdk-py/tests/__init__.py +0 -0
- package/packages/sdk-py/tests/test_builder.py +101 -0
- package/packages/sdk-ts/dist/__tests__/facade.test.d.ts +2 -0
- package/packages/sdk-ts/dist/__tests__/facade.test.d.ts.map +1 -0
- package/packages/sdk-ts/dist/__tests__/facade.test.js +257 -0
- package/packages/sdk-ts/dist/__tests__/facade.test.js.map +1 -0
- package/packages/sdk-ts/dist/__tests__/unit.test.d.ts +2 -0
- package/packages/sdk-ts/dist/__tests__/unit.test.d.ts.map +1 -0
- package/packages/sdk-ts/dist/__tests__/unit.test.js +124 -0
- package/packages/sdk-ts/dist/__tests__/unit.test.js.map +1 -0
- package/packages/sdk-ts/dist/client.d.ts +2 -0
- package/packages/sdk-ts/dist/client.d.ts.map +1 -1
- package/packages/sdk-ts/dist/client.js +2 -0
- package/packages/sdk-ts/dist/client.js.map +1 -1
- package/packages/sdk-ts/dist/index.d.ts +1 -0
- package/packages/sdk-ts/dist/index.d.ts.map +1 -1
- package/packages/sdk-ts/dist/index.js +1 -0
- package/packages/sdk-ts/dist/index.js.map +1 -1
- package/packages/sdk-ts/dist/protocol.d.ts +1 -0
- package/packages/sdk-ts/dist/protocol.d.ts.map +1 -1
- package/packages/sdk-ts/dist/relay.d.ts +44 -0
- package/packages/sdk-ts/dist/relay.d.ts.map +1 -1
- package/packages/sdk-ts/dist/relay.js +89 -11
- package/packages/sdk-ts/dist/relay.js.map +1 -1
- package/packages/sdk-ts/dist/relaycast.js +2 -2
- package/packages/sdk-ts/dist/relaycast.js.map +1 -1
- package/packages/sdk-ts/dist/workflows/barrier.d.ts +72 -0
- package/packages/sdk-ts/dist/workflows/barrier.d.ts.map +1 -0
- package/packages/sdk-ts/dist/workflows/barrier.js +162 -0
- package/packages/sdk-ts/dist/workflows/barrier.js.map +1 -0
- package/packages/sdk-ts/dist/workflows/builder.d.ts +101 -0
- package/packages/sdk-ts/dist/workflows/builder.d.ts.map +1 -0
- package/packages/sdk-ts/dist/workflows/builder.js +179 -0
- package/packages/sdk-ts/dist/workflows/builder.js.map +1 -0
- package/packages/sdk-ts/dist/workflows/cli.d.ts +10 -0
- package/packages/sdk-ts/dist/workflows/cli.d.ts.map +1 -0
- package/packages/sdk-ts/dist/workflows/cli.js +82 -0
- package/packages/sdk-ts/dist/workflows/cli.js.map +1 -0
- package/packages/sdk-ts/dist/workflows/coordinator.d.ts +68 -0
- package/packages/sdk-ts/dist/workflows/coordinator.d.ts.map +1 -0
- package/packages/sdk-ts/dist/workflows/coordinator.js +353 -0
- package/packages/sdk-ts/dist/workflows/coordinator.js.map +1 -0
- package/packages/sdk-ts/dist/workflows/index.d.ts +10 -0
- package/packages/sdk-ts/dist/workflows/index.d.ts.map +1 -0
- package/packages/sdk-ts/dist/workflows/index.js +10 -0
- package/packages/sdk-ts/dist/workflows/index.js.map +1 -0
- package/packages/sdk-ts/dist/workflows/memory-db.d.ts +17 -0
- package/packages/sdk-ts/dist/workflows/memory-db.d.ts.map +1 -0
- package/packages/sdk-ts/dist/workflows/memory-db.js +33 -0
- package/packages/sdk-ts/dist/workflows/memory-db.js.map +1 -0
- package/packages/sdk-ts/dist/workflows/run.d.ts +31 -0
- package/packages/sdk-ts/dist/workflows/run.d.ts.map +1 -0
- package/packages/sdk-ts/dist/workflows/run.js +24 -0
- package/packages/sdk-ts/dist/workflows/run.js.map +1 -0
- package/packages/sdk-ts/dist/workflows/runner.d.ts +119 -0
- package/packages/sdk-ts/dist/workflows/runner.d.ts.map +1 -0
- package/packages/sdk-ts/dist/workflows/runner.js +650 -0
- package/packages/sdk-ts/dist/workflows/runner.js.map +1 -0
- package/packages/sdk-ts/dist/workflows/state.d.ts +77 -0
- package/packages/sdk-ts/dist/workflows/state.d.ts.map +1 -0
- package/packages/sdk-ts/dist/workflows/state.js +140 -0
- package/packages/sdk-ts/dist/workflows/state.js.map +1 -0
- package/packages/sdk-ts/dist/workflows/templates.d.ts +47 -0
- package/packages/sdk-ts/dist/workflows/templates.d.ts.map +1 -0
- package/packages/sdk-ts/dist/workflows/templates.js +395 -0
- package/packages/sdk-ts/dist/workflows/templates.js.map +1 -0
- package/packages/sdk-ts/dist/workflows/types.d.ts +126 -0
- package/packages/sdk-ts/dist/workflows/types.d.ts.map +1 -0
- package/packages/sdk-ts/dist/workflows/types.js +8 -0
- package/packages/sdk-ts/dist/workflows/types.js.map +1 -0
- package/packages/sdk-ts/package.json +9 -3
- package/packages/sdk-ts/src/__tests__/error-scenarios.test.ts +682 -0
- package/packages/sdk-ts/src/__tests__/facade.test.ts +296 -0
- package/packages/sdk-ts/src/__tests__/swarm-coordinator.test.ts +416 -0
- package/packages/sdk-ts/src/__tests__/unit.test.ts +152 -0
- package/packages/sdk-ts/src/__tests__/workflow-runner.test.ts +333 -0
- package/packages/sdk-ts/src/client.ts +4 -0
- package/packages/sdk-ts/src/index.ts +1 -0
- package/packages/sdk-ts/src/protocol.ts +1 -1
- package/packages/sdk-ts/src/relay.ts +112 -11
- package/packages/sdk-ts/src/relaycast.ts +2 -2
- package/packages/sdk-ts/src/workflows/README.md +450 -0
- package/packages/sdk-ts/src/workflows/barrier.ts +254 -0
- package/packages/sdk-ts/src/workflows/builder.ts +241 -0
- package/packages/sdk-ts/src/workflows/builtin-templates/bug-fix.yaml +75 -0
- package/packages/sdk-ts/src/workflows/builtin-templates/code-review.yaml +82 -0
- package/packages/sdk-ts/src/workflows/builtin-templates/documentation.yaml +70 -0
- package/packages/sdk-ts/src/workflows/builtin-templates/feature-dev.yaml +76 -0
- package/packages/sdk-ts/src/workflows/builtin-templates/refactor.yaml +82 -0
- package/packages/sdk-ts/src/workflows/builtin-templates/security-audit.yaml +84 -0
- package/packages/sdk-ts/src/workflows/cli.ts +93 -0
- package/packages/sdk-ts/src/workflows/coordinator.ts +520 -0
- package/packages/sdk-ts/src/workflows/index.ts +9 -0
- package/packages/sdk-ts/src/workflows/memory-db.ts +39 -0
- package/packages/sdk-ts/src/workflows/run.ts +47 -0
- package/packages/sdk-ts/src/workflows/runner.ts +873 -0
- package/packages/sdk-ts/src/workflows/schema.json +321 -0
- package/packages/sdk-ts/src/workflows/state.ts +279 -0
- package/packages/sdk-ts/src/workflows/templates.ts +544 -0
- package/packages/sdk-ts/src/workflows/types.ts +178 -0
- package/packages/sdk-ts/tsconfig.json +6 -1
- package/packages/spawner/package.json +1 -1
- package/packages/state/package.json +1 -1
- package/packages/storage/package.json +2 -2
- package/packages/telemetry/package.json +1 -1
- package/packages/trajectory/package.json +2 -2
- package/packages/user-directory/package.json +2 -2
- package/packages/utils/package.json +3 -3
- package/packages/wrapper/package.json +5 -6
- package/scripts/postinstall.js +106 -2
- package/packages/api-types/.trajectories/active/traj_xbsvuzogscey.json +0 -15
- package/packages/api-types/.trajectories/index.json +0 -12
- package/packages/api-types/dist/index.d.ts +0 -21
- package/packages/api-types/dist/index.d.ts.map +0 -1
- package/packages/api-types/dist/index.js +0 -22
- package/packages/api-types/dist/index.js.map +0 -1
- package/packages/api-types/dist/schemas/agent.d.ts +0 -259
- package/packages/api-types/dist/schemas/agent.d.ts.map +0 -1
- package/packages/api-types/dist/schemas/agent.js +0 -102
- package/packages/api-types/dist/schemas/agent.js.map +0 -1
- package/packages/api-types/dist/schemas/api.d.ts +0 -290
- package/packages/api-types/dist/schemas/api.d.ts.map +0 -1
- package/packages/api-types/dist/schemas/api.js +0 -162
- package/packages/api-types/dist/schemas/api.js.map +0 -1
- package/packages/api-types/dist/schemas/decision.d.ts +0 -230
- package/packages/api-types/dist/schemas/decision.d.ts.map +0 -1
- package/packages/api-types/dist/schemas/decision.js +0 -104
- package/packages/api-types/dist/schemas/decision.js.map +0 -1
- package/packages/api-types/dist/schemas/fleet.d.ts +0 -615
- package/packages/api-types/dist/schemas/fleet.d.ts.map +0 -1
- package/packages/api-types/dist/schemas/fleet.js +0 -71
- package/packages/api-types/dist/schemas/fleet.js.map +0 -1
- package/packages/api-types/dist/schemas/history.d.ts +0 -180
- package/packages/api-types/dist/schemas/history.d.ts.map +0 -1
- package/packages/api-types/dist/schemas/history.js +0 -72
- package/packages/api-types/dist/schemas/history.js.map +0 -1
- package/packages/api-types/dist/schemas/index.d.ts +0 -14
- package/packages/api-types/dist/schemas/index.d.ts.map +0 -1
- package/packages/api-types/dist/schemas/index.js +0 -22
- package/packages/api-types/dist/schemas/index.js.map +0 -1
- package/packages/api-types/dist/schemas/message.d.ts +0 -456
- package/packages/api-types/dist/schemas/message.d.ts.map +0 -1
- package/packages/api-types/dist/schemas/message.js +0 -88
- package/packages/api-types/dist/schemas/message.js.map +0 -1
- package/packages/api-types/dist/schemas/session.d.ts +0 -60
- package/packages/api-types/dist/schemas/session.d.ts.map +0 -1
- package/packages/api-types/dist/schemas/session.js +0 -36
- package/packages/api-types/dist/schemas/session.js.map +0 -1
- package/packages/api-types/dist/schemas/task.d.ts +0 -111
- package/packages/api-types/dist/schemas/task.d.ts.map +0 -1
- package/packages/api-types/dist/schemas/task.js +0 -64
- package/packages/api-types/dist/schemas/task.js.map +0 -1
- package/packages/api-types/package.json +0 -61
- package/packages/api-types/scripts/generate-openapi.ts +0 -106
- package/packages/api-types/src/index.ts +0 -22
- package/packages/api-types/src/schemas/agent.test.ts +0 -164
- package/packages/api-types/src/schemas/agent.ts +0 -110
- package/packages/api-types/src/schemas/api.test.ts +0 -372
- package/packages/api-types/src/schemas/api.ts +0 -194
- package/packages/api-types/src/schemas/decision.test.ts +0 -324
- package/packages/api-types/src/schemas/decision.ts +0 -136
- package/packages/api-types/src/schemas/fleet.test.ts +0 -212
- package/packages/api-types/src/schemas/fleet.ts +0 -83
- package/packages/api-types/src/schemas/history.test.ts +0 -242
- package/packages/api-types/src/schemas/history.ts +0 -84
- package/packages/api-types/src/schemas/index.ts +0 -148
- package/packages/api-types/src/schemas/message.test.ts +0 -192
- package/packages/api-types/src/schemas/message.ts +0 -98
- package/packages/api-types/src/schemas/session.test.ts +0 -104
- package/packages/api-types/src/schemas/session.ts +0 -40
- package/packages/api-types/src/schemas/task.test.ts +0 -192
- package/packages/api-types/src/schemas/task.ts +0 -78
- package/packages/api-types/tsconfig.json +0 -19
- package/packages/api-types/vitest.config.ts +0 -9
- package/packages/benchmark/README.md +0 -200
- package/packages/benchmark/datasets/coding-tasks.yaml +0 -127
- package/packages/benchmark/datasets/coordination-tasks.yaml +0 -122
- package/packages/benchmark/datasets/quick-test.yaml +0 -20
- package/packages/benchmark/dist/benchmark.d.ts +0 -47
- package/packages/benchmark/dist/benchmark.d.ts.map +0 -1
- package/packages/benchmark/dist/benchmark.js +0 -224
- package/packages/benchmark/dist/benchmark.js.map +0 -1
- package/packages/benchmark/dist/cli.d.ts +0 -8
- package/packages/benchmark/dist/cli.d.ts.map +0 -1
- package/packages/benchmark/dist/cli.js +0 -185
- package/packages/benchmark/dist/cli.js.map +0 -1
- package/packages/benchmark/dist/harbor.d.ts +0 -53
- package/packages/benchmark/dist/harbor.d.ts.map +0 -1
- package/packages/benchmark/dist/harbor.js +0 -127
- package/packages/benchmark/dist/harbor.js.map +0 -1
- package/packages/benchmark/dist/index.d.ts +0 -48
- package/packages/benchmark/dist/index.d.ts.map +0 -1
- package/packages/benchmark/dist/index.js +0 -50
- package/packages/benchmark/dist/index.js.map +0 -1
- package/packages/benchmark/dist/runners/base.d.ts +0 -63
- package/packages/benchmark/dist/runners/base.d.ts.map +0 -1
- package/packages/benchmark/dist/runners/base.js +0 -156
- package/packages/benchmark/dist/runners/base.js.map +0 -1
- package/packages/benchmark/dist/runners/index.d.ts +0 -10
- package/packages/benchmark/dist/runners/index.d.ts.map +0 -1
- package/packages/benchmark/dist/runners/index.js +0 -10
- package/packages/benchmark/dist/runners/index.js.map +0 -1
- package/packages/benchmark/dist/runners/single.d.ts +0 -19
- package/packages/benchmark/dist/runners/single.d.ts.map +0 -1
- package/packages/benchmark/dist/runners/single.js +0 -111
- package/packages/benchmark/dist/runners/single.js.map +0 -1
- package/packages/benchmark/dist/runners/subagent.d.ts +0 -32
- package/packages/benchmark/dist/runners/subagent.d.ts.map +0 -1
- package/packages/benchmark/dist/runners/subagent.js +0 -212
- package/packages/benchmark/dist/runners/subagent.js.map +0 -1
- package/packages/benchmark/dist/runners/swarm.d.ts +0 -36
- package/packages/benchmark/dist/runners/swarm.d.ts.map +0 -1
- package/packages/benchmark/dist/runners/swarm.js +0 -273
- package/packages/benchmark/dist/runners/swarm.js.map +0 -1
- package/packages/benchmark/dist/types.d.ts +0 -178
- package/packages/benchmark/dist/types.d.ts.map +0 -1
- package/packages/benchmark/dist/types.js +0 -16
- package/packages/benchmark/dist/types.js.map +0 -1
- package/packages/benchmark/package.json +0 -80
- package/packages/benchmark/src/benchmark.ts +0 -298
- package/packages/benchmark/src/cli.ts +0 -240
- package/packages/benchmark/src/harbor.ts +0 -170
- package/packages/benchmark/src/index.ts +0 -73
- package/packages/benchmark/src/runners/base.ts +0 -205
- package/packages/benchmark/src/runners/index.ts +0 -10
- package/packages/benchmark/src/runners/single.ts +0 -121
- package/packages/benchmark/src/runners/subagent.ts +0 -240
- package/packages/benchmark/src/runners/swarm.ts +0 -326
- package/packages/benchmark/src/types.ts +0 -205
- package/packages/benchmark/tsconfig.json +0 -20
- package/packages/cli-tester/README.md +0 -277
- package/packages/cli-tester/dist/index.d.ts +0 -21
- package/packages/cli-tester/dist/index.d.ts.map +0 -1
- package/packages/cli-tester/dist/index.js +0 -21
- package/packages/cli-tester/dist/index.js.map +0 -1
- package/packages/cli-tester/dist/utils/credential-check.d.ts +0 -56
- package/packages/cli-tester/dist/utils/credential-check.d.ts.map +0 -1
- package/packages/cli-tester/dist/utils/credential-check.js +0 -230
- package/packages/cli-tester/dist/utils/credential-check.js.map +0 -1
- package/packages/cli-tester/dist/utils/socket-client.d.ts +0 -76
- package/packages/cli-tester/dist/utils/socket-client.d.ts.map +0 -1
- package/packages/cli-tester/dist/utils/socket-client.js +0 -153
- package/packages/cli-tester/dist/utils/socket-client.js.map +0 -1
- package/packages/cli-tester/docker/Dockerfile +0 -61
- package/packages/cli-tester/docker/docker-compose.yml +0 -71
- package/packages/cli-tester/docker/entrypoint.sh +0 -58
- package/packages/cli-tester/package.json +0 -32
- package/packages/cli-tester/scripts/clear-auth.sh +0 -101
- package/packages/cli-tester/scripts/inject-message.sh +0 -42
- package/packages/cli-tester/scripts/start.sh +0 -71
- package/packages/cli-tester/scripts/test-cli.sh +0 -56
- package/packages/cli-tester/scripts/test-full-spawn.sh +0 -238
- package/packages/cli-tester/scripts/test-registration.sh +0 -182
- package/packages/cli-tester/scripts/test-setup-flow.sh +0 -202
- package/packages/cli-tester/scripts/test-spawn.sh +0 -140
- package/packages/cli-tester/scripts/test-with-daemon.sh +0 -247
- package/packages/cli-tester/scripts/verify-auth.sh +0 -112
- package/packages/cli-tester/src/index.ts +0 -40
- package/packages/cli-tester/src/utils/credential-check.ts +0 -284
- package/packages/cli-tester/src/utils/socket-client.ts +0 -211
- package/packages/cli-tester/tests/credential-check.test.ts +0 -56
- package/packages/cli-tester/tsconfig.json +0 -11
- package/packages/sdk/dist/browser-client.d.ts +0 -212
- package/packages/sdk/dist/browser-client.d.ts.map +0 -1
- package/packages/sdk/dist/browser-client.js +0 -750
- package/packages/sdk/dist/browser-client.js.map +0 -1
- package/packages/sdk/dist/browser-framing.d.ts +0 -46
- package/packages/sdk/dist/browser-framing.d.ts.map +0 -1
- package/packages/sdk/dist/browser-framing.js +0 -122
- package/packages/sdk/dist/browser-framing.js.map +0 -1
- package/packages/sdk/dist/standalone.d.ts +0 -89
- package/packages/sdk/dist/standalone.d.ts.map +0 -1
- package/packages/sdk/dist/standalone.js +0 -131
- package/packages/sdk/dist/standalone.js.map +0 -1
- package/packages/sdk/dist/transports/index.d.ts +0 -92
- package/packages/sdk/dist/transports/index.d.ts.map +0 -1
- package/packages/sdk/dist/transports/index.js +0 -129
- package/packages/sdk/dist/transports/index.js.map +0 -1
- package/packages/sdk/dist/transports/socket-transport.d.ts +0 -30
- package/packages/sdk/dist/transports/socket-transport.d.ts.map +0 -1
- package/packages/sdk/dist/transports/socket-transport.js +0 -94
- package/packages/sdk/dist/transports/socket-transport.js.map +0 -1
- package/packages/sdk/dist/transports/types.d.ts +0 -69
- package/packages/sdk/dist/transports/types.d.ts.map +0 -1
- package/packages/sdk/dist/transports/types.js +0 -10
- package/packages/sdk/dist/transports/types.js.map +0 -1
- package/packages/sdk/dist/transports/websocket-transport.d.ts +0 -55
- package/packages/sdk/dist/transports/websocket-transport.d.ts.map +0 -1
- package/packages/sdk/dist/transports/websocket-transport.js +0 -180
- package/packages/sdk/dist/transports/websocket-transport.js.map +0 -1
- package/packages/sdk/src/browser-client.ts +0 -985
- package/packages/sdk/src/browser-framing.test.ts +0 -115
- package/packages/sdk/src/browser-framing.ts +0 -150
- package/packages/sdk/src/standalone.ts +0 -183
- package/packages/sdk/src/transports/index.ts +0 -197
- package/packages/sdk/src/transports/socket-transport.ts +0 -115
- package/packages/sdk/src/transports/types.ts +0 -77
- package/packages/sdk/src/transports/websocket-transport.ts +0 -245
|
@@ -1,324 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Decision Schema Tests
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { describe, it, expect } from 'vitest';
|
|
6
|
-
import {
|
|
7
|
-
DecisionUrgencySchema,
|
|
8
|
-
DecisionCategorySchema,
|
|
9
|
-
DecisionOptionSchema,
|
|
10
|
-
ApiDecisionSchema,
|
|
11
|
-
DecisionSchema,
|
|
12
|
-
PendingDecisionSchema,
|
|
13
|
-
TrajectoryDecisionTypeSchema,
|
|
14
|
-
TrajectoryDecisionOutcomeSchema,
|
|
15
|
-
TrajectoryDecisionSchema,
|
|
16
|
-
TrajectorySchema,
|
|
17
|
-
} from './decision.js';
|
|
18
|
-
|
|
19
|
-
describe('Decision Schemas', () => {
|
|
20
|
-
describe('DecisionUrgencySchema', () => {
|
|
21
|
-
it('should validate urgency levels', () => {
|
|
22
|
-
expect(DecisionUrgencySchema.parse('low')).toBe('low');
|
|
23
|
-
expect(DecisionUrgencySchema.parse('medium')).toBe('medium');
|
|
24
|
-
expect(DecisionUrgencySchema.parse('high')).toBe('high');
|
|
25
|
-
expect(DecisionUrgencySchema.parse('critical')).toBe('critical');
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('should reject invalid urgency', () => {
|
|
29
|
-
expect(() => DecisionUrgencySchema.parse('urgent')).toThrow();
|
|
30
|
-
expect(() => DecisionUrgencySchema.parse('P1')).toThrow();
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
describe('DecisionCategorySchema', () => {
|
|
35
|
-
it('should validate categories', () => {
|
|
36
|
-
expect(DecisionCategorySchema.parse('approval')).toBe('approval');
|
|
37
|
-
expect(DecisionCategorySchema.parse('choice')).toBe('choice');
|
|
38
|
-
expect(DecisionCategorySchema.parse('input')).toBe('input');
|
|
39
|
-
expect(DecisionCategorySchema.parse('confirmation')).toBe('confirmation');
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('should reject invalid category', () => {
|
|
43
|
-
expect(() => DecisionCategorySchema.parse('question')).toThrow();
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
describe('DecisionOptionSchema', () => {
|
|
48
|
-
it('should validate option with description', () => {
|
|
49
|
-
const option = {
|
|
50
|
-
id: 'opt-1',
|
|
51
|
-
label: 'Option A',
|
|
52
|
-
description: 'This is option A',
|
|
53
|
-
};
|
|
54
|
-
const result = DecisionOptionSchema.parse(option);
|
|
55
|
-
expect(result.id).toBe('opt-1');
|
|
56
|
-
expect(result.label).toBe('Option A');
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('should allow option without description', () => {
|
|
60
|
-
const option = {
|
|
61
|
-
id: 'opt-2',
|
|
62
|
-
label: 'Option B',
|
|
63
|
-
};
|
|
64
|
-
const result = DecisionOptionSchema.parse(option);
|
|
65
|
-
expect(result.description).toBeUndefined();
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
describe('ApiDecisionSchema', () => {
|
|
70
|
-
it('should validate complete API decision', () => {
|
|
71
|
-
const decision = {
|
|
72
|
-
id: 'dec-001',
|
|
73
|
-
agentName: 'FullStack',
|
|
74
|
-
title: 'Choose database',
|
|
75
|
-
description: 'Select the database to use for the project',
|
|
76
|
-
options: [
|
|
77
|
-
{ id: 'opt-1', label: 'PostgreSQL', description: 'Relational DB' },
|
|
78
|
-
{ id: 'opt-2', label: 'MongoDB', description: 'Document DB' },
|
|
79
|
-
],
|
|
80
|
-
urgency: 'high',
|
|
81
|
-
category: 'choice',
|
|
82
|
-
createdAt: '2025-01-22T10:00:00Z',
|
|
83
|
-
expiresAt: '2025-01-22T12:00:00Z',
|
|
84
|
-
context: { projectType: 'web-app' },
|
|
85
|
-
};
|
|
86
|
-
const result = ApiDecisionSchema.parse(decision);
|
|
87
|
-
expect(result.options).toHaveLength(2);
|
|
88
|
-
expect(result.urgency).toBe('high');
|
|
89
|
-
expect(result.category).toBe('choice');
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it('should allow decision without options', () => {
|
|
93
|
-
const decision = {
|
|
94
|
-
id: 'dec-002',
|
|
95
|
-
agentName: 'Worker',
|
|
96
|
-
title: 'Approve deployment',
|
|
97
|
-
description: 'Approve the deployment to production',
|
|
98
|
-
urgency: 'critical',
|
|
99
|
-
category: 'approval',
|
|
100
|
-
createdAt: '2025-01-22T11:00:00Z',
|
|
101
|
-
};
|
|
102
|
-
const result = ApiDecisionSchema.parse(decision);
|
|
103
|
-
expect(result.options).toBeUndefined();
|
|
104
|
-
expect(result.expiresAt).toBeUndefined();
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
describe('DecisionSchema', () => {
|
|
109
|
-
it('should validate decision with string timestamp', () => {
|
|
110
|
-
const decision = {
|
|
111
|
-
id: 'dec-003',
|
|
112
|
-
agentName: 'Backend',
|
|
113
|
-
timestamp: '2025-01-22T10:30:00Z',
|
|
114
|
-
type: 'input',
|
|
115
|
-
title: 'Enter API key',
|
|
116
|
-
description: 'Provide the third-party API key',
|
|
117
|
-
priority: 'medium',
|
|
118
|
-
};
|
|
119
|
-
const result = DecisionSchema.parse(decision);
|
|
120
|
-
expect(result.timestamp).toBe('2025-01-22T10:30:00Z');
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('should validate decision with numeric timestamp', () => {
|
|
124
|
-
const decision = {
|
|
125
|
-
id: 'dec-004',
|
|
126
|
-
agentName: 'Frontend',
|
|
127
|
-
timestamp: 1705920600000,
|
|
128
|
-
type: 'confirmation',
|
|
129
|
-
title: 'Confirm delete',
|
|
130
|
-
description: 'Are you sure you want to delete this file?',
|
|
131
|
-
priority: 'low',
|
|
132
|
-
};
|
|
133
|
-
const result = DecisionSchema.parse(decision);
|
|
134
|
-
expect(result.timestamp).toBe(1705920600000);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it('should validate decision with options and context', () => {
|
|
138
|
-
const decision = {
|
|
139
|
-
id: 'dec-005',
|
|
140
|
-
agentName: 'Lead',
|
|
141
|
-
timestamp: Date.now(),
|
|
142
|
-
type: 'choice',
|
|
143
|
-
title: 'Select framework',
|
|
144
|
-
description: 'Choose the frontend framework',
|
|
145
|
-
options: [
|
|
146
|
-
{ id: 'react', label: 'React' },
|
|
147
|
-
{ id: 'vue', label: 'Vue' },
|
|
148
|
-
],
|
|
149
|
-
priority: 'high',
|
|
150
|
-
context: { team: 'frontend' },
|
|
151
|
-
expiresAt: '2025-01-23T10:00:00Z',
|
|
152
|
-
};
|
|
153
|
-
const result = DecisionSchema.parse(decision);
|
|
154
|
-
expect(result.options).toHaveLength(2);
|
|
155
|
-
expect(result.context).toEqual({ team: 'frontend' });
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
describe('PendingDecisionSchema', () => {
|
|
160
|
-
it('should validate pending decision', () => {
|
|
161
|
-
const decision = {
|
|
162
|
-
id: 'pending-001',
|
|
163
|
-
agent: 'Worker',
|
|
164
|
-
question: 'Which approach should we use?',
|
|
165
|
-
options: ['Approach A', 'Approach B', 'Approach C'],
|
|
166
|
-
context: 'Building new feature',
|
|
167
|
-
priority: 'medium',
|
|
168
|
-
createdAt: '2025-01-22T09:00:00Z',
|
|
169
|
-
expiresAt: '2025-01-22T17:00:00Z',
|
|
170
|
-
};
|
|
171
|
-
const result = PendingDecisionSchema.parse(decision);
|
|
172
|
-
expect(result.options).toHaveLength(3);
|
|
173
|
-
expect(result.priority).toBe('medium');
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
it('should allow pending decision without options', () => {
|
|
177
|
-
const decision = {
|
|
178
|
-
id: 'pending-002',
|
|
179
|
-
agent: 'Backend',
|
|
180
|
-
question: 'What is the expected response format?',
|
|
181
|
-
priority: 'low',
|
|
182
|
-
createdAt: '2025-01-22T10:00:00Z',
|
|
183
|
-
};
|
|
184
|
-
const result = PendingDecisionSchema.parse(decision);
|
|
185
|
-
expect(result.options).toBeUndefined();
|
|
186
|
-
expect(result.context).toBeUndefined();
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
describe('TrajectoryDecisionTypeSchema', () => {
|
|
191
|
-
it('should validate decision types', () => {
|
|
192
|
-
expect(TrajectoryDecisionTypeSchema.parse('tool_call')).toBe('tool_call');
|
|
193
|
-
expect(TrajectoryDecisionTypeSchema.parse('message')).toBe('message');
|
|
194
|
-
expect(TrajectoryDecisionTypeSchema.parse('file_edit')).toBe('file_edit');
|
|
195
|
-
expect(TrajectoryDecisionTypeSchema.parse('command')).toBe('command');
|
|
196
|
-
expect(TrajectoryDecisionTypeSchema.parse('question')).toBe('question');
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
describe('TrajectoryDecisionOutcomeSchema', () => {
|
|
201
|
-
it('should validate outcomes', () => {
|
|
202
|
-
expect(TrajectoryDecisionOutcomeSchema.parse('success')).toBe('success');
|
|
203
|
-
expect(TrajectoryDecisionOutcomeSchema.parse('error')).toBe('error');
|
|
204
|
-
expect(TrajectoryDecisionOutcomeSchema.parse('pending')).toBe('pending');
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
describe('TrajectoryDecisionSchema', () => {
|
|
209
|
-
it('should validate simple trajectory decision', () => {
|
|
210
|
-
const decision = {
|
|
211
|
-
id: 'traj-001',
|
|
212
|
-
timestamp: '2025-01-22T10:00:00Z',
|
|
213
|
-
agent: 'FullStack',
|
|
214
|
-
type: 'tool_call',
|
|
215
|
-
summary: 'Read file package.json',
|
|
216
|
-
details: 'Reading package.json to check dependencies',
|
|
217
|
-
outcome: 'success',
|
|
218
|
-
};
|
|
219
|
-
const result = TrajectoryDecisionSchema.parse(decision);
|
|
220
|
-
expect(result.id).toBe('traj-001');
|
|
221
|
-
expect(result.type).toBe('tool_call');
|
|
222
|
-
expect(result.outcome).toBe('success');
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
it('should validate trajectory decision with children (recursive)', () => {
|
|
226
|
-
const decision = {
|
|
227
|
-
id: 'traj-002',
|
|
228
|
-
timestamp: '2025-01-22T10:05:00Z',
|
|
229
|
-
agent: 'Lead',
|
|
230
|
-
type: 'command',
|
|
231
|
-
summary: 'Run build process',
|
|
232
|
-
outcome: 'success',
|
|
233
|
-
children: [
|
|
234
|
-
{
|
|
235
|
-
id: 'traj-003',
|
|
236
|
-
timestamp: '2025-01-22T10:05:01Z',
|
|
237
|
-
agent: 'Lead',
|
|
238
|
-
type: 'tool_call',
|
|
239
|
-
summary: 'Execute npm run build',
|
|
240
|
-
outcome: 'success',
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
id: 'traj-004',
|
|
244
|
-
timestamp: '2025-01-22T10:05:30Z',
|
|
245
|
-
agent: 'Lead',
|
|
246
|
-
type: 'message',
|
|
247
|
-
summary: 'Build completed',
|
|
248
|
-
outcome: 'success',
|
|
249
|
-
},
|
|
250
|
-
],
|
|
251
|
-
};
|
|
252
|
-
const result = TrajectoryDecisionSchema.parse(decision);
|
|
253
|
-
expect(result.children).toHaveLength(2);
|
|
254
|
-
expect(result.children?.[0].type).toBe('tool_call');
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
it('should validate deeply nested children', () => {
|
|
258
|
-
const decision = {
|
|
259
|
-
id: 'root',
|
|
260
|
-
timestamp: '2025-01-22T10:00:00Z',
|
|
261
|
-
agent: 'Root',
|
|
262
|
-
type: 'command',
|
|
263
|
-
summary: 'Root command',
|
|
264
|
-
children: [
|
|
265
|
-
{
|
|
266
|
-
id: 'level-1',
|
|
267
|
-
timestamp: '2025-01-22T10:01:00Z',
|
|
268
|
-
agent: 'Root',
|
|
269
|
-
type: 'tool_call',
|
|
270
|
-
summary: 'Level 1',
|
|
271
|
-
children: [
|
|
272
|
-
{
|
|
273
|
-
id: 'level-2',
|
|
274
|
-
timestamp: '2025-01-22T10:02:00Z',
|
|
275
|
-
agent: 'Root',
|
|
276
|
-
type: 'file_edit',
|
|
277
|
-
summary: 'Level 2',
|
|
278
|
-
},
|
|
279
|
-
],
|
|
280
|
-
},
|
|
281
|
-
],
|
|
282
|
-
};
|
|
283
|
-
const result = TrajectoryDecisionSchema.parse(decision);
|
|
284
|
-
expect(result.children?.[0].children?.[0].id).toBe('level-2');
|
|
285
|
-
});
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
describe('TrajectorySchema', () => {
|
|
289
|
-
it('should validate complete trajectory', () => {
|
|
290
|
-
const trajectory = {
|
|
291
|
-
agentName: 'FullStack',
|
|
292
|
-
sessionId: 'session-001',
|
|
293
|
-
decisions: [
|
|
294
|
-
{
|
|
295
|
-
id: 'traj-001',
|
|
296
|
-
timestamp: '2025-01-22T10:00:00Z',
|
|
297
|
-
agent: 'FullStack',
|
|
298
|
-
type: 'tool_call',
|
|
299
|
-
summary: 'Start work',
|
|
300
|
-
outcome: 'success',
|
|
301
|
-
},
|
|
302
|
-
],
|
|
303
|
-
startTime: '2025-01-22T10:00:00Z',
|
|
304
|
-
endTime: '2025-01-22T12:00:00Z',
|
|
305
|
-
};
|
|
306
|
-
const result = TrajectorySchema.parse(trajectory);
|
|
307
|
-
expect(result.agentName).toBe('FullStack');
|
|
308
|
-
expect(result.decisions).toHaveLength(1);
|
|
309
|
-
expect(result.endTime).toBe('2025-01-22T12:00:00Z');
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
it('should allow trajectory without endTime (in progress)', () => {
|
|
313
|
-
const trajectory = {
|
|
314
|
-
agentName: 'Worker',
|
|
315
|
-
sessionId: 'session-002',
|
|
316
|
-
decisions: [],
|
|
317
|
-
startTime: '2025-01-22T11:00:00Z',
|
|
318
|
-
};
|
|
319
|
-
const result = TrajectorySchema.parse(trajectory);
|
|
320
|
-
expect(result.endTime).toBeUndefined();
|
|
321
|
-
expect(result.decisions).toHaveLength(0);
|
|
322
|
-
});
|
|
323
|
-
});
|
|
324
|
-
});
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Decision Schemas
|
|
3
|
-
*
|
|
4
|
-
* Zod schemas for decision queue types used across the dashboard and API.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { z } from 'zod';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Decision urgency/priority enum
|
|
11
|
-
*/
|
|
12
|
-
export const DecisionUrgencySchema = z.enum(['low', 'medium', 'high', 'critical']);
|
|
13
|
-
export type DecisionUrgency = z.infer<typeof DecisionUrgencySchema>;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Decision category enum
|
|
17
|
-
*/
|
|
18
|
-
export const DecisionCategorySchema = z.enum(['approval', 'choice', 'input', 'confirmation']);
|
|
19
|
-
export type DecisionCategory = z.infer<typeof DecisionCategorySchema>;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Decision option schema
|
|
23
|
-
*/
|
|
24
|
-
export const DecisionOptionSchema = z.object({
|
|
25
|
-
id: z.string(),
|
|
26
|
-
label: z.string(),
|
|
27
|
-
description: z.string().optional(),
|
|
28
|
-
});
|
|
29
|
-
export type DecisionOption = z.infer<typeof DecisionOptionSchema>;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* API Decision schema (from API response)
|
|
33
|
-
*/
|
|
34
|
-
export const ApiDecisionSchema = z.object({
|
|
35
|
-
id: z.string(),
|
|
36
|
-
agentName: z.string(),
|
|
37
|
-
title: z.string(),
|
|
38
|
-
description: z.string(),
|
|
39
|
-
options: z.array(DecisionOptionSchema).optional(),
|
|
40
|
-
urgency: DecisionUrgencySchema,
|
|
41
|
-
category: DecisionCategorySchema,
|
|
42
|
-
createdAt: z.string(),
|
|
43
|
-
expiresAt: z.string().optional(),
|
|
44
|
-
context: z.record(z.unknown()).optional(),
|
|
45
|
-
});
|
|
46
|
-
export type ApiDecision = z.infer<typeof ApiDecisionSchema>;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Decision schema (component format)
|
|
50
|
-
*/
|
|
51
|
-
export const DecisionSchema = z.object({
|
|
52
|
-
id: z.string(),
|
|
53
|
-
agentName: z.string(),
|
|
54
|
-
timestamp: z.union([z.string(), z.number()]),
|
|
55
|
-
type: DecisionCategorySchema,
|
|
56
|
-
title: z.string(),
|
|
57
|
-
description: z.string(),
|
|
58
|
-
options: z.array(DecisionOptionSchema).optional(),
|
|
59
|
-
priority: DecisionUrgencySchema,
|
|
60
|
-
context: z.record(z.unknown()).optional(),
|
|
61
|
-
expiresAt: z.union([z.string(), z.number()]).optional(),
|
|
62
|
-
});
|
|
63
|
-
export type Decision = z.infer<typeof DecisionSchema>;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Pending decision schema (simplified format)
|
|
67
|
-
*/
|
|
68
|
-
export const PendingDecisionSchema = z.object({
|
|
69
|
-
id: z.string(),
|
|
70
|
-
agent: z.string(),
|
|
71
|
-
question: z.string(),
|
|
72
|
-
options: z.array(z.string()).optional(),
|
|
73
|
-
context: z.string().optional(),
|
|
74
|
-
priority: DecisionUrgencySchema,
|
|
75
|
-
createdAt: z.string(),
|
|
76
|
-
expiresAt: z.string().optional(),
|
|
77
|
-
});
|
|
78
|
-
export type PendingDecision = z.infer<typeof PendingDecisionSchema>;
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Trajectory decision type enum (for tracking)
|
|
82
|
-
*/
|
|
83
|
-
export const TrajectoryDecisionTypeSchema = z.enum([
|
|
84
|
-
'tool_call',
|
|
85
|
-
'message',
|
|
86
|
-
'file_edit',
|
|
87
|
-
'command',
|
|
88
|
-
'question',
|
|
89
|
-
]);
|
|
90
|
-
export type TrajectoryDecisionType = z.infer<typeof TrajectoryDecisionTypeSchema>;
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Trajectory decision outcome enum
|
|
94
|
-
*/
|
|
95
|
-
export const TrajectoryDecisionOutcomeSchema = z.enum(['success', 'error', 'pending']);
|
|
96
|
-
export type TrajectoryDecisionOutcome = z.infer<typeof TrajectoryDecisionOutcomeSchema>;
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Trajectory decision schema (for decision tracking)
|
|
100
|
-
*/
|
|
101
|
-
export const TrajectoryDecisionSchema: z.ZodType<TrajectoryDecision> = z.lazy(() =>
|
|
102
|
-
z.object({
|
|
103
|
-
id: z.string(),
|
|
104
|
-
timestamp: z.string(),
|
|
105
|
-
agent: z.string(),
|
|
106
|
-
type: TrajectoryDecisionTypeSchema,
|
|
107
|
-
summary: z.string(),
|
|
108
|
-
details: z.string().optional(),
|
|
109
|
-
context: z.string().optional(),
|
|
110
|
-
outcome: TrajectoryDecisionOutcomeSchema.optional(),
|
|
111
|
-
children: z.array(TrajectoryDecisionSchema).optional(),
|
|
112
|
-
})
|
|
113
|
-
);
|
|
114
|
-
export type TrajectoryDecision = {
|
|
115
|
-
id: string;
|
|
116
|
-
timestamp: string;
|
|
117
|
-
agent: string;
|
|
118
|
-
type: TrajectoryDecisionType;
|
|
119
|
-
summary: string;
|
|
120
|
-
details?: string;
|
|
121
|
-
context?: string;
|
|
122
|
-
outcome?: TrajectoryDecisionOutcome;
|
|
123
|
-
children?: TrajectoryDecision[];
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Trajectory schema
|
|
128
|
-
*/
|
|
129
|
-
export const TrajectorySchema = z.object({
|
|
130
|
-
agentName: z.string(),
|
|
131
|
-
sessionId: z.string(),
|
|
132
|
-
decisions: z.array(TrajectoryDecisionSchema),
|
|
133
|
-
startTime: z.string(),
|
|
134
|
-
endTime: z.string().optional(),
|
|
135
|
-
});
|
|
136
|
-
export type Trajectory = z.infer<typeof TrajectorySchema>;
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fleet Schema Tests
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { describe, it, expect } from 'vitest';
|
|
6
|
-
import {
|
|
7
|
-
PeerServerStatusSchema,
|
|
8
|
-
PeerServerSchema,
|
|
9
|
-
FleetDataSchema,
|
|
10
|
-
ProjectSchema,
|
|
11
|
-
FleetServerSchema,
|
|
12
|
-
FleetStatsSchema,
|
|
13
|
-
} from './fleet.js';
|
|
14
|
-
|
|
15
|
-
describe('Fleet Schemas', () => {
|
|
16
|
-
describe('PeerServerStatusSchema', () => {
|
|
17
|
-
it('should validate valid statuses', () => {
|
|
18
|
-
expect(PeerServerStatusSchema.parse('connected')).toBe('connected');
|
|
19
|
-
expect(PeerServerStatusSchema.parse('disconnected')).toBe('disconnected');
|
|
20
|
-
expect(PeerServerStatusSchema.parse('error')).toBe('error');
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('should reject invalid status', () => {
|
|
24
|
-
expect(() => PeerServerStatusSchema.parse('unknown')).toThrow();
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
describe('PeerServerSchema', () => {
|
|
29
|
-
it('should validate valid peer server', () => {
|
|
30
|
-
const server = {
|
|
31
|
-
id: 'server-1',
|
|
32
|
-
url: 'http://localhost:3888',
|
|
33
|
-
name: 'Primary Server',
|
|
34
|
-
status: 'connected',
|
|
35
|
-
agentCount: 5,
|
|
36
|
-
latency: 42,
|
|
37
|
-
};
|
|
38
|
-
const result = PeerServerSchema.parse(server);
|
|
39
|
-
expect(result.id).toBe('server-1');
|
|
40
|
-
expect(result.status).toBe('connected');
|
|
41
|
-
expect(result.agentCount).toBe(5);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('should allow optional fields', () => {
|
|
45
|
-
const server = {
|
|
46
|
-
id: 'server-2',
|
|
47
|
-
url: 'http://localhost:3889',
|
|
48
|
-
status: 'disconnected',
|
|
49
|
-
agentCount: 0,
|
|
50
|
-
};
|
|
51
|
-
const result = PeerServerSchema.parse(server);
|
|
52
|
-
expect(result.name).toBeUndefined();
|
|
53
|
-
expect(result.latency).toBeUndefined();
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('should reject missing required fields', () => {
|
|
57
|
-
expect(() => PeerServerSchema.parse({ id: 'server-1' })).toThrow();
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
describe('FleetDataSchema', () => {
|
|
62
|
-
it('should validate fleet data with servers and agents', () => {
|
|
63
|
-
const fleet = {
|
|
64
|
-
servers: [
|
|
65
|
-
{
|
|
66
|
-
id: 'server-1',
|
|
67
|
-
url: 'http://localhost:3888',
|
|
68
|
-
status: 'connected',
|
|
69
|
-
agentCount: 2,
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
agents: [
|
|
73
|
-
{
|
|
74
|
-
name: 'Agent1',
|
|
75
|
-
status: 'online',
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
totalMessages: 150,
|
|
79
|
-
};
|
|
80
|
-
const result = FleetDataSchema.parse(fleet);
|
|
81
|
-
expect(result.servers).toHaveLength(1);
|
|
82
|
-
expect(result.agents).toHaveLength(1);
|
|
83
|
-
expect(result.totalMessages).toBe(150);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('should allow empty arrays', () => {
|
|
87
|
-
const fleet = {
|
|
88
|
-
servers: [],
|
|
89
|
-
agents: [],
|
|
90
|
-
totalMessages: 0,
|
|
91
|
-
};
|
|
92
|
-
const result = FleetDataSchema.parse(fleet);
|
|
93
|
-
expect(result.servers).toHaveLength(0);
|
|
94
|
-
expect(result.agents).toHaveLength(0);
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
describe('ProjectSchema', () => {
|
|
99
|
-
it('should validate project with lead', () => {
|
|
100
|
-
const project = {
|
|
101
|
-
id: 'proj-1',
|
|
102
|
-
path: '/workspace/project',
|
|
103
|
-
name: 'My Project',
|
|
104
|
-
agents: [{ name: 'Worker', status: 'online' }],
|
|
105
|
-
lead: {
|
|
106
|
-
name: 'Lead',
|
|
107
|
-
connected: true,
|
|
108
|
-
},
|
|
109
|
-
};
|
|
110
|
-
const result = ProjectSchema.parse(project);
|
|
111
|
-
expect(result.lead?.name).toBe('Lead');
|
|
112
|
-
expect(result.lead?.connected).toBe(true);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it('should allow project without lead', () => {
|
|
116
|
-
const project = {
|
|
117
|
-
id: 'proj-2',
|
|
118
|
-
path: '/workspace/other',
|
|
119
|
-
agents: [],
|
|
120
|
-
};
|
|
121
|
-
const result = ProjectSchema.parse(project);
|
|
122
|
-
expect(result.lead).toBeUndefined();
|
|
123
|
-
expect(result.name).toBeUndefined();
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
describe('FleetServerSchema', () => {
|
|
128
|
-
it('should validate fleet server with all metrics', () => {
|
|
129
|
-
const server = {
|
|
130
|
-
id: 'fleet-server-1',
|
|
131
|
-
name: 'Production Server',
|
|
132
|
-
status: 'healthy',
|
|
133
|
-
agents: [
|
|
134
|
-
{ name: 'Agent1', status: 'online' },
|
|
135
|
-
{ name: 'Agent2', status: 'busy' },
|
|
136
|
-
],
|
|
137
|
-
cpuUsage: 45.5,
|
|
138
|
-
memoryUsage: 72.3,
|
|
139
|
-
activeConnections: 12,
|
|
140
|
-
uptime: 86400,
|
|
141
|
-
lastHeartbeat: '2025-01-22T10:00:00Z',
|
|
142
|
-
};
|
|
143
|
-
const result = FleetServerSchema.parse(server);
|
|
144
|
-
expect(result.status).toBe('healthy');
|
|
145
|
-
expect(result.agents).toHaveLength(2);
|
|
146
|
-
expect(result.cpuUsage).toBe(45.5);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it('should validate degraded status', () => {
|
|
150
|
-
const server = {
|
|
151
|
-
id: 'fleet-server-2',
|
|
152
|
-
name: 'Secondary Server',
|
|
153
|
-
status: 'degraded',
|
|
154
|
-
agents: [],
|
|
155
|
-
cpuUsage: 95,
|
|
156
|
-
memoryUsage: 88,
|
|
157
|
-
activeConnections: 3,
|
|
158
|
-
uptime: 3600,
|
|
159
|
-
lastHeartbeat: '2025-01-22T09:59:00Z',
|
|
160
|
-
};
|
|
161
|
-
const result = FleetServerSchema.parse(server);
|
|
162
|
-
expect(result.status).toBe('degraded');
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it('should reject invalid status', () => {
|
|
166
|
-
const server = {
|
|
167
|
-
id: 'fleet-server-3',
|
|
168
|
-
name: 'Bad Server',
|
|
169
|
-
status: 'unknown',
|
|
170
|
-
agents: [],
|
|
171
|
-
cpuUsage: 0,
|
|
172
|
-
memoryUsage: 0,
|
|
173
|
-
activeConnections: 0,
|
|
174
|
-
uptime: 0,
|
|
175
|
-
lastHeartbeat: '2025-01-22T10:00:00Z',
|
|
176
|
-
};
|
|
177
|
-
expect(() => FleetServerSchema.parse(server)).toThrow();
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
describe('FleetStatsSchema', () => {
|
|
182
|
-
it('should validate complete stats', () => {
|
|
183
|
-
const stats = {
|
|
184
|
-
totalAgents: 10,
|
|
185
|
-
onlineAgents: 7,
|
|
186
|
-
busyAgents: 3,
|
|
187
|
-
pendingDecisions: 2,
|
|
188
|
-
activeTasks: 5,
|
|
189
|
-
};
|
|
190
|
-
const result = FleetStatsSchema.parse(stats);
|
|
191
|
-
expect(result.totalAgents).toBe(10);
|
|
192
|
-
expect(result.onlineAgents).toBe(7);
|
|
193
|
-
expect(result.busyAgents).toBe(3);
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
it('should validate zero stats', () => {
|
|
197
|
-
const stats = {
|
|
198
|
-
totalAgents: 0,
|
|
199
|
-
onlineAgents: 0,
|
|
200
|
-
busyAgents: 0,
|
|
201
|
-
pendingDecisions: 0,
|
|
202
|
-
activeTasks: 0,
|
|
203
|
-
};
|
|
204
|
-
const result = FleetStatsSchema.parse(stats);
|
|
205
|
-
expect(result.totalAgents).toBe(0);
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
it('should reject missing fields', () => {
|
|
209
|
-
expect(() => FleetStatsSchema.parse({ totalAgents: 5 })).toThrow();
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
});
|