| 1 | package agent |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | |
| 6 | "reasonix/internal/persistentshell" |
| 7 | "reasonix/internal/sessiontemp" |
| 8 | ) |
| 9 | |
| 10 | // withSubagentSessionTemp installs a private temporary directory and persistent |
| 11 | // shell for one sub-agent run. The returned release must be deferred by the |
| 12 | // caller so both are retired when the run ends. |
| 13 | func withSubagentSessionTemp(ctx context.Context) (context.Context, func()) { |
| 14 | m := sessiontemp.New() |
| 15 | m.Retain() |
| 16 | ps := persistentshell.New() |
| 17 | ps.Retain() |
| 18 | ctx = sessiontemp.WithManager(ctx, m) |
| 19 | ctx = persistentshell.WithManager(ctx, ps) |
| 20 | return ctx, func() { |
| 21 | ps.Release() |
| 22 | m.Release() |
| 23 | } |
| 24 | } |
| 25 |