summaryrefslogtreecommitdiffhomepage
path: root/packages/sdk/js/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/sdk/js/src')
-rw-r--r--packages/sdk/js/src/client.ts10
-rw-r--r--packages/sdk/js/src/index.ts41
-rw-r--r--packages/sdk/js/src/server.ts26
3 files changed, 38 insertions, 39 deletions
diff --git a/packages/sdk/js/src/client.ts b/packages/sdk/js/src/client.ts
new file mode 100644
index 000000000..a5ed488e6
--- /dev/null
+++ b/packages/sdk/js/src/client.ts
@@ -0,0 +1,10 @@
+import { createClient } from "./gen/client/client.js"
+import { type Config } from "./gen/client/types.js"
+import { OpencodeClient } from "./gen/sdk.gen.js"
+export * from "./gen/types.gen.js"
+export { type Config, OpencodeClient }
+
+export function createOpencodeClient(config?: Config) {
+ const client = createClient(config)
+ return new OpencodeClient({ client })
+}
diff --git a/packages/sdk/js/src/index.ts b/packages/sdk/js/src/index.ts
index 4c3bde2ff..03cf66634 100644
--- a/packages/sdk/js/src/index.ts
+++ b/packages/sdk/js/src/index.ts
@@ -1,39 +1,2 @@
-import { createClient } from "./gen/client/client.js"
-import { type Config } from "./gen/client/types.js"
-import { OpencodeClient } from "./gen/sdk.gen.js"
-export * from "./gen/types.gen.js"
-export {
- type Config,
- OpencodeClient
-}
-import { spawn } from "child_process"
-
-export function createOpencodeClient(config?: Config) {
- const client = createClient(config)
- return new OpencodeClient({ client })
-}
-
-export type ServerConfig = {
- host?: string
- port?: number
-}
-
-export async function createOpencodeServer(config?: ServerConfig) {
- config = Object.assign(
- {
- host: "127.0.0.1",
- port: 4096,
- },
- config ?? {},
- )
-
- const proc = spawn(`opencode`, [`serve`, `--host=${config.host}`, `--port=${config.port}`])
- const url = `http://${config.host}:${config.port}`
-
- return {
- url,
- close() {
- proc.kill()
- },
- }
-}
+export * from "./client.js"
+export * from "./server.js"
diff --git a/packages/sdk/js/src/server.ts b/packages/sdk/js/src/server.ts
new file mode 100644
index 000000000..edaa4cf63
--- /dev/null
+++ b/packages/sdk/js/src/server.ts
@@ -0,0 +1,26 @@
+import { spawn } from "node:child_process"
+
+export type ServerConfig = {
+ host?: string
+ port?: number
+}
+
+export async function createOpencodeServer(config?: ServerConfig) {
+ config = Object.assign(
+ {
+ host: "127.0.0.1",
+ port: 4096,
+ },
+ config ?? {},
+ )
+
+ const proc = spawn(`opencode`, [`serve`, `--host=${config.host}`, `--port=${config.port}`])
+ const url = `http://${config.host}:${config.port}`
+
+ return {
+ url,
+ close() {
+ proc.kill()
+ },
+ }
+}