summaryrefslogtreecommitdiffhomepage
path: root/js/example/cli.ts
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-05-19 19:29:38 -0400
committerDax Raad <[email protected]>2025-05-26 12:40:17 -0400
commit2437ce3f8b79a7f9d987862b633f3340bfa2c1c4 (patch)
treed46690ea1bf8043871e26b6139f96997b16a6252 /js/example/cli.ts
parentfa8a46326afa2d7fbb592542abf243f248cb5992 (diff)
downloadopencode-2437ce3f8b79a7f9d987862b633f3340bfa2c1c4.tar.gz
opencode-2437ce3f8b79a7f9d987862b633f3340bfa2c1c4.zip
toolz
Diffstat (limited to 'js/example/cli.ts')
-rw-r--r--js/example/cli.ts27
1 files changed, 27 insertions, 0 deletions
diff --git a/js/example/cli.ts b/js/example/cli.ts
new file mode 100644
index 000000000..bb7522cbb
--- /dev/null
+++ b/js/example/cli.ts
@@ -0,0 +1,27 @@
+import { hc } from "hono/client";
+import type { Server } from "../src/server/server";
+
+const message = process.argv.slice(2).join(" ");
+console.log(message);
+
+const client = hc<Server.App>(`http://localhost:16713`);
+const session = await client.session_create.$post().then((res) => res.json());
+const result = await client.session_chat
+ .$post({
+ json: {
+ sessionID: session.id,
+ parts: [
+ {
+ type: "text",
+ text: message,
+ },
+ ],
+ },
+ })
+ .then((res) => res.json());
+
+for (const part of result.parts) {
+ if (part.type === "text") {
+ console.log(part.text);
+ }
+}