CreateSession creates a new conversation session with the Copilot CLI. Sessions maintain conversation state, handle events, and manage tool execution. If the client is not connected, this will automatically start the runtime. The config parameter is optional. If no OnPermissionRequest handler is p
(config *SystemMessageConfig)
| 631 | // extractTransformCallbacks separates transform callbacks from a SystemMessageConfig, |
| 632 | // returning a wire-safe config and a map of callbacks (nil if none). |
| 633 | func extractTransformCallbacks(config *SystemMessageConfig) (*SystemMessageConfig, map[string]SectionTransformFn) { |
| 634 | if config == nil || config.Mode != "customize" || len(config.Sections) == 0 { |
| 635 | return config, nil |
| 636 | } |
| 637 | |
| 638 | callbacks := make(map[string]SectionTransformFn) |
| 639 | wireSections := make(map[string]SectionOverride) |
| 640 | for id, override := range config.Sections { |
| 641 | if override.Transform != nil { |
| 642 | callbacks[id] = override.Transform |
| 643 | wireSections[id] = SectionOverride{Action: "transform"} |
| 644 | } else { |
| 645 | wireSections[id] = override |
| 646 | } |
| 647 | } |
| 648 | |
| 649 | if len(callbacks) == 0 { |
| 650 | return config, nil |
| 651 | } |
| 652 | |
| 653 | wireConfig := &SystemMessageConfig{ |
| 654 | Mode: config.Mode, |
| 655 | Content: config.Content, |
| 656 | Sections: wireSections, |
| 657 | } |
| 658 | return wireConfig, callbacks |
| 659 | } |
| 660 | |
| 661 | func (c *Client) CreateSession(ctx context.Context, config *SessionConfig) (*Session, error) { |
| 662 | if config == nil { |
no outgoing calls
no test coverage detected
searching dependent graphs…