Dax Raad 9 months ago
parent
commit
a96c2ce65c
4 changed files with 81 additions and 67 deletions
  1. 9 9
      js/src/session/message.ts
  2. 4 5
      js/src/session/session.ts
  3. 62 50
      pkg/client/gen/openapi.json
  4. 6 3
      pkg/client/generated-client.go

+ 9 - 9
js/src/session/message.ts

@@ -2,15 +2,6 @@ import z from "zod";
 import { Bus } from "../bus";
 
 export namespace Message {
-  export const Event = {
-    Updated: Bus.event(
-      "message.updated",
-      z.object({
-        sessionID: z.string(),
-        messageID: z.string(),
-      }),
-    ),
-  };
   export const ToolCall = z
     .object({
       state: z.literal("call"),
@@ -167,4 +158,13 @@ export namespace Message {
       ref: "Message.Info",
     });
   export type Info = z.infer<typeof Info>;
+
+  export const Event = {
+    Updated: Bus.event(
+      "message.updated",
+      z.object({
+        info: Info,
+      }),
+    ),
+  };
 }

+ 4 - 5
js/src/session/session.ts

@@ -35,7 +35,7 @@ export namespace Session {
     Updated: Bus.event(
       "session.updated",
       z.object({
-        sessionID: z.string(),
+        info: Info,
       }),
     ),
   };
@@ -60,7 +60,7 @@ export namespace Session {
     await Storage.writeJSON("session/info/" + result.id, result);
     await share(result.id);
     Bus.publish(Event.Updated, {
-      sessionID: result.id,
+      info: result,
     });
     return result;
   }
@@ -94,7 +94,7 @@ export namespace Session {
     sessions.set(id, session);
     await Storage.writeJSON("session/info/" + id, session);
     Bus.publish(Event.Updated, {
-      sessionID: id,
+      info: session,
     });
     return session;
   }
@@ -147,8 +147,7 @@ export namespace Session {
         msg,
       );
       Bus.publish(Message.Event.Updated, {
-        sessionID: input.sessionID,
-        messageID: msg.id,
+        info: msg,
       });
     }
     const app = await App.use();

+ 62 - 50
pkg/client/gen/openapi.json

@@ -357,16 +357,12 @@
           "properties": {
             "type": "object",
             "properties": {
-              "sessionID": {
-                "type": "string"
-              },
-              "messageID": {
-                "type": "string"
+              "info": {
+                "$ref": "#/components/schemas/Message.Info"
               }
             },
             "required": [
-              "sessionID",
-              "messageID"
+              "info"
             ]
           }
         },
@@ -375,49 +371,6 @@
           "properties"
         ]
       },
-      "Event.session.updated": {
-        "type": "object",
-        "properties": {
-          "type": {
-            "type": "string",
-            "const": "session.updated"
-          },
-          "properties": {
-            "type": "object",
-            "properties": {
-              "sessionID": {
-                "type": "string"
-              }
-            },
-            "required": [
-              "sessionID"
-            ]
-          }
-        },
-        "required": [
-          "type",
-          "properties"
-        ]
-      },
-      "Session.Info": {
-        "type": "object",
-        "properties": {
-          "id": {
-            "type": "string",
-            "pattern": "^ses"
-          },
-          "shareID": {
-            "type": "string"
-          },
-          "title": {
-            "type": "string"
-          }
-        },
-        "required": [
-          "id",
-          "title"
-        ]
-      },
       "Message.Info": {
         "type": "object",
         "properties": {
@@ -760,6 +713,65 @@
           "type"
         ]
       },
+      "Event.session.updated": {
+        "type": "object",
+        "properties": {
+          "type": {
+            "type": "string",
+            "const": "session.updated"
+          },
+          "properties": {
+            "type": "object",
+            "properties": {
+              "info": {
+                "type": "object",
+                "properties": {
+                  "id": {
+                    "type": "string",
+                    "pattern": "^ses"
+                  },
+                  "shareID": {
+                    "type": "string"
+                  },
+                  "title": {
+                    "type": "string"
+                  }
+                },
+                "required": [
+                  "id",
+                  "title"
+                ]
+              }
+            },
+            "required": [
+              "info"
+            ]
+          }
+        },
+        "required": [
+          "type",
+          "properties"
+        ]
+      },
+      "Session.Info": {
+        "type": "object",
+        "properties": {
+          "id": {
+            "type": "string",
+            "pattern": "^ses"
+          },
+          "shareID": {
+            "type": "string"
+          },
+          "title": {
+            "type": "string"
+          }
+        },
+        "required": [
+          "id",
+          "title"
+        ]
+      },
       "Provider.Info": {
         "type": "object",
         "properties": {

+ 6 - 3
pkg/client/generated-client.go

@@ -41,8 +41,7 @@ type EventLspClientDiagnostics struct {
 // EventMessageUpdated defines model for Event.message.updated.
 type EventMessageUpdated struct {
 	Properties struct {
-		MessageID string `json:"messageID"`
-		SessionID string `json:"sessionID"`
+		Info MessageInfo `json:"info"`
 	} `json:"properties"`
 	Type string `json:"type"`
 }
@@ -50,7 +49,11 @@ type EventMessageUpdated struct {
 // EventSessionUpdated defines model for Event.session.updated.
 type EventSessionUpdated struct {
 	Properties struct {
-		SessionID string `json:"sessionID"`
+		Info struct {
+			Id      string  `json:"id"`
+			ShareID *string `json:"shareID,omitempty"`
+			Title   string  `json:"title"`
+		} `json:"info"`
 	} `json:"properties"`
 	Type string `json:"type"`
 }