contracts.ts 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /** Host-owned Session identity and read-only paths; no dependency on a Session store implementation. */
  2. export interface ReportSession {
  3. readonly sessionId: string;
  4. readonly sessionKind: string;
  5. }
  6. export interface ReportLocations {
  7. inspectSession(sessionId: string): Promise<
  8. | {
  9. readonly session: ReportSession;
  10. readonly paths: { readonly sessionDir: string; readonly snapshots: string };
  11. }
  12. | undefined
  13. >;
  14. }
  15. export interface ReportSessions {
  16. listChildren(sessionId: string): Promise<readonly { readonly sessionId: string }[]>;
  17. getTaskAgentBinding(sessionId: string): Promise<{ readonly definition: unknown } | undefined>;
  18. }
  19. interface SessionReportArtifactBase {
  20. readonly name: string;
  21. readonly bytes: number;
  22. /** Local collection priority only. Uploaders must minimize these artifacts before transfer. */
  23. readonly required: true;
  24. }
  25. export type SessionReportArtifact = SessionReportArtifactBase &
  26. (
  27. | { readonly path: string; readonly content?: never }
  28. | { readonly content: string; readonly path?: never }
  29. );
  30. export interface SessionReportManifest {
  31. readonly schemaVersion: 1;
  32. readonly rootSessionId: string;
  33. readonly sessionIds: readonly string[];
  34. readonly artifacts: readonly SessionReportArtifact[];
  35. }
  36. export interface SessionReportCapability {
  37. collect(sessionId: string): Promise<SessionReportManifest>;
  38. }
  39. export interface SessionLlmCallToolEnvelope {
  40. readonly name: string;
  41. readonly description: string;
  42. readonly parameters: unknown;
  43. }
  44. /** Secret-free, non-message inputs needed to reconstruct an agent LLM call. */
  45. export interface SessionLlmCallEnvelope {
  46. readonly schemaVersion: 1;
  47. readonly systemPrompt: string;
  48. readonly tools: readonly SessionLlmCallToolEnvelope[];
  49. readonly model: string;
  50. readonly provider: string;
  51. readonly api: string;
  52. readonly thinkingLevel: string;
  53. readonly maxTokens?: number;
  54. readonly hostMaxOutputTokens?: number;
  55. readonly maxSerializedInputBytes?: number;
  56. readonly cacheRetention?: string;
  57. readonly outputSchema?: Readonly<Record<string, unknown>>;
  58. readonly outputRevisionInstruction?: string;
  59. }
  60. export interface SessionLlmCallReportCapability {
  61. writeCurrent(input: {
  62. readonly sessionId: string;
  63. readonly turnId: string;
  64. readonly envelope: SessionLlmCallEnvelope;
  65. }): Promise<void>;
  66. freezeCompletedCompaction(input: {
  67. readonly sessionId: string;
  68. readonly compactionId: string;
  69. }): Promise<void>;
  70. pruneAfterRewind(input: { readonly sessionId: string }): Promise<void>;
  71. copySnapshotCompanions(input: {
  72. readonly sourceSessionId: string;
  73. readonly targetSessionId: string;
  74. readonly snapshotFiles: readonly string[];
  75. }): Promise<void>;
  76. }