summaryrefslogtreecommitdiffhomepage
path: root/js/example
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-05-29 11:58:40 -0400
committerDax Raad <[email protected]>2025-05-29 11:58:40 -0400
commit80597cd3fdf149cef87db55f03a3cc0bfd723a7a (patch)
treeb9332733cca2084a86334eb88fdc5115ab37b922 /js/example
parent48f81fe4d3a286ead827888e030f9bd89c864dee (diff)
downloadopencode-80597cd3fdf149cef87db55f03a3cc0bfd723a7a.tar.gz
opencode-80597cd3fdf149cef87db55f03a3cc0bfd723a7a.zip
type error fix
Diffstat (limited to 'js/example')
-rw-r--r--js/example/broken.ts1
-rw-r--r--js/example/cli.ts21
-rw-r--r--js/example/ink.tsx122
3 files changed, 0 insertions, 144 deletions
diff --git a/js/example/broken.ts b/js/example/broken.ts
deleted file mode 100644
index e073ad008..000000000
--- a/js/example/broken.ts
+++ /dev/null
@@ -1 +0,0 @@
-export const x: number = "asd";
diff --git a/js/example/cli.ts b/js/example/cli.ts
deleted file mode 100644
index 9c9e07edd..000000000
--- a/js/example/cli.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { App } from "../src/app";
-import path from "path";
-import { edit } from "../src/tool";
-import { FileTimes } from "../src/tool/util/file-times";
-
-await App.provide({ directory: process.cwd() }, async () => {
- const file = path.join(process.cwd(), "example/broken.ts");
- FileTimes.read(file);
- const tool = await edit.execute(
- {
- file_path: file,
- old_string: "x:",
- new_string: "x:",
- },
- {
- toolCallId: "test",
- messages: [],
- },
- );
- console.log(tool.output);
-});
diff --git a/js/example/ink.tsx b/js/example/ink.tsx
deleted file mode 100644
index 5eaab4d3b..000000000
--- a/js/example/ink.tsx
+++ /dev/null
@@ -1,122 +0,0 @@
-import React, { useEffect, useState } from "react";
-import type { Server } from "../src/server/server";
-import type { Session } from "../src/session/session";
-import { hc } from "hono/client";
-import { createInterface, Interface } from "readline";
-
-const client = hc<Server.App>(`http://localhost:16713`);
-
-
-const session = await client.session_create.$post().then((res) => res.json());
-
-const initial: {
- session: {
- info: {
- [sessionID: string]: Session.Info;
- };
- message: {
- [sessionID: string]: {
- [messageID: string]: Session.Message;
- };
- };
- };
-} = {
- session: {
- info: {
- [session.id]: session
- },
- message: {
- [session.id]: {}
- },
- },
-};
-
-import { render, Text, Newline, useStdout, Box } from "ink";
-import TextInput from "ink-text-input"
-
-function App() {
- const [state, setState] = useState(initial)
- const [input, setInput] = useState("")
-
- useEffect(() => {
- fetch("http://localhost:16713/event")
- .then(stream => {
- const decoder = new TextDecoder();
- stream.body!.pipeTo(
- new WritableStream({
- write(chunk) {
- const data = decoder.decode(chunk);
- if (data.startsWith("data: ")) {
- try {
- const event = JSON.parse(data.substring(6));
- switch (event.type) {
- case "storage.write":
- const splits: string[] = event.properties.key.split("/");
- let item = state as any;
- for (let i = 0; i < splits.length; i++) {
- const part = splits[i];
- if (i === splits.length - 1) {
- item[part] = event.properties.body;
- continue;
- }
- if (!item[part]) item[part] = {};
- item = item[part];
- }
- }
- setState({ ...state })
- } catch {
- }
- }
- },
- }),
- )
- });
- }, [])
-
-
- return (
- <>
- <Text>{session.title}</Text>
- {
- Object.values(state.session.message[session.id])
- .filter(message => message.role !== "system")
- .map(message => {
- return Object.values(message.parts)
- .map((part, index) => {
- if (part.type === "text") {
- return <Text key={`${message.id}-${index}`}>{message.role}: {part.text}</Text>
- }
- if (part.type === "tool-invocation") {
- return <Text key={`${message.id}-${index}`}>{message.role}: {part.toolInvocation.toolName} {JSON.stringify(part.toolInvocation.args)}</Text>
- }
- })
- })
- }
- <Box gap={1} >
- <Text>Input:</Text>
- <TextInput
- value={input}
- onChange={setInput}
- onSubmit={() => {
- setInput("")
- client.session_chat.$post({
- json: {
- sessionID: session.id,
- parts: [
- {
- type: "text",
- text: input,
- },
- ],
- }
- })
- }}
- />
- </Box>
- </>
- );
-};
-
-console.clear();
-render(<App />);
-