(ctx context.Context, raw json.RawMessage)
| 912 | } |
| 913 | |
| 914 | func (h *HostAPIHandler) handleSessionsCreate(ctx context.Context, raw json.RawMessage) (any, error) { |
| 915 | if h.sessions == nil { |
| 916 | return nil, errors.New("extension: session manager is not configured") |
| 917 | } |
| 918 | |
| 919 | var params hostAPISessionCreateParams |
| 920 | if err := decodeHostAPIParams(raw, ¶ms); err != nil { |
| 921 | return nil, err |
| 922 | } |
| 923 | if strings.TrimSpace(params.Agent) == "" { |
| 924 | return nil, invalidParamsRPCError(errors.New("agent is required")) |
| 925 | } |
| 926 | |
| 927 | sess, err := h.sessions.Create(ctx, session.CreateOpts{ |
| 928 | AgentName: strings.TrimSpace(params.Agent), |
| 929 | Provider: strings.TrimSpace(params.Provider), |
| 930 | Model: strings.TrimSpace(params.Model), |
| 931 | ReasoningEffort: strings.TrimSpace(params.ReasoningEffort), |
| 932 | Workspace: strings.TrimSpace(params.Workspace), |
| 933 | Type: session.SessionTypeSystem, |
| 934 | }) |
| 935 | if err != nil { |
| 936 | return nil, err |
| 937 | } |
| 938 | |
| 939 | if prompt := strings.TrimSpace(params.Prompt); prompt != "" { |
| 940 | if _, err := h.submitPrompt(ctx, sess.ID, prompt); err != nil { |
| 941 | return nil, err |
| 942 | } |
| 943 | } |
| 944 | |
| 945 | return hostAPISessionCreateResult{ |
| 946 | SessionID: sess.ID, |
| 947 | Provider: sess.Info().Provider, |
| 948 | }, nil |
| 949 | } |
| 950 | |
| 951 | func (h *HostAPIHandler) handleSessionsPrompt(ctx context.Context, raw json.RawMessage) (any, error) { |
| 952 | var params hostAPISessionPromptParams |
nothing calls this directly
no test coverage detected