mirror of
https://github.com/sst/opencode.git
synced 2025-08-04 05:28:16 +00:00
share types
This commit is contained in:
parent
2f10961ba8
commit
5944ae2023
3 changed files with 9 additions and 38 deletions
1
bun.lock
1
bun.lock
|
@ -79,6 +79,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "catalog:",
|
"@types/node": "catalog:",
|
||||||
|
"opencode": "workspace:*",
|
||||||
"typescript": "catalog:",
|
"typescript": "catalog:",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
"toolbeam-docs-theme": "0.3.0"
|
"toolbeam-docs-theme": "0.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"opencode": "workspace:*",
|
||||||
"@types/node": "catalog:",
|
"@types/node": "catalog:",
|
||||||
"typescript": "catalog:"
|
"typescript": "catalog:"
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,8 @@ import DiffView from "./DiffView"
|
||||||
import CodeBlock from "./CodeBlock"
|
import CodeBlock from "./CodeBlock"
|
||||||
import MarkdownView from "./MarkdownView"
|
import MarkdownView from "./MarkdownView"
|
||||||
import styles from "./share.module.css"
|
import styles from "./share.module.css"
|
||||||
import { type UIMessage } from "ai"
|
import { type Message } from "opencode/session/message"
|
||||||
|
import { type Session } from "opencode/session"
|
||||||
|
|
||||||
const MIN_DURATION = 2
|
const MIN_DURATION = 2
|
||||||
|
|
||||||
|
@ -47,38 +48,7 @@ type Status =
|
||||||
| "error"
|
| "error"
|
||||||
| "reconnecting"
|
| "reconnecting"
|
||||||
|
|
||||||
type SessionMessage = UIMessage<{
|
|
||||||
time: {
|
|
||||||
created: number
|
|
||||||
completed?: number
|
|
||||||
}
|
|
||||||
assistant?: {
|
|
||||||
modelID: string
|
|
||||||
providerID: string
|
|
||||||
cost: number
|
|
||||||
tokens: {
|
|
||||||
input: number
|
|
||||||
output: number
|
|
||||||
reasoning: number
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sessionID: string
|
|
||||||
tool: Record<
|
|
||||||
string,
|
|
||||||
{
|
|
||||||
[key: string]: any
|
|
||||||
time: {
|
|
||||||
start: number
|
|
||||||
end: number
|
|
||||||
}
|
|
||||||
}
|
|
||||||
>
|
|
||||||
}>
|
|
||||||
|
|
||||||
type SessionInfo = {
|
|
||||||
title: string
|
|
||||||
cost?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
type TodoStatus = "pending" | "in_progress" | "completed"
|
type TodoStatus = "pending" | "in_progress" | "completed"
|
||||||
|
|
||||||
|
@ -531,8 +501,8 @@ function ToolFooter(props: { time: number }) {
|
||||||
export default function Share(props: {
|
export default function Share(props: {
|
||||||
id: string
|
id: string
|
||||||
api: string
|
api: string
|
||||||
info: SessionInfo
|
info: Session.Info
|
||||||
messages: Record<string, SessionMessage>
|
messages: Record<string, Message.Info>
|
||||||
}) {
|
}) {
|
||||||
let hasScrolled = false
|
let hasScrolled = false
|
||||||
|
|
||||||
|
@ -547,8 +517,8 @@ export default function Share(props: {
|
||||||
})
|
})
|
||||||
|
|
||||||
const [store, setStore] = createStore<{
|
const [store, setStore] = createStore<{
|
||||||
info?: SessionInfo
|
info?: Session.Info
|
||||||
messages: Record<string, SessionMessage>
|
messages: Record<string, Message.Info>
|
||||||
}>({ info: props.info, messages: props.messages })
|
}>({ info: props.info, messages: props.messages })
|
||||||
const messages = createMemo(() =>
|
const messages = createMemo(() =>
|
||||||
Object.values(store.messages).toSorted((a, b) => a.id?.localeCompare(b.id)),
|
Object.values(store.messages).toSorted((a, b) => a.id?.localeCompare(b.id)),
|
||||||
|
@ -659,7 +629,7 @@ export default function Share(props: {
|
||||||
const result = {
|
const result = {
|
||||||
created: undefined as number | undefined,
|
created: undefined as number | undefined,
|
||||||
system: [] as string[],
|
system: [] as string[],
|
||||||
messages: [] as SessionMessage[],
|
messages: [] as Message.Info[],
|
||||||
models: {} as Record<string, string[]>,
|
models: {} as Record<string, string[]>,
|
||||||
cost: 0,
|
cost: 0,
|
||||||
tokens: {
|
tokens: {
|
||||||
|
@ -701,7 +671,6 @@ export default function Share(props: {
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
})
|
})
|
||||||
const [showingSystemPrompt, showSystemPrompt] = createSignal(false)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main class={`${styles.root} not-content`}>
|
<main class={`${styles.root} not-content`}>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue