mirror of
https://github.com/sst/opencode.git
synced 2025-09-06 21:20:33 +00:00
toolz
This commit is contained in:
parent
fa8a46326a
commit
2437ce3f8b
14 changed files with 973 additions and 13 deletions
27
js/example/cli.ts
Normal file
27
js/example/cli.ts
Normal file
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue