The open source coding agent.
TypeScript
sync
Dax Raad5c491758f57b
diff --git a/js/src/index.ts b/js/src/index.tsindex 16fa0e43ef4..100e2bd0746 100644--- a/js/src/index.ts+++ b/js/src/index.ts@@ -40,7 +40,8 @@ cliawait Share.init();const session = await Session.create();const shareID = await Session.share(session.id);- if (shareID) console.log("Share ID:", shareID);+ if (shareID)+ console.log("Share ID: https://dev.opencode.ai/share/" + shareID);const result = await Session.chat(session.id, {type: "text",text: message.join(" "),diff --git a/js/src/share/share.ts b/js/src/share/share.tsindex 6c0573e9168..6191da684c8 100644--- a/js/src/share/share.ts+++ b/js/src/share/share.ts@@ -2,8 +2,11 @@ import { App } from "../app";import { Bus } from "../bus";import { Session } from "../session/session";import { Storage } from "../storage/storage";+import { Log } from "../util/log";export namespace Share {+ const log = Log.create({ service: "share" });+const state = App.state("share", async () => {Bus.subscribe(Storage.Event.Write, async (payload) => {const [root, ...splits] = payload.properties.key.split("/");@@ -11,12 +14,6 @@ export namespace Share {const [type, sessionID] = splits;const session = await Session.get(sessionID);if (!session.shareID) return;- console.log({- sessionID: sessionID,- shareID: session.shareID,- key: payload.properties.key,- content: payload.properties.content,- });await fetch(`${URL}/share_sync`, {method: "POST",body: JSON.stringify({@@ -25,7 +22,9 @@ export namespace Share {key: payload.properties.key,content: payload.properties.content,}),- }).then(console.log);+ })+ .then((x) => x.text())+ .then(console.log);});});diff --git a/js/src/util/log.ts b/js/src/util/log.tsindex dff97f962c4..2d51b0d24bb 100644--- a/js/src/util/log.ts+++ b/js/src/util/log.ts@@ -39,7 +39,7 @@ export namespace Log {}).map(([key, value]) => `${key}=${value}`).join(" ");- return [prefix, message].join(" ") + "\n";+ return [new Date().toISOString(), prefix, message].join(" ") + "\n";}const result = {info(message?: any, extra?: Record<string, any>) {