Browse Source

Clean up code formatting and remove unused imports for better consistency

🤖 Generated with opencode
Co-Authored-By: opencode <[email protected]>
Dax Raad 9 months ago
parent
commit
b75456f5dd
3 changed files with 11 additions and 13 deletions
  1. 0 1
      js/src/bus/index.ts
  2. 3 4
      js/src/index.ts
  3. 8 8
      js/src/session/session.ts

+ 0 - 1
js/src/bus/index.ts

@@ -52,7 +52,6 @@ export namespace Bus {
     };
     log.info("publishing", {
       type: def.type,
-      ...properties,
     });
     for (const key of [def.type, "*"]) {
       const match = state().subscriptions.get(key);

+ 3 - 4
js/src/index.ts

@@ -5,7 +5,6 @@ import path from "path";
 import { Bus } from "./bus";
 import { Session } from "./session/session";
 import cac from "cac";
-import { Storage } from "./storage/storage";
 import { Share } from "./share/share";
 
 const cli = cac("opencode");
@@ -24,11 +23,11 @@ cli.command("generate", "Generate OpenAPI and event specs").action(async () => {
   await fs.mkdir(dir, { recursive: true });
   await Bun.write(
     path.join(dir, "openapi.json"),
-    JSON.stringify(specs, null, 2)
+    JSON.stringify(specs, null, 2),
   );
   await Bun.write(
     path.join(dir, "event.json"),
-    JSON.stringify(Bus.specs(), null, 2)
+    JSON.stringify(Bus.specs(), null, 2),
   );
 });
 
@@ -58,7 +57,7 @@ cli
             part.toolInvocation.args,
             part.toolInvocation.state === "result"
               ? part.toolInvocation.result
-              : ""
+              : "",
           );
         }
       }

+ 8 - 8
js/src/session/session.ts

@@ -88,8 +88,8 @@ export namespace Session {
     if (session.shareID) return session.shareID;
     const shareID = await Share.create(id);
     if (!shareID) return;
-    await update(id, () => {
-      session.shareID = shareID;
+    await update(id, (draft) => {
+      draft.shareID = shareID;
     });
     return shareID as string;
   }
@@ -179,8 +179,8 @@ export namespace Session {
         ]),
         model,
       }).then((result) => {
-        return Session.update(sessionID, (session) => {
-          session.title = result.text;
+        return Session.update(sessionID, (draft) => {
+          draft.title = result.text;
         });
       });
       await write(system);
@@ -293,10 +293,10 @@ export namespace Session {
     session.tokens.input += usage.inputTokens || 0;
     session.tokens.output += usage.outputTokens || 0;
     session.tokens.reasoning += usage.reasoningTokens || 0;
-    await update(sessionID, (session) => {
-      session.tokens.input += usage.inputTokens || 0;
-      session.tokens.output += usage.outputTokens || 0;
-      session.tokens.reasoning += usage.reasoningTokens || 0;
+    await update(sessionID, (draft) => {
+      draft.tokens.input += usage.inputTokens || 0;
+      draft.tokens.output += usage.outputTokens || 0;
+      draft.tokens.reasoning += usage.reasoningTokens || 0;
     });
     return next;
   }