@@ -46,6 +46,24 @@ json build_session_create_request(const SessionConfig& config);
4646// / @return JSON object ready to send to server
4747json build_session_resume_request (const std::string& session_id, const ResumeSessionConfig& config);
4848
49+ // / Build the CLI argument vector that {@link Client} will pass to the spawned
50+ // / Copilot CLI process, given a fully-populated {@link ClientOptions}.
51+ // / Exposed for conformance unit testing of process-launch behavior. Mirrors
52+ // / what `start_cli_server()` emits before command resolution (i.e. no Node /
53+ // / `cmd /c` wrapping is applied).
54+ // / @param options Client options
55+ // / @return Argument list (does not include the executable itself)
56+ std::vector<std::string> build_cli_command_args (const ClientOptions& options);
57+
58+ // / Build the environment-variable map that {@link Client} will use when
59+ // / spawning the Copilot CLI process. The returned map reflects the SDK's
60+ // / additions and removals (COPILOT_HOME, COPILOT_CONNECTION_TOKEN,
61+ // / COPILOT_SDK_AUTH_TOKEN, NODE_DEBUG erase) layered on top of the explicit
62+ // / `options.environment`. Exposed for conformance unit testing.
63+ // / @param options Client options
64+ // / @return Environment map ready for ProcessOptions::environment
65+ std::map<std::string, std::string> build_cli_environment (const ClientOptions& options);
66+
4967// =============================================================================
5068// CopilotClient - Main client class
5169// =============================================================================
@@ -126,6 +144,17 @@ class Client
126144 // / @return Future that resolves to list of session metadata
127145 std::future<std::vector<SessionMetadata>> list_sessions ();
128146
147+ // / List sessions matching a filter (matches upstream nodejs SDK).
148+ // / @param filter Filter criteria (cwd / git_root / repository / branch)
149+ // / @return Future that resolves to list of matching session metadata
150+ std::future<std::vector<SessionMetadata>> list_sessions (SessionListFilter filter);
151+
152+ // / Get metadata for a specific session by ID (O(1) lookup).
153+ // / @param session_id ID of the session
154+ // / @return Future that resolves to metadata, or nullopt if not found
155+ std::future<std::optional<SessionMetadata>>
156+ get_session_metadata (const std::string& session_id);
157+
129158 // / Delete a session
130159 // / @param session_id ID of the session to delete
131160 // / @return Future that completes when deleted
@@ -157,6 +186,18 @@ class Client
157186 // / @throws Error if not authenticated
158187 std::future<std::vector<ModelInfo>> list_models ();
159188
189+ // / Provide a custom handler for listing available models (BYOK mode).
190+ // / When set, Client::list_models() calls this handler instead of querying
191+ // / the CLI server. Results are still cached after the first successful call;
192+ // / pass nullptr to revert to default RPC-based behavior. Matches upstream
193+ // / nodejs CopilotClientOptions.onListModels.
194+ using ListModelsHandler = std::function<std::vector<ModelInfo>()>;
195+ void set_on_list_models (ListModelsHandler handler);
196+
197+ // / Get the negotiated protocol version (set after successful start()).
198+ // / Returns std::nullopt before connection is established.
199+ std::optional<int > negotiated_protocol_version () const ;
200+
160201 // =========================================================================
161202 // Lifecycle Events
162203 // =========================================================================
@@ -217,6 +258,10 @@ class Client
217258 // / Handle incoming user input requests
218259 json handle_user_input_request (const json& params);
219260
261+ json handle_elicitation_request (const json& params);
262+ json handle_exit_plan_mode_request (const json& params);
263+ json handle_auto_mode_switch_request (const json& params);
264+
220265 // / Handle incoming hook invocations
221266 json handle_hooks_invoke (const json& params);
222267
@@ -241,9 +286,17 @@ class Client
241286 mutable std::mutex models_cache_mutex_;
242287 std::optional<std::vector<ModelInfo>> models_cache_;
243288
289+ // BYOK: optional custom models handler (when set, takes precedence over RPC).
290+ mutable std::mutex on_list_models_mutex_;
291+ ListModelsHandler on_list_models_;
292+
244293 // Lifecycle handlers
245294 mutable std::mutex lifecycle_mutex_;
246295 std::vector<LifecycleHandler> lifecycle_handlers_;
296+
297+ // Protocol version negotiation result (set after verify_protocol_version()).
298+ mutable std::mutex protocol_version_mutex_;
299+ std::optional<int > negotiated_protocol_version_;
247300};
248301
249302} // namespace copilot
0 commit comments