validateNewClientForMode checks the cross-cutting requirements that [ModeEmpty] places on [ClientOptions]. Called from [NewClient].
(opts *ClientOptions)
| 15 | // validateNewClientForMode checks the cross-cutting requirements that |
| 16 | // [ModeEmpty] places on [ClientOptions]. Called from [NewClient]. |
| 17 | func validateNewClientForMode(opts *ClientOptions) { |
| 18 | if opts == nil || opts.Mode != ModeEmpty { |
| 19 | return |
| 20 | } |
| 21 | // Empty mode requires durable, app-owned storage. Either: |
| 22 | // - the app supplied a BaseDirectory the runtime can write to, |
| 23 | // - the app supplied a SessionFS implementation, |
| 24 | // - or the app is connecting to an externally-managed runtime via |
| 25 | // URIConnection (in which case the host owns storage). |
| 26 | if opts.BaseDirectory != "" { |
| 27 | return |
| 28 | } |
| 29 | if opts.SessionFS != nil { |
| 30 | return |
| 31 | } |
| 32 | if _, ok := opts.Connection.(URIConnection); ok { |
| 33 | return |
| 34 | } |
| 35 | panic("Client is in Mode=ModeEmpty but neither BaseDirectory, SessionFS, nor a URIConnection was supplied. " + |
| 36 | "Empty mode requires explicit, per-tenant storage; set ClientOptions.BaseDirectory or .SessionFS, " + |
| 37 | "or connect to an externally-managed runtime via URIConnection.") |
| 38 | } |
| 39 | |
| 40 | // validateToolFilterList rejects bare "*" entries with an actionable error |
| 41 | // pointing at the [ToolSet] builder. Called for both availableTools and |
no outgoing calls
no test coverage detected
searching dependent graphs…