(ctx context.Context, cancel context.CancelFunc, additionalPrompt string)
| 1103 | } |
| 1104 | |
| 1105 | func (a *App) CompactSession(ctx context.Context, cancel context.CancelFunc, additionalPrompt string) { |
| 1106 | a.cancel = cancel |
| 1107 | |
| 1108 | sess := a.session |
| 1109 | if sess == nil { |
| 1110 | cancel() |
| 1111 | return |
| 1112 | } |
| 1113 | |
| 1114 | go func() { |
| 1115 | defer cancel() |
| 1116 | |
| 1117 | agentName := a.runtime.CurrentAgentName(ctx) |
| 1118 | completed := false |
| 1119 | events := make(chan runtime.Event, 100) |
| 1120 | go func() { |
| 1121 | defer close(events) |
| 1122 | a.runtime.Summarize(ctx, sess, additionalPrompt, runtime.NewChannelSink(events)) |
| 1123 | }() |
| 1124 | for event := range events { |
| 1125 | if ctx.Err() != nil { |
| 1126 | return |
| 1127 | } |
| 1128 | if e, ok := event.(*runtime.SessionCompactionEvent); ok && e.Status == "completed" { |
| 1129 | completed = true |
| 1130 | } |
| 1131 | a.sendEvent(ctx, event) |
| 1132 | } |
| 1133 | if !completed && ctx.Err() == nil { |
| 1134 | a.sendEvent(ctx, runtime.SessionCompaction(sess.ID, "completed", agentName)) |
| 1135 | } |
| 1136 | }() |
| 1137 | } |
| 1138 | |
| 1139 | func (a *App) PlainTextTranscript() string { |
| 1140 | return transcript.PlainText(a.session) |
nothing calls this directly
no test coverage detected