hosted-capability-contracts.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import type {
  2. InternalTurnPromptReadRegistry,
  3. PromptReadScope,
  4. PromptSnapshotSource,
  5. } from '@mavis/agent-core';
  6. import type { RuntimeConversation } from '@mavis/conversation-contract';
  7. import type { LocalRuntimeLogger } from '../common/logger.js';
  8. import type { MetricsClient } from '../common/metrics.js';
  9. import type { LocalRuntimeConfig } from '../config/types.js';
  10. import type { RemoteTokenCounter } from '../context/remote-token-counter.js';
  11. import type { ReviewActivityIdentity } from './activity-events.js';
  12. import type { createReviewAfterLlmHook } from './after-llm-hook.js';
  13. import type { ReviewTurnState } from './turn-state.js';
  14. export interface HostedReviewTurnIdentity {
  15. readonly sessionId: string;
  16. readonly turnId: string;
  17. }
  18. export interface HostedReviewIntent {
  19. readonly kind: string;
  20. readonly attributes?: Readonly<Record<string, string>>;
  21. }
  22. export interface HostedReviewPromptInput extends HostedReviewTurnIdentity {
  23. readonly agentName: string;
  24. readonly workspaceDir: string;
  25. readonly userInput: string;
  26. readonly intent?: HostedReviewIntent;
  27. readonly promptRead?: PromptReadScope;
  28. }
  29. export interface HostedReviewCapabilityOptions {
  30. readonly reviewPromptDir: string;
  31. readonly configGetter: () => LocalRuntimeConfig;
  32. readonly conversation?: RuntimeConversation;
  33. readonly metricsClient?: MetricsClient;
  34. readonly logger?: Pick<LocalRuntimeLogger, 'info' | 'warn' | 'error'>;
  35. readonly remoteCounter?: RemoteTokenCounter;
  36. readonly nowMs?: () => number;
  37. readonly promptSnapshots?: () => PromptSnapshotSource | undefined;
  38. readonly internalTurnPromptReads?: () => InternalTurnPromptReadRegistry | undefined;
  39. }
  40. export interface StoredReviewTurn {
  41. readonly state: ReviewTurnState;
  42. promptRead?: PromptReadScope;
  43. afterLlmHook?: ReturnType<typeof createReviewAfterLlmHook>;
  44. subagentRun?: Promise<HostedReviewSubagentResult>;
  45. activity?: ReviewActivityIdentity & { terminal?: boolean };
  46. }
  47. export type HostedReviewSubagentResult =
  48. | { readonly status: 'succeeded'; readonly finalText: string }
  49. | { readonly status: 'failed'; readonly errorMessage: string }
  50. | { readonly status: 'aborted' };