@@ -32,6 +32,7 @@ import (
3232)
3333
3434const version = "0.0.0-dev"
35+ const chromeNativeHostProtocolVersion = "1"
3536
3637func main () {
3738 os .Exit (run (os .Args [1 :], os .Stdin , os .Stdout , os .Stderr ))
@@ -236,8 +237,14 @@ func handleChromeNativeHostMessage(raw json.RawMessage) map[string]any {
236237 switch strings .ToLower (strings .TrimSpace (messageType )) {
237238 case "ping" :
238239 return map [string ]any {"type" : "pong" , "ok" : true }
240+ case "hello" , "capabilities" :
241+ return chromeNativeHostCapabilitiesResponse ()
242+ case "runtime" , "session" :
243+ return chromeNativeHostRuntimeResponse (strings .ToLower (strings .TrimSpace (messageType )))
239244 case "status" :
240- return map [string ]any {"type" : "status" , "ok" : true , "runtime" : "ccgo" , "version" : version }
245+ response := chromeNativeHostRuntimeResponse ("status" )
246+ response ["capabilities" ] = chromeNativeHostCapabilities ()
247+ return response
241248 default :
242249 if messageType == "" {
243250 messageType = "(missing)"
@@ -246,6 +253,42 @@ func handleChromeNativeHostMessage(raw json.RawMessage) map[string]any {
246253 }
247254}
248255
256+ func chromeNativeHostCapabilitiesResponse () map [string ]any {
257+ return map [string ]any {
258+ "type" : "capabilities" ,
259+ "ok" : true ,
260+ "runtime" : "ccgo" ,
261+ "version" : version ,
262+ "protocol_version" : chromeNativeHostProtocolVersion ,
263+ "capabilities" : chromeNativeHostCapabilities (),
264+ }
265+ }
266+
267+ func chromeNativeHostRuntimeResponse (responseType string ) map [string ]any {
268+ if responseType == "" {
269+ responseType = "runtime"
270+ }
271+ return map [string ]any {
272+ "type" : responseType ,
273+ "ok" : true ,
274+ "runtime" : "ccgo" ,
275+ "version" : version ,
276+ "protocol_version" : chromeNativeHostProtocolVersion ,
277+ "pid" : os .Getpid (),
278+ }
279+ }
280+
281+ func chromeNativeHostCapabilities () map [string ]any {
282+ return map [string ]any {
283+ "ping" : true ,
284+ "status" : true ,
285+ "hello" : true ,
286+ "capabilities" : true ,
287+ "runtime" : true ,
288+ "session" : true ,
289+ }
290+ }
291+
249292func applyCWDFlag (state * bootstrap.State , raw string ) error {
250293 cwd := strings .TrimSpace (raw )
251294 if cwd == "" {
0 commit comments