summaryrefslogtreecommitdiffhomepage
path: root/packages/function
diff options
context:
space:
mode:
authorFrank <[email protected]>2025-06-10 15:50:40 -0400
committerFrank <[email protected]>2025-06-10 15:50:42 -0400
commit772e1851c049f4f861632dacdee9cb1b3e0bda17 (patch)
tree55b593c297b61665bb5c50245742406adbe03d87 /packages/function
parent5ab2ff9589aadc36c778b919940475f0a966f8d2 (diff)
downloadopencode-772e1851c049f4f861632dacdee9cb1b3e0bda17.tar.gz
opencode-772e1851c049f4f861632dacdee9cb1b3e0bda17.zip
Share: render url on frontend
Diffstat (limited to 'packages/function')
-rw-r--r--packages/function/src/api.ts22
1 files changed, 0 insertions, 22 deletions
diff --git a/packages/function/src/api.ts b/packages/function/src/api.ts
index c2e166db7..a312b1280 100644
--- a/packages/function/src/api.ts
+++ b/packages/function/src/api.ts
@@ -1,6 +1,5 @@
import { DurableObject } from "cloudflare:workers"
import { randomUUID } from "node:crypto"
-import { Base64 } from "js-base64"
type Env = {
SYNC_SERVER: DurableObjectNamespace<SyncServer>
@@ -184,9 +183,6 @@ export default {
let info
const messages: Record<string, any> = {}
- let cost = 0
- const models: Set<string> = new Set()
- const version = "v0.1.1"
data.forEach((d) => {
const [root, type, ...splits] = d.key.split("/")
if (root !== "session") return
@@ -197,31 +193,13 @@ export default {
if (type === "message") {
const [, messageID] = splits
messages[messageID] = d.content
-
- const assistant = d.content.metadata?.assistant
- if (assistant) {
- cost += assistant.cost
- models.add(assistant.modelID)
- }
}
})
- const encodedTitle = encodeURIComponent(
- Base64.encode(
- // Convert to ASCII
- encodeURIComponent(
- // Truncate to fit S3's max key size
- info.title.substring(0, 700),
- ),
- ),
- )
- const encodedCost = encodeURIComponent(`$${cost.toFixed(2)}`)
-
return new Response(
JSON.stringify({
info,
messages,
- ogImage: `https://social-cards.sst.dev/opencode-share/${encodedTitle}.png?cost=${encodedCost}&model=${Array.from(models).join(",")}&version=${version}&id=${id}`,
}),
{
headers: { "Content-Type": "application/json" },