agent-service.ts 960 B

1234567891011121314151617181920212223
  1. import {
  2. LocalAgentService,
  3. type LocalAgentServiceOptions,
  4. } from '../../src/service/agent/application/agent.service.js';
  5. /**
  6. * Builds a `LocalAgentService` for tests that are not about model validation.
  7. *
  8. * Every Agent write path is fail-closed on the candidate-model gate (see
  9. * `AgentConfigDocuments.assertCandidateModelIsUsable`): an unbound validator
  10. * means "the runtime is not ready", not "allowed". Production binds the real
  11. * validator in `runtime-session-composition`; storage/service tests that only
  12. * exercise persistence bind a permissive one here so the gate does not mask
  13. * what they actually assert.
  14. *
  15. * Tests covering the gate itself bind their own validator instead of using
  16. * this helper.
  17. */
  18. export function createTestAgentService(options: LocalAgentServiceOptions): LocalAgentService {
  19. const service = new LocalAgentService(options);
  20. service.bindCandidateModelValidator(async () => ({ ok: true }));
  21. return service;
  22. }