Dax Raad 7 месяцев назад
Родитель
Сommit
61160dc220

+ 0 - 24
README.md

@@ -52,30 +52,6 @@ $ bun run packages/opencode/src/index.ts
 
 ### FAQ
 
-#### How do I use this with OpenRouter?
-
-OpenRouter is not in the Models.dev database yet, but you can configure it manually.
-
-```json title="opencode.json"
-{
-  "$schema": "https://opencode.ai/config.json",
-  "provider": {
-    "openrouter": {
-      "npm": "@openrouter/ai-sdk-provider",
-      "name": "OpenRouter",
-      "options": {},
-      "models": {
-        "anthropic/claude-3.5-sonnet": {
-          "name": "Claude 3.5 Sonnet"
-        }
-      }
-    }
-  }
-}
-```
-
-And then to configure an api key you can do `opencode auth login` and select "Other -> 'openrouter'"
-
 #### How is this different than Claude Code?
 
 It's very similar to Claude Code in terms of capability. Here are the key differences:

+ 28 - 0
packages/opencode/src/server/server.ts

@@ -290,6 +290,34 @@ export namespace Server {
           return c.json(session)
         },
       )
+      .post(
+        "/session_unshare",
+        describeRoute({
+          description: "Unshare the session",
+          responses: {
+            200: {
+              description: "Successfully unshared session",
+              content: {
+                "application/json": {
+                  schema: resolver(Session.Info),
+                },
+              },
+            },
+          },
+        }),
+        zValidator(
+          "json",
+          z.object({
+            sessionID: z.string(),
+          }),
+        ),
+        async (c) => {
+          const body = c.req.valid("json")
+          await Session.unshare(body.sessionID)
+          const session = await Session.get(body.sessionID)
+          return c.json(session)
+        },
+      )
       .post(
         "/session_messages",
         describeRoute({

+ 8 - 0
packages/opencode/src/session/index.ts

@@ -159,6 +159,14 @@ export namespace Session {
     return share
   }
 
+  export async function unshare(id: string) {
+    await Storage.remove("session/share/" + id)
+    await update(id, (draft) => {
+      draft.share = undefined
+    })
+    await Share.remove(id)
+  }
+
   export async function update(id: string, editor: (session: Info) => void) {
     const { sessions } = state()
     const session = await get(id)

+ 7 - 0
packages/opencode/src/share/share.ts

@@ -70,4 +70,11 @@ export namespace Share {
       .then((x) => x.json())
       .then((x) => x as { url: string; secret: string })
   }
+
+  export async function remove(id: string) {
+    return fetch(`${URL}/share_delete`, {
+      method: "POST",
+      body: JSON.stringify({ id }),
+    }).then((x) => x.json())
+  }
 }

+ 5 - 0
packages/opencode/src/storage/storage.ts

@@ -24,6 +24,11 @@ export namespace Storage {
     }
   })
 
+  export async function remove(key: string) {
+    const target = path.join(state().dir, key + ".json")
+    await fs.unlink(target).catch(() => {})
+  }
+
   export async function readJSON<T>(key: string) {
     return Bun.file(path.join(state().dir, key + ".json")).json() as Promise<T>
   }