use new share url

This commit is contained in:
Dax Raad
2025-12-11 00:43:00 -05:00
parent 231390cb7b
commit 578072bb8e
2 changed files with 9 additions and 31 deletions

View File

@@ -11,9 +11,11 @@ import type * as SDK from "@opencode-ai/sdk/v2"
export namespace ShareNext {
const log = Log.create({ service: "share-next" })
async function url() {
return Config.get().then((x) => x.enterprise?.url ?? "https://opncd.ai")
}
export async function init() {
const config = await Config.get()
if (!config.enterprise) return
Bus.subscribe(Session.Event.Updated, async (evt) => {
await sync(evt.properties.info.id, [
{
@@ -62,8 +64,7 @@ export namespace ShareNext {
export async function create(sessionID: string) {
log.info("creating share", { sessionID })
const url = await Config.get().then((x) => x.enterprise!.url)
const result = await fetch(`${url}/api/share`, {
const result = await fetch(`${await url()}/api/share`, {
method: "POST",
headers: {
"Content-Type": "application/json",
@@ -126,11 +127,10 @@ export namespace ShareNext {
const queued = queue.get(sessionID)
if (!queued) return
queue.delete(sessionID)
const url = await Config.get().then((x) => x.enterprise!.url)
const share = await get(sessionID)
if (!share) return
await fetch(`${url}/api/share/${share.id}/sync`, {
await fetch(`${await url()}/api/share/${share.id}/sync`, {
method: "POST",
headers: {
"Content-Type": "application/json",
@@ -146,10 +146,9 @@ export namespace ShareNext {
export async function remove(sessionID: string) {
log.info("removing share", { sessionID })
const url = await Config.get().then((x) => x.enterprise!.url)
const share = await get(sessionID)
if (!share) return
await fetch(`${url}/api/share/${share.id}`, {
await fetch(`${await url()}/api/share/${share.id}`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",